[Ffmpeg-devel] [PATCH] remove ac3 tables from parser.c
Limin Wang
lance.lmwang
Fri Mar 9 02:55:47 CET 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
* Justin Ruggles <justinruggles at bellsouth.net> [2007-03-08 18:21:09 -0500]:
> This removes duplication in the AC-3 tables between encoder and parser.
>
> For now, there is not a place for common AC-3 code, so with this patch,
> parser.c includes ac3tab.h. Once there is an ac3.c, parser.c will be
> changed to include ac3.h instead.
>
> -Justin
I think table data shouldn't put into header file. we can put it into c file
and extern the array in the header file or define a function to get it.
So just remove the static and extern them in ac3tab.h.
Thanks,
Limin
> Index: libavcodec/ac3tab.h
> ===================================================================
> --- libavcodec/ac3tab.h (revision 8300)
> +++ libavcodec/ac3tab.h (working copy)
> @@ -24,6 +24,14 @@
> * tables taken directly from AC3 spec.
> */
>
> +/**
> + * Maps audio coding mode (acmod) to number of full-bandwidth channels.
> + * from ATSC A/52 Table 5.8 Audio Coding Mode
> + */
> +static const uint8_t ac3_channels[8] = {
> + 2, 1, 2, 3, 3, 4, 4, 5
> +};
> +
> /* possible frequencies */
> static const uint16_t ac3_freqs[3] = { 48000, 44100, 32000 };
>
> @@ -33,6 +41,51 @@
> 160, 192, 224, 256, 320, 384, 448, 512, 576, 640
> };
>
> +/**
> + * Possible frame sizes (1 word = 16 bits).
> + * from ATSC A/52 Table 5.18 Frame Size Code Table
> + */
> +static const uint16_t ac3_frame_sizes[64][3] = {
> + { 64, 69, 96 },
> + { 64, 70, 96 },
> + { 80, 87, 120 },
> + { 80, 88, 120 },
> + { 96, 104, 144 },
> + { 96, 105, 144 },
> + { 112, 121, 168 },
> + { 112, 122, 168 },
> + { 128, 139, 192 },
> + { 128, 140, 192 },
> + { 160, 174, 240 },
> + { 160, 175, 240 },
> + { 192, 208, 288 },
> + { 192, 209, 288 },
> + { 224, 243, 336 },
> + { 224, 244, 336 },
> + { 256, 278, 384 },
> + { 256, 279, 384 },
> + { 320, 348, 480 },
> + { 320, 349, 480 },
> + { 384, 417, 576 },
> + { 384, 418, 576 },
> + { 448, 487, 672 },
> + { 448, 488, 672 },
> + { 512, 557, 768 },
> + { 512, 558, 768 },
> + { 640, 696, 960 },
> + { 640, 697, 960 },
> + { 768, 835, 1152 },
> + { 768, 836, 1152 },
> + { 896, 975, 1344 },
> + { 896, 976, 1344 },
> + { 1024, 1114, 1536 },
> + { 1024, 1115, 1536 },
> + { 1152, 1253, 1728 },
> + { 1152, 1254, 1728 },
> + { 1280, 1393, 1920 },
> + { 1280, 1394, 1920 },
> +};
> +
> /* AC3 MDCT window */
>
> /* MDCT window */
> Index: libavcodec/parser.c
> ===================================================================
> --- libavcodec/parser.c (revision 8300)
> +++ libavcodec/parser.c (working copy)
> @@ -22,6 +22,9 @@
> #include "avcodec.h"
> #include "mpegvideo.h"
> #include "mpegaudio.h"
> +#ifdef CONFIG_AC3_PARSER
> +#include "ac3tab.h"
> +#endif
> #include "parser.h"
>
> AVCodecParser *av_first_parser = NULL;
> @@ -581,61 +584,7 @@
> #define AAC_HEADER_SIZE 7
>
> #ifdef CONFIG_AC3_PARSER
> -static const int ac3_sample_rates[4] = {
> - 48000, 44100, 32000, 0
> -};
>
> -static const int ac3_frame_sizes[64][3] = {
> - { 64, 69, 96 },
> - { 64, 70, 96 },
> - { 80, 87, 120 },
> - { 80, 88, 120 },
> - { 96, 104, 144 },
> - { 96, 105, 144 },
> - { 112, 121, 168 },
> - { 112, 122, 168 },
> - { 128, 139, 192 },
> - { 128, 140, 192 },
> - { 160, 174, 240 },
> - { 160, 175, 240 },
> - { 192, 208, 288 },
> - { 192, 209, 288 },
> - { 224, 243, 336 },
> - { 224, 244, 336 },
> - { 256, 278, 384 },
> - { 256, 279, 384 },
> - { 320, 348, 480 },
> - { 320, 349, 480 },
> - { 384, 417, 576 },
> - { 384, 418, 576 },
> - { 448, 487, 672 },
> - { 448, 488, 672 },
> - { 512, 557, 768 },
> - { 512, 558, 768 },
> - { 640, 696, 960 },
> - { 640, 697, 960 },
> - { 768, 835, 1152 },
> - { 768, 836, 1152 },
> - { 896, 975, 1344 },
> - { 896, 976, 1344 },
> - { 1024, 1114, 1536 },
> - { 1024, 1115, 1536 },
> - { 1152, 1253, 1728 },
> - { 1152, 1254, 1728 },
> - { 1280, 1393, 1920 },
> - { 1280, 1394, 1920 },
> -};
> -
> -static const int ac3_bitrates[64] = {
> - 32, 32, 40, 40, 48, 48, 56, 56, 64, 64, 80, 80, 96, 96, 112, 112,
> - 128, 128, 160, 160, 192, 192, 224, 224, 256, 256, 320, 320, 384,
> - 384, 448, 448, 512, 512, 576, 576, 640, 640,
> -};
> -
> -static const uint8_t ac3_channels[8] = {
> - 2, 1, 2, 3, 3, 4, 4, 5
> -};
> -
> static const uint8_t eac3_blocks[4] = {
> 1, 2, 3, 6
> };
> @@ -672,7 +621,7 @@
> fscod = get_bits(&bits, 2);
> frmsizecod = get_bits(&bits, 6);
>
> - if(fscod == 3)
> + if(fscod == 3 || frmsizecod > 37)
> return 0;
>
> skip_bits(&bits, 5); /* bsid */
> @@ -687,8 +636,8 @@
> lfeon = get_bits1(&bits);
>
> halfratecod = FFMAX(bsid, 8) - 8;
> - *sample_rate = ac3_sample_rates[fscod] >> halfratecod;
> - *bit_rate = (ac3_bitrates[frmsizecod] * 1000) >> halfratecod;
> + *sample_rate = ac3_freqs[fscod] >> halfratecod;
> + *bit_rate = (ac3_bitratetab[frmsizecod >> 1] * 1000) >> halfratecod;
> *channels = ac3_channels[acmod] + lfeon;
> *samples = 6 * 256;
>
> @@ -709,11 +658,11 @@
> if(fscod2 == 3)
> return 0;
>
> - *sample_rate = ac3_sample_rates[fscod2] / 2;
> + *sample_rate = ac3_freqs[fscod2] / 2;
> } else {
> numblkscod = get_bits(&bits, 2);
>
> - *sample_rate = ac3_sample_rates[fscod];
> + *sample_rate = ac3_freqs[fscod];
> }
>
> acmod = get_bits(&bits, 3);
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iQEVAwUBRfC+o0ztbf7dKiuoAQKwdQf/aZctIyaDlMtyInWcv5i6zvH7/G4RGa33
k69Ks9GkNTkNrrZZ5EnOGhVbl/cMMm2TDgwZ+cd9q5ctn8CTZskutuLBbAvG5Pti
fEkZX/Xlw1bdECho5jwT5qkFhYYgAEkS27o9BEXjQ3qlEF4iFziuCfV//klJv3Pp
oY43Fqva02MKHcVnGa1C/q3ltzr6ScBAGlcNCntEUsYc+DAg3eYROVkI32gI/LsI
2xoysI9pyx6Q7I3BpRmU7aWLq/sJ9mjjuPvC8ZMx1VuZ5PmzaMuojhWQEoNdpzPU
RlEj8jtyTDTfAIHg/JC1pGpSBFGyiAVlnOipZBbdEHap2EmTleKT1A==
=UxXo
-----END PGP SIGNATURE-----
More information about the ffmpeg-devel
mailing list