Commit cc2a8443 authored by Justin Ruggles's avatar Justin Ruggles

move some common values to ac3.h and utilize them

Originally committed as revision 9679 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent cb503702
...@@ -154,7 +154,7 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd, ...@@ -154,7 +154,7 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
/* delta bit allocation */ /* delta bit allocation */
if (deltbae == 0 || deltbae == 1) { if (deltbae == DBA_REUSE || deltbae == DBA_NEW) {
int band, seg, delta; int band, seg, delta;
band = 0; band = 0;
for (seg = 0; seg < deltnseg; seg++) { for (seg = 0; seg < deltnseg; seg++) {
......
...@@ -43,6 +43,26 @@ ...@@ -43,6 +43,26 @@
#define EXP_D25 2 #define EXP_D25 2
#define EXP_D45 3 #define EXP_D45 3
/** Delta bit allocation strategy */
typedef enum {
DBA_REUSE = 0,
DBA_NEW,
DBA_NONE,
DBA_RESERVED
} AC3DeltaStrategy;
/** Channel mode (audio coding mode) */
typedef enum {
AC3_ACMOD_DUALMONO = 0,
AC3_ACMOD_MONO,
AC3_ACMOD_STEREO,
AC3_ACMOD_3F,
AC3_ACMOD_2F1R,
AC3_ACMOD_3F1R,
AC3_ACMOD_2F2R,
AC3_ACMOD_3F2R
} AC3ChannelMode;
typedef struct AC3BitAllocParameters { typedef struct AC3BitAllocParameters {
int fscod; /* frequency */ int fscod; /* frequency */
int halfratecod; int halfratecod;
......
...@@ -64,13 +64,13 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr) ...@@ -64,13 +64,13 @@ int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr)
hdr->bsmod = get_bits(&gbc, 3); hdr->bsmod = get_bits(&gbc, 3);
hdr->acmod = get_bits(&gbc, 3); hdr->acmod = get_bits(&gbc, 3);
if((hdr->acmod & 1) && hdr->acmod != 1) { if((hdr->acmod & 1) && hdr->acmod != AC3_ACMOD_MONO) {
hdr->cmixlev = get_bits(&gbc, 2); hdr->cmixlev = get_bits(&gbc, 2);
} }
if(hdr->acmod & 4) { if(hdr->acmod & 4) {
hdr->surmixlev = get_bits(&gbc, 2); hdr->surmixlev = get_bits(&gbc, 2);
} }
if(hdr->acmod == 2) { if(hdr->acmod == AC3_ACMOD_STEREO) {
hdr->dsurmod = get_bits(&gbc, 2); hdr->dsurmod = get_bits(&gbc, 2);
} }
hdr->lfeon = get_bits1(&gbc); hdr->lfeon = get_bits1(&gbc);
......
This diff is collapsed.
...@@ -453,7 +453,7 @@ static void bit_alloc_masking(AC3EncodeContext *s, ...@@ -453,7 +453,7 @@ static void bit_alloc_masking(AC3EncodeContext *s,
0, s->nb_coefs[ch], 0, s->nb_coefs[ch],
ff_fgaintab[s->fgaincod[ch]], ff_fgaintab[s->fgaincod[ch]],
ch == s->lfe_channel, ch == s->lfe_channel,
2, 0, NULL, NULL, NULL, DBA_NONE, 0, NULL, NULL, NULL,
mask[blk][ch]); mask[blk][ch]);
} }
} }
...@@ -534,7 +534,7 @@ static int compute_bit_allocation(AC3EncodeContext *s, ...@@ -534,7 +534,7 @@ static int compute_bit_allocation(AC3EncodeContext *s,
/* audio blocks */ /* audio blocks */
for(i=0;i<NB_BLOCKS;i++) { for(i=0;i<NB_BLOCKS;i++) {
frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
if (s->acmod == 2) { if (s->acmod == AC3_ACMOD_STEREO) {
frame_bits++; /* rematstr */ frame_bits++; /* rematstr */
if(i==0) frame_bits += 4; if(i==0) frame_bits += 4;
} }
...@@ -723,11 +723,11 @@ static void output_frame_header(AC3EncodeContext *s, unsigned char *frame) ...@@ -723,11 +723,11 @@ static void output_frame_header(AC3EncodeContext *s, unsigned char *frame)
put_bits(&s->pb, 5, s->bsid); put_bits(&s->pb, 5, s->bsid);
put_bits(&s->pb, 3, s->bsmod); put_bits(&s->pb, 3, s->bsmod);
put_bits(&s->pb, 3, s->acmod); put_bits(&s->pb, 3, s->acmod);
if ((s->acmod & 0x01) && s->acmod != 0x01) if ((s->acmod & 0x01) && s->acmod != AC3_ACMOD_MONO)
put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */ put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */
if (s->acmod & 0x04) if (s->acmod & 0x04)
put_bits(&s->pb, 2, 1); /* XXX -6 dB */ put_bits(&s->pb, 2, 1); /* XXX -6 dB */
if (s->acmod == 0x02) if (s->acmod == AC3_ACMOD_STEREO)
put_bits(&s->pb, 2, 0); /* surround not indicated */ put_bits(&s->pb, 2, 0); /* surround not indicated */
put_bits(&s->pb, 1, s->lfe); /* LFE */ put_bits(&s->pb, 1, s->lfe); /* LFE */
put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */ put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */
...@@ -810,7 +810,7 @@ static void output_audio_block(AC3EncodeContext *s, ...@@ -810,7 +810,7 @@ static void output_audio_block(AC3EncodeContext *s,
put_bits(&s->pb, 1, 0); /* no new coupling strategy */ put_bits(&s->pb, 1, 0); /* no new coupling strategy */
} }
if (s->acmod == 2) if (s->acmod == AC3_ACMOD_STEREO)
{ {
if(block_num==0) if(block_num==0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment