aac: Rework extradata parsing code

Message ID 20180412214449.75819-1-vittorio.giovara@gmail.com
State New
Headers show
Series
  • aac: Rework extradata parsing code
Related show

Commit Message

Vittorio Giovara April 12, 2018, 9:44 p.m.
- enable the parsing code
- use the new buffer instead of replacing the context one
- do not push/pop configuration, just discard the exiting one
- propagate errors correctly
---
 libavcodec/aacdec.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

Luca Barbato April 13, 2018, 12:22 a.m. | #1
On 13/04/2018 06:44, Vittorio Giovara wrote:
> -    if (new_extradata && 0) {

Uh?
wm4 April 13, 2018, 2:43 p.m. | #2
On Fri, 13 Apr 2018 09:22:30 +0900
Luca Barbato <lu_zero@gentoo.org> wrote:

> On 13/04/2018 06:44, Vittorio Giovara wrote:
> > -    if (new_extradata && 0) {  
> 
> Uh?


faa2930f191099621e03c55cca32662467d3cc15

flvdec: reenable extradata passing code
James Almer April 13, 2018, 10:02 p.m. | #3
On 4/13/2018 11:43 AM, wm4 wrote:
> On Fri, 13 Apr 2018 09:22:30 +0900
> Luca Barbato <lu_zero@gentoo.org> wrote:
> 
>> On 13/04/2018 06:44, Vittorio Giovara wrote:
>>> -    if (new_extradata && 0) {  
>>
>> Uh?
> 
> 
> faa2930f191099621e03c55cca32662467d3cc15
> 
> flvdec: reenable extradata passing code

What flv sample had issues before that commit? Would be best to make
sure it still works before applying this patch.

Patch

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index cf97181092..0c899285dd 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -324,20 +324,14 @@  static int aac_decode_frame(AVCodecContext *avctx, void *data,
                                        AV_PKT_DATA_JP_DUALMONO,
                                        &jp_dualmono_size);
 
-    if (new_extradata && 0) {
-        av_free(avctx->extradata);
-        avctx->extradata = av_mallocz(new_extradata_size +
-                                      AV_INPUT_BUFFER_PADDING_SIZE);
-        if (!avctx->extradata)
-            return AVERROR(ENOMEM);
-        avctx->extradata_size = new_extradata_size;
-        memcpy(avctx->extradata, new_extradata, new_extradata_size);
-        push_output_configuration(ac);
-        if (decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
-                                         avctx->extradata,
-                                         avctx->extradata_size*8LL, 1) < 0) {
-            pop_output_configuration(ac);
-            return AVERROR_INVALIDDATA;
+    if (new_extradata) {
+        /* discard previous configuration */
+        ac->oc[1].status = OC_NONE;
+        err = decode_audio_specific_config(ac, ac->avctx, &ac->oc[1].m4ac,
+                                           new_extradata,
+                                           new_extradata_size * 8LL, 1);
+        if (err < 0) {
+            return err;
         }
     }