summaryrefslogtreecommitdiffstats
path: root/libavcodec/aacpsy.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-24 02:41:53 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-24 02:41:53 +0100
commit0bb57f8bf029427059be21a562527dcfa0e264c9 (patch)
tree8e6743c4fc1f16f36899bdea87e485735c0d8d59 /libavcodec/aacpsy.c
parentb955d4072e3e563b230c9ab4d6575577a3dc7314 (diff)
parent0fec2cb15cc6ff1fcc724c774ec36abadcb7b6ad (diff)
downloadffmpeg-streaming-0bb57f8bf029427059be21a562527dcfa0e264c9.zip
ffmpeg-streaming-0bb57f8bf029427059be21a562527dcfa0e264c9.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: Remove ffmpeg. aacenc: Simplify windowing aacenc: Move saved overlap samples to the beginning of the same buffer as incoming samples. aacenc: Deinterleave input samples before processing. aacenc: Store channel count in AACEncContext. aacenc: Move Q^3/4 calculation to it's own table aacenc: Request normalized float samples instead of converting s16 samples to float. aacpsy: Replace an if with FFMAX in LAME windowing. aacenc: cosmetics, replace 'rd' with 'bits' in codebook_trellis_rate to make it more clear what is being calculated. aacpsy: cosmetics, change a FIXME to a NOTE about subshort comparisons aacenc: cosmetics: move init() and end() to the bottom of the file. aacenc: aac_encode_init() cleanup XWD encoder and decoder vc1: don't read the interpfrm and bfraction elements for interlaced frames mxfdec: fix memleak on mxf_read_close() westwood: split the AUD and VQA demuxers into separate files. Conflicts: .gitignore Changelog Makefile configure doc/ffmpeg.texi ffmpeg.c libavcodec/Makefile libavcodec/aacenc.c libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/version.h libavformat/Makefile libavformat/img2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aacpsy.c')
-rw-r--r--libavcodec/aacpsy.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
index f81ed48..396a2d2 100644
--- a/libavcodec/aacpsy.c
+++ b/libavcodec/aacpsy.c
@@ -400,7 +400,7 @@ static av_unused FFPsyWindowInfo psy_3gpp_window(FFPsyContext *ctx,
int stay_short = 0;
for (i = 0; i < 8; i++) {
for (j = 0; j < 128; j++) {
- v = iir_filter(la[(i*128+j)*ctx->avctx->channels], pch->iir_state);
+ v = iir_filter(la[i*128+j], pch->iir_state);
sum += v*v;
}
s[i] = sum;
@@ -776,9 +776,8 @@ static void lame_apply_block_type(AacPsyChannel *ctx, FFPsyWindowInfo *wi, int u
ctx->next_window_seq = blocktype;
}
-static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx,
- const int16_t *audio, const int16_t *la,
- int channel, int prev_type)
+static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
+ const float *la, int channel, int prev_type)
{
AacPsyContext *pctx = (AacPsyContext*) ctx->model_priv_data;
AacPsyChannel *pch = &pctx->ch[channel];
@@ -795,20 +794,20 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx,
float attack_intensity[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_subshort[(AAC_NUM_BLOCKS_SHORT + 1) * PSY_LAME_NUM_SUBBLOCKS];
float energy_short[AAC_NUM_BLOCKS_SHORT + 1] = { 0 };
- int chans = ctx->avctx->channels;
- const int16_t *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN) * chans;
+ const float *firbuf = la + (AAC_BLOCK_SIZE_SHORT/4 - PSY_LAME_FIR_LEN);
int j, att_sum = 0;
/* LAME comment: apply high pass filter of fs/4 */
for (i = 0; i < AAC_BLOCK_SIZE_LONG; i++) {
float sum1, sum2;
- sum1 = firbuf[(i + ((PSY_LAME_FIR_LEN - 1) / 2)) * chans];
+ sum1 = firbuf[i + (PSY_LAME_FIR_LEN - 1) / 2];
sum2 = 0.0;
for (j = 0; j < ((PSY_LAME_FIR_LEN - 1) / 2) - 1; j += 2) {
- sum1 += psy_fir_coeffs[j] * (firbuf[(i + j) * chans] + firbuf[(i + PSY_LAME_FIR_LEN - j) * chans]);
- sum2 += psy_fir_coeffs[j + 1] * (firbuf[(i + j + 1) * chans] + firbuf[(i + PSY_LAME_FIR_LEN - j - 1) * chans]);
+ sum1 += psy_fir_coeffs[j] * (firbuf[i + j] + firbuf[i + PSY_LAME_FIR_LEN - j]);
+ sum2 += psy_fir_coeffs[j + 1] * (firbuf[i + j + 1] + firbuf[i + PSY_LAME_FIR_LEN - j - 1]);
}
- hpfsmpl[i] = sum1 + sum2;
+ /* NOTE: The LAME psymodel expects it's input in the range -32768 to 32768. Tuning this for normalized floats would be difficult. */
+ hpfsmpl[i] = (sum1 + sum2) * 32768.0f;
}
/* Calculate the energies of each sub-shortblock */
@@ -823,16 +822,15 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx,
float const *const pfe = pf + AAC_BLOCK_SIZE_LONG / (AAC_NUM_BLOCKS_SHORT * PSY_LAME_NUM_SUBBLOCKS);
float p = 1.0f;
for (; pf < pfe; pf++)
- if (p < fabsf(*pf))
- p = fabsf(*pf);
+ p = FFMAX(p, fabsf(*pf));
pch->prev_energy_subshort[i] = energy_subshort[i + PSY_LAME_NUM_SUBBLOCKS] = p;
energy_short[1 + i / PSY_LAME_NUM_SUBBLOCKS] += p;
- /* FIXME: The indexes below are [i + 3 - 2] in the LAME source.
- * Obviously the 3 and 2 have some significance, or this would be just [i + 1]
- * (which is what we use here). What the 3 stands for is ambigious, as it is both
- * number of short blocks, and the number of sub-short blocks.
- * It seems that LAME is comparing each sub-block to sub-block + 1 in the
- * previous block.
+ /* NOTE: The indexes below are [i + 3 - 2] in the LAME source.
+ * Obviously the 3 and 2 have some significance, or this would be just [i + 1]
+ * (which is what we use here). What the 3 stands for is ambiguous, as it is both
+ * number of short blocks, and the number of sub-short blocks.
+ * It seems that LAME is comparing each sub-block to sub-block + 1 in the
+ * previous block.
*/
if (p > energy_subshort[i + 1])
p = p / energy_subshort[i + 1];
OpenPOWER on IntegriCloud