diff mbox series

[FFmpeg-devel,09/14] h264dec: do not abort if decoding extradata fails

Message ID 20200327125747.13460-9-anton@khirnov.net
State Accepted
Headers show
Series [FFmpeg-devel,01/14] mpeg4videodec: do not copy a range of fields at once
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Anton Khirnov March 27, 2020, 12:57 p.m. UTC
Such errors are not necessarily fatal and decoding might still be
possible, e.g. it happens for MVC streams where we do not handle the
subset SPS thus failing to parse its corresponding PPS.
---
 libavcodec/h264dec.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

James Almer March 27, 2020, 2:54 p.m. UTC | #1
On 3/27/2020 9:57 AM, Anton Khirnov wrote:
> Such errors are not necessarily fatal and decoding might still be
> possible, e.g. it happens for MVC streams where we do not handle the
> subset SPS thus failing to parse its corresponding PPS.
> ---
>  libavcodec/h264dec.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
> index b6c51ed1e2..dba0634fa0 100644
> --- a/libavcodec/h264dec.c
> +++ b/libavcodec/h264dec.c
> @@ -414,10 +414,14 @@ static av_cold int h264_decode_init(AVCodecContext *avctx)
>              ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
>                                             &h->ps, &h->is_avc, &h->nal_length_size,
>                                             avctx->err_recognition, avctx);
> -            if (ret < 0) {
> -                h264_decode_end(avctx);
> -                return ret;
> -            }
> +           if (ret < 0) {
> +               av_log(avctx, AV_LOG_WARNING, "Error decoding the extradata\n");

Should be AV_LOG_ERROR if AV_EF_EXPLODE is enabled.

> +               if (avctx->err_recognition & AV_EF_EXPLODE) {
> +                   h264_decode_end(avctx);
> +                   return ret;
> +               }
> +               ret = 0;
> +           }
>          }
>      }

LGTM otherwise.
diff mbox series

Patch

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index b6c51ed1e2..dba0634fa0 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -414,10 +414,14 @@  static av_cold int h264_decode_init(AVCodecContext *avctx)
             ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
                                            &h->ps, &h->is_avc, &h->nal_length_size,
                                            avctx->err_recognition, avctx);
-            if (ret < 0) {
-                h264_decode_end(avctx);
-                return ret;
-            }
+           if (ret < 0) {
+               av_log(avctx, AV_LOG_WARNING, "Error decoding the extradata\n");
+               if (avctx->err_recognition & AV_EF_EXPLODE) {
+                   h264_decode_end(avctx);
+                   return ret;
+               }
+               ret = 0;
+           }
         }
     }