1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

libvo-aacenc: Only produce extradata if the global header flag is set

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2011-04-12 10:35:23 +03:00
parent 451d566f4b
commit 2d3267936a

View File

@ -62,12 +62,6 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
return AVERROR_UNKNOWN; return AVERROR_UNKNOWN;
} }
avctx->extradata_size = 2;
avctx->extradata = av_mallocz(avctx->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
for (index = 0; index < 16; index++) for (index = 0; index < 16; index++)
if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index])
break; break;
@ -76,8 +70,16 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
avctx->sample_rate); avctx->sample_rate);
return AVERROR_NOTSUPP; return AVERROR_NOTSUPP;
} }
avctx->extradata[0] = 0x02 << 3 | index >> 1; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3; avctx->extradata_size = 2;
avctx->extradata = av_mallocz(avctx->extradata_size +
FF_INPUT_BUFFER_PADDING_SIZE);
if (!avctx->extradata)
return AVERROR(ENOMEM);
avctx->extradata[0] = 0x02 << 3 | index >> 1;
avctx->extradata[1] = (index & 0x01) << 7 | avctx->channels << 3;
}
return 0; return 0;
} }