[FFmpeg-devel] h264: fix RTSP stream decoding

sergey at gavrushkin.com sergey at gavrushkin.com
Fri Dec 29 23:48:19 EET 2017


> Please add "Fixes ticket #6422" to the commit message.
> 
> And maybe remove "rtsp" from the commit title, the issue
> is reproducible with files.

Done.

Please feel free to edit commit title/message as you wish for merge.

Thank you, 
Sergey

-------------------------------------



From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
From: Sergey Gavrushkin <sergey at gavrushkin.com <mailto:sergey at gavrushkin.com>>
Date: Fri, 29 Dec 2017 20:03:50 +0300
Subject: [PATCH] h264: fix decoding

Fixes ticket #6422 . 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


More information about the ffmpeg-devel mailing list