[Ffmpeg-cvslog] r8816 - in trunk/libavcodec: Makefile ac3.c ac3.h ac3tab.c ac3tab.h

aurel subversion
Thu Apr 26 00:12:51 CEST 2007


Author: aurel
Date: Thu Apr 26 00:12:51 2007
New Revision: 8816

Log:
move ac3 tables from a .h to a .c

Added:
   trunk/libavcodec/ac3tab.c
      - copied, changed from r8815, /trunk/libavcodec/ac3tab.h
   trunk/libavcodec/ac3tab.h
      - copied, changed from r8815, /trunk/libavcodec/ac3.h
Modified:
   trunk/libavcodec/Makefile
   trunk/libavcodec/ac3.c
   trunk/libavcodec/ac3.h

Modified: trunk/libavcodec/Makefile
==============================================================================
--- trunk/libavcodec/Makefile	(original)
+++ trunk/libavcodec/Makefile	Thu Apr 26 00:12:51 2007
@@ -47,7 +47,7 @@ OBJS= bitstream.o \
 HEADERS = avcodec.h opt.h
 
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o
-OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3.o
+OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
 OBJS-$(CONFIG_ASV1_DECODER)            += asv1.o
 OBJS-$(CONFIG_ASV1_ENCODER)            += asv1.o
@@ -273,7 +273,7 @@ OBJS-$(CONFIG_XVID)                    +
 
 
 OBJS-$(CONFIG_AAC_PARSER)              += parser.o
-OBJS-$(CONFIG_AC3_PARSER)              += parser.o ac3.o
+OBJS-$(CONFIG_AC3_PARSER)              += parser.o ac3tab.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs.o parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)           += dvbsubdec.o
 OBJS-$(CONFIG_DVDSUB_PARSER)           += dvdsubdec.o

Modified: trunk/libavcodec/ac3.c
==============================================================================
--- trunk/libavcodec/ac3.c	(original)
+++ trunk/libavcodec/ac3.c	Thu Apr 26 00:12:51 2007
@@ -26,9 +26,11 @@
 
 #include "avcodec.h"
 #include "ac3.h"
-#include "ac3tab.h"
 #include "bitstream.h"
 
