Merge commit 'd1f539c97e04e7cebecaf6916c5064f243d39fcf'
authorClément Bœsch <clement@stupeflix.com>
Fri, 1 Jul 2016 12:17:56 +0000 (14:17 +0200)
committerClément Bœsch <clement@stupeflix.com>
Fri, 1 Jul 2016 12:19:09 +0000 (14:19 +0200)
* commit 'd1f539c97e04e7cebecaf6916c5064f243d39fcf':
  h264: merge the two reinit blocks in slice_header_parse()

Merged-by: Clément Bœsch <clement@stupeflix.com>
1  2 
libavcodec/h264_slice.c

@@@ -1414,8 -1201,7 +1414,7 @@@ static int h264_slice_header_parse(H264
          }
      }
  
-     if (h->context_initialized &&
-         (must_reinit || needs_reinit)) {
 -    if (!h->context_initialized || needs_reinit) {
++    if (!h->context_initialized || must_reinit || needs_reinit) {
          h->context_initialized = 0;
          if (sl != h->slice_ctx) {
              av_log(h->avctx, AV_LOG_ERROR,
              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);
 +               "pix_fmt: %s\n", h->width, h->height, av_get_pix_fmt_name(h->avctx->pix_fmt));
  
          if ((ret = h264_slice_header_init(h)) < 0) {
              av_log(h->avctx, AV_LOG_ERROR,
              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, 1)) < 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 (!first_slice) {
 +        if (h->poc.frame_num != frame_num) {
 +            av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n",
 +                   h->poc.frame_num, frame_num);
 +            return AVERROR_INVALIDDATA;
 +        }
 +    }
 +
      if (!h->setup_finished)
          h->poc.frame_num = frame_num;