[FFmpeg-soc] [soc]: r679 - in eac3: ac3/ac3.c ac3/ac3.h ac3/ac3dec.c ac3/ac3dec.h ac3dec.c checkout.sh eac3.h eac3_parser.c eac3dec.c ffmpeg.patch

bwolowiec subversion at mplayerhq.hu
Fri Aug 10 23:45:42 CEST 2007


Author: bwolowiec
Date: Fri Aug 10 23:45:42 2007
New Revision: 679

Log:
code alterations for cooperation with new versions of files


Removed:
   eac3/ac3/ac3.c
   eac3/ac3/ac3.h
   eac3/ac3/ac3dec.c
   eac3/ac3/ac3dec.h
Modified:
   eac3/ac3dec.c
   eac3/checkout.sh
   eac3/eac3.h
   eac3/eac3_parser.c
   eac3/eac3dec.c
   eac3/ffmpeg.patch

Modified: eac3/ac3dec.c
==============================================================================
--- eac3/ac3dec.c	(original)
+++ eac3/ac3dec.c	Fri Aug 10 23:45:42 2007
@@ -37,6 +37,7 @@
 #include "bitstream.h"
 #include "dsputil.h"
 #include "random.h"
+#include "ac3dec.h"
 
 /**
  * Table of bin locations for rematrixing bands

Modified: eac3/checkout.sh
==============================================================================
--- eac3/checkout.sh	(original)
+++ eac3/checkout.sh	Fri Aug 10 23:45:42 2007
@@ -1,4 +1,4 @@
-FILES="ac3.c ac3.h ac3tab.c ac3tab.h eac3dec.c eac3.h eac3_parser.c"
+FILES="ac3.c ac3.h ac3tab.c ac3tab.h eac3dec.c eac3.h eac3_parser.c ac3dec.c ac3dec.h"
 
 echo "checking out ffmpeg svn"
 for i in $FILES ac3_parser.c Makefile aac_ac3_parser.c aac_ac3_parser.h aac_parser.c allcodecs.c avcodec.h ../libavformat/allformats.h ../libavformat/raw.c; do

Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h	(original)
+++ eac3/eac3.h	Fri Aug 10 23:45:42 2007
@@ -28,11 +28,17 @@
 #include "ac3.h"
 #include "random.h"
 
+/* override ac3.h to include coupling channel */
+#undef AC3_MAX_CHANNELS
+#define AC3_MAX_CHANNELS 7
+
 #define DBA_NEW      0x01
 #define DBA_NONE     0x02
 #define DBA_RESERVED 0x03
 #define DBA_REUSE    0x00
 
+#define AC3_MAX_COEFS   256
+
 // TODO
 #define MAX_CHANNELS AC3_MAX_CHANNELS
 
@@ -58,17 +64,6 @@
 #define AC3_OUTPUT_LFEON      0x10
 /** AC-3 channel mode (audio coding mode) */
 
