Browse code

avcodec/aac_adtstoasc_bsf: validate and forward extradata if the stream is already ASC

Fixes ticket #5973

Reviewed-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
(cherry picked from commit 6e1902bab4349a79c45807af18ebf5b50f7b436b)

James Almer authored on 2016/11/25 09:10:47
Showing 2 changed files
... ...
@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
2 2
 releases are sorted from youngest to oldest.
3 3
 
4 4
 version 3.2.1:
5
+- avcodec/aac_adtstoasc_bsf: validate and forward extradata if the stream is already ASC
5 6
 - mss2: only use error correction for matching block counts
6 7
 - softfloat: decrease MIN_EXP to cover full float range
7 8
 - libopusdec: default to stereo for invalid number of channels
... ...
@@ -136,8 +136,16 @@ fail:
136 136
 
137 137
 static int aac_adtstoasc_init(AVBSFContext *ctx)
138 138
 {
139
-    av_freep(&ctx->par_out->extradata);
140
-    ctx->par_out->extradata_size = 0;
139
+    /* Validate the extradata if the stream is already MPEG-4 AudioSpecificConfig */
140
+    if (ctx->par_in->extradata) {
141
+        MPEG4AudioConfig mp4ac;
142
+        int ret = avpriv_mpeg4audio_get_config(&mp4ac, ctx->par_in->extradata,
143
+                                               ctx->par_in->extradata_size * 8, 1);
144
+        if (ret < 0) {
145
+            av_log(ctx, AV_LOG_ERROR, "Error parsing AudioSpecificConfig extradata!\n");
146
+            return ret;
147
+        }
148
+    }
141 149
 
142 150
     return 0;
143 151
 }