[FFmpeg-devel] h264: fix RTSP stream decoding

Tristan Matthews tmatth at videolan.org
Fri Dec 29 20:08:20 EET 2017


Hi,

On Fri, Dec 29, 2017 at 12:43 PM, sergey at gavrushkin.com
<sergey at gavrushkin.com> wrote:
> Hello,
>
> FFmpeg stop working with the latest model of camera that I work now. I've investigated it and found that "bad" commit is 98c97994c5b90bdae02accb155eeceeb5224b8ef. There was additional check for ret value and err_recognition, that was ignored while refactoring to h264_parse.c function.
>
> Test RTSP streams are available here:
>
> rtsp://admin:123456@69.42.237.230:1569/mpeg4cif <rtsp://admin:123456@69.42.237.230:1569/mpeg4cif>
> rtsp://admin:123456@69.42.237.230:1568/mpeg4cif

This seems to fix the reported issue here.

Best,
Tristan

>
> P.S. It is my first patch so please write any notes what I should provide for accepting.
>
> Thank you,
> Sergey
>
>
> -------------------------------------
>
>
>
> From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
> From: Sergey Gavrushkin <sergey at gavrushkin.com>
> Date: Fri, 29 Dec 2017 20:03:50 +0300
> Subject: [PATCH] h264: fix RTSP stream decoding
>
> It is a regression fix for an issue that was introduced in commit
> 98c97994c5b90bdae02accb155eeceeb5224b8ef. Variable err_recognition is
> ignored while extradata is decoded and the whole decoding process is
> failed due to timeout.
> ---
>  libavcodec/h264_parse.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> index fee28d9..009d50c 100644
> --- a/libavcodec/h264_parse.c
> +++ b/libavcodec/h264_parse.c
> @@ -347,7 +347,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
>  }
>
>  static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
> -                               int is_avc, void *logctx)
> +                               int is_avc, int err_recognition, void *logctx)
>  {
>      H2645Packet pkt = { 0 };
>      int i, ret = 0;
> @@ -363,13 +363,13 @@ static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
>          switch (nal->type) {
>          case H264_NAL_SPS:
>              ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 0);
> -            if (ret < 0)
> +            if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
>                  goto fail;
>              break;
>          case H264_NAL_PPS:
>              ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
>                                                         nal->size_bits);
> -            if (ret < 0)
> +            if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
>                  goto fail;
>              break;
>          default:
> @@ -393,7 +393,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int buf_size, H264ParamSe
>  {
>      int ret;
>
> -    ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx);
> +    ret = decode_extradata_ps(buf, buf_size, ps, 1, err_recognition, logctx);
>      if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) {
>          GetByteContext gbc;
>          PutByteContext pbc;
> @@ -425,7 +425,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int buf_size, H264ParamSe
>          escaped_buf_size = bytestream2_tell_p(&pbc);
>          AV_WB16(escaped_buf, escaped_buf_size - 2);
>
> -        (void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, logctx);
> +        (void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, err_recognition, logctx);
>          // lorex.mp4 decodes ok even with extradata decoding failing
>          av_freep(&escaped_buf);
>      }
> @@ -486,7 +486,7 @@ int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
>          *nal_length_size = (data[4] & 0x03) + 1;
>      } else {
>          *is_avc = 0;
> -        ret = decode_extradata_ps(data, size, ps, 0, logctx);
> +        ret = decode_extradata_ps(data, size, ps, 0, err_recognition, logctx);
>          if (ret < 0)
>              return ret;
>      }
> --
> 2.6.4
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list