[FFmpeg-devel] avcodec/aacdec_template: Allow duplicated elements

Submitted by Michael Niedermayer on Oct. 7, 2018, 11:44 a.m.

Details

Message ID 20181007114418.19705-1-michael@niedermayer.cc
State Accepted
Commit 8f1524802469cb701040561cd05a9a924dec3627
Headers show

Commit Message

Michael Niedermayer Oct. 7, 2018, 11:44 a.m.
Such streams are invalid according to
4.5.2.1 Top level payloads for the audio object types AAC main, AAC SSR, AAC LC and AAC LTP
4.5.2.1.1 Definitions
...cIn the raw_data_block(), several instances of the
same syntactic element may occur, but must have a different 4 bit
element_instance_tag, except for data_stream_element()'s and
fill_element()'s.

Fixes: Ticket7477

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/aacdec_template.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Paul B Mahol Oct. 11, 2018, 10:56 a.m.
On 10/7/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Such streams are invalid according to
> 4.5.2.1 Top level payloads for the audio object types AAC main, AAC SSR, AAC
> LC and AAC LTP
> 4.5.2.1.1 Definitions
> ...cIn the raw_data_block(), several instances of the
> same syntactic element may occur, but must have a different 4 bit
> element_instance_tag, except for data_stream_element()'s and
> fill_element()'s.
>
> Fixes: Ticket7477
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/aacdec_template.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index b60b31a92c..dce6035d67 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -3161,12 +3161,15 @@ static int aac_decode_frame_int(AVCodecContext
> *avctx, void *data,
>
>          if (elem_type < TYPE_DSE) {
>              if (che_presence[elem_type][elem_id]) {
> -                av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d
> duplicate\n",
> +                int error = che_presence[elem_type][elem_id] > 1;
> +                av_log(ac->avctx, error ? AV_LOG_ERROR : AV_LOG_DEBUG,
> "channel element %d.%d duplicate\n",
>                         elem_type, elem_id);
> -                err = AVERROR_INVALIDDATA;
> -                goto fail;
> +                if (error) {
> +                    err = AVERROR_INVALIDDATA;
> +                    goto fail;
> +                }
>              }
> -            che_presence[elem_type][elem_id] = 1;
> +            che_presence[elem_type][elem_id]++;
>
>              if (!(che=get_che(ac, elem_type, elem_id))) {
>                  av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is
> not allocated\n",
> --
> 2.19.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

probably ok
Michael Niedermayer Oct. 11, 2018, 10:45 p.m.
On Thu, Oct 11, 2018 at 12:56:30PM +0200, Paul B Mahol wrote:
> On 10/7/18, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > Such streams are invalid according to
> > 4.5.2.1 Top level payloads for the audio object types AAC main, AAC SSR, AAC
> > LC and AAC LTP
> > 4.5.2.1.1 Definitions
> > ...cIn the raw_data_block(), several instances of the
> > same syntactic element may occur, but must have a different 4 bit
> > element_instance_tag, except for data_stream_element()'s and
> > fill_element()'s.
> >
> > Fixes: Ticket7477
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavcodec/aacdec_template.c | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> > index b60b31a92c..dce6035d67 100644
> > --- a/libavcodec/aacdec_template.c
> > +++ b/libavcodec/aacdec_template.c
> > @@ -3161,12 +3161,15 @@ static int aac_decode_frame_int(AVCodecContext
> > *avctx, void *data,
> >
> >          if (elem_type < TYPE_DSE) {
> >              if (che_presence[elem_type][elem_id]) {
> > -                av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d
> > duplicate\n",
> > +                int error = che_presence[elem_type][elem_id] > 1;
> > +                av_log(ac->avctx, error ? AV_LOG_ERROR : AV_LOG_DEBUG,
> > "channel element %d.%d duplicate\n",
> >                         elem_type, elem_id);
> > -                err = AVERROR_INVALIDDATA;
> > -                goto fail;
> > +                if (error) {
> > +                    err = AVERROR_INVALIDDATA;
> > +                    goto fail;
> > +                }
> >              }
> > -            che_presence[elem_type][elem_id] = 1;
> > +            che_presence[elem_type][elem_id]++;
> >
> >              if (!(che=get_che(ac, elem_type, elem_id))) {
> >                  av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is
> > not allocated\n",
> > --
> > 2.19.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> 
> probably ok

will apply

thanks

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index b60b31a92c..dce6035d67 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -3161,12 +3161,15 @@  static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
 
         if (elem_type < TYPE_DSE) {
             if (che_presence[elem_type][elem_id]) {
-                av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d duplicate\n",
+                int error = che_presence[elem_type][elem_id] > 1;
+                av_log(ac->avctx, error ? AV_LOG_ERROR : AV_LOG_DEBUG, "channel element %d.%d duplicate\n",
                        elem_type, elem_id);
-                err = AVERROR_INVALIDDATA;
-                goto fail;
+                if (error) {
+                    err = AVERROR_INVALIDDATA;
+                    goto fail;
+                }
             }
-            che_presence[elem_type][elem_id] = 1;
+            che_presence[elem_type][elem_id]++;
 
             if (!(che=get_che(ac, elem_type, elem_id))) {
                 av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n",