1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

AAC encoder: fix valgrind errors

Move wi.clipping computation outside of psy_lame_window, LFE
channels don't even call that, and make the LFE path also
initialize window_type[1] which is needed by analyze_channel
This commit is contained in:
Claudio Freire 2016-04-05 23:13:44 -03:00
parent 2c697c650c
commit 8005b6de4f
2 changed files with 16 additions and 17 deletions

View File

@ -554,10 +554,11 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
if (!frame)
la = NULL;
if (tag == TYPE_LFE) {
wi[ch].window_type[0] = ONLY_LONG_SEQUENCE;
wi[ch].window_type[0] = wi[ch].window_type[1] = ONLY_LONG_SEQUENCE;
wi[ch].window_shape = 0;
wi[ch].num_windows = 1;
wi[ch].grouping[0] = 1;
wi[ch].clipping[0] = 0;
/* Only the lowest 12 coefficients are used in a LFE channel.
* The expression below results in only the bottom 8 coefficients
@ -582,9 +583,22 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ics->tns_max_bands = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ?
ff_tns_max_bands_128 [s->samplerate_index]:
ff_tns_max_bands_1024[s->samplerate_index];
clip_avoidance_factor = 0.0f;
for (w = 0; w < ics->num_windows; w++)
ics->group_len[w] = wi[ch].grouping[w];
/* Calculate input sample maximums and evaluate clipping risk */
clip_avoidance_factor = 0.0f;
for (w = 0; w < ics->num_windows; w++) {
const float *wbuf = overlap + w * 128;
const int wlen = 2048 / ics->num_windows;
float max = 0;
int j;
/* mdct input is 2 * output */
for (j = 0; j < wlen; j++)
max = FFMAX(max, fabsf(wbuf[j]));
wi[ch].clipping[w] = max;
}
for (w = 0; w < ics->num_windows; w++) {
if (wi[ch].clipping[w] > CLIP_AVOIDANCE_FACTOR) {
ics->window_clipping[w] = 1;

View File

@ -975,21 +975,6 @@ static FFPsyWindowInfo psy_lame_window(FFPsyContext *ctx, const float *audio,
lame_apply_block_type(pch, &wi, uselongblock);
/* Calculate input sample maximums and evaluate clipping risk */
if (audio) {
for (i = 0; i < AAC_NUM_BLOCKS_SHORT; i++) {
const float *wbuf = audio + i * AAC_BLOCK_SIZE_SHORT;
float max = 0;
int j;
for (j = 0; j < AAC_BLOCK_SIZE_SHORT; j++)
max = FFMAX(max, fabsf(wbuf[j]));
clippings[i] = max;
}
} else {
for (i = 0; i < 8; i++)
clippings[i] = 0;
}
wi.window_type[1] = prev_type;
if (wi.window_type[0] != EIGHT_SHORT_SEQUENCE) {
float clipping = 0.0f;