[FFmpeg-soc] [soc]: r742 - in eac3: ac3tab.c ac3tab.h eac3.h eac3_parser.c
bwolowiec
subversion at mplayerhq.hu
Mon Aug 13 15:02:09 CEST 2007
Author: bwolowiec
Date: Mon Aug 13 15:02:09 2007
New Revision: 742
Log:
Part of spectral extension code.
Modified:
eac3/ac3tab.c
eac3/ac3tab.h
eac3/eac3.h
eac3/eac3_parser.c
Modified: eac3/ac3tab.c
==============================================================================
--- eac3/ac3tab.c (original)
+++ eac3/ac3tab.c Mon Aug 13 15:02:09 2007
@@ -1347,3 +1347,9 @@ const uint8_t ff_eac3_frm_expstr[32][6]
const uint8_t ff_eac3_defcplbndstrc[18] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1 };
+/**
+ * Table E2.15 Default Spectral Extension Banding Structure
+ */
+const uint8_t ff_eac3_defspxbndstrc[17] =
+{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1};
+
Modified: eac3/ac3tab.h
==============================================================================
--- eac3/ac3tab.h (original)
+++ eac3/ac3tab.h Mon Aug 13 15:02:09 2007
@@ -57,6 +57,7 @@ extern const int16_t ff_vq_hebap7[512][6
extern const int16_t (*ff_vq_hebap[8])[6];
extern const uint8_t ff_eac3_frm_expstr[32][6];
extern const uint8_t ff_eac3_defcplbndstrc[18];
+extern const uint8_t ff_eac3_defspxbndstrc[17];
#endif /* AC3TAB_H */
Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h (original)
+++ eac3/eac3.h Mon Aug 13 15:02:09 2007
@@ -176,9 +176,6 @@ typedef struct EAC3Context{
int spxbndstrc[MAX_SPX_CODES]; ///< Spectral extension band structure
int spxcoe[MAX_CHANNELS]; ///< Spectral extension coordinates exists
int spxblnd[MAX_CHANNELS]; ///< Spectral extension blend
- int mstrspxco[MAX_CHANNELS]; ///< Master spectral extension coordinates
- int spxcoexp[MAX_CHANNELS][MAX_SPX_CODES]; ///< Spectral extension coordinate exponent
- int spxcomant[MAX_CHANNELS][MAX_SPX_CODES]; ///< Spectral extension coordinate mantissa
int ecplinu; // 1); ///< Enhanced coupling in use
int chincpl[MAX_CHANNELS]; ///< Channel in coupling
int phsflginu; // 1); ///< Phase flag in use
@@ -289,6 +286,7 @@ typedef struct EAC3Context{
int16_t mask[MAX_CHANNELS][350]; ///< masking values
float cplco[AC3_MAX_CHANNELS][18]; ///< coupling coordinates
+ float spxco[AC3_MAX_CHANNELS][18]; ///< Spectral extension coordinates
DECLARE_ALIGNED_16(float, transform_coeffs[MAX_CHANNELS][AC3_MAX_COEFS]);
Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c (original)
+++ eac3/eac3_parser.c Mon Aug 13 15:02:09 2007
@@ -26,7 +26,7 @@
#include "ac3.h"
#include "random.h"
-#undef DEBUG
+//#undef DEBUG
#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);}
@@ -532,6 +532,7 @@ int ff_eac3_parse_audblk(GetBitContext *
GET_BITS(s->spxinu, gbc, 1);
if(s->spxinu)
{
+// av_log(s->avctx, AV_LOG_INFO, "Spectral extension in use\n");
if(s->acmod == 0x1)
{
s->chinspx[1] = 1;
@@ -566,6 +567,9 @@ int ff_eac3_parse_audblk(GetBitContext *
for(bnd = s->spxbegf+1; bnd < s->spxendf; bnd++) {
GET_BITS(s->spxbndstrc[bnd], gbc, 1);
}
+ }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;
@@ -620,17 +624,20 @@ int ff_eac3_parse_audblk(GetBitContext *
if(s->spxcoe[ch])
{
+ int spxcoexp, spxcomant, mstrspxco;
GET_BITS(s->spxblnd[ch], gbc, 5);
- GET_BITS(s->mstrspxco[ch], gbc, 2);
+ GET_BITS(mstrspxco, gbc, 2);
+ mstrspxco*=3;
/* nspxbnds determined from spxbegf, spxendf, and spxbndstrc[ ] */
- if(s->nspxbnds >= MAX_SPX_CODES){
- av_log(s->avctx, AV_LOG_ERROR, "s->nspxbnds >= MAX_SPX_CODES");
- return -1;
- }
for(bnd = 0; bnd < s->nspxbnds; bnd++)
{
- GET_BITS(s->spxcoexp[ch][bnd], gbc, 4);
- GET_BITS(s->spxcomant[ch][bnd], gbc, 2);
+ GET_BITS(spxcoexp, gbc, 4);
+ GET_BITS(spxcomant, gbc, 2);
+ 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];
}
}
}
@@ -889,7 +896,7 @@ int ff_eac3_parse_audblk(GetBitContext *
/* nrematbnds determined from cplinu, ecplinu, spxinu, cplbegf, ecplbegf and spxbegf
* TODO XXX (code from AC-3) */
s->nrematbnds = 4;
- if(s->cplinu && s->cplbegf <= 2)
+ if(s->cplinu[blk] && s->cplbegf <= 2)
s->nrematbnds -= 1 + (s->cplbegf == 0);
for(bnd = 0; bnd < s->nrematbnds; bnd++) {
GET_BITS(s->rematflg[bnd], gbc, 1);
@@ -1075,8 +1082,10 @@ int ff_eac3_parse_audblk(GetBitContext *
}
else
{
- for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
- s->fgaincod[ch] = 0x4;
+ if(!blk){
+ for(ch = !s->cplinu[blk]; ch <= s->nfchans+s->lfeon; ch++)
+ s->fgaincod[ch] = 0x4;
+ }
}
if(s->strmtyp == 0x0)
{
@@ -1178,9 +1187,8 @@ int ff_eac3_parse_audblk(GetBitContext *
s->psd[ch], s->bndpsd[ch]);
- // TODO hmm... :)
s->bit_alloc_params.fscod = s->fscod;
- s->bit_alloc_params.halfratecod = 0; // TODO
+ s->bit_alloc_params.halfratecod = 0;
{
int fgain = ff_fgaintab[s->fgaincod[ch]];
More information about the FFmpeg-soc
mailing list