-typedef enum {
-    AC3_CHANNEL_MODE_DUALMONO = 0,
-    AC3_CHANNEL_MODE_MONO,
-    AC3_CHANNEL_MODE_STEREO,
-    AC3_CHANNEL_MODE_3F,
-    AC3_CHANNEL_MODE_2F_1R,
-    AC3_CHANNEL_MODE_3F_1R,
-    AC3_CHANNEL_MODE_2F_2R,
-    AC3_CHANNEL_MODE_3F_2R
-} AC3ChannelMode;
-
 typedef struct EAC3Context{
     // TODO erase unused variables
     // TODO add documentation

Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c	(original)
+++ eac3/eac3_parser.c	Fri Aug 10 23:45:42 2007
@@ -37,6 +37,7 @@
 #endif //DEBUG
 
 #include "eac3.h"
+#include "ac3dec.h"
 
 int ff_eac3_parse_syncinfo(GetBitContext *gbc, EAC3Context *s){
     GET_BITS(s->syncword, gbc, 16);
@@ -72,6 +73,7 @@ int ff_eac3_parse_bsi(GetBitContext *gbc
     s->lfe_channel = s->ntchans+1;
     if(s->lfeon){
         s->nlfemant = 7;
+        s->strtmant[s->lfe_channel] = 0;
         s->endmant[s->lfe_channel] = 7;
         s->nchgrps[s->lfe_channel] = 2;
 
@@ -479,6 +481,10 @@ int ff_eac3_parse_audblk(GetBitContext *
     //int grp, sbnd, n, bin;
     int seg, bnd, ch, i;
     int got_cplchan;
+    mant_groups m;
+
+    m.b1ptr = m.b2ptr = m.b4ptr = 3;
+
     /* These fields for block switch and dither flags */
     if(s->blkswe)
     {
@@ -675,9 +681,14 @@ int ff_eac3_parse_audblk(GetBitContext *
                     s->cplendf = s->spxbegf - 1;
                 }
 
+                av_log(s->avctx, AV_LOG_DEBUG, "cplbegf=%i cplendf=%i\n", s->cplbegf, s->cplendf);
                 // calc
                 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]){
+                    av_log(s->avctx, AV_LOG_ERROR, "cplstrtmant > cplendmant [blk=%i]\n", blk);
+                    return -1;
+                }
 
                 s->cplstrtmant = s->strtmant[CPL_CH];
                 s->cplendmant = s->endmant[CPL_CH];
@@ -695,6 +706,7 @@ int ff_eac3_parse_audblk(GetBitContext *
                 //TODO calc ncplsubnd ?
                 s->ncplsubnd =  s->cplendf - s->cplbegf;
                 s->ncplbnd = s->ncplsubnd;
+                assert(!s->cplbndstrc[0]);
                 for(bnd = s->cplbegf+1; bnd < s->cplendf; bnd++){
                     s->ncplbnd -= s->cplbndstrc[bnd];
                 }
@@ -797,6 +809,12 @@ int ff_eac3_parse_audblk(GetBitContext *
                             s->cplco[ch][bnd] *=  pow(2.0, -(s->cplcoexp[ch][bnd]+mstrcplco));
                         }
                     } /* cplcoe[ch] */
+                    else{
+                        if(!blk){
+                            av_log(s->avctx, AV_LOG_ERROR,  "no coupling coordinates in first block");
+                            return -1;
+                        }
+                    }
                 }
                 else /* ! chincpl[ch] */
                 {
@@ -924,7 +942,6 @@ int ff_eac3_parse_audblk(GetBitContext *
     {
         if(s->cplexpstr[blk] != EXP_REUSE)
         {
-            int grp;
             /* ncplgrps derived from cplbegf, ecplbegf, cplendf, ecplendf, and cplexpstr */
             /* TODO add support for enhanced coupling */
             switch(s->chexpstr[blk][CPL_CH]){
@@ -944,7 +961,7 @@ int ff_eac3_parse_audblk(GetBitContext *
                 GET_BITS(s->cplexps[grp], gbc, 7);
             }*/
             ff_ac3_decode_exponents(gbc, s->chexpstr[blk][CPL_CH], s->nchgrps[CPL_CH],
-                    s->cplabsexp<<1, s->dexps[CPL_CH]+1);
+                    s->cplabsexp<<1, s->dexps[CPL_CH] + s->strtmant[CPL_CH]);
         }
     }
     for(ch = 1; ch <= s->nfchans; ch++) /* exponents for full bandwidth channels */
@@ -1227,13 +1244,19 @@ int ff_eac3_parse_audblk(GetBitContext *
     /* These fields for quantized mantissa values */
 
     got_cplchan = 0;
-    ff_ac3_get_transform_coeffs(gbc, s->bap, s->dexps, s->nfchans+s->lfeon, s->chincpl, s->dithflag, s->transform_coeffs, s->strtmant, s->endmant, &s->dith_state, s->ncplbnd, s->cplbndstrc, s->cplco);
+//    ff_ac3_get_transform_coeffs(gbc, s->bap, s->dexps, s->nfchans+s->lfeon, s->chincpl, s->dithflag, s->transform_coeffs, s->strtmant, s->endmant, &s->dith_state, s->ncplbnd, s->cplbndstrc, s->cplco);
+
+    // TODO only for debug
+    for(ch=0; ch<=s->nfchans+s->lfeon; ch++)
+        memset(s->transform_coeffs[ch], 0, 256*sizeof(float));
 
     for(ch = 1; ch <= s->nfchans; ch++)
     {
         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);
             // ff_ac3_get_transform
+            //memset(s->transform_coeffs[ch], 0, (256)*sizeof(float));
         }
         else if(s->chahtinu[ch] == 1)
         {
@@ -1379,22 +1402,54 @@ int ff_eac3_parse_audblk(GetBitContext *
         }
         if(s->cplinu[blk] && s->chincpl[ch] && !got_cplchan)
         {
-            if(s->cplahtinu){
-                av_log(s->avctx, AV_LOG_ERROR,  "NOT IMPLEMENTED CPLINU && AHT");
-                return -1;
-            }
-#if 0
-            av_log(s->avctx, AV_LOG_ERROR,  "NOT IMPLEMENTED");
-            return -1;
+
             if(s->cplahtinu == 0)
             {
+                /*
                 for(bin = 0; bin < s->ncplmant; bin++) { // TODO ncplmant ?
                     GET_BITS(s->cplmant[bin], gbc, (0-16)); // TODO 0-16 :]
                 }
+                */
+                ff_ac3_get_transform_coeffs_ch(&m, gbc, s->dexps[CPL_CH], s->bap[CPL_CH], s->transform_coeffs[CPL_CH], s->strtmant[CPL_CH], s->endmant[CPL_CH], &s->dith_state);
+               // uncouple_channels(ctx);
+                {
+                    //TODO (form ac3)
+                    int i, j, ch, bnd, subbnd;
+
+                    subbnd = s->cplbegf+1;
+                    i = s->strtmant[CPL_CH];
+                    av_log(NULL, AV_LOG_DEBUG, "strtmant=%i endmant=%i\n", s->strtmant[CPL_CH], s->endmant[CPL_CH]);
+                    av_log(NULL, AV_LOG_DEBUG, "ncplbnd=%i ncplsubbnd=%i\n", s->ncplbnd, s->ncplsubnd);
+                    /*
+                    for(bnd=0; bnd<256; bnd++){
+                        av_log(NULL, AV_LOG_INFO, "%i: %f\n", bnd, transform_coeffs[CPL_CH][bnd]);
+                    }*/
+                    for(bnd=0; bnd<s->ncplbnd; bnd++) {
+                        do {
+                            for(j=0; j<12; j++) {
+                                for(ch=1; ch<=s->nfchans; ch++) {// TODO lfe?
+                                    if(s->chincpl[ch]) {
+                                        s->transform_coeffs[ch][i] =
+                                            s->transform_coeffs[CPL_CH][i] *
+                                            s->cplco[ch][bnd] * 8.0f;
+                                    }
+                                }
+                                av_log(NULL, AV_LOG_DEBUG, "%i ", i);
+                                i++;
+                            }
+                            av_log(NULL, AV_LOG_DEBUG, "cplbndstrc[%i] = %i bnd=%i\n ", subbnd,
+                                    s->cplbndstrc[subbnd], bnd);
+                        } while(s->cplbndstrc[subbnd++] && subbnd<=s->cplendf);
+                    }
+                    av_log(NULL, AV_LOG_DEBUG, "\n");
+                }
                 got_cplchan = 1;
             }
             else if(s->cplahtinu == 1)
             {
+                av_log(s->avctx, AV_LOG_ERROR,  "NOT IMPLEMENTED CPLINU && AHT");
+                return -1;
+#if 0
                 GET_BITS(s->cplgaqmod, gbc, 2);
                 if((s->cplgaqmod > 0x0) && (s->cplgaqmod < 0x3) )
                 {
@@ -1422,18 +1477,20 @@ int ff_eac3_parse_audblk(GetBitContext *
                 }
                 got_cplchan = 1;
                 s->cplahtinu = -1; /* AHT info for this frame has been read ? do not read again */
+#endif
             }
             else {
                 got_cplchan = 1;
             }
-#endif
         }
     }
+
     if(s->lfeon) /* mantissas of low frequency effects channel */
     {
         if(s->lfeahtinu == 0)
         {
             //ff_ac3_get_transform
+            ff_ac3_get_transform_coeffs_ch(&m, gbc, s->dexps[s->lfe_channel], s->bap[s->lfe_channel], s->transform_coeffs[s->lfe_channel], s->strtmant[s->lfe_channel], s->endmant[s->lfe_channel], &s->dith_state);
         }
         else if(s->lfeahtinu == 1)
         {

Modified: eac3/eac3dec.c
==============================================================================
--- eac3/eac3dec.c	(original)
+++ eac3/eac3dec.c	Fri Aug 10 23:45:42 2007
@@ -21,6 +21,8 @@
 
 #include "avcodec.h"
 #include "eac3.h"
+#include "ac3dec.h"
+#include "ac3.h"
 
 static void do_imdct_256(EAC3Context *ctx, int ch)
 {
@@ -143,7 +145,7 @@ static int eac3_decode_frame(AVCodecCont
         /* apply scaling to coefficients (dialnorm, dynrng) */
         for(ch=1; ch<=c->nfchans + c->lfeon; ch++) {
             float gain=2.0f;
-            if(c->acmod == AC3_CHANNEL_MODE_DUALMONO) {
+            if(c->acmod == AC3_ACMOD_DUALMONO) {
                 gain *= ff_ac3_dialnorm_tbl[c->dialnorm[ch-1]] * ff_ac3_dynrng_tbl[c->dynrng[ch-1]];
             } else {
                 gain *= ff_ac3_dialnorm_tbl[c->dialnorm[0]] * ff_ac3_dynrng_tbl[c->dynrng[0]];
@@ -207,8 +209,8 @@ static int eac3_decode_init(AVCodecConte
     EAC3Context *ctx = avctx->priv_data;
 
     ctx->avctx = avctx;
-    ff_ac3_decoder_tables_init();
     ac3_common_init();
+    ff_ac3_tables_init();
     av_init_random(0, &ctx->dith_state);
     ff_mdct_init(&ctx->imdct_256, 8, 1);
     ff_mdct_init(&ctx->imdct_512, 9, 1);

Modified: eac3/ffmpeg.patch
==============================================================================
--- eac3/ffmpeg.patch	(original)
+++ eac3/ffmpeg.patch	Fri Aug 10 23:45:42 2007
@@ -50,7 +50,7 @@ Index: libavcodec/Makefile
  OBJS-$(CONFIG_DVVIDEO_DECODER)         += dv.o
  OBJS-$(CONFIG_DVVIDEO_ENCODER)         += dv.o
  OBJS-$(CONFIG_DXA_DECODER)             += dxa.o
-+OBJS-$(CONFIG_EAC3_DECODER)            += eac3dec.o eac3_parser.o
++OBJS-$(CONFIG_EAC3_DECODER)            += eac3dec.o eac3_parser.o ac3dec.o
  OBJS-$(CONFIG_EIGHTBPS_DECODER)        += 8bps.o
  OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o golomb.o
  OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o



More information about the FFmpeg-soc mailing list