diff mbox

[FFmpeg-devel] aac: Rework extradata parsing code

Message ID CABLWnS-cjWeMYJjNSz_emb_XxWsipTsQySk+iTZoEsYvozhw6g@mail.gmail.com
State New
Headers show

Commit Message

Vittorio Giovara April 17, 2018, 3:47 p.m. UTC
- 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
---

ping


 libavcodec/aacdec_template.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

Comments

wm4 April 17, 2018, 8:05 p.m. UTC | #1
On Tue, 17 Apr 2018 11:47:00 -0400
Vittorio Giovara <vittorio.giovara@gmail.com> wrote:

> - 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
> ---
> 
> ping
> 
> 
>  libavcodec/aacdec_template.c | 22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index cf97181092..0c899285dd 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -3324,20 +3324,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;
>          }
>      }
> 

Generally LGTM. Is there a proper test for this? (Apparently not...)
Michael Niedermayer April 18, 2018, 8:39 p.m. UTC | #2
On Tue, Apr 17, 2018 at 11:47:00AM -0400, Vittorio Giovara wrote:
> - 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
> ---
> 
> ping
> 
> 
>  libavcodec/aacdec_template.c | 22 ++++++++--------------
>  1 file changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
> index cf97181092..0c899285dd 100644
> --- a/libavcodec/aacdec_template.c
> +++ b/libavcodec/aacdec_template.c
> @@ -3324,20 +3324,14 @@ static int aac_decode_frame(AVCodecContext
> *avctx, void *data,
>                                         AV_PKT_DATA_JP_DUALMONO,
>                                         &jp_dualmono_size);

This patch is corrupted by newlines

Applying: aac: Rework extradata parsing code
error: corrupt patch at line 14
error: could not build fake ancestor


[...]
diff mbox

Patch

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index cf97181092..0c899285dd 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -3324,20 +3324,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;
         }
     }