+static uint8_t bndtab[51];
+static uint8_t masktab[253];
+
 static inline int calc_lowcomp1(int a, int b0, int b1, int c)
 {
     if ((b0 + 256) == b1) {
@@ -70,7 +72,7 @@ void ff_ac3_bit_alloc_calc_psd(int8_t *e
         for(i=j;i<end1;i++) {
             /* logadd */
             int adr = FFMIN(FFABS(v - psd[j]) >> 1, 255);
-            v = FFMAX(v, psd[j]) + latab[adr];
+            v = FFMAX(v, psd[j]) + ff_ac3_latab[adr];
             j++;
         }
         bndpsd[k]=v;
@@ -147,7 +149,7 @@ void ff_ac3_bit_alloc_calc_mask(AC3BitAl
         if (tmp > 0) {
             excite[bin] += tmp >> 2;
         }
-        mask[bin] = FFMAX(hth[bin >> s->halfratecod][s->fscod], excite[bin]);
+        mask[bin] = FFMAX(ff_ac3_hth[bin >> s->halfratecod][s->fscod], excite[bin]);
     }
 
     /* delta bit allocation */
@@ -185,10 +187,10 @@ void ff_ac3_bit_alloc_calc_bap(int16_t *
     j = masktab[start];
     do {
         v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor;
-        end1 = FFMIN(bndtab[j] + bndsz[j], end);
+        end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end);
         for (k = i; k < end1; k++) {
             address = av_clip((psd[i] - v) >> 5, 0, 63);
-            bap[i] = baptab[address];
+            bap[i] = ff_ac3_baptab[address];
             i++;
         }
     } while (end > bndtab[j++]);
@@ -229,7 +231,7 @@ void ac3_common_init(void)
     l = 0;
     for(i=0;i<50;i++) {
         bndtab[i] = l;
-        v = bndsz[i];
+        v = ff_ac3_bndsz[i];
         for(j=0;j<v;j++) masktab[k++]=i;
         l += v;
     }

Modified: trunk/libavcodec/ac3.h
==============================================================================
--- trunk/libavcodec/ac3.h	(original)
+++ trunk/libavcodec/ac3.h	Thu Apr 26 00:12:51 2007
@@ -24,6 +24,8 @@
  * Common code between AC3 encoder and decoder.
  */
 
+#include "ac3tab.h"
+
 #define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
 #define AC3_MAX_CHANNELS 6 /* including LFE channel */
 
@@ -77,17 +79,6 @@ typedef struct {
     /** @} */
 } AC3HeaderInfo;
 
-extern const uint16_t ff_ac3_frame_sizes[38][3];
-extern const uint8_t ff_ac3_channels[8];
-extern const uint16_t ff_ac3_freqs[3];
-extern const uint16_t ff_ac3_bitratetab[19];
-extern const int16_t ff_ac3_window[256];
-extern const uint8_t ff_sdecaytab[4];
-extern const uint8_t ff_fdecaytab[4];
-extern const uint16_t ff_sgaintab[4];
-extern const uint16_t ff_dbkneetab[4];
-extern const int16_t ff_floortab[8];
-extern const uint16_t ff_fgaintab[8];
 
 void ac3_common_init(void);
 

Copied: trunk/libavcodec/ac3tab.c (from r8815, /trunk/libavcodec/ac3tab.h)
==============================================================================
--- /trunk/libavcodec/ac3tab.h	(original)
+++ trunk/libavcodec/ac3tab.c	Thu Apr 26 00:12:51 2007
@@ -20,10 +20,12 @@
  */
 
 /**
- * @file ac3tab.h
+ * @file ac3tab.c
  * tables taken directly from AC3 spec.
  */
 
+#include "ac3tab.h"
+
 /**
  * Possible frame sizes.
  * from ATSC A/52 Table 5.18 Frame Size Code Table.
@@ -124,9 +126,7 @@ const int16_t ff_ac3_window[256] = {
 32767,32767,32767,32767,32767,32767,32767,32767,
 };
 
-static uint8_t masktab[253];
-
-static const uint8_t latab[260]= {
+const uint8_t ff_ac3_latab[260]= {
 0x0040,0x003f,0x003e,0x003d,0x003c,0x003b,0x003a,0x0039,0x0038,0x0037,
 0x0036,0x0035,0x0034,0x0034,0x0033,0x0032,0x0031,0x0030,0x002f,0x002f,
 0x002e,0x002d,0x002c,0x002c,0x002b,0x002a,0x0029,0x0029,0x0028,0x0027,
@@ -155,7 +155,7 @@ static const uint8_t latab[260]= {
 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
 };
 
-static const uint16_t hth[50][3]= {
+const uint16_t ff_ac3_hth[50][3]= {
 { 0x04d0,0x04f0,0x0580 },
 { 0x04d0,0x04f0,0x0580 },
 { 0x0440,0x0460,0x04b0 },
@@ -208,7 +208,7 @@ static const uint16_t hth[50][3]= {
 { 0x0840,0x0840,0x04e0 },
 };
 
-static const uint8_t baptab[64]= {
+const uint8_t ff_ac3_baptab[64]= {
     0, 1, 1, 1, 1, 1, 2, 2, 3, 3,
     3, 4, 4, 5, 5, 6, 6, 6, 6, 7,
     7, 7, 7, 8, 8, 8, 8, 9, 9, 9,
@@ -242,10 +242,8 @@ const uint16_t ff_fgaintab[8]= {
     0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400,
 };
 
-static const uint8_t bndsz[50]={
+const uint8_t ff_ac3_bndsz[50]={
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
     3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
 };
-
-static uint8_t bndtab[51];

Copied: trunk/libavcodec/ac3tab.h (from r8815, /trunk/libavcodec/ac3.h)
==============================================================================
--- /trunk/libavcodec/ac3.h	(original)
+++ trunk/libavcodec/ac3tab.h	Thu Apr 26 00:12:51 2007
@@ -1,5 +1,5 @@
 /*
- * Common code between AC3 encoder and decoder
+ * AC3 tables
  * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
  *
  * This file is part of FFmpeg.
@@ -19,141 +19,25 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/**
- * @file ac3.h
- * Common code between AC3 encoder and decoder.
- */
-
-#define AC3_MAX_CODED_FRAME_SIZE 3840 /* in bytes */
-#define AC3_MAX_CHANNELS 6 /* including LFE channel */
-
-#define NB_BLOCKS 6 /* number of PCM blocks inside an AC3 frame */
-#define AC3_FRAME_SIZE (NB_BLOCKS * 256)
-
-/* exponent encoding strategy */
-#define EXP_REUSE 0
-#define EXP_NEW   1
-
-#define EXP_D15   1
-#define EXP_D25   2
-#define EXP_D45   3
-
-typedef struct AC3BitAllocParameters {
-    int fscod; /* frequency */
-    int halfratecod;
-    int sgain, sdecay, fdecay, dbknee, floor;
-    int cplfleak, cplsleak;
-} AC3BitAllocParameters;
-
-/**
- * @struct AC3HeaderInfo
- * Coded AC-3 header values up to the lfeon element, plus derived values.
- */
-typedef struct {
-    /** @defgroup coded Coded elements
-     * @{
-     */
-    uint16_t sync_word;
-    uint16_t crc1;
-    uint8_t fscod;
-    uint8_t frmsizecod;
-    uint8_t bsid;
-    uint8_t bsmod;
-    uint8_t acmod;
-    uint8_t cmixlev;
-    uint8_t surmixlev;
-    uint8_t dsurmod;
-    uint8_t lfeon;
-    /** @} */
+#ifndef AC3TAB_H
+#define AC3TAB_H
 
-    /** @defgroup derived Derived values
-     * @{
-     */
-    uint8_t halfratecod;
-    uint16_t sample_rate;
-    uint32_t bit_rate;
-    uint8_t channels;
-    uint16_t frame_size;
-    /** @} */
-} AC3HeaderInfo;
+#include "common.h"
 
 extern const uint16_t ff_ac3_frame_sizes[38][3];
 extern const uint8_t ff_ac3_channels[8];
 extern const uint16_t ff_ac3_freqs[3];
 extern const uint16_t ff_ac3_bitratetab[19];
 extern const int16_t ff_ac3_window[256];
+extern const uint8_t  ff_ac3_latab[260];
+extern const uint16_t ff_ac3_hth[50][3];
+extern const uint8_t  ff_ac3_baptab[64];
 extern const uint8_t ff_sdecaytab[4];
 extern const uint8_t ff_fdecaytab[4];
 extern const uint16_t ff_sgaintab[4];
 extern const uint16_t ff_dbkneetab[4];
 extern const int16_t ff_floortab[8];
 extern const uint16_t ff_fgaintab[8];
+extern const uint8_t  ff_ac3_bndsz[50];
 
-void ac3_common_init(void);
-
-/**
- * Calculates the log power-spectral density of the input signal.
- * This gives a rough estimate of signal power in the frequency domain by using
- * the spectral envelope (exponents).  The psd is also separately grouped
- * into critical bands for use in the calculating the masking curve.
- * 128 units in psd = -6 dB.  The dbknee parameter in AC3BitAllocParameters
- * determines the reference level.
- *
- * @param[in]  exp        frequency coefficient exponents
- * @param[in]  start      starting bin location
- * @param[in]  end        ending bin location
- * @param[out] psd        signal power for each frequency bin
- * @param[out] bndpsd     signal power for each critical band
- */
-void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd,
-                               int16_t *bndpsd);
-
-/**
- * Calculates the masking curve.
- * First, the excitation is calculated using parameters in \p s and the signal
- * power in each critical band.  The excitation is compared with a predefined
- * hearing threshold table to produce the masking curve.  If delta bit
- * allocation information is provided, it is used for adjusting the masking
- * curve, usually to give a closer match to a better psychoacoustic model.
- *
- * @param[in]  s          adjustable bit allocation parameters
- * @param[in]  bndpsd     signal power for each critical band
- * @param[in]  start      starting bin location
- * @param[in]  end        ending bin location
- * @param[in]  fgain      fast gain (estimated signal-to-mask ratio)
- * @param[in]  is_lfe     whether or not the channel being processed is the LFE
- * @param[in]  deltbae    delta bit allocation exists (none, reuse, or new)
- * @param[in]  deltnseg   number of delta segments
- * @param[in]  deltoffst  location offsets for each segment
- * @param[in]  deltlen    length of each segment
- * @param[in]  deltba     delta bit allocation for each segment
- * @param[out] mask       calculated masking curve
- */
-void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd,
-                                int start, int end, int fgain, int is_lfe,
-                                int deltbae, int deltnseg, uint8_t *deltoffst,
-                                uint8_t *deltlen, uint8_t *deltba,
-                                int16_t *mask);
-
-/**
- * Calculates bit allocation pointers.
- * The SNR is the difference between the masking curve and the signal.  AC-3
- * uses this value for each frequency bin to allocate bits.  The \p snroffset
- * parameter is a global adjustment to the SNR for all bins.
- *
- * @param[in]  mask       masking curve
- * @param[in]  psd        signal power for each frequency bin
- * @param[in]  start      starting bin location
- * @param[in]  end        ending bin location
- * @param[in]  snroffset  SNR adjustment
- * @param[in]  floor      noise floor
- * @param[out] bap        bit allocation pointers
- */
-void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end,
-                               int snroffset, int floor, uint8_t *bap);
-
-void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap,
-                                   int8_t *exp, int start, int end,
-                                   int snroffset, int fgain, int is_lfe,
-                                   int deltbae,int deltnseg,
-                                   uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba);
+#endif /* AC3TAB_H */




More information about the ffmpeg-cvslog mailing list