[FFmpeg-devel] [PATCH] avcodec/aac_adtstoasc: recover original extradata if the stream is already ASC
James Almer
jamrial at gmail.com
Fri Nov 25 00:24:26 EET 2016
On 11/21/2016 11:13 PM, James Almer wrote:
> Fixes ticket #5973
>
> Signed-off-by: James Almer <jamrial at gmail.com>
> ---
> Maybe init() should propagate the extradata down the filter chain instead
> of this, since if an aac stream has extradata then it means that it's an
> ASC stream. Neither ADTS or LATM use extradata.
>
> What's preferred?
Ping
>
> libavcodec/aac_adtstoasc_bsf.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
> index 48889fc..76cf32e 100644
> --- a/libavcodec/aac_adtstoasc_bsf.c
> +++ b/libavcodec/aac_adtstoasc_bsf.c
> @@ -54,8 +54,19 @@ static int aac_adtstoasc_filter(AVBSFContext *bsfc, AVPacket *out)
>
> init_get_bits(&gb, in->data, AAC_ADTS_HEADER_SIZE * 8);
>
> - if (bsfc->par_in->extradata && show_bits(&gb, 12) != 0xfff)
> + if (bsfc->par_in->extradata && show_bits(&gb, 12) != 0xfff) {
> + if (!bsfc->par_out->extradata) {
> + /* Stream is already AudioSpecificConfig. Restore its original extradata */
> + bsfc->par_out->extradata = av_mallocz(bsfc->par_in->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
> + if (!bsfc->par_out->extradata) {
> + ret = AVERROR(ENOMEM);
> + goto fail;
> + }
> + bsfc->par_out->extradata_size = bsfc->par_in->extradata_size;
> + memcpy(bsfc->par_out->extradata, bsfc->par_in->extradata, bsfc->par_in->extradata_size);
> + }
> goto finish;
> + }
>
> if (avpriv_aac_parse_header(&gb, &hdr) < 0) {
> av_log(bsfc, AV_LOG_ERROR, "Error parsing ADTS frame header!\n");
More information about the ffmpeg-devel
mailing list