Merge commit '54986d6db9116ef9704b1ce8414ffdb7f1ca127f'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 29 Apr 2015 10:04:26 +0000 (12:04 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 29 Apr 2015 10:11:09 +0000 (12:11 +0200)
* commit '54986d6db9116ef9704b1ce8414ffdb7f1ca127f':
  h264: move context reinit lower down in update_thread_context()

Conflicts:
libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h264_slice.c

@@@ -436,10 -414,10 +436,10 @@@ int ff_h264_update_thread_context(AVCod
  {
      H264Context *h = dst->priv_data, *h1 = src->priv_data;
      int inited = h->context_initialized, err = 0;
-     int context_reinitialized = 0;
+     int need_reinit = 0;
      int i, ret;
  
 -    if (dst == src || !h1->context_initialized)
 +    if (dst == src)
          return 0;
  
      if (inited &&
           h->sps.chroma_format_idc != h1->sps.chroma_format_idc ||
           h->sps.colorspace        != h1->sps.colorspace)) {
  
-         h->width     = h1->width;
-         h->height    = h1->height;
-         h->mb_height = h1->mb_height;
-         h->mb_width  = h1->mb_width;
-         h->mb_num    = h1->mb_num;
-         h->mb_stride = h1->mb_stride;
-         h->b_stride  = h1->b_stride;
-         // SPS/PPS
-         if ((ret = copy_parameter_set((void **)h->sps_buffers,
-                                       (void **)h1->sps_buffers,
-                                       MAX_SPS_COUNT, sizeof(SPS))) < 0)
-             return ret;
-         h->sps = h1->sps;
-         if ((ret = copy_parameter_set((void **)h->pps_buffers,
-                                       (void **)h1->pps_buffers,
-                                       MAX_PPS_COUNT, sizeof(PPS))) < 0)
-             return ret;
-         h->pps = h1->pps;
-         if ((err = h264_slice_header_init(h, 1)) < 0) {
-             av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed\n");
-             return err;
-         }
-         context_reinitialized = 1;
- #if 0
-         h264_set_parameter_from_sps(h);
-         //Note we set context_reinitialized which will cause h264_set_parameter_from_sps to be reexecuted
-         h->cur_chroma_format_idc = h1->cur_chroma_format_idc;
- #endif
 -        /* set bits_per_raw_sample to the previous value. the check for changed
 -         * bit depth in h264_set_parameter_from_sps() uses it and sets it to
 -         * the current value */
 -        h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma;
+         need_reinit = 1;
      }
  
 +    /* copy block_offset since frame_start may not be called */
 +    memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
 +
      if (!inited) {
          H264SliceContext *orig_slice_ctx = h->slice_ctx;
          H264Picture *orig_DPB = h->DPB;
      copy_picture_range(h->delayed_pic, h1->delayed_pic,
                         MAX_DELAYED_PIC_COUNT + 2, h, h1);
  
 -    h->last_slice_type = h1->last_slice_type;
 +    h->frame_recovered       = h1->frame_recovered;
  
-     if (context_reinitialized)
+     if (need_reinit) {
+         h->width     = h1->width;
+         h->height    = h1->height;
+         h->mb_height = h1->mb_height;
+         h->mb_width  = h1->mb_width;
+         h->mb_num    = h1->mb_num;
+         h->mb_stride = h1->mb_stride;
+         h->b_stride  = h1->b_stride;
+         if ((err = h264_slice_header_init(h, 1)) < 0) {
+             av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed");
+             return err;
+         }
+         /* copy block_offset since frame_start may not be called */
+         memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset));
          ff_h264_set_parameter_from_sps(h);
+     }
  
      if (!h->cur_pic_ptr)
          return 0;