mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-26 19:01:44 +02:00
aacdec: separate out scalefactor dequantization from decoding
Allows to template away dequantization.
This commit is contained in:
parent
ed009bfd3d
commit
60b60dd635
@ -147,6 +147,7 @@ typedef struct SingleChannelElement {
|
|||||||
TemporalNoiseShaping tns;
|
TemporalNoiseShaping tns;
|
||||||
enum BandType band_type[128]; ///< band types
|
enum BandType band_type[128]; ///< band types
|
||||||
int band_type_run_end[120]; ///< band type run end points
|
int band_type_run_end[120]; ///< band type run end points
|
||||||
|
int sfo[120]; ///< scalefactor offsets
|
||||||
INTFLOAT_UNION(sf, [120]); ///< scalefactors
|
INTFLOAT_UNION(sf, [120]); ///< scalefactors
|
||||||
INTFLOAT_ALIGNED_UNION(32, coeffs, 1024); ///< coefficients for IMDCT, maybe processed
|
INTFLOAT_ALIGNED_UNION(32, coeffs, 1024); ///< coefficients for IMDCT, maybe processed
|
||||||
INTFLOAT_ALIGNED_UNION(32, saved, 1536); ///< overlap
|
INTFLOAT_ALIGNED_UNION(32, saved, 1536); ///< overlap
|
||||||
|
@ -1446,7 +1446,8 @@ static int decode_band_types(AACDecContext *ac, enum BandType band_type[120],
|
|||||||
*
|
*
|
||||||
* @return Returns error status. 0 - OK, !0 - error
|
* @return Returns error status. 0 - OK, !0 - error
|
||||||
*/
|
*/
|
||||||
static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContext *gb,
|
static int decode_scalefactors(AACDecContext *ac, int sfo[120],
|
||||||
|
GetBitContext *gb,
|
||||||
unsigned int global_gain,
|
unsigned int global_gain,
|
||||||
IndividualChannelStream *ics,
|
IndividualChannelStream *ics,
|
||||||
enum BandType band_type[120],
|
enum BandType band_type[120],
|
||||||
@ -1461,7 +1462,7 @@ static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContex
|
|||||||
int run_end = band_type_run_end[idx];
|
int run_end = band_type_run_end[idx];
|
||||||
if (band_type[idx] == ZERO_BT) {
|
if (band_type[idx] == ZERO_BT) {
|
||||||
for (; i < run_end; i++, idx++)
|
for (; i < run_end; i++, idx++)
|
||||||
sf[idx] = FIXR(0.);
|
sfo[idx] = 0;
|
||||||
} else if ((band_type[idx] == INTENSITY_BT) ||
|
} else if ((band_type[idx] == INTENSITY_BT) ||
|
||||||
(band_type[idx] == INTENSITY_BT2)) {
|
(band_type[idx] == INTENSITY_BT2)) {
|
||||||
for (; i < run_end; i++, idx++) {
|
for (; i < run_end; i++, idx++) {
|
||||||
@ -1473,11 +1474,7 @@ static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContex
|
|||||||
"Clipped intensity stereo position (%d -> %d)",
|
"Clipped intensity stereo position (%d -> %d)",
|
||||||
offset[2], clipped_offset);
|
offset[2], clipped_offset);
|
||||||
}
|
}
|
||||||
#if USE_FIXED
|
sfo[idx] = clipped_offset;
|
||||||
sf[idx] = 100 - clipped_offset;
|
|
||||||
#else
|
|
||||||
sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO];
|
|
||||||
#endif /* USE_FIXED */
|
|
||||||
}
|
}
|
||||||
} else if (band_type[idx] == NOISE_BT) {
|
} else if (band_type[idx] == NOISE_BT) {
|
||||||
for (; i < run_end; i++, idx++) {
|
for (; i < run_end; i++, idx++) {
|
||||||
@ -1492,11 +1489,7 @@ static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContex
|
|||||||
"Clipped noise gain (%d -> %d)",
|
"Clipped noise gain (%d -> %d)",
|
||||||
offset[1], clipped_offset);
|
offset[1], clipped_offset);
|
||||||
}
|
}
|
||||||
#if USE_FIXED
|
sfo[idx] = clipped_offset;
|
||||||
sf[idx] = -(100 + clipped_offset);
|
|
||||||
#else
|
|
||||||
sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO];
|
|
||||||
#endif /* USE_FIXED */
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (; i < run_end; i++, idx++) {
|
for (; i < run_end; i++, idx++) {
|
||||||
@ -1506,11 +1499,7 @@ static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContex
|
|||||||
"Scalefactor (%d) out of range.\n", offset[0]);
|
"Scalefactor (%d) out of range.\n", offset[0]);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
#if USE_FIXED
|
sfo[idx] = offset[0];
|
||||||
sf[idx] = -offset[0];
|
|
||||||
#else
|
|
||||||
sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO];
|
|
||||||
#endif /* USE_FIXED */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1518,6 +1507,60 @@ static int decode_scalefactors(AACDecContext *ac, INTFLOAT sf[120], GetBitContex
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert integer scalefactors to the decoder's native expected
|
||||||
|
* scalefactor values.
|
||||||
|
*/
|
||||||
|
static void dequant_scalefactors(SingleChannelElement *sce)
|
||||||
|
{
|
||||||
|
IndividualChannelStream *ics = &sce->ics;
|
||||||
|
const enum BandType *band_type = sce->band_type;
|
||||||
|
const int *band_type_run_end = sce->band_type_run_end;
|
||||||
|
const int *sfo = sce->sfo;
|
||||||
|
INTFLOAT *sf = sce->AAC_RENAME(sf);
|
||||||
|
|
||||||
|
int g, i, idx = 0;
|
||||||
|
for (g = 0; g < ics->num_window_groups; g++) {
|
||||||
|
for (i = 0; i < ics->max_sfb;) {
|
||||||
|
int run_end = band_type_run_end[idx];
|
||||||
|
switch (band_type[idx]) {
|
||||||
|
case ZERO_BT:
|
||||||
|
for (; i < run_end; i++, idx++)
|
||||||
|
sf[idx] = FIXR(0.);
|
||||||
|
break;
|
||||||
|
case INTENSITY_BT: /* fallthrough */
|
||||||
|
case INTENSITY_BT2:
|
||||||
|
for (; i < run_end; i++, idx++) {
|
||||||
|
#if USE_FIXED
|
||||||
|
sf[idx] = 100 - sfo[idx];
|
||||||
|
#else
|
||||||
|
sf[idx] = ff_aac_pow2sf_tab[-sfo[idx] + POW_SF2_ZERO];
|
||||||
|
#endif /* USE_FIXED */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NOISE_BT:
|
||||||
|
for (; i < run_end; i++, idx++) {
|
||||||
|
#if USE_FIXED
|
||||||
|
sf[idx] = -(100 + sfo[idx]);
|
||||||
|
#else
|
||||||
|
sf[idx] = -ff_aac_pow2sf_tab[sfo[idx] + POW_SF2_ZERO];
|
||||||
|
#endif /* USE_FIXED */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
for (; i < run_end; i++, idx++) {
|
||||||
|
#if USE_FIXED
|
||||||
|
sf[idx] = -sfo[idx];
|
||||||
|
#else
|
||||||
|
sf[idx] = -ff_aac_pow2sf_tab[sfo[idx] - 100 + POW_SF2_ZERO];
|
||||||
|
#endif /* USE_FIXED */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decode pulse data; reference: table 4.7.
|
* Decode pulse data; reference: table 4.7.
|
||||||
*/
|
*/
|
||||||
@ -2007,10 +2050,12 @@ static int decode_ics(AACDecContext *ac, SingleChannelElement *sce,
|
|||||||
if ((ret = decode_band_types(ac, sce->band_type,
|
if ((ret = decode_band_types(ac, sce->band_type,
|
||||||
sce->band_type_run_end, gb, ics)) < 0)
|
sce->band_type_run_end, gb, ics)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
if ((ret = decode_scalefactors(ac, sce->AAC_RENAME(sf), gb, global_gain, ics,
|
if ((ret = decode_scalefactors(ac, sce->sfo, gb, global_gain, ics,
|
||||||
sce->band_type, sce->band_type_run_end)) < 0)
|
sce->band_type, sce->band_type_run_end)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
dequant_scalefactors(sce);
|
||||||
|
|
||||||
pulse_present = 0;
|
pulse_present = 0;
|
||||||
if (!scale_flag) {
|
if (!scale_flag) {
|
||||||
if (!eld_syntax && (pulse_present = get_bits1(gb))) {
|
if (!eld_syntax && (pulse_present = get_bits1(gb))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user