Message ID | 20161122021351.8128-1-jamrial@gmail.com |
---|---|
State | New |
Headers | show |
On 11/21/2016 11:13 PM, James Almer wrote: > Fixes ticket #5973 > > Signed-off-by: James Almer <jamrial@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");
On Tue, Nov 22, 2016 at 3:13 AM, James Almer <jamrial@gmail.com> wrote: > Fixes ticket #5973 > > Signed-off-by: James Almer <jamrial@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? > Forwarding the extradata right away in init is probably better. As you say any of the other alternatives don't use any. Could try to parse it to make sure its valid, and not forwarding garbage, if you really care. - Hendrik
On 11/24/2016 8:13 PM, Hendrik Leppkes wrote: > On Tue, Nov 22, 2016 at 3:13 AM, James Almer <jamrial@gmail.com> wrote: >> Fixes ticket #5973 >> >> Signed-off-by: James Almer <jamrial@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? >> > > Forwarding the extradata right away in init is probably better. As you > say any of the other alternatives don't use any. > Could try to parse it to make sure its valid, and not forwarding > garbage, if you really care. Sure, will send a new patch to do that. Thanks. > > - Hendrik > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
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");
Fixes ticket #5973 Signed-off-by: James Almer <jamrial@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? libavcodec/aac_adtstoasc_bsf.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)