[FFmpeg-soc] [soc]: r497 - in eac3: ac3tab.c ac3tab.h eac3.h eac3_parser.c
bwolowiec
subversion at mplayerhq.hu
Sat Jul 21 10:59:46 CEST 2007
Author: bwolowiec
Date: Sat Jul 21 10:59:46 2007
New Revision: 497
Log:
Part of AHT 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 Sat Jul 21 10:59:46 2007
@@ -208,6 +208,16 @@ const uint16_t ff_ac3_hth[50][3]= {
{ 0x0840,0x0840,0x04e0 },
};
+const uint8_t ff_ac3_hebaptab[64] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
+ 8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
+ 11, 11, 11, 12, 12, 12, 12, 13, 13, 13,
+ 13, 14, 14, 14, 14, 15, 15, 15, 15, 16,
+ 16, 16, 16, 17, 17, 17, 17, 18, 18, 18,
+ 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19,
+};
+
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,
Modified: eac3/ac3tab.h
==============================================================================
--- eac3/ac3tab.h (original)
+++ eac3/ac3tab.h Sat Jul 21 10:59:46 2007
@@ -31,6 +31,7 @@ extern const uint16_t ff_ac3_bitratetab[
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_hebaptab[64];
extern const uint8_t ff_ac3_baptab[64];
extern const uint8_t ff_sdecaytab[4];
extern const uint8_t ff_fdecaytab[4];
Modified: eac3/eac3.h
==============================================================================
--- eac3/eac3.h (original)
+++ eac3/eac3.h Sat Jul 21 10:59:46 2007
@@ -175,6 +175,8 @@ typedef struct EAC3Context{
int blkstrtinfoe; // 1); ///< Block start information exists
uint32_t blkstrtinfo; ///< Block start information
int ncplblks;
+ int ncplregs;
+ int nchregs[MAX_CHANNELS];
// EAC3Audblk
int blksw[MAX_CHANNELS]; // 1); ///< Block switch flag
@@ -290,6 +292,7 @@ typedef struct EAC3Context{
int cplgaqsections;
int chgaqbin[MAX_CHANNELS][TODO_SIZE]; // [][nchmant]
int chgaqsections[MAX_CHANNELS];
+ int chactivegaqbins[MAX_CHANNELS];
int nchmant[MAX_CHANNELS]; ///< Number of fbw channel mantissas
int ncplsubnd; ///< Number of coupling sub-bands
int ncplbnd; ///< Number of structured coupled bands
@@ -315,6 +318,7 @@ typedef struct EAC3Context{
int nfchans; ///< Number of fbw channels
uint8_t bap[MAX_CHANNELS][AC3_MAX_COEFS]; ///< bit allocation pointers
+ uint8_t hebap[MAX_CHANNELS][AC3_MAX_COEFS];
int16_t psd[MAX_CHANNELS][AC3_MAX_COEFS]; ///< scaled exponents
int16_t bndpsd[MAX_CHANNELS][350]; ///< interpolated exponents FIXME in ac3dec [50] !?
int16_t mask[MAX_CHANNELS][350]; ///< masking values
@@ -364,4 +368,9 @@ int ff_eac3_parse_audfrm(GetBitContext *
int ff_eac3_parse_audblk(GetBitContext *gbc, EAC3Context *s, const int blk);
int ff_eac3_parse_auxdata(GetBitContext *gbc, EAC3Context *s);
+#define EAC3_GAQ_NO 0
+#define EAC3_GAQ_12 1
+#define EAC3_GAQ_14 2
+#define EAC3_GAQ_124 3
+
#endif
Modified: eac3/eac3_parser.c
==============================================================================
--- eac3/eac3_parser.c (original)
+++ eac3/eac3_parser.c Sat Jul 21 10:59:46 2007
@@ -363,14 +363,39 @@ int ff_eac3_parse_audfrm(GetBitContext *
/* ncplregs derived from cplstre and cplexpstr ? see Section E3.3.2 */
av_log(s, AV_LOG_ERROR, "AHT NOT IMPLEMENTED");
return -1;
-#if 0
+
+ /* AHT is only available in 6 block mode (numblkscod ==0x3) */
+
+ s->ncplregs = 0;
+ for(blk = 0; blk < 6; blk++){
+ if(s->cplstre[blk]==1 || s->cplexpstr[blk] != EXP_REUSE)
+ s->ncplregs++;
+ }
+ s->nchregs[0] = s->ncplregs;
+
+ for(ch = 1; ch <= s->nfchans+s->lfeon; ch++){
+ s->nchregs[ch] = 0;
+ for(blk = 0; blk < 6; blk++){
+ if(s->chexpstr[blk][ch] != EXP_REUSE)
+ s->nchregs[ch]++;
+ }
+ }
+
/*
+ s->nlferegs = 0;
+ for(blk = 0; blk < 6; blk++){
+ if(s->lfeexpstr[blk] != EXP_REUSE)
+ s->nlferegs++;
+ }
+ */
+
if( (s->ncplblks == 6) && (s->ncplregs ==1) ) {
GET_BITS(s->cplahtinu, gbc, 1);
}
else {
- cplahtinu = 0
+ s->cplahtinu = 0;
}
+ s->chahtinu[0] = s->cplahtinu;
for(ch = 1; ch <= s->nfchans; ch++)
{
@@ -379,21 +404,21 @@ int ff_eac3_parse_audfrm(GetBitContext *
GET_BITS(s->chahtinu[ch], gbc, 1);
}
else {
- chahtinu[ch] = 0
+ s->chahtinu[ch] = 0;
}
}
- if(lfeon)
+
+ if(s->lfeon)
{
- // nlferegs derived from lfeexpstr ? see Section E3.3.2
- if(nlferegs == 1) {
+ if(s->nchregs[s->lfe_channel] == 1) {
GET_BITS(s->lfeahtinu, gbc, 1);
}
else {
- lfeahtinu = 0
+ s->lfeahtinu = 0;
}
+ s->chahtinu[s->lfe_channel] = s->lfeahtinu;
}
- */
-#endif
+
}
/* These fields for audio frame SNR offset data */
if(s->snroffststr == 0x0)
@@ -1164,6 +1189,8 @@ int ff_eac3_parse_audblk(GetBitContext *
int snroffst = (((s->csnroffst - 15) << 4) + s->fsnroffst[ch]) << 2;
//av_log(NULL, AV_LOG_INFO, "s->csnroffst=%i s->fsnroffst=%i snroffst = %i\n",
// s->csnroffst, s->fsnroffst[ch], snroffst);
+
+ // TODO calculate hebap
ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], start, end,
snroffst, s->bit_alloc_params.floor,
s->bap[ch]);
@@ -1186,11 +1213,48 @@ int ff_eac3_parse_audblk(GetBitContext *
}
else if(s->chahtinu[ch] == 1)
{
- av_log(s, AV_LOG_ERROR, "AHT NOT IMPLEMENTED");
- return -1;
+ int endbap, bin, n;
+
+ av_log(s, AV_LOG_INFO, "AHT NOT TESTED");
-#if 0
GET_BITS(s->chgaqmod[ch], gbc, 2);
+
+ 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;
+ }
+ }
+
+
+ switch(s->chgaqmod[ch]){
+ case EAC3_GAQ_NO: /* No GAQ gains present */
+ s->chgaqsections[ch] = 0;
+ break;
+ case EAC3_GAQ_12: /* GAQ gains 1 and 2 */
+ case EAC3_GAQ_14: /* GAQ gains 1 and 4 */
+ s->chgaqsections[ch] = s->chactivegaqbins[ch];
+ /* chactivegaqbins[ch] was computed earlier */
+ break;
+ case EAC3_GAQ_124: /* GAQ gains 1, 2, and 4 */
+ s->chgaqsections[ch] = s->chactivegaqbins[ch] / 3;
+ if (s->chactivegaqbins[ch] % 3) s->chgaqsections[ch]++;
+ break;
+ }
+
if((s->chgaqmod[ch] > 0x0) && (s->chgaqmod[ch] < 0x3) )
{
for(n = 0; n < s->chgaqsections[ch]; n++) { // TODO chgaqsections ?
@@ -1199,13 +1263,16 @@ int ff_eac3_parse_audblk(GetBitContext *
}
else if(s->chgaqmod[ch] == 0x3)
{
- for(n = 0; n < s->chgaqsections[ch]; n++) { //TODO chgaqsections ?
+ for(n = 0; n < s->chgaqsections[ch]; n++) {
GET_BITS(s->chgaqgain[ch][n], gbc, 5);
}
}
- for(bin = 0; bin < s->nchmant[ch]; bin++) // TODO nchmant ?
+
+ // TODO add VQ and GAQ
+#if 0
+ for(bin = 0; bin < s->nchmant[ch]; bin++)
{
- if(s->chgaqbin[ch][bin]) // TODO chgaqbin ?
+ if(s->chgaqbin[ch][bin]>0) // XXX !=0, >0 ?
{
for(n = 0; n < 6; n++) {
GET_BITS(s->pre_chmant[n][ch][bin], gbc, (0-16)); // TODO 0-16 :]
@@ -1215,8 +1282,8 @@ int ff_eac3_parse_audblk(GetBitContext *
GET_BITS(s->pre_chmant[0][ch][bin], gbc, (0-9)); // TODO 0-9 :]
}
}
- s->chahtinu[ch] = -1; /* AHT info for this frame has been read ? do not read again */
#endif
+ s->chahtinu[ch] = -1; /* AHT info for this frame has been read ? do not read again */
}
if(s->cplinu[blk] && s->chincpl[ch] && !got_cplchan)
{
More information about the FFmpeg-soc
mailing list