[FFmpeg-soc] [soc]: r675 - in eac3/ac3: ac3.h ac3dec.c

bwolowiec subversion at mplayerhq.hu
Fri Aug 10 22:23:17 CEST 2007


Author: bwolowiec
Date: Fri Aug 10 22:23:17 2007
New Revision: 675

Log:
minor changes to allow to use the code in eac3


Modified:
   eac3/ac3/ac3.h
   eac3/ac3/ac3dec.c

Modified: eac3/ac3/ac3.h
==============================================================================
--- eac3/ac3/ac3.h	(original)
+++ eac3/ac3/ac3.h	Fri Aug 10 22:23:17 2007
@@ -29,6 +29,9 @@
 
 #include "ac3tab.h"
 #include "bitstream.h"
+#include "random.h"
+
+#define CPL_CH 0
 
 #define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
 #define AC3_MAX_CHANNELS 6 /* including LFE channel */
@@ -177,11 +180,11 @@ void ff_ac3_window_init(float *window);
 void ff_ac3_tables_init(void);
 
 /** tables for ungrouping mantissas */
-extern float ff_b1_mantissas[32][3];
-extern float ff_b2_mantissas[128][3];
-extern float ff_b3_mantissas[8];
-extern float ff_b4_mantissas[128][2];
-extern float ff_b5_mantissas[16];
+extern float ff_ac3_b1_mantissas[32][3];
+extern float ff_ac3_b2_mantissas[128][3];
+extern float ff_ac3_b3_mantissas[8];
+extern float ff_ac3_b4_mantissas[128][2];
+extern float ff_ac3_b5_mantissas[16];
 
 /** dynamic range table. converts codes to scale factors. */
 extern float ff_ac3_dynrng_tbl[256];
@@ -205,4 +208,20 @@ extern uint8_t ff_ac3_exp_ungroup_tbl[12
 void ff_ac3_decode_exponents(GetBitContext *gb, int expstr, int ngrps,
                              uint8_t absexp, int8_t *dexps);
 
+/**
+ * Grouped mantissas for 3-level 5-level and 11-level quantization
+ */
+typedef struct {
+    float b1_mant[3];
+    float b2_mant[3];
+    float b4_mant[2];
+    int b1ptr;
+    int b2ptr;
+    int b4ptr;
+} mant_groups;
+
+int ff_ac3_get_transform_coeffs_ch(mant_groups *m, GetBitContext *gb, uint8_t *exps,
+        uint8_t *bap, float *coeffs, int start, int end, AVRandomState *dith_state);
+
+
 #endif /* AC3_H */

Modified: eac3/ac3/ac3dec.c
==============================================================================
--- eac3/ac3/ac3dec.c	(original)
+++ eac3/ac3/ac3dec.c	Fri Aug 10 22:23:17 2007
@@ -48,10 +48,10 @@ static const uint8_t rematrix_band_tbl[5
  * table for exponent to scale_factor mapping
  * ff_ac3_scale_factors[i] = 2 ^ -i
  */
-static float ff_ac3_scale_factors[25];
+float ff_ac3_scale_factors[25];
 
 /** table for grouping exponents */
-static uint8_t ff_ac3_exp_ungroup_tbl[128][3];
+uint8_t ff_ac3_exp_ungroup_tbl[128][3];
 
 
 /** tables for ungrouping mantissas */
@@ -123,7 +123,6 @@ static const uint8_t ac3_default_coeffs[
 /* override ac3.h to include coupling channel */
 #undef AC3_MAX_CHANNELS
 #define AC3_MAX_CHANNELS 7
-#define CPL_CH 0
 
 #define AC3_OUTPUT_LFEON  8
 
@@ -485,40 +484,18 @@ static void uncouple_channels(AC3DecodeC
 }
 
 /**
- * Grouped mantissas for 3-level 5-level and 11-level quantization
- */
-typedef struct {
-    float b1_mant[3];
-    float b2_mant[3];
-    float b4_mant[2];
-    int b1ptr;
-    int b2ptr;
-    int b4ptr;
-} mant_groups;
-
-/**
  * Get the transform coefficients for a particular channel
  * reference: Section 7.3 Quantization and Decoding of Mantissas
  */
-static int get_transform_coeffs_ch(AC3DecodeContext *ctx, int ch_index, mant_groups *m)
+int ff_ac3_get_transform_coeffs_ch(mant_groups *m, GetBitContext *gb, uint8_t *exps, uint8_t *bap, float *coeffs, int start, int end, AVRandomState *dith_state)
 {
-    GetBitContext *gb = &ctx->gb;
-    int i, gcode, tbap, start, end;
-    uint8_t *exps;
-    uint8_t *bap;
-    float *coeffs;
-
-    exps = ctx->dexps[ch_index];
-    bap = ctx->bap[ch_index];
-    coeffs = ctx->transform_coeffs[ch_index];
-    start = ctx->startmant[ch_index];
-    end = ctx->endmant[ch_index];
+    int i, gcode, tbap;
 
     for (i = start; i < end; i++) {
         tbap = bap[i];
         switch (tbap) {
             case 0:
-                coeffs[i] = ((av_random(&ctx->dith_state) & 0xFFFF) * LEVEL_MINUS_3DB) / 32768.0f;
+                coeffs[i] = ((av_random(dith_state) & 0xFFFF) * LEVEL_MINUS_3DB) / 32768.0f;
                 break;
 
             case 1:
@@ -618,13 +595,13 @@ static int get_transform_coeffs(AC3Decod
 
     for (ch = 1; ch <= ctx->nchans; ch++) {
         /* transform coefficients for full-bandwidth channel */
-        if (get_transform_coeffs_ch(ctx, ch, &m))
+        if (ff_ac3_get_transform_coeffs_ch(&m, &ctx->gb, ctx->dexps[ch], ctx->bap[ch], ctx->transform_coeffs[ch], ctx->startmant[ch], ctx->endmant[ch], &ctx->dith_state))
             return -1;
         /* tranform coefficients for coupling channel come right after the
            coefficients for the first coupled channel*/
         if (ctx->chincpl[ch])  {
             if (!got_cplchan) {
-                if (get_transform_coeffs_ch(ctx, CPL_CH, &m)) {
+                if (ff_ac3_get_transform_coeffs_ch(&m, &ctx->gb, ctx->dexps[CPL_CH], ctx->bap[CPL_CH], ctx->transform_coeffs[CPL_CH], ctx->startmant[CPL_CH], ctx->endmant[CPL_CH], &ctx->dith_state)){
                     av_log(ctx->avctx, AV_LOG_ERROR, "error in decoupling channels\n");
                     return -1;
                 }



More information about the FFmpeg-soc mailing list