FFmpeg-soc
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
September 2007
- 13 participants
- 130 discussions
Author: reynaldo
Date: Thu Sep 13 16:08:34 2007
New Revision: 1348
Log:
COSMETICS
Modified:
qcelp/qcelpdec.c
Modified: qcelp/qcelpdec.c
==============================================================================
--- qcelp/qcelpdec.c (original)
+++ qcelp/qcelpdec.c Thu Sep 13 16:08:34 2007
@@ -54,7 +54,7 @@ typedef struct
int frame_num;
} QCELPContext;
-static void qcelp_update_pitchf_mem(float *pitchf_mem, const float *last)
+static void qcelp_update_filter_mem(float *pitchf_mem, const float *last)
{
memmove(pitchf_mem, pitchf_mem+40, 110*sizeof(float));
memmove(pitchf_mem+110, last, 40*sizeof(float));
@@ -484,7 +484,7 @@ static int qcelp_do_pitchfilter(QCELPFra
if(k==39)
{
- qcelp_update_pitchf_mem(pitch_mem, &pv[i-k]);
+ qcelp_update_filter_mem(pitch_mem, &pv[i-k]);
}
k=(k<39)? k+1:0;
1
0
Author: bwolowiec
Date: Wed Sep 12 09:53:51 2007
New Revision: 1341
Log:
rename ntchans to num_channels
Modified:
eac3/eac3.h
eac3/eac3dec.c
Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h (original)
+++ eac3/eac3.h Wed Sep 12 09:53:51 2007
@@ -176,7 +176,7 @@ typedef struct EAC3Context{
AVRandomState dith_state; ///< for dither generation
- int ntchans; ///< Total of all channels
+ int num_channels; ///< Total of all channels
int lfe_channel; ///< Index of LFE channel
GetBitContext *gbc; ///< Bitstream reader
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Wed Sep 12 09:53:51 2007
@@ -351,14 +351,14 @@ static int parse_bsi(GetBitContext *gbc,
// calculate number of channels
s->nfchans = ff_ac3_channels[s->acmod];
- s->ntchans = s->nfchans;
- s->lfe_channel = s->ntchans+1;
+ s->num_channels = s->nfchans;
+ s->lfe_channel = s->num_channels+1;
if(s->lfeon){
s->strtmant[s->lfe_channel] = 0;
s->endmant[s->lfe_channel] = 7;
s->nchgrps[s->lfe_channel] = 2;
s->chincpl[s->lfe_channel] = 0;
- s->ntchans++;
+ s->num_channels++;
}
s->bsid = get_bits(gbc, 5);
@@ -607,21 +607,21 @@ static int parse_audfrm(GetBitContext *g
/* ncplregs derived from cplstre and cplexpstr - see Section E3.3.2 */
int nchregs;
s->chahtinu[CPL_CH]=0;
- for(ch = (s->ncplblks!=6); ch <= s->ntchans; ch++){
+ for(ch = (s->ncplblks!=6); ch <= s->num_channels; ch++){
nchregs = 0;
for(blk = 0; blk < 6; blk++)
nchregs += (s->chexpstr[blk][ch] != EXP_REUSE);
s->chahtinu[ch] = (nchregs == 1) && get_bits1(gbc);
}
}else{
- for(ch=0; ch<=s->ntchans; ch++)
+ for(ch=0; ch<=s->num_channels; ch++)
s->chahtinu[ch] = 0;
}
/* Audio frame SNR offset data */
if(s->snroffststr == 0x0){
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
- for(ch=0; ch<= s->ntchans; ch++)
+ for(ch=0; ch<= s->num_channels; ch++)
s->snroffst[ch] = snroffst;
}
/* Audio frame transient pre-noise processing data */
@@ -1051,7 +1051,7 @@ static int parse_audblk(GetBitContext *g
}
}
/* Exponents */
- for(ch=!s->cplinu[blk]; ch<=s->ntchans; ch++){
+ for(ch=!s->cplinu[blk]; ch<=s->num_channels; ch++){
if(s->chexpstr[blk][ch]!=EXP_REUSE){
s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
ff_ac3_decode_exponents(gbc, s->chexpstr[blk][ch], s->nchgrps[ch],
@@ -1089,21 +1089,21 @@ static int parse_audblk(GetBitContext *g
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
if(s->snroffststr == 0x1){
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
- for(ch=!s->cplinu[blk]; ch<= s->ntchans; ch++)
+ for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
s->snroffst[ch] = snroffst;
}else if(s->snroffststr == 0x2){
- for(ch=!s->cplinu[blk]; ch<= s->ntchans; ch++)
+ for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
}
}
}
if(s->frmfgaincode && get_bits1(gbc)){
- for(ch = !s->cplinu[blk]; ch <= s->ntchans; ch++)
+ for(ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
s->fgain[ch] = ff_fgaintab[get_bits(gbc, 3)];
}else{
if(!blk){
- for(ch = !s->cplinu[blk]; ch <= s->ntchans; ch++)
+ for(ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
s->fgain[ch] = ff_fgaintab[0x4];
}
}
@@ -1142,7 +1142,7 @@ static int parse_audblk(GetBitContext *g
}
}else{
if(!blk){
- for(ch=0; ch<=s->ntchans; ch++){
+ for(ch=0; ch<=s->num_channels; ch++){
s->deltbae[ch] = DBA_NONE;
}
}
@@ -1157,7 +1157,7 @@ static int parse_audblk(GetBitContext *g
}
/* run bit allocation */
- for(ch = !s->cplinu[blk]; ch<=s->ntchans; ch++){
+ for(ch = !s->cplinu[blk]; ch<=s->num_channels; ch++){
int start=0, end=0;
start = s->strtmant[ch];
end = s->endmant[ch];
@@ -1188,11 +1188,11 @@ static int parse_audblk(GetBitContext *g
got_cplchan = 0;
// TODO only for debug
- for(ch=0; ch<=s->ntchans; ch++)
+ for(ch=0; ch<=s->num_channels; ch++)
memset(s->transform_coeffs[ch], 0, 256*sizeof(float));
/* Quantized mantissa values */
- for(ch = 1; ch <= s->ntchans; ch++){
+ for(ch = 1; ch <= s->num_channels; ch++){
get_eac3_transform_coeffs_ch(gbc, s, blk, ch, &m);
if(s->cplinu[blk] && s->chincpl[ch] && !got_cplchan){
get_eac3_transform_coeffs_ch(gbc, s, blk, CPL_CH, &m);
@@ -1267,15 +1267,15 @@ static int eac3_decode_frame(AVCodecCont
/* channel config */
if (avctx->request_channels == 0) {
if(avctx->channels == 0)
- avctx->channels = c->ntchans;
- } else if(c->ntchans < avctx->request_channels) {
+ avctx->channels = c->num_channels;
+ } else if(c->num_channels < avctx->request_channels) {
av_log(avctx, AV_LOG_ERROR, "Cannot upmix EAC3 from %d to %d channels.\n",
- c->ntchans, avctx->request_channels);
+ c->num_channels, avctx->request_channels);
return -1;
} else {
- if(avctx->request_channels > 2 && avctx->request_channels != c->ntchans) {
+ if(avctx->request_channels > 2 && avctx->request_channels != c->num_channels) {
av_log(avctx, AV_LOG_ERROR, "Cannot downmix EAC3 from %d to %d channels.\n",
- c->ntchans, avctx->request_channels);
+ c->num_channels, avctx->request_channels);
return -1;
}
avctx->channels = avctx->request_channels;
@@ -1308,7 +1308,7 @@ static int eac3_decode_frame(AVCodecCont
do_imdct(c);
- if(avctx->channels != c->ntchans){
+ if(avctx->channels != c->num_channels){
ff_ac3_downmix(c->output, c->nfchans, avctx->channels, c->downmix_coeffs);
}
4
6
Author: bwolowiec
Date: Wed Sep 12 23:34:44 2007
New Revision: 1347
Log:
cosmetics
Modified:
eac3/eac3dec.c
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Wed Sep 12 23:34:44 2007
@@ -360,9 +360,9 @@ static int parse_bsi(GetBitContext *gbc,
s->lfe_channel = s->num_channels+1;
if (s->lfeon) {
s->strtmant[s->lfe_channel] = 0;
- s->endmant[s->lfe_channel] = 7;
- s->nchgrps[s->lfe_channel] = 2;
- s->chincpl[s->lfe_channel] = 0;
+ s->endmant [s->lfe_channel] = 7;
+ s->nchgrps [s->lfe_channel] = 2;
+ s->chincpl [s->lfe_channel] = 0;
s->num_channels++;
}
1
0
Author: bwolowiec
Date: Wed Sep 12 23:33:30 2007
New Revision: 1346
Log:
cosmetics
Modified:
eac3/eac3dec.c
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Wed Sep 12 23:33:30 2007
@@ -66,11 +66,11 @@ static void uncouple_channels(EAC3Contex
subbnd = s->cplbegf+1;
i = s->strtmant[CPL_CH];
- for(bnd=0; bnd<s->ncplbnd; bnd++){
+ for (bnd = 0; bnd < s->ncplbnd; bnd++) {
do {
- for(j=0; j<12; j++){
- for(ch=1; ch<=s->nfchans; ch++){
- if(s->chincpl[ch]){
+ for (j = 0; j < 12; j++) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chincpl[ch]) {
s->transform_coeffs[ch][i] =
s->transform_coeffs[CPL_CH][i] *
s->cplco[ch][bnd] * 8.0f;
@@ -97,8 +97,8 @@ static void spectral_extension(EAC3Conte
copystartmant = spxbandtable[s->spxstrtf];
copyendmant = spxbandtable[s->spxbegf];
- for(ch = 1; ch <= s->nfchans; ch++){
- if(!s->chinspx[ch])
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (!s->chinspx[ch])
continue;
copyindex = copystartmant;
@@ -106,10 +106,10 @@ static void spectral_extension(EAC3Conte
for (bnd = 0; bnd < s->nspxbnds; bnd++){
bandsize = s->spxbndsztab[bnd];
- if ((copyindex + bandsize) > copyendmant){
+ if ((copyindex + bandsize) > copyendmant) {
copyindex = copystartmant;
wrapflag[bnd] = 1;
- }else
+ } else
wrapflag[bnd] = 0;
for (bin = 0; bin < bandsize; bin++){
if (copyindex == copyendmant)
@@ -120,14 +120,15 @@ static void spectral_extension(EAC3Conte
noffset[ch] = s->spxblnd[ch] / 32.0;
spxmant = spxbandtable[s->spxbegf];
- if (s->spxcoe[ch]){
+ if (s->spxcoe[ch]) {
for (bnd = 0; bnd < s->nspxbnds; bnd++){
bandsize = s->spxbndsztab[bnd];
nratio = ((spxmant + 0.5*bandsize) / spxbandtable[s->spxendf]) - noffset[ch];
if (nratio < 0.0)
nratio = 0.0;
- else if (nratio > 1.0)
- nratio = 1.0;
+ else
+ if (nratio > 1.0)
+ nratio = 1.0;
nblendfact[ch][bnd] = sqrt(nratio);
sblendfact[ch][bnd] = sqrt(1 - nratio);
spxmant += bandsize;
@@ -145,7 +146,7 @@ static void spectral_extension(EAC3Conte
rmsenergy[ch][bnd] = sqrt(accum / bandsize);
}
- if (s->chinspxatten[ch]){
+ if (s->chinspxatten[ch]) {
/* apply notch filter at baseband / extension region border */
filtbin = spxbandtable[s->spxbegf] - 2;
for (bin = 0; bin < 3; bin++){
@@ -159,7 +160,7 @@ static void spectral_extension(EAC3Conte
filtbin += s->spxbndsztab[0];
/* apply notch at all other wrap points */
for (bnd = 1; bnd < s->nspxbnds; bnd++){
- if (wrapflag[bnd]){
+ if (wrapflag[bnd]) {
filtbin = filtbin - 5;
for (bin = 0; bin < 3; bin++){
s->transform_coeffs[ch][filtbin] *= ff_eac3_spxattentab[s->spxattencod[ch]][bin];
@@ -208,48 +209,50 @@ static void get_transform_coeffs_aht_ch(
endbap = chgaqmod<2?12:17;
chgaqsections = 0;
- for(bin = 0; bin < s->endmant[ch]; bin++){
- if(s->hebap[ch][bin] > 7 && s->hebap[ch][bin] < endbap)
+ for (bin = 0; bin < s->endmant[ch]; bin++) {
+ if (s->hebap[ch][bin] > 7 && s->hebap[ch][bin] < endbap)
chgaqsections++;
}
- if(chgaqmod == EAC3_GAQ_12 || chgaqmod == EAC3_GAQ_14){
- for(n = 0; n < chgaqsections; n++){
+ if (chgaqmod == EAC3_GAQ_12 || chgaqmod == EAC3_GAQ_14) {
+ for (n = 0; n < chgaqsections; n++) {
s->chgaqgain[n] = get_bits1(gbc);
}
- }else if(chgaqmod == EAC3_GAQ_124){
- int grpgain;
- chgaqsections = (chgaqsections+2)/3;
- for(n = 0; n < chgaqsections; n++){
- grpgain = get_bits(gbc, 5);
- s->chgaqgain[3*n] = grpgain/9;
- s->chgaqgain[3*n+1] = (grpgain%9)/3;
- s->chgaqgain[3*n+2] = grpgain%3;
+ } else {
+ if (chgaqmod == EAC3_GAQ_124) {
+ int grpgain;
+ chgaqsections = (chgaqsections+2)/3;
+ for (n = 0; n < chgaqsections; n++) {
+ grpgain = get_bits(gbc, 5);
+ s->chgaqgain[3*n] = grpgain/9;
+ s->chgaqgain[3*n+1] = (grpgain%9)/3;
+ s->chgaqgain[3*n+2] = grpgain%3;
+ }
}
}
m=0;
- for(bin = s->strtmant[ch]; bin < s->endmant[ch]; bin++){
- if(s->hebap[ch][bin]>7){
+ for (bin = s->strtmant[ch]; bin < s->endmant[ch]; bin++) {
+ if (s->hebap[ch][bin] > 7) {
// GAQ (E3.3.4.2)
// XXX what about gaqmod = 0 ?
// difference between Gk=1 and gaqmod=0 ?
- if(s->hebap[ch][bin] < endbap){
+ if (s->hebap[ch][bin] < endbap) {
// hebap in active range
// Gk = 1<<bg
bg = ff_gaq_gk[chgaqmod][s->chgaqgain[m++]];
- }else{
+ } else {
bg = 0;
}
bits = ff_bits_vs_hebap[s->hebap[ch][bin]];
- for(n = 0; n < 6; n++){
+ for (n = 0; n < 6; n++) {
// pre_chmant[n][ch][bin]
pre_chmant = get_sbits(gbc, bits-bg);
- if(bg && pre_chmant == -(1<<(bits-bg-1))){
+ if (bg && pre_chmant == -(1 << (bits - bg - 1))) {
// large mantissa
pre_chmant = get_sbits(gbc, bits - ((bg==1)?1:0));
- if(bg==1)
+ if (bg == 1)
//Gk = 2
mant = (float)pre_chmant/((1<<(bits-1))-1);
else
@@ -258,9 +261,9 @@ static void get_transform_coeffs_aht_ch(
g = 0;
remap = 1;
- }else{
+ } else {
// small mantissa
- if(bg)
+ if (bg)
//Gk = 2 or 4
mant = (float)pre_chmant/((1<<(bits-1))-1);
else
@@ -272,24 +275,24 @@ static void get_transform_coeffs_aht_ch(
}
//TODO when remap needed ?
- if(remap){
+ if (remap) {
mant = (float)
(ff_eac3_gaq_remap[s->hebap[ch][bin]-8][0][g][0]/32768.0f + 1.0f)
- * mant / (1<<g) +
- (ff_eac3_gaq_remap[s->hebap[ch][bin]-8][mant<0][g][1]) / 32768.0f;
+ * mant / (1<<g) +
+ (ff_eac3_gaq_remap[s->hebap[ch][bin]-8][mant<0][g][1]) / 32768.0f;
}
s->pre_chmant[n][ch][bin] = mant;
}
- }else{
+ } else {
// hebap = 0 or VQ
- if(s->hebap[ch][bin]){
+ if (s->hebap[ch][bin]) {
pre_chmant = get_bits(gbc, ff_bits_vs_hebap[s->hebap[ch][bin]]);
- for(n = 0; n < 6; n++){
+ for (n = 0; n < 6; n++) {
s->pre_chmant[n][ch][bin] =
ff_vq_hebap[s->hebap[ch][bin]][pre_chmant][n] / 32768.0f;
}
- }else{
- for(n = 0; n < 6; n++){
+ } else {
+ for (n = 0; n < 6; n++) {
s->pre_chmant[n][ch][bin] = 0;
}
}
@@ -301,9 +304,9 @@ static void idct_transform_coeffs_ch(EAC
// TODO fast IDCT
int bin, i;
float tmp;
- for(bin=s->strtmant[ch]; bin<s->endmant[ch]; bin++){
+ for (bin = s->strtmant[ch]; bin < s->endmant[ch]; bin++) {
tmp = 0;
- for(i=0; i<6; i++){
+ for (i = 0; i < 6; i++) {
tmp += (i?sqrt(2):1) * s->pre_chmant[i][ch][bin] * cos(M_PI*i*(2*blk + 1)/12);
}
s->transform_coeffs[ch][bin] = tmp * ff_ac3_scale_factors[s->dexps[ch][bin]];
@@ -312,15 +315,17 @@ static void idct_transform_coeffs_ch(EAC
static void get_eac3_transform_coeffs_ch(GetBitContext *gbc, EAC3Context *s, int blk,
int ch, mant_groups *m){
- if(s->chahtinu[ch] == 0){
+ if (s->chahtinu[ch] == 0) {
ff_ac3_get_transform_coeffs_ch(m, gbc, s->dexps[ch], s->bap[ch],
s->transform_coeffs[ch], s->strtmant[ch], s->endmant[ch],
&s->dith_state);
- }else if(s->chahtinu[ch] == 1){
- get_transform_coeffs_aht_ch(gbc, s, ch);
- s->chahtinu[ch] = -1; /* AHT info for this frame has been read - do not read again */
+ } else {
+ if (s->chahtinu[ch] == 1) {
+ get_transform_coeffs_aht_ch(gbc, s, ch);
+ s->chahtinu[ch] = -1; /* AHT info for this frame has been read - do not read again */
+ }
}
- if(s->chahtinu[ch] != 0){
+ if (s->chahtinu[ch] != 0) {
idct_transform_coeffs_ch(s, ch, blk);
}
}
@@ -329,21 +334,21 @@ static int parse_bsi(GetBitContext *gbc,
int i, blk;
s->strmtyp = get_bits(gbc, 2);
- if(s->strmtyp){
+ if (s->strmtyp) {
log_missing_feature(s->avctx, "Dependent substream");
return -1;
}
s->substreamid = get_bits(gbc, 3);
s->frmsiz = get_bits(gbc, 11);
s->fscod = get_bits(gbc, 2);
- if(s->fscod == 3){
+ if (s->fscod == 3) {
log_missing_feature(s->avctx, "Reduced Sampling Rates");
return -1;
#if 0
s->fscod2 = get_bits(gbc, 2);
s->numblkscod = 3; /* six blocks per frame */
#endif
- }else{
+ } else {
s->numblkscod = get_bits(gbc, 2);
}
s->acmod = get_bits(gbc, 3);
@@ -353,7 +358,7 @@ static int parse_bsi(GetBitContext *gbc,
s->nfchans = ff_ac3_channels[s->acmod];
s->num_channels = s->nfchans;
s->lfe_channel = s->num_channels+1;
- if(s->lfeon){
+ if (s->lfeon) {
s->strtmant[s->lfe_channel] = 0;
s->endmant[s->lfe_channel] = 7;
s->nchgrps[s->lfe_channel] = 2;
@@ -362,109 +367,113 @@ static int parse_bsi(GetBitContext *gbc,
}
s->bsid = get_bits(gbc, 5);
- if(s->bsid < 11 || s->bsid > 16){
+ if (s->bsid < 11 || s->bsid > 16) {
av_log(s->avctx, AV_LOG_ERROR, "bsid should be between 11 and 16\n");
return -1;
}
- for(i = 0; i < (s->acmod?1:2); i++){
+ for (i = 0; i < (s->acmod ? 1 : 2); i++) {
s->dialnorm[i] = ff_ac3_dialnorm_tbl[get_bits(gbc, 5)];
- if(get_bits1(gbc)){
+ if (get_bits1(gbc)) {
skip_bits(gbc, 8); //skip Compression gain word
}
}
- if(s->strmtyp == 1){
+ if (s->strmtyp == 1) {
/* if dependent stream */
- if(get_bits1(gbc)){
+ if (get_bits1(gbc)) {
s->chanmap = get_bits(gbc, 16);
- }else{
+ } else {
//TODO default channel map based on acmod and lfeon
}
}
/* set stereo downmixing coefficients
reference: Section 7.8.2 Downmixing Into Two Channels */
- for(i=0; i<s->nfchans; i++) {
+ for (i = 0; i < s->nfchans; i++) {
s->downmix_coeffs[i][0] = mixlevels[eac3_default_coeffs[s->acmod][i][0]];
s->downmix_coeffs[i][1] = mixlevels[eac3_default_coeffs[s->acmod][i][1]];
}
s->mixmdate = get_bits1(gbc);
- if(s->mixmdate){
+ if (s->mixmdate) {
/* Mixing metadata */
- if(s->acmod > 2){
+ if (s->acmod > 2) {
/* if more than 2 channels */
s->dmixmod = get_bits(gbc, 2);
}
- if((s->acmod & 1) && (s->acmod > 2)){
+ if ((s->acmod & 1) && (s->acmod > 2)) {
/* if three front channels exist */
skip_bits(gbc, 3); //skip Lt/Rt center mix level
s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = mixlevels[get_bits(gbc, 3)];
}
- if(s->acmod & 4){
+ if (s->acmod & 4) {
/* if a surround channel exists */
float surmixlev;
skip_bits(gbc, 3); //skip Lt/Rt surround mix level
surmixlev = mixlevels[get_bits(gbc, 3)];
- if(s->acmod & 2){
+ if (s->acmod & 2) {
//two surround channels
s->downmix_coeffs[s->acmod-4][0] = s->downmix_coeffs[s->acmod-3][1] =
surmixlev;
- }else{
+ } else {
s->downmix_coeffs[s->acmod-2][0] = s->downmix_coeffs[s->acmod-2][1] =
surmixlev * LEVEL_MINUS_3DB;
}
}
- if(s->lfeon){
+ if (s->lfeon) {
/* if the LFE channel exists */
s->lfemixlevcode = get_bits1(gbc);
- if(s->lfemixlevcode){
+ if (s->lfemixlevcode) {
s->lfemixlevcod = get_bits(gbc, 5);
}
}
- if(!s->strmtyp){
+ if (!s->strmtyp) {
/* if independent stream */
- for(i = 0; i < (s->acmod?1:2); i++){
- if(get_bits1(gbc)){
+ for (i = 0; i < (s->acmod ? 1 : 2); i++) {
+ if (get_bits1(gbc)) {
s->pgmscl[i] = get_bits(gbc, 6);
- }else{
+ } else {
//TODO program scale factor = 0dB
}
}
- if(get_bits1(gbc)){
+ if (get_bits1(gbc)) {
s->extpgmscl = get_bits(gbc, 6);
}
s->mixdef = get_bits(gbc, 2);
- if(s->mixdef == 1){
+ if (s->mixdef == 1) {
/* mixing option 2 */
skip_bits(gbc, 5);
- }else if(s->mixdef == 2){
- /* mixing option 3 */
- skip_bits(gbc, 12);
- }else if(s->mixdef == 3){
- /* mixing option 4 */
- s->mixdeflen = get_bits(gbc, 5);
- skip_bits(gbc, 8*(s->mixdeflen+2));
- }
- if(s->acmod < 2){
- /* if mono or dual mono source */
- for(i = 0; i < (s->acmod?1:2); i++){
- if(get_bits1(gbc)){
- s->paninfo[i] = get_bits(gbc, 14);
- }else{
- //TODO default = center
+ } else {
+ if (s->mixdef == 2) {
+ /* mixing option 3 */
+ skip_bits(gbc, 12);
+ } else {
+ if (s->mixdef == 3) {
+ /* mixing option 4 */
+ s->mixdeflen = get_bits(gbc, 5);
+ skip_bits(gbc, 8*(s->mixdeflen+2));
}
}
- }
- s->frmmixcfginfoe = get_bits1(gbc);
- if(s->frmmixcfginfoe){
- /* mixing configuration information */
- if(!s->numblkscod){
- s->blkmixcfginfo[0] = get_bits(gbc, 5);
- }else{
- for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++){
- if(get_bits1(gbc)){
- s->blkmixcfginfo[blk] = get_bits(gbc, 5);
+ if (s->acmod < 2) {
+ /* if mono or dual mono source */
+ for (i = 0; i < (s->acmod ? 1 : 2); i++) {
+ if (get_bits1(gbc)) {
+ s->paninfo[i] = get_bits(gbc, 14);
+ } else {
+ //TODO default = center
+ }
+ }
+ }
+ s->frmmixcfginfoe = get_bits1(gbc);
+ if (s->frmmixcfginfoe) {
+ /* mixing configuration information */
+ if (!s->numblkscod) {
+ s->blkmixcfginfo[0] = get_bits(gbc, 5);
+ } else {
+ for (blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++) {
+ if (get_bits1(gbc)) {
+ s->blkmixcfginfo[blk] = get_bits(gbc, 5);
+ }
}
}
}
@@ -472,40 +481,40 @@ static int parse_bsi(GetBitContext *gbc,
}
}
s->infomdate = get_bits1(gbc);
- if(s->infomdate){
+ if (s->infomdate) {
/* Informational metadata */
skip_bits(gbc, 3); //skip Bit stream mode
skip_bits(gbc, 2); //skip copyright bit and original bitstream bit
- if(s->acmod == AC3_ACMOD_STEREO) /* if in 2/0 mode */{
+ if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
skip_bits(gbc, 4); //skip Dolby surround and headphone mode
}
- if(s->acmod >= 6){
+ if (s->acmod >= 6) {
/* if both surround channels exist */
skip_bits(gbc, 2); //skip Dolby surround EX mode
}
- for(i = 0; i < (s->acmod?1:2); i++){
- if(get_bits1(gbc)){
+ for (i = 0; i < (s->acmod ? 1 : 2); i++) {
+ if (get_bits1(gbc)) {
skip_bits(gbc, 8); //skip Mix level, Room type and A/D converter type
}
}
- if(s->fscod < 3){
+ if (s->fscod < 3) {
/* if not half sample rate */
skip_bits1(gbc); //skip Source sample rate code
}
}
- if((!s->strmtyp) && (s->numblkscod != 3) ){
+ if ((!s->strmtyp) && (s->numblkscod != 3)) {
skip_bits1(gbc); //converter synchronization flag
}
- if(s->strmtyp == 2){
+ if (s->strmtyp == 2) {
/* if bit stream converted from AC-3 */
- if(s->numblkscod == 3 || get_bits1(gbc)){
+ if (s->numblkscod == 3 || get_bits1(gbc)) {
/* 6 blocks per frame */
skip_bits(gbc, 6); // skip Frame size code
}
}
- if(get_bits1(gbc)){
+ if (get_bits1(gbc)) {
int addbsil = get_bits(gbc, 6);
- for(i=0; i<addbsil+1; i++){
+ for (i = 0; i < addbsil + 1; i++) {
skip_bits(gbc, 8); // Additional bit stream information
}
}
@@ -517,12 +526,12 @@ static int parse_audfrm(GetBitContext *g
int blk, ch;
/* Audio frame exist flags and strategy data */
- if(s->numblkscod == 3){
+ if (s->numblkscod == 3) {
/* six blocks per frame */
/* LUT-based exponent strategy syntax */
s->expstre = get_bits1(gbc);
s->ahte = get_bits1(gbc);
- }else{
+ } else {
/* AC-3 style exponent strategy syntax */
s->expstre = 1;
s->ahte = 0;
@@ -530,13 +539,13 @@ static int parse_audfrm(GetBitContext *g
s->snroffststr = get_bits(gbc, 2);
s->transproce = get_bits1(gbc);
s->blkswe = get_bits1(gbc);
- if(!s->blkswe){
- for(ch = 1; ch <= s->nfchans; ch++)
+ if (!s->blkswe) {
+ for (ch = 1; ch <= s->nfchans; ch++)
s->blksw[ch] = 0;
}
s->dithflage = get_bits1(gbc);
- if(!s->dithflage){
- for(ch = 1; ch <= s->nfchans; ch++)
+ if (!s->dithflage) {
+ for (ch = 1; ch <= s->nfchans; ch++)
s->dithflag[ch] = 1; /* dither on */
}
s->dithflag[CPL_CH] = s->dithflag[s->lfe_channel] = 0;
@@ -548,90 +557,90 @@ static int parse_audfrm(GetBitContext *g
s->skipflde = get_bits1(gbc);
s->spxattene = get_bits1(gbc);
/* Coupling data */
- if(s->acmod > 1){
+ if (s->acmod > 1) {
s->cplstre[0] = 1;
s->cplinu[0] = get_bits1(gbc);
s->ncplblks = s->cplinu[0];
- for(blk = 1; blk < ff_eac3_blocks[s->numblkscod]; blk++){
+ for (blk = 1; blk < ff_eac3_blocks[s->numblkscod]; blk++) {
s->cplstre[blk] = get_bits1(gbc);
- if(s->cplstre[blk]){
+ if (s->cplstre[blk]) {
s->cplinu[blk] = get_bits1(gbc);
- }else{
+ } else {
s->cplinu[blk] = s->cplinu[blk-1];
}
s->ncplblks += s->cplinu[blk];
}
- }else{
+ } else {
memset(s->cplinu, 0, sizeof(int) * ff_eac3_blocks[s->numblkscod]);
s->ncplblks = 0;
}
/* Exponent strategy data */
- if(s->expstre){
+ if (s->expstre) {
/* AC-3 style exponent strategy syntax */
- for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++){
- for(ch = !s->cplinu[blk]; ch <= s->nfchans; ch++){
+ for (blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++) {
+ for (ch = !s->cplinu[blk]; ch <= s->nfchans; ch++) {
s->chexpstr[blk][ch] = get_bits(gbc, 2);
}
}
- }else{
+ } else {
/* LUT-based exponent strategy syntax */
int frmchexpstr;
/* cplexpstr[blk] and chexpstr[blk][ch] derived from table lookups. see Table E2.14 */
- for(ch = !((s->acmod > 1) && (s->ncplblks)); ch <= s->nfchans; ch++){
+ for (ch = !((s->acmod > 1) && (s->ncplblks)); ch <= s->nfchans; ch++) {
frmchexpstr = get_bits(gbc, 5);
- for(blk=0; blk<6; blk++){
+ for (blk = 0; blk < 6; blk++) {
s->chexpstr[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
}
}
}
/* LFE exponent strategy */
- if(s->lfeon){
- for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++){
+ if (s->lfeon) {
+ for (blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++) {
s->chexpstr[blk][s->lfe_channel] = get_bits1(gbc);
}
}
/* Converter exponent strategy data */
- if(!s->strmtyp){
- if(s->numblkscod == 3 || get_bits1(gbc)){
- for(ch = 1; ch <= s->nfchans; ch++){
+ if (!s->strmtyp) {
+ if (s->numblkscod == 3 || get_bits1(gbc)) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
skip_bits(gbc, 5); //skip Converter channel exponent strategy
}
}
}
/* AHT data */
- if(s->ahte){
+ if (s->ahte) {
/* AHT is only available in 6 block mode (numblkscod ==3) */
/* coupling can use AHT only when coupling in use for all blocks */
/* ncplregs derived from cplstre and cplexpstr - see Section E3.3.2 */
int nchregs;
s->chahtinu[CPL_CH]=0;
- for(ch = (s->ncplblks!=6); ch <= s->num_channels; ch++){
+ for (ch = (s->ncplblks != 6); ch <= s->num_channels; ch++) {
nchregs = 0;
- for(blk = 0; blk < 6; blk++)
+ for (blk = 0; blk < 6; blk++)
nchregs += (s->chexpstr[blk][ch] != EXP_REUSE);
s->chahtinu[ch] = (nchregs == 1) && get_bits1(gbc);
}
- }else{
- for(ch=0; ch<=s->num_channels; ch++)
+ } else {
+ for (ch = 0; ch <= s->num_channels; ch++)
s->chahtinu[ch] = 0;
}
/* Audio frame SNR offset data */
- if(!s->snroffststr){
+ if (!s->snroffststr) {
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
- for(ch=0; ch<= s->num_channels; ch++)
+ for (ch = 0; ch <= s->num_channels; ch++)
s->snroffst[ch] = snroffst;
}
/* Audio frame transient pre-noise processing data */
- if(s->transproce){
+ if (s->transproce) {
av_log(s->avctx, AV_LOG_ERROR, "transient pre-noise processing NOT IMPLEMENTED\n");
return -1;
#if 0
- for(ch = 1; ch <= s->nfchans; ch++){
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chintransproc[ch] = get_bits1(gbc);
- if(s->chintransproc[ch]){
+ if (s->chintransproc[ch]) {
s->transprocloc[ch] = get_bits(gbc, 10);
s->transproclen[ch] = get_bits(gbc, 8);
}
@@ -639,19 +648,19 @@ static int parse_audfrm(GetBitContext *g
#endif
}
/* Spectral extension attenuation data */
- if(s->spxattene){
- for(ch = 1; ch <= s->nfchans; ch++){
+ if (s->spxattene) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chinspxatten[ch] = get_bits1(gbc);
- if(s->chinspxatten[ch]){
+ if (s->chinspxatten[ch]) {
s->spxattencod[ch] = get_bits(gbc, 5);
}
}
- }else{
- for(ch = 1; ch <= s->nfchans; ch++)
+ } else {
+ for (ch = 1; ch <= s->nfchans; ch++)
s->chinspxatten[ch]=0;
}
/* Block start information */
- if(s->numblkscod && get_bits1(gbc)){
+ if (s->numblkscod && get_bits1(gbc)) {
/* nblkstrtbits determined from frmsiz (see Section E2.3.2.27) */
// nblkstrtbits = (numblks - 1) * (4 + ceiling (log2 (words_per_frame)))
// where numblks is derived from the numblkscod in Table E2.9
@@ -661,7 +670,7 @@ static int parse_audfrm(GetBitContext *g
s->blkstrtinfo = get_bits(gbc, nblkstrtbits);
}
/* Syntax state initialization */
- for(ch = 1; ch <= s->nfchans; ch++){
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->firstspxcos[ch] = 1;
s->firstcplcos[ch] = 1;
}
@@ -679,91 +688,93 @@ static int parse_audblk(GetBitContext *g
m.b1ptr = m.b2ptr = m.b4ptr = 3;
/* Block switch and dither flags */
- if(s->blkswe){
- for(ch = 1; ch <= s->nfchans; ch++){
+ if (s->blkswe) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->blksw[ch] = get_bits1(gbc);
}
}
- if(s->dithflage){
- for(ch = 1; ch <= s->nfchans; ch++){
+ if (s->dithflage) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->dithflag[ch] = get_bits1(gbc);
}
}
/* Dynamic range control */
- for(i = 0; i < (s->acmod?1:2); i++){
- if(get_bits1(gbc)){
+ for (i = 0; i < (s->acmod ? 1 : 2); i++) {
+ if (get_bits1(gbc)) {
s->dynrng[i] = ff_ac3_dynrng_tbl[get_bits(gbc, 8)];
- }else{
- if(!blk){
+ } else {
+ if (!blk) {
s->dynrng[i] = 1.0f;
}
}
}
/* Spectral extension strategy information */
- if((!blk) || get_bits1(gbc)){
+ if ((!blk) || get_bits1(gbc)) {
s->spxinu = get_bits1(gbc);
- if(s->spxinu){
+ if (s->spxinu) {
log_missing_feature(s->avctx, "Spectral extension");
return -1;
#if 0
- if(s->acmod == AC3_ACMOD_MONO){
+ if (s->acmod == AC3_ACMOD_MONO) {
s->chinspx[1] = 1;
- }else{
- for(ch = 1; ch <= s->nfchans; ch++){
+ } else {
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chinspx[ch] = get_bits1(gbc);
}
}
#if 0
{
int nspx=0;
- for(ch=1; ch<=s->nfchans; ch++){
+ for (ch = 1; ch <= s->nfchans; ch++) {
nspx+=s->chinspx[ch];
}
- if(!nspx)
+ if (!nspx)
av_log(s->avctx, AV_LOG_INFO, "No channels in spectral extension\n");
}
#endif
s->spxstrtf = get_bits(gbc, 2);
s->spxbegf = get_bits(gbc, 3);
s->spxendf = get_bits(gbc, 3);
- if(s->spxbegf < 6){
+ if (s->spxbegf < 6) {
s->spxbegf += 2;
- }else{
+ } else {
s->spxbegf = s->spxbegf * 2 - 3;
}
- if(s->spxendf < 3){
+ if (s->spxendf < 3) {
s->spxendf += 5;
- }else{
+ } else {
s->spxendf = s->spxendf * 2 + 3;
}
- for(ch = 1; ch <= s->nfchans; ch++){
- if(s->chinspx[ch])
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chinspx[ch])
s->endmant[ch] = 25 + 12 * s->spxbegf;
}
- if(get_bits1(gbc)){
- for(bnd = s->spxbegf+1; bnd < s->spxendf; bnd++){
+ if (get_bits1(gbc)) {
+ for (bnd = s->spxbegf + 1; bnd < s->spxendf; bnd++) {
s->spxbndstrc[bnd] = get_bits1(gbc);
}
- }else if(!blk){
- for(bnd = 0; bnd < 17; bnd++)
- s->spxbndstrc[bnd] = ff_eac3_defspxbndstrc[bnd];
+ } else {
+ if (!blk) {
+ for (bnd = 0; bnd < 17; bnd++)
+ s->spxbndstrc[bnd] = ff_eac3_defspxbndstrc[bnd];
+ }
}
// calculate number of spectral extension bands
s->nspxbnds = 1;
s->spxbndsztab[0] = 12;
for (bnd = s->spxbegf+1; bnd < s->spxendf; bnd ++){
- if (!s->spxbndstrc[bnd]){
+ if (!s->spxbndstrc[bnd]) {
s->spxbndsztab[s->nspxbnds] = 12;
s->nspxbnds++;
- }else{
+ } else {
s->spxbndsztab[s->nspxbnds - 1] += 12;
}
}
#endif
- }else{
+ } else {
/* !spxinu */
- for(ch = 1; ch <= s->nfchans; ch++){
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chinspx[ch] = 0;
s->firstspxcos[ch] = 1;
}
@@ -771,140 +782,144 @@ static int parse_audblk(GetBitContext *g
}
/* Spectral extension coordinates */
- if(s->spxinu){
- for(ch = 1; ch <= s->nfchans; ch++){
- if(s->chinspx[ch]){
- if(s->firstspxcos[ch]){
+ if (s->spxinu) {
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chinspx[ch]) {
+ if (s->firstspxcos[ch]) {
s->spxcoe[ch] = 1;
s->firstspxcos[ch] = 0;
- }else{
+ } else {
/* !firstspxcos[ch] */
s->spxcoe[ch] = get_bits1(gbc);
}
- if(!blk && !s->spxcoe[ch]){
+ if (!blk && !s->spxcoe[ch]) {
av_log(s->avctx, AV_LOG_ERROR, "no spectral extension coordinates in first block\n");
return -1;
}
- if(s->spxcoe[ch]){
+ if (s->spxcoe[ch]) {
int spxcoexp, spxcomant, mstrspxco;
s->spxblnd[ch] = get_bits(gbc, 5);
mstrspxco = get_bits(gbc, 2);
mstrspxco*=3;
/* nspxbnds determined from spxbegf, spxendf, and spxbndstrc[ ] */
- for(bnd = 0; bnd < s->nspxbnds; bnd++){
+ for (bnd = 0; bnd < s->nspxbnds; bnd++) {
spxcoexp = get_bits(gbc, 4);
spxcomant = get_bits(gbc, 2);
- if(spxcoexp==15)
+ if (spxcoexp == 15)
s->spxco[ch][bnd] = spxcomant / 4.0f;
else
s->spxco[ch][bnd] = (spxcomant+4) / 8.0f;
s->spxco[ch][bnd] *= ff_ac3_scale_factors[spxcoexp + mstrspxco];
}
}
- }else{
+ } else {
/* !chinspx[ch] */
s->firstspxcos[ch] = 1;
}
}
}
/* Coupling strategy and enhanced coupling strategy information */
- if(s->cplstre[blk]){
- if (s->cplinu[blk]){
+ if (s->cplstre[blk]) {
+ if (s->cplinu[blk]) {
s->ecplinu = get_bits1(gbc);
- if (s->acmod == AC3_ACMOD_STEREO){
+ if (s->acmod == AC3_ACMOD_STEREO) {
s->chincpl[1] = 1;
s->chincpl[2] = 1;
- }else{
- for(ch = 1; ch <= s->nfchans; ch++){
+ } else {
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chincpl[ch] = get_bits1(gbc);
}
}
- if (!s->ecplinu){
+ if (!s->ecplinu) {
/* standard coupling in use */
- if(s->acmod == AC3_ACMOD_STEREO) /* if in 2/0 mode */ {
+ if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
s->phsflginu = get_bits1(gbc);
}
s->cplbegf = get_bits(gbc, 4);
- if (!s->spxinu){
+ if (!s->spxinu) {
/* if SPX not in use */
s->cplendf = get_bits(gbc, 4);
s->cplendf += 3;
- }else{
+ } else {
/* SPX in use */
s->cplendf = s->spxbegf - 1;
}
s->strtmant[CPL_CH] = 37 + (12 * s->cplbegf);
s->endmant[CPL_CH] = 37 + (12 * s->cplendf);
- if(s->strtmant[CPL_CH] > s->endmant[CPL_CH]){
+ if (s->strtmant[CPL_CH] > s->endmant[CPL_CH]) {
av_log(s->avctx, AV_LOG_ERROR, "cplstrtmant > cplendmant [blk=%i]\n", blk);
return -1;
}
- for(ch = 1; ch <= s->nfchans; ch++){
- if(s->chincpl[ch])
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chincpl[ch])
s->endmant[ch] = s->strtmant[CPL_CH];
}
- if(get_bits1(gbc)){
- for(bnd = s->cplbegf+1; bnd < s->cplendf; bnd++){
+ if (get_bits1(gbc)) {
+ for (bnd = s->cplbegf + 1; bnd < s->cplendf; bnd++) {
s->cplbndstrc[bnd] = get_bits1(gbc);
}
- }else if(!blk){
- for(bnd = 0; bnd < 18; bnd++)
- s->cplbndstrc[bnd] = ff_eac3_defcplbndstrc[bnd];
+ } else {
+ if (!blk) {
+ for (bnd = 0; bnd < 18; bnd++)
+ s->cplbndstrc[bnd] = ff_eac3_defcplbndstrc[bnd];
+ }
}
s->ncplsubnd = s->cplendf - s->cplbegf;
s->ncplbnd = s->ncplsubnd;
- for(bnd = s->cplbegf+1; bnd < s->cplendf; bnd++){
+ for (bnd = s->cplbegf + 1; bnd < s->cplendf; bnd++) {
s->ncplbnd -= s->cplbndstrc[bnd];
}
- }else{
+ } else {
/* enhanced coupling in use */
log_missing_feature(s->avctx, "Enhanced coupling");
return -1;
#if 0
s->ecplbegf = get_bits(gbc, 4);
- if(s->ecplbegf < 3){
+ if (s->ecplbegf < 3) {
s->ecpl_start_subbnd = s->ecplbegf * 2;
- }else if(s->ecplbegf < 13){
- s->ecpl_start_subbnd = s->ecplbegf + 2;
- }else{
- s->ecpl_start_subbnd = s->ecplbegf * 2 - 10;
+ } else {
+ if (s->ecplbegf < 13) {
+ s->ecpl_start_subbnd = s->ecplbegf + 2;
+ } else {
+ s->ecpl_start_subbnd = s->ecplbegf * 2 - 10;
+ }
}
- if (!s->spxinu){
+ if (!s->spxinu) {
/* if SPX not in use */
s->ecplendf = get_bits(gbc, 4);
s->ecpl_end_subbnd = s->ecplendf + 7;
- }else{
+ } else {
/* SPX in use */
- if(s->spxbegf < 6){
+ if (s->spxbegf < 6) {
s->ecpl_end_subbnd = s->spxbegf + 5;
- }else{
+ } else {
s->ecpl_end_subbnd = s->spxbegf * 2;
}
}
- if (get_bits1(gbc)){
- for(sbnd = FFMAX(9, s->ecpl_start_subbnd+1);
+ if (get_bits1(gbc)) {
+ for (sbnd = FFMAX(9, s->ecpl_start_subbnd + 1);
sbnd < s->ecpl_end_subbnd; sbnd++){
s->ecplbndstrc[sbnd] = get_bits1(gbc);
}
- }else{
- if(!blk){
- for(sbnd = 0; sbnd < 22; sbnd++)
- s->ecplbndstrc[sbnd] = ff_eac3_defecplbndstrc[sbnd]
+ } else {
+ if (!blk) {
+ for (sbnd = 0; sbnd < 22; sbnd++)
+ s->ecplbndstrc[sbnd] = ff_eac3_defecplbndstrc[sbnd];
}
}
//necplbnd = ecpl_end_subbnd - ecpl_start_subbnd;
//necplbnd -= ecplbndstrc[ecpl_start_subbnd] + ... + ecplbndstrc[ecpl_end_subbnd -1]
s->necplbnd = s->ecpl_end_subbnd - s->ecpl_start_subbnd;
- for(bnd=s->ecpl_start_subbnd; bnd<s->ecpl_end_subbnd; bnd++){
+ for (bnd = s->ecpl_start_subbnd; bnd < s->ecpl_end_subbnd; bnd++) {
s->necplbnd -= s->ecplbndstrc[bnd];
}
#endif
} /* ecplinu[blk] */
- }else{
+ } else {
/* !cplinu[blk] */
- for(ch = 1; ch <= s->nfchans; ch++){
+ for (ch = 1; ch <= s->nfchans; ch++) {
s->chincpl[ch] = 0;
s->firstcplcos[ch] = 1;
}
@@ -914,96 +929,97 @@ static int parse_audblk(GetBitContext *g
}
} /* cplstre[blk] */
/* Coupling coordinates */
- if(s->cplinu[blk]){
- if(!s->ecplinu){
+ if (s->cplinu[blk]) {
+ if (!s->ecplinu) {
/* standard coupling in use */
- for(ch = 1; ch <= s->nfchans; ch++){
- if(s->chincpl[ch]){
- if (s->firstcplcos[ch]){
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chincpl[ch]) {
+ if (s->firstcplcos[ch]) {
s->cplcoe[ch] = 1;
s->firstcplcos[ch] = 0;
- }else{
+ } else {
/* !firstcplcos[ch] */
s->cplcoe[ch] = get_bits1(gbc);
}
- if(s->cplcoe[ch]){
+ if (s->cplcoe[ch]) {
int cplcoexp, cplcomant, mstrcplco;
mstrcplco = get_bits(gbc, 2);
mstrcplco = 3 * mstrcplco;
/* ncplbnd derived from cplbegf, cplendf, and cplbndstrc */
- for(bnd = 0; bnd < s->ncplbnd; bnd++){
+ for (bnd = 0; bnd < s->ncplbnd; bnd++) {
cplcoexp = get_bits(gbc, 4);
cplcomant = get_bits(gbc, 4);
- if(cplcoexp==15)
+ if (cplcoexp == 15)
s->cplco[ch][bnd] = cplcomant / 16.0f;
else
s->cplco[ch][bnd] = (cplcomant + 16.0f) / 32.0f;
s->cplco[ch][bnd] *= ff_ac3_scale_factors[cplcoexp + mstrcplco];
}
} /* cplcoe[ch] */
- else{
- if(!blk){
+ else {
+ if (!blk) {
av_log(s->avctx, AV_LOG_ERROR, "no coupling coordinates in first block\n");
return -1;
}
}
- }else{
+ } else {
/* ! chincpl[ch] */
s->firstcplcos[ch] = 1;
}
} /* ch */
- if((s->acmod == AC3_ACMOD_STEREO) && s->phsflginu && (s->cplcoe[1] || s->cplcoe[2])){
- for(bnd = 0; bnd < s->ncplbnd; bnd++){
+ if ((s->acmod == AC3_ACMOD_STEREO) && s->phsflginu
+ && (s->cplcoe[1] || s->cplcoe[2])) {
+ for (bnd = 0; bnd < s->ncplbnd; bnd++) {
s->phsflg[bnd] = get_bits1(gbc);
}
}
s->nchgrps[CPL_CH] = (s->endmant[CPL_CH] - s->strtmant[CPL_CH]) /
(3 << (s->chexpstr[blk][CPL_CH] - 1));
- }else{
+ } else {
/* enhanced coupling in use */
//TODO calc nchgrps[CPL_CH]
#if 0
s->firstchincpl = -1;
s->ecplangleintrp = get_bits1(gbc);
- for(ch = 1; ch <= s->nfchans; ch++){
- if(s->chincpl[ch]){
- if(s->firstchincpl == -1){
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (s->chincpl[ch]) {
+ if (s->firstchincpl == -1) {
s->firstchincpl = ch;
}
- if(s->firstcplcos[ch]){
+ if (s->firstcplcos[ch]) {
s->ecplparam1e[ch] = 1;
- if (ch > s->firstchincpl){
+ if (ch > s->firstchincpl) {
s->ecplparam2e[ch] = 1;
- }else{
+ } else {
s->ecplparam2e[ch] = 0;
}
s->firstcplcos[ch] = 0;
- }else{
+ } else {
/* !firstcplcos[ch] */
s->ecplparam1e[ch] = get_bits1(gbc);
- if(ch > s->firstchincpl){
+ if (ch > s->firstchincpl) {
s->ecplparam2e[ch] = get_bits1(gbc);
- }else{
+ } else {
s->ecplparam2e[ch] = 0;
}
}
- if(s->ecplparam1e[ch]){
+ if (s->ecplparam1e[ch]) {
/* necplbnd derived from ecpl_start_subbnd, ecpl_end_subbnd, and ecplbndstrc */
- for(bnd = 0; bnd < s->necplbnd; bnd++){
+ for (bnd = 0; bnd < s->necplbnd; bnd++) {
s->ecplamp[ch][bnd] = get_bits(gbc, 5);
}
}
- if(s->ecplparam2e[ch]){
+ if (s->ecplparam2e[ch]) {
/* necplbnd derived from ecpl_start_subbnd, ecpl_end_subbnd, and ecplbndstrc */
- for(bnd = 0; bnd < s->necplbnd; bnd++){
+ for (bnd = 0; bnd < s->necplbnd; bnd++) {
s->ecplangle[ch][bnd] = get_bits(gbc, 6);
s->ecplchaos[ch][bnd] = get_bits(gbc, 3);
}
}
- if(ch > s->firstchincpl){
+ if (ch > s->firstchincpl) {
s->ecpltrans[ch] = get_bits1(gbc);
}
- }else{
+ } else {
/* !chincpl[ch] */
s->firstcplcos[ch] = 1;
}
@@ -1012,30 +1028,30 @@ static int parse_audblk(GetBitContext *g
} /* ecplinu[blk] */
} /* cplinu[blk] */
/* Rematrixing operation in the 2/0 mode */
- if(s->acmod == AC3_ACMOD_STEREO) /* if in 2/0 mode */{
- if (!blk || get_bits1(gbc)){
+ if (s->acmod == AC3_ACMOD_STEREO) { /* if in 2/0 mode */
+ if (!blk || get_bits1(gbc)) {
/* nrematbnds determined from cplinu, ecplinu, spxinu, cplbegf, ecplbegf and spxbegf */
// TODO spx in one channel
int end = (s->cplinu[blk] || s->spxinu) ?
FFMIN(s->endmant[1], s->endmant[2]) : (ff_ac3_rematrix_band_tbl[4]-1);
- for(bnd = 0; ff_ac3_rematrix_band_tbl[bnd] <= end; bnd++){
+ for (bnd = 0; ff_ac3_rematrix_band_tbl[bnd] <= end; bnd++) {
s->rematflg[bnd] = get_bits1(gbc);
}
s->nrematbnds = bnd;
}
}
/* Channel bandwidth code */
- for(ch = 1; ch <= s->nfchans; ch++){
- if(!blk && s->chexpstr[blk][ch]==EXP_REUSE){
+ for (ch = 1; ch <= s->nfchans; ch++) {
+ if (!blk && s->chexpstr[blk][ch] == EXP_REUSE) {
av_log(s->avctx, AV_LOG_ERROR, "no channel exponent strategy in first block\n");
return -1;
}
- if(s->chexpstr[blk][ch] != EXP_REUSE){
+ if (s->chexpstr[blk][ch] != EXP_REUSE) {
grpsize = 3 << (s->chexpstr[blk][ch] - 1);
s->strtmant[ch] = 0;
- if((!s->chincpl[ch]) && (!s->chinspx[ch])){
+ if ((!s->chincpl[ch]) && (!s->chinspx[ch])) {
chbwcod = get_bits(gbc, 6);
- if(chbwcod > 60){
+ if (chbwcod > 60) {
av_log(s->avctx, AV_LOG_ERROR, "chbwcod > 60\n");
return -1;
}
@@ -1046,31 +1062,31 @@ static int parse_audblk(GetBitContext *g
}
}
/* Exponents */
- for(ch=!s->cplinu[blk]; ch<=s->num_channels; ch++){
- if(s->chexpstr[blk][ch]!=EXP_REUSE){
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++) {
+ if (s->chexpstr[blk][ch] != EXP_REUSE) {
s->dexps[ch][0] = get_bits(gbc, 4) << !ch;
ff_ac3_decode_exponents(gbc, s->chexpstr[blk][ch], s->nchgrps[ch],
s->dexps[ch][0], s->dexps[ch]+s->strtmant[ch]+!!ch);
- if(ch != CPL_CH && ch != s->lfe_channel)
+ if (ch != CPL_CH && ch != s->lfe_channel)
skip_bits(gbc, 2); /* skip gainrng */
}
}
/* Bit-allocation parametric information */
- if(s->bamode){
- if(get_bits1(gbc)){
+ if (s->bamode) {
+ if (get_bits1(gbc)) {
s->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gbc, 2)]; /* Table 7.6 */
s->bit_alloc_params.fdecay = ff_fdecaytab[get_bits(gbc, 2)]; /* Table 7.7 */
s->bit_alloc_params.sgain = ff_sgaintab [get_bits(gbc, 2)]; /* Table 7.8 */
s->bit_alloc_params.dbknee = ff_dbkneetab[get_bits(gbc, 2)]; /* Table 7.9 */
s->bit_alloc_params.floor = ff_floortab [get_bits(gbc, 3)]; /* Table 7.10 */
- }else{
- if(!blk){
+ } else {
+ if (!blk) {
av_log(s->avctx, AV_LOG_ERROR, "no bit allocation information in first block\n");
return -1;
}
}
- }else{
+ } else {
s->bit_alloc_params.sdecay = ff_sdecaytab[2]; /* Table 7.6 */
s->bit_alloc_params.fdecay = ff_fdecaytab[1]; /* Table 7.7 */
s->bit_alloc_params.sgain = ff_sgaintab[1]; /* Table 7.8 */
@@ -1078,81 +1094,83 @@ static int parse_audblk(GetBitContext *g
s->bit_alloc_params.floor = ff_floortab[7]; /* Table 7.10 */
}
- if(s->snroffststr){
+ if (s->snroffststr) {
av_log(s->avctx, AV_LOG_INFO, "NOT TESTED\n");
- if(!blk || get_bits1(gbc) ){
+ if (!blk || get_bits1(gbc)) {
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
- if(s->snroffststr == 1){
+ if (s->snroffststr == 1) {
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
- for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
s->snroffst[ch] = snroffst;
- }else if(s->snroffststr == 2){
- for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
- s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
+ } else {
+ if (s->snroffststr == 2) {
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
+ s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
+ }
}
}
}
- if(s->frmfgaincode && get_bits1(gbc)){
- for(ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
+ if (s->frmfgaincode && get_bits1(gbc)) {
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
s->fgain[ch] = ff_fgaintab[get_bits(gbc, 3)];
- }else{
- if(!blk){
- for(ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
+ } else {
+ if (!blk) {
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
s->fgain[ch] = ff_fgaintab[4];
}
}
- if(!s->strmtyp){
- if(get_bits1(gbc)){
+ if (!s->strmtyp) {
+ if (get_bits1(gbc)) {
skip_bits(gbc, 10); //Converter SNR offset
}
}
- if(s->cplinu[blk]){
- if (s->firstcplleak){
+ if (s->cplinu[blk]) {
+ if (s->firstcplleak) {
s->cplleake = 1;
s->firstcplleak = 0;
- }else{
+ } else {
/* !firstcplleak */
s->cplleake = get_bits1(gbc);
}
- if(s->cplleake){
+ if (s->cplleake) {
s->bit_alloc_params.cplfleak = get_bits(gbc, 3);
s->bit_alloc_params.cplsleak = get_bits(gbc, 3);
}
}
/* Delta bit allocation information */
- if(s->dbaflde && get_bits1(gbc)){
- for(ch = !s->cplinu[blk]; ch <= s->nfchans; ch++){
+ if (s->dbaflde && get_bits1(gbc)) {
+ for (ch = !s->cplinu[blk]; ch <= s->nfchans; ch++) {
s->deltbae[ch] = get_bits(gbc, 2);
}
- for(ch = !s->cplinu[blk]; ch <= s->nfchans; ch++){
- if(s->deltbae[ch]==DBA_NEW){
+ for (ch = !s->cplinu[blk]; ch <= s->nfchans; ch++) {
+ if (s->deltbae[ch] == DBA_NEW) {
s->deltnseg[ch] = get_bits(gbc, 3);
- for(seg = 0; seg <= s->deltnseg[ch]; seg++){
+ for (seg = 0; seg <= s->deltnseg[ch]; seg++) {
s->deltoffst[ch][seg] = get_bits(gbc, 5);
s->deltlen[ch][seg] = get_bits(gbc, 4);
s->deltba[ch][seg] = get_bits(gbc, 3);
}
}
}
- }else{
- if(!blk){
- for(ch=0; ch<=s->num_channels; ch++){
+ } else {
+ if (!blk) {
+ for (ch = 0; ch <= s->num_channels; ch++) {
s->deltbae[ch] = DBA_NONE;
}
}
}
/* Inclusion of unused dummy data */
- if(s->skipflde){
- if(get_bits1(gbc)){
+ if (s->skipflde) {
+ if (get_bits1(gbc)) {
int skipl = get_bits(gbc, 9);
while(skipl--) skip_bits(gbc, 8);
}
}
/* run bit allocation */
- for(ch = !s->cplinu[blk]; ch<=s->num_channels; ch++){
+ for (ch = !s->cplinu[blk]; ch <= s->num_channels; ch++) {
int start=0, end=0;
start = s->strtmant[ch];
end = s->endmant[ch];
@@ -1170,36 +1188,37 @@ static int parse_audblk(GetBitContext *g
s->deltoffst[ch], s->deltlen[ch],
s->deltba[ch], s->mask[ch]);
- if(s->chahtinu[ch]==0)
+ if (s->chahtinu[ch] == 0)
ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_baptab,
s->bap[ch]);
- else if(s->chahtinu[ch]==1)
- ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
- s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_hebaptab,
- s->hebap[ch]);
+ else
+ if (s->chahtinu[ch] == 1)
+ ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
+ s->snroffst[ch], s->bit_alloc_params.floor, ff_ac3_hebaptab,
+ s->hebap[ch]);
}
got_cplchan = 0;
// TODO only for debug
- for(ch=0; ch<=s->num_channels; ch++)
+ for (ch = 0; ch <= s->num_channels; ch++)
memset(s->transform_coeffs[ch], 0, 256*sizeof(float));
/* Quantized mantissa values */
- for(ch = 1; ch <= s->num_channels; ch++){
+ for (ch = 1; ch <= s->num_channels; ch++) {
get_eac3_transform_coeffs_ch(gbc, s, blk, ch, &m);
- if(s->cplinu[blk] && s->chincpl[ch] && !got_cplchan){
+ if (s->cplinu[blk] && s->chincpl[ch] && !got_cplchan) {
get_eac3_transform_coeffs_ch(gbc, s, blk, CPL_CH, &m);
got_cplchan = 1;
}
}
- if(s->cplinu[blk])
+ if (s->cplinu[blk])
uncouple_channels(s);
//apply spectral extension
- if(s->spxinu)
+ if (s->spxinu)
spectral_extension(s);
return 0;
@@ -1212,8 +1231,8 @@ static void do_imdct(EAC3Context *ctx)
{
int ch;
- for(ch=1; ch<=ctx->nfchans+ctx->lfeon; ch++) {
- if(ctx->blksw[ch]) {
+ for (ch = 1; ch <= ctx->nfchans + ctx->lfeon; ch++) {
+ if (ctx->blksw[ch]) {
/* 256-point IMDCT */
ff_ac3_do_imdct_256(ctx->tmp_output, ctx->transform_coeffs[ch],
&ctx->imdct_256, ctx->tmp_imdct);
@@ -1245,15 +1264,15 @@ static int eac3_decode_frame(AVCodecCont
init_get_bits(&gbc, buf, buf_size*8);
c->syncword = get_bits(&gbc, 16);
- if(c->syncword != 0x0B77)
+ if (c->syncword != 0x0B77)
return -1;
- if(parse_bsi(&gbc, c) || parse_audfrm(&gbc, c))
+ if (parse_bsi(&gbc, c) || parse_audfrm(&gbc, c))
return -1;
- if(c->fscod == 3){
+ if (c->fscod == 3) {
avctx->sample_rate = ff_ac3_freqs[c->fscod2] / 2;
- }else{
+ } else {
avctx->sample_rate = ff_ac3_freqs[c->fscod];
}
@@ -1261,55 +1280,58 @@ static int eac3_decode_frame(AVCodecCont
/* channel config */
if (!avctx->request_channels) {
- if(!avctx->channels)
+ if (!avctx->channels)
avctx->channels = c->num_channels;
- } else if(c->num_channels < avctx->request_channels) {
- av_log(avctx, AV_LOG_ERROR, "Cannot upmix EAC3 from %d to %d channels.\n",
- c->num_channels, avctx->request_channels);
- return -1;
} else {
- if(avctx->request_channels > 2 && avctx->request_channels != c->num_channels) {
- av_log(avctx, AV_LOG_ERROR, "Cannot downmix EAC3 from %d to %d channels.\n",
+ if (c->num_channels < avctx->request_channels) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot upmix EAC3 from %d to %d channels.\n",
c->num_channels, avctx->request_channels);
return -1;
+ } else {
+ if (avctx->request_channels > 2
+ && avctx->request_channels != c->num_channels) {
+ av_log(avctx, AV_LOG_ERROR, "Cannot downmix EAC3 from %d to %d channels.\n",
+ c->num_channels, avctx->request_channels);
+ return -1;
+ }
+ avctx->channels = avctx->request_channels;
}
- avctx->channels = avctx->request_channels;
}
- for(blk = 0; blk < ff_eac3_blocks[c->numblkscod]; blk++){
- if(parse_audblk(&gbc, c, blk)){
+ for (blk = 0; blk < ff_eac3_blocks[c->numblkscod]; blk++) {
+ if (parse_audblk(&gbc, c, blk)) {
av_log(c->avctx, AV_LOG_ERROR, "Error in parse_audblk\n");
return -1;
}
/* recover coefficients if rematrixing is in use */
- if(c->acmod == AC3_ACMOD_STEREO)
+ if (c->acmod == AC3_ACMOD_STEREO)
ff_ac3_do_rematrixing(c->transform_coeffs,
FFMIN(c->endmant[1], c->endmant[2]),
c->nrematbnds, c->rematflg);
/* apply scaling to coefficients (dialnorm, dynrng) */
- for(ch=1; ch<=c->nfchans + c->lfeon; ch++) {
+ for (ch = 1; ch <= c->nfchans + c->lfeon; ch++) {
float gain=2.0f;
- if(c->acmod == AC3_ACMOD_DUALMONO) {
+ if (c->acmod == AC3_ACMOD_DUALMONO) {
gain *= c->dialnorm[ch-1] * c->dynrng[ch-1];
} else {
gain *= c->dialnorm[0] * c->dynrng[0];
}
- for(i=0; i<c->endmant[ch]; i++) {
+ for (i = 0; i < c->endmant[ch]; i++) {
c->transform_coeffs[ch][i] *= gain;
}
}
do_imdct(c);
- if(avctx->channels != c->num_channels){
+ if (avctx->channels != c->num_channels) {
ff_ac3_downmix(c->output, c->nfchans, avctx->channels, c->downmix_coeffs);
}
// convert float to 16-bit integer
- for(ch = 0; ch<avctx->channels; ch++) {
- for(i=0; i<AC3_BLOCK_SIZE; i++) {
+ for (ch = 0; ch < avctx->channels; ch++) {
+ for (i = 0; i < AC3_BLOCK_SIZE; i++) {
c->output[ch][i] = c->output[ch][i] * c->mul_bias +
c->add_bias;
}
@@ -1338,7 +1360,7 @@ static int eac3_decode_init(AVCodecConte
ff_mdct_init(&ctx->imdct_256, 8, 1);
ff_mdct_init(&ctx->imdct_512, 9, 1);
dsputil_init(&ctx->dsp, avctx);
- if(ctx->dsp.float_to_int16 == ff_float_to_int16_c) {
+ if (ctx->dsp.float_to_int16 == ff_float_to_int16_c) {
ctx->add_bias = 385.0f;
ctx->mul_bias = 1.0f;
} else {
1
0
Author: bwolowiec
Date: Wed Sep 12 22:43:28 2007
New Revision: 1345
Log:
remove blkstrtinfoe
Modified:
eac3/eac3.h
eac3/eac3dec.c
Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h (original)
+++ eac3/eac3.h Wed Sep 12 22:43:28 2007
@@ -89,7 +89,6 @@ typedef struct EAC3Context{
int transproclen[AC3_MAX_CHANNELS]; ///< Transient processing length
int chinspxatten[AC3_MAX_CHANNELS]; ///< Channel in spectral extension attenuation process
int spxattencod[AC3_MAX_CHANNELS]; ///< spectral extension attenuation code
- int blkstrtinfoe; ///< Block start information exists
uint32_t blkstrtinfo; ///< Block start information
int ncplblks;
///@}
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Wed Sep 12 22:43:28 2007
@@ -651,12 +651,7 @@ static int parse_audfrm(GetBitContext *g
s->chinspxatten[ch]=0;
}
/* Block start information */
- if (s->numblkscod){
- s->blkstrtinfoe = get_bits1(gbc);
- }else{
- s->blkstrtinfoe = 0;
- }
- if(s->blkstrtinfoe){
+ if(s->numblkscod && get_bits1(gbc)){
/* nblkstrtbits determined from frmsiz (see Section E2.3.2.27) */
// nblkstrtbits = (numblks - 1) * (4 + ceiling (log2 (words_per_frame)))
// where numblks is derived from the numblkscod in Table E2.9
1
0
Author: kostya
Date: Wed Sep 12 15:22:27 2007
New Revision: 1344
Log:
Luma DC quantizer differs for RV30 and RV40
Modified:
rv40/rv40.c
Modified: rv40/rv40.c
==============================================================================
--- rv40/rv40.c (original)
+++ rv40/rv40.c Wed Sep 12 15:22:27 2007
@@ -1626,6 +1626,7 @@ static int rv40_decode_macroblock(RV40De
int cbp, cbp2;
int i, blknum, blkoff;
DCTELEM block16[64];
+ int luma_dc_quant;
// calculate which neighbours are available
memset(r->avail, 0, sizeof(r->avail));
@@ -1643,10 +1644,11 @@ static int rv40_decode_macroblock(RV40De
if(cbp == -1)
return -1;
+ luma_dc_quant = r->rv30 ? rv30_luma_dc_quant[r->quant] : rv40_luma_quant[r->si.type>>1][r->quant];
if(r->is16){
memset(block16, 0, sizeof(block16));
rv40_decode_block(block16, gb, r->cur_vlcs, 3, 0);
- rv40_dequant4x4_16x16(block16, 0, rv40_qscale_tab[rv40_luma_quant[r->si.type>>1][r->quant]],rv40_qscale_tab[r->quant]);
+ rv40_dequant4x4_16x16(block16, 0, rv40_qscale_tab[luma_dc_quant],rv40_qscale_tab[r->quant]);
rv40_intra_inv_transform_noround(block16, 0);
}
@@ -1657,7 +1659,7 @@ static int rv40_decode_macroblock(RV40De
if(cbp & 1)
rv40_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->luma_vlc, 0);
if((cbp & 1) || r->is16){
- rv40_dequant4x4(s->block[blknum], blkoff, rv40_qscale_tab[rv40_luma_quant[r->si.type>>1][r->quant]],rv40_qscale_tab[r->quant]);
+ rv40_dequant4x4(s->block[blknum], blkoff, rv40_qscale_tab[luma_dc_quant],rv40_qscale_tab[r->quant]);
if(r->is16) //FIXME: optimize
s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)];
rv40_intra_inv_transform(s->block[blknum], blkoff);
1
0
Author: marco
Date: Wed Sep 12 11:53:10 2007
New Revision: 1343
Log:
fix typo
Modified:
dirac/libavcodec/dirac.c
Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c (original)
+++ dirac/libavcodec/dirac.c Wed Sep 12 11:53:10 2007
@@ -2665,7 +2665,7 @@ static int parse_frame(DiracContext *s)
if (s->wavelet_idx > 7)
return -1;
- /* Overrid wavelet depth. */
+ /* Override wavelet depth. */
if (get_bits1(gb)) {
dprintf(s->avctx, "Non default depth\n");
s->frame_decoding.wavelet_depth = svq3_get_ue_golomb(gb);
1
0
Hi
heres some quick review of the EAC-3 code, ive not really reviewed the
highlevel structure as i dont know AC3 that well and the variable names
make it quite impossible to understand the code without looking everything
up in the spec
note, diego, theres a question for you somewhere below
ac3dec.c:
[...]
> /**
> * table for exponent to scale_factor mapping
> - * scale_factors[i] = 2 ^ -i
> + * ff_ac3_scale_factors[i] = 2 ^ -i
> */
> -static float scale_factors[25];
> +float ff_ac3_scale_factors[25];
>
> /** table for grouping exponents */
> -static uint8_t exp_ungroup_tbl[128][3];
> +uint8_t ff_ac3_exp_ungroup_tbl[128][3];
>
>
all these renamings will need to be commited seperately!
[...]
>
> /* reverse the post-rotation & reordering from standard IMDCT */
> for(k=0; k<32; k++) {
> - z[i][32+k].re = -o_ptr[128+2*k];
> - z[i][32+k].im = -o_ptr[2*k];
> - z[i][31-k].re = o_ptr[2*k+1];
> - z[i][31-k].im = o_ptr[128+2*k+1];
> + z[i][32+k].re = -tmp_output[128+2*k];
> + z[i][32+k].im = -tmp_output[2*k];
> + z[i][31-k].re = tmp_output[2*k+1];
> + z[i][31-k].im = tmp_output[128+2*k+1];
> }
> }
>
> /* apply AC-3 post-rotation & reordering */
> for(k=0; k<64; k++) {
> - o_ptr[ 2*k ] = -z[0][ k].im;
> - o_ptr[ 2*k+1] = z[0][63-k].re;
> - o_ptr[128+2*k ] = -z[0][ k].re;
> - o_ptr[128+2*k+1] = z[0][63-k].im;
> - o_ptr[256+2*k ] = -z[1][ k].re;
> - o_ptr[256+2*k+1] = z[1][63-k].im;
> - o_ptr[384+2*k ] = z[1][ k].im;
> - o_ptr[384+2*k+1] = -z[1][63-k].re;
> + tmp_output[ 2*k ] = -z[0][ k].im;
> + tmp_output[ 2*k+1] = z[0][63-k].re;
> + tmp_output[128+2*k ] = -z[0][ k].re;
> + tmp_output[128+2*k+1] = z[0][63-k].im;
> + tmp_output[256+2*k ] = -z[1][ k].re;
> + tmp_output[256+2*k+1] = z[1][63-k].im;
> + tmp_output[384+2*k ] = z[1][ k].im;
> + tmp_output[384+2*k+1] = -z[1][63-k].re;
> }
this renamings can be avoided
[...]
eac3dec.c:
[...]
> #ifdef DEBUG
> #define GET_BITS(a, gbc, n) {a = get_bits(gbc, n); av_log(NULL, AV_LOG_INFO, "%s: %i\n", __STRING(a), a);}
> #define GET_SBITS(a, gbc, n) {a = get_sbits(gbc, n); av_log(NULL, AV_LOG_INFO, "%s: %i\n", __STRING(a), a);}
> #else
> #define GET_BITS(a, gbc, n) a = get_bits(gbc, n)
> #define GET_SBITS(a, gbc, n) a = get_sbits(gbc, n)
> #endif //DEBUG
i think it has been said already but these are ugly, and i wont
accept that in ffmpeg svn
>
> static void spectral_extension(EAC3Context *s);
> static void get_transform_coeffs_aht_ch(GetBitContext *gbc, EAC3Context *s, int ch);
> static void idct_transform_coeffs_ch(EAC3Context *s, int ch, int blk);
> static void get_eac3_transform_coeffs_ch(GetBitContext *gbc, EAC3Context *s, int blk,
> int ch, mant_groups *m);
> static void uncouple_channels(EAC3Context *s);
> static void log_missing_feature(AVCodecContext *avctx, const char *log);
please order functions so that you dont need these
[...]
> };
>
> static int parse_bsi(GetBitContext *gbc, EAC3Context *s){
please add a doxygen comment saying that bsi == bit stream identification
or even better rename the function so this isnt needed
[...]
> // calculate number of channels
> s->nfchans = ff_ac3_channels[s->acmod];
> s->ntchans = s->nfchans;
rename this to a meaningfull variable name
if meaningless variable names occur in the spec ill accept them though
i do not think its a good idea, personally, if i would be writing the
decoder i would rename every variable and not use a single name from the
spec
and then just add the names from the spec in comments in the struct ...
but this one does not occur in the spec so theres no excuse for such
a meaningless name, channel_count or num_channels would be more
related to what the thing is
btw, would you be very opposed to rename all "ac3 variables" to some
variables made of english words?
[...]
> if(s->bsid < 11 || s->bsid > 16){
> av_log(s->avctx, AV_LOG_ERROR, "bsid should be between 11 and 16\n");
the error is "bsid is not within ..."
> return -1;
> }
>
> for(i = 0; i < (s->acmod?1:2); i++){
> s->dialnorm[i] = ff_ac3_dialnorm_tbl[get_bits(gbc, 5)];
you mix tab and tbl as abbreviations for table, choose one and use that
consistently
> if(get_bits1(gbc)){
> skip_bits(gbc, 8); //skip Compression gain word
> }
> }
> if(s->strmtyp == 0x1){
> /* if dependent stream */
> if(get_bits1(gbc)){
> GET_BITS(s->chanmap, gbc, 16);
> }else{
> //TODO default channel map based on acmod and lfeon
> }
shouldnt this be log_missing_feature() or something?
> }
>
> /* set stereo downmixing coefficients
> reference: Section 7.8.2 Downmixing Into Two Channels */
> for(i=0; i<s->nfchans; i++) {
you mix for(i=0; and for(i = 0;
> s->downmix_coeffs[i][0] = mixlevels[eac3_default_coeffs[s->acmod][i][0]];
> s->downmix_coeffs[i][1] = mixlevels[eac3_default_coeffs[s->acmod][i][1]];
> }
>
> GET_BITS(s->mixmdate, gbc, 1);
> if(s->mixmdate){
> /* Mixing metadata */
now if only the variables had names which made sense then this comment
wouldnt have been needed ...
i really dont understand why they called it mixmdate not mixmdata ...
> if(s->acmod > 0x2){
> /* if more than 2 channels */
> GET_BITS(s->dmixmod, gbc, 2);
> }
> if((s->acmod & 0x1) && (s->acmod > 0x2)){
the 0x prefix is unneeded
[...]
> if(s->frmmixcfginfoe){
> /* mixing configuration information */
beautifull abbreviation, still id use frame_mix_cfg its shorter and makes
sense, alsoitsmorereadableasthewordsareseperated
[...]
> static int parse_audfrm(GetBitContext *gbc, EAC3Context *s){
parse_audio_frame ?
[...]
> memset(s->cplinu, 0, sizeof(int) * ff_eac3_blocks[s->numblkscod]);
sizeof(*s->cplinu)
[...]
> /* AHT data */
> if(s->ahte){
> /* AHT is only available in 6 block mode (numblkscod ==0x3) */
> /* coupling can use AHT only when coupling in use for all blocks */
> /* ncplregs derived from cplstre and cplexpstr - see Section E3.3.2 */
> int nchregs;
> s->chahtinu[CPL_CH]=0;
> for(ch = (s->ncplblks!=6); ch <= s->ntchans; ch++){
> nchregs = 0;
> for(blk = 0; blk < 6; blk++)
> nchregs += (s->chexpstr[blk][ch] != EXP_REUSE);
> s->chahtinu[ch] = (nchregs == 1) && get_bits1(gbc);
> }
> }else{
> for(ch=0; ch<=s->ntchans; ch++)
> s->chahtinu[ch] = 0;
isnt this a memset(0, sizeof(s->chahtinu)) ?
> }
> /* Audio frame SNR offset data */
> if(s->snroffststr == 0x0){
> int csnroffst = (get_bits(gbc, 6) - 15) << 4;
> int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
> for(ch=0; ch<= s->ntchans; ch++)
> s->snroffst[ch] = snroffst;
> }
> /* Audio frame transient pre-noise processing data */
> if(s->transproce){
> av_log(s->avctx, AV_LOG_ERROR, "transient pre-noise processing NOT IMPLEMENTED\n");
why not log_missing_feature() ?
[...]
> /* Block start information */
> if (s->numblkscod != 0x0){
the != 0 is superflous
> GET_BITS(s->blkstrtinfoe, gbc, 1);
> }else{
> s->blkstrtinfoe = 0;
> }
> if(s->blkstrtinfoe){
if(s->numblkscod && get_bits1()){
[...]
> /* enhanced coupling in use */
> log_missing_feature(s->avctx, "Enhanced coupling");
> return -1;
> #if 0
> GET_BITS(s->ecplbegf, gbc, 4);
> if(s->ecplbegf < 3){
why is all the untested code commented out? that way it wont be compiled and
could easily become broken with noone noticing
[...]
> s->bit_alloc_params.sdecay = ff_sdecaytab[0x2]; /* Table 7.6 */
> s->bit_alloc_params.fdecay = ff_fdecaytab[0x1]; /* Table 7.7 */
> s->bit_alloc_params.sgain = ff_sgaintab[0x1]; /* Table 7.8 */
> s->bit_alloc_params.dbknee = ff_dbkneetab[0x2]; /* Table 7.9 */
> s->bit_alloc_params.floor = ff_floortab[0x7]; /* Table 7.10 */
the 0x is superflous
> }
>
> if(s->snroffststr != 0x0){
> av_log(s->avctx, AV_LOG_INFO, "NOT TESTED\n");
inconsistent relative to the other not tested things
> if(!blk || get_bits1(gbc) ){
> int csnroffst = (get_bits(gbc, 6) - 15) << 4;
> if(s->snroffststr == 0x1){
> int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
> for(ch=!s->cplinu[blk]; ch<= s->ntchans; ch++)
> s->snroffst[ch] = snroffst;
> }else if(s->snroffststr == 0x2){
> for(ch=!s->cplinu[blk]; ch<= s->ntchans; ch++)
> s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
> }
if(s->snroffststr < 3){
for(ch=!s->cplinu[blk]; ch<=s->ntchans; ch++){
if(ch==!s->cplinu[blk] || s->snroffststr == 2)
snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
s->snroffst[ch] = snroffst;
}
}
also this init code looks quite similar to the snroffststr == 0
case so maybe it could be merged somehow?
[...]
> if(s->strmtyp == 0x0){
if(!s->strmtyp){
[...]
> int start=0, end=0;
> start = s->strtmant[ch];
> end = s->endmant[ch];
?
>
> ff_ac3_bit_alloc_calc_psd((int8_t *)s->dexps[ch], start, end,
> s->psd[ch], s->bndpsd[ch]);
why the int8_t cast?
[...]
> // TODO only for debug
> for(ch=0; ch<=s->ntchans; ch++)
> memset(s->transform_coeffs[ch], 0, 256*sizeof(float));
then remove it or put it under #ifdef DEBUG_WHATEVER
[...]
> if (nratio < 0.0)
> nratio = 0.0;
> else if (nratio > 1.0)
> nratio = 1.0;
FFMIN/FFMAX
[...]
> filtbin = filtbin - 5;
-=5
[...]
> if (s->chgaqmod[ch] < 2){
> endbap = 12;
> }else{
> endbap = 17;
> }
>
> s->chactivegaqbins[ch] = 0;
> for(bin = 0; bin < s->endmant[ch]; bin++){
> if(s->hebap[ch][bin] > 7 && s->hebap[ch][bin] < endbap){
> s->chgaqbin[ch][bin] = 1; /* Gain word is present */
> s->chactivegaqbins[ch]++;
> }else if (s->hebap[ch][bin] >= endbap){
> s->chgaqbin[ch][bin] = -1;/* Gain word not present */
> }else{
> s->chgaqbin[ch][bin] = 0;
> }
> }
this is copy and pasted 1:1 from the pseudo code in the a52b spec
even the comments, and i suspect that applies to other parts as well
in principle that should be ok but well IANAL, diego whats your
oppinion about it? is it ok to copy and paste code from the spec?
or would it be better if we didnt do that, and what about the variable
names, they are practically all copy and pasted from the spec
[...]
> /**
> * Performs Inverse MDCT transform
> */
> static void do_imdct(EAC3Context *ctx)
> {
> int ch;
>
> for(ch=1; ch<=ctx->nfchans+ctx->lfeon; ch++) {
> if(ctx->blksw[ch]) {
> /* 256-point IMDCT */
> ff_ac3_do_imdct_256(ctx->tmp_output, ctx->transform_coeffs[ch],
> &ctx->imdct_256, ctx->tmp_imdct);
> } else {
> /* 512-point IMDCT */
> ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output,
> ctx->transform_coeffs[ch],
> ctx->tmp_imdct);
> }
> /* apply window function, overlap/add output, save delay */
> ctx->dsp.vector_fmul_add_add(ctx->output[ch-1], ctx->tmp_output,
> ctx->window, ctx->delay[ch-1], 0,
> AC3_BLOCK_SIZE, 1);
> ctx->dsp.vector_fmul_reverse(ctx->delay[ch-1], ctx->tmp_output+256,
> ctx->window, AC3_BLOCK_SIZE);
> }
> }
>
> static int eac3_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
> uint8_t *buf, int buf_size){
the { placement is inconsistant
[...]
> avctx->bit_rate = (c->frmsiz * (avctx->sample_rate) * 16 / ( ff_eac3_blocks[c->numblkscod] * 256)) / 1000;
superflous ()
[...]
> // convert float to 16-bit integer
> for(ch = 0; ch<avctx->channels; ch++) {
> for(i=0; i<AC3_BLOCK_SIZE; i++) {
> c->output[ch][i] = c->output[ch][i] * c->mul_bias +
> c->add_bias;
> }
> c->dsp.float_to_int16(c->int_output[ch], c->output[ch],
> AC3_BLOCK_SIZE);
inefficient
you shouldnt add 0 and mutiply by 1 but rather use 2 cases and
you should try to apply that bias at a more efficint point like on some
dequantization coeff or such if possible
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The worst form of inequality is to try to make unequal things equal.
-- Aristotle
4
5
Author: bwolowiec
Date: Wed Sep 12 10:05:34 2007
New Revision: 1342
Log:
cosmetics
Modified:
eac3/eac3dec.c
Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c (original)
+++ eac3/eac3dec.c Wed Sep 12 10:05:34 2007
@@ -336,12 +336,12 @@ static int parse_bsi(GetBitContext *gbc,
s->substreamid = get_bits(gbc, 3);
s->frmsiz = get_bits(gbc, 11);
s->fscod = get_bits(gbc, 2);
- if(s->fscod == 0x3){
+ if(s->fscod == 3){
log_missing_feature(s->avctx, "Reduced Sampling Rates");
return -1;
#if 0
s->fscod2 = get_bits(gbc, 2);
- s->numblkscod = 0x3; /* six blocks per frame */
+ s->numblkscod = 3; /* six blocks per frame */
#endif
}else{
s->numblkscod = get_bits(gbc, 2);
@@ -373,7 +373,7 @@ static int parse_bsi(GetBitContext *gbc,
skip_bits(gbc, 8); //skip Compression gain word
}
}
- if(s->strmtyp == 0x1){
+ if(s->strmtyp == 1){
/* if dependent stream */
if(get_bits1(gbc)){
s->chanmap = get_bits(gbc, 16);
@@ -392,21 +392,21 @@ static int parse_bsi(GetBitContext *gbc,
s->mixmdate = get_bits1(gbc);
if(s->mixmdate){
/* Mixing metadata */
- if(s->acmod > 0x2){
+ if(s->acmod > 2){
/* if more than 2 channels */
s->dmixmod = get_bits(gbc, 2);
}
- if((s->acmod & 0x1) && (s->acmod > 0x2)){
+ if((s->acmod & 1) && (s->acmod > 2)){
/* if three front channels exist */
skip_bits(gbc, 3); //skip Lt/Rt center mix level
s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = mixlevels[get_bits(gbc, 3)];
}
- if(s->acmod & 0x4){
+ if(s->acmod & 4){
/* if a surround channel exists */
float surmixlev;
skip_bits(gbc, 3); //skip Lt/Rt surround mix level
surmixlev = mixlevels[get_bits(gbc, 3)];
- if(s->acmod & 0x2){
+ if(s->acmod & 2){
//two surround channels
s->downmix_coeffs[s->acmod-4][0] = s->downmix_coeffs[s->acmod-3][1] =
surmixlev;
@@ -422,7 +422,7 @@ static int parse_bsi(GetBitContext *gbc,
s->lfemixlevcod = get_bits(gbc, 5);
}
}
- if(s->strmtyp == 0){
+ if(!s->strmtyp){
/* if independent stream */
for(i = 0; i < (s->acmod?1:2); i++){
if(get_bits1(gbc)){
@@ -435,18 +435,18 @@ static int parse_bsi(GetBitContext *gbc,
s->extpgmscl = get_bits(gbc, 6);
}
s->mixdef = get_bits(gbc, 2);
- if(s->mixdef == 0x1){
+ if(s->mixdef == 1){
/* mixing option 2 */
skip_bits(gbc, 5);
- }else if(s->mixdef == 0x2){
+ }else if(s->mixdef == 2){
/* mixing option 3 */
skip_bits(gbc, 12);
- }else if(s->mixdef == 0x3){
+ }else if(s->mixdef == 3){
/* mixing option 4 */
s->mixdeflen = get_bits(gbc, 5);
skip_bits(gbc, 8*(s->mixdeflen+2));
}
- if(s->acmod < 0x2){
+ if(s->acmod < 2){
/* if mono or dual mono source */
for(i = 0; i < (s->acmod?1:2); i++){
if(get_bits1(gbc)){
@@ -459,7 +459,7 @@ static int parse_bsi(GetBitContext *gbc,
s->frmmixcfginfoe = get_bits1(gbc);
if(s->frmmixcfginfoe){
/* mixing configuration information */
- if(s->numblkscod == 0x0){
+ if(!s->numblkscod){
s->blkmixcfginfo[0] = get_bits(gbc, 5);
}else{
for(blk = 0; blk < ff_eac3_blocks[s->numblkscod]; blk++){
@@ -479,7 +479,7 @@ static int parse_bsi(GetBitContext *gbc,
if(s->acmod == AC3_ACMOD_STEREO) /* if in 2/0 mode */{
skip_bits(gbc, 4); //skip Dolby surround and headphone mode
}
- if(s->acmod >= 0x6){
+ if(s->acmod >= 6){
/* if both surround channels exist */
skip_bits(gbc, 2); //skip Dolby surround EX mode
}
@@ -488,17 +488,17 @@ static int parse_bsi(GetBitContext *gbc,
skip_bits(gbc, 8); //skip Mix level, Room type and A/D converter type
}
}
- if(s->fscod < 0x3){
+ if(s->fscod < 3){
/* if not half sample rate */
skip_bits1(gbc); //skip Source sample rate code
}
}
- if((s->strmtyp == 0x0) && (s->numblkscod != 0x3) ){
+ if((!s->strmtyp) && (s->numblkscod != 3) ){
skip_bits1(gbc); //converter synchronization flag
}
- if(s->strmtyp == 0x2){
+ if(s->strmtyp == 2){
/* if bit stream converted from AC-3 */
- if(s->numblkscod == 0x3 || get_bits1(gbc)){
+ if(s->numblkscod == 3 || get_bits1(gbc)){
/* 6 blocks per frame */
skip_bits(gbc, 6); // skip Frame size code
}
@@ -517,7 +517,7 @@ static int parse_audfrm(GetBitContext *g
int blk, ch;
/* Audio frame exist flags and strategy data */
- if(s->numblkscod == 0x3){
+ if(s->numblkscod == 3){
/* six blocks per frame */
/* LUT-based exponent strategy syntax */
s->expstre = get_bits1(gbc);
@@ -548,7 +548,7 @@ static int parse_audfrm(GetBitContext *g
s->skipflde = get_bits1(gbc);
s->spxattene = get_bits1(gbc);
/* Coupling data */
- if(s->acmod > 0x1){
+ if(s->acmod > 1){
s->cplstre[0] = 1;
s->cplinu[0] = get_bits1(gbc);
s->ncplblks = s->cplinu[0];
@@ -579,7 +579,7 @@ static int parse_audfrm(GetBitContext *g
/* LUT-based exponent strategy syntax */
int frmchexpstr;
/* cplexpstr[blk] and chexpstr[blk][ch] derived from table lookups. see Table E2.14 */
- for(ch = !((s->acmod > 0x1) && (s->ncplblks > 0)); ch <= s->nfchans; ch++){
+ for(ch = !((s->acmod > 1) && (s->ncplblks)); ch <= s->nfchans; ch++){
frmchexpstr = get_bits(gbc, 5);
for(blk=0; blk<6; blk++){
s->chexpstr[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk];
@@ -593,8 +593,8 @@ static int parse_audfrm(GetBitContext *g
}
}
/* Converter exponent strategy data */
- if(s->strmtyp == 0x0){
- if(s->numblkscod == 0x3 || get_bits1(gbc)){
+ if(!s->strmtyp){
+ if(s->numblkscod == 3 || get_bits1(gbc)){
for(ch = 1; ch <= s->nfchans; ch++){
skip_bits(gbc, 5); //skip Converter channel exponent strategy
}
@@ -602,7 +602,7 @@ static int parse_audfrm(GetBitContext *g
}
/* AHT data */
if(s->ahte){
- /* AHT is only available in 6 block mode (numblkscod ==0x3) */
+ /* AHT is only available in 6 block mode (numblkscod ==3) */
/* coupling can use AHT only when coupling in use for all blocks */
/* ncplregs derived from cplstre and cplexpstr - see Section E3.3.2 */
int nchregs;
@@ -618,7 +618,7 @@ static int parse_audfrm(GetBitContext *g
s->chahtinu[ch] = 0;
}
/* Audio frame SNR offset data */
- if(s->snroffststr == 0x0){
+ if(!s->snroffststr){
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
for(ch=0; ch<= s->num_channels; ch++)
@@ -651,7 +651,7 @@ static int parse_audfrm(GetBitContext *g
s->chinspxatten[ch]=0;
}
/* Block start information */
- if (s->numblkscod != 0x0){
+ if (s->numblkscod){
s->blkstrtinfoe = get_bits1(gbc);
}else{
s->blkstrtinfoe = 0;
@@ -700,7 +700,7 @@ static int parse_audblk(GetBitContext *g
if(get_bits1(gbc)){
s->dynrng[i] = ff_ac3_dynrng_tbl[get_bits(gbc, 8)];
}else{
- if(blk==0){
+ if(!blk){
s->dynrng[i] = 1.0f;
}
}
@@ -1076,22 +1076,22 @@ static int parse_audblk(GetBitContext *g
}
}
}else{
- s->bit_alloc_params.sdecay = ff_sdecaytab[0x2]; /* Table 7.6 */
- s->bit_alloc_params.fdecay = ff_fdecaytab[0x1]; /* Table 7.7 */
- s->bit_alloc_params.sgain = ff_sgaintab[0x1]; /* Table 7.8 */
- s->bit_alloc_params.dbknee = ff_dbkneetab[0x2]; /* Table 7.9 */
- s->bit_alloc_params.floor = ff_floortab[0x7]; /* Table 7.10 */
+ s->bit_alloc_params.sdecay = ff_sdecaytab[2]; /* Table 7.6 */
+ s->bit_alloc_params.fdecay = ff_fdecaytab[1]; /* Table 7.7 */
+ s->bit_alloc_params.sgain = ff_sgaintab[1]; /* Table 7.8 */
+ s->bit_alloc_params.dbknee = ff_dbkneetab[2]; /* Table 7.9 */
+ s->bit_alloc_params.floor = ff_floortab[7]; /* Table 7.10 */
}
- if(s->snroffststr != 0x0){
+ if(s->snroffststr){
av_log(s->avctx, AV_LOG_INFO, "NOT TESTED\n");
if(!blk || get_bits1(gbc) ){
int csnroffst = (get_bits(gbc, 6) - 15) << 4;
- if(s->snroffststr == 0x1){
+ if(s->snroffststr == 1){
int snroffst = (csnroffst + get_bits(gbc, 4)) << 2;
for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
s->snroffst[ch] = snroffst;
- }else if(s->snroffststr == 0x2){
+ }else if(s->snroffststr == 2){
for(ch=!s->cplinu[blk]; ch<= s->num_channels; ch++)
s->snroffst[ch] = (csnroffst + get_bits(gbc, 4)) << 2;
}
@@ -1104,10 +1104,10 @@ static int parse_audblk(GetBitContext *g
}else{
if(!blk){
for(ch = !s->cplinu[blk]; ch <= s->num_channels; ch++)
- s->fgain[ch] = ff_fgaintab[0x4];
+ s->fgain[ch] = ff_fgaintab[4];
}
}
- if(s->strmtyp == 0x0){
+ if(!s->strmtyp){
if(get_bits1(gbc)){
skip_bits(gbc, 10); //Converter SNR offset
}
@@ -1265,8 +1265,8 @@ static int eac3_decode_frame(AVCodecCont
avctx->bit_rate = (c->frmsiz * (avctx->sample_rate) * 16 / ( ff_eac3_blocks[c->numblkscod] * 256)) / 1000;
/* channel config */
- if (avctx->request_channels == 0) {
- if(avctx->channels == 0)
+ if (!avctx->request_channels) {
+ if(!avctx->channels)
avctx->channels = c->num_channels;
} else if(c->num_channels < avctx->request_channels) {
av_log(avctx, AV_LOG_ERROR, "Cannot upmix EAC3 from %d to %d channels.\n",
1
0
Author: marco
Date: Mon Sep 10 18:14:17 2007
New Revision: 1335
Log:
fix the code to check for a zero codeblock
Modified:
dirac/libavcodec/dirac.c
Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c (original)
+++ dirac/libavcodec/dirac.c Mon Sep 10 18:14:17 2007
@@ -3155,7 +3155,11 @@ static void encode_codeblock(DiracContex
int zero = 0;
for (y = top; y < bottom; y++) {
for (x = left; x < right; x++) {
- if (coeffs[x + y * s->padded_width] != 0) {
+ int xpos, ypos;
+ xpos = coeff_posx(s, level, orientation, x);
+ ypos = coeff_posy(s, level, orientation, y);
+
+ if (coeffs[xpos + ypos * s->padded_width] != 0) {
zero = 0;
break;
}
3
2