[FFmpeg-cvslog] h264: merge the two reinit blocks in slice_header_parse()

Anton Khirnov git at videolan.org
Fri Jul 1 14:21:09 CEST 2016


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue May 10 13:34:59 2016 +0200| [d1f539c97e04e7cebecaf6916c5064f243d39fcf] | committer: Anton Khirnov

h264: merge the two reinit blocks in slice_header_parse()

The only difference is that the first of them contains a
ff_h264_flush_change() call. While that is not necessary in the second
block, it should cause no problems either.

Reduce the verbosity of the reinit log message from info to verbose,
since now it will be displayed during every decode session.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1f539c97e04e7cebecaf6916c5064f243d39fcf
---

 libavcodec/h264_slice.c |   21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index cfd4c94..13988f4 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1201,7 +1201,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
         }
     }
 
-    if (h->context_initialized && needs_reinit) {
+    if (!h->context_initialized || needs_reinit) {
         h->context_initialized = 0;
         if (sl != h->slice_ctx) {
             av_log(h->avctx, AV_LOG_ERROR,
@@ -1219,7 +1219,7 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
             return ret;
         h->avctx->pix_fmt = ret;
 
-        av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, "
+        av_log(h->avctx, AV_LOG_VERBOSE, "Reinit context to %dx%d, "
                "pix_fmt: %d\n", h->width, h->height, h->avctx->pix_fmt);
 
         if ((ret = h264_slice_header_init(h)) < 0) {
@@ -1228,23 +1228,6 @@ static int h264_slice_header_parse(H264Context *h, H264SliceContext *sl)
             return ret;
         }
     }
-    if (!h->context_initialized) {
-        if (sl != h->slice_ctx) {
-            av_log(h->avctx, AV_LOG_ERROR,
-                   "Cannot (re-)initialize context during parallel decoding.\n");
-            return AVERROR_PATCHWELCOME;
-        }
-
-        if ((ret = get_pixel_format(h)) < 0)
-            return ret;
-        h->avctx->pix_fmt = ret;
-
-        if ((ret = h264_slice_header_init(h)) < 0) {
-            av_log(h->avctx, AV_LOG_ERROR,
-                   "h264_slice_header_init() failed\n");
-            return ret;
-        }
-    }
 
     frame_num = get_bits(&sl->gb, sps->log2_max_frame_num);
     if (!h->setup_finished)



More information about the ffmpeg-cvslog mailing list