diff mbox

[FFmpeg-devel] avcodec/aac_adtstoasc: validate and forward extradata if the stream is already ASC

Message ID 20161125001833.3560-1-jamrial@gmail.com
State Accepted
Commit 45d199d5b0b7f09eb9baa29929a3bd07ed46223b
Headers show

Commit Message

James Almer Nov. 25, 2016, 12:18 a.m. UTC
Fixes ticket #5973

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/aac_adtstoasc_bsf.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

James Almer Nov. 25, 2016, 10:23 p.m. UTC | #1
On 11/24/2016 9:18 PM, James Almer wrote:
> Fixes ticket #5973
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/aac_adtstoasc_bsf.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
> index 48889fc..1067160 100644
> --- a/libavcodec/aac_adtstoasc_bsf.c
> +++ b/libavcodec/aac_adtstoasc_bsf.c
> @@ -136,8 +136,16 @@ fail:
>  
>  static int aac_adtstoasc_init(AVBSFContext *ctx)
>  {
> -    av_freep(&ctx->par_out->extradata);
> -    ctx->par_out->extradata_size = 0;
> +    /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */
> +    if (ctx->par_in->extradata) {
> +        MPEG4AudioConfig mp4ac;
> +        int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata,
> +                                               ctx->par_in->extradata_size * 8, 1);
> +        if (ret < 0) {
> +            av_log(ctx, AV_LOG_ERROR, "Error parsing AudioSpecificConfig extradata!\n");
> +            return ret;
> +        }
> +    }
>  
>      return 0;
>  }

Approved by Hendrik on IRC, pushed and backported to release/3.2

Thanks.
diff mbox

Patch

diff --git a/libavcodec/aac_adtstoasc_bsf.c b/libavcodec/aac_adtstoasc_bsf.c
index 48889fc..1067160 100644
--- a/libavcodec/aac_adtstoasc_bsf.c
+++ b/libavcodec/aac_adtstoasc_bsf.c
@@ -136,8 +136,16 @@  fail:
 
 static int aac_adtstoasc_init(AVBSFContext *ctx)
 {
-    av_freep(&ctx->par_out->extradata);
-    ctx->par_out->extradata_size = 0;
+    /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */
+    if (ctx->par_in->extradata) {
+        MPEG4AudioConfig mp4ac;
+        int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata,
+                                               ctx->par_in->extradata_size * 8, 1);
+        if (ret < 0) {
+            av_log(ctx, AV_LOG_ERROR, "Error parsing AudioSpecificConfig extradata!\n");
+            return ret;
+        }
+    }
 
     return 0;
 }