Merge commit '3178f4d33ff62243f7cdddb081db516ea34396c9'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 19:10:49 +0000 (20:10 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 19:16:21 +0000 (20:16 +0100)
* commit '3178f4d33ff62243f7cdddb081db516ea34396c9':
  h264: move rbsp_buffer into the per-slice context

Conflicts:
libavcodec/h264.c
libavcodec/h264_parser.c
libavcodec/h264_slice.c

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

@@@ -293,8 -277,15 +294,8 @@@ const uint8_t *ff_h264_decode_nal(H264C
      }
  #endif
  
-     av_fast_padded_malloc(&h->rbsp_buffer, &h->rbsp_buffer_size, length+MAX_MBPAIR_SIZE);
-     dst = h->rbsp_buffer;
 -    if (i >= length - 1) { // no escaped 0
 -        *dst_length = length;
 -        *consumed   = length + 1; // +1 for the header
 -        return src;
 -    }
 -
 -    av_fast_malloc(&sl->rbsp_buffer, &sl->rbsp_buffer_size,
 -                   length + FF_INPUT_BUFFER_PADDING_SIZE);
++    av_fast_padded_malloc(&sl->rbsp_buffer, &sl->rbsp_buffer_size, length+MAX_MBPAIR_SIZE);
+     dst = sl->rbsp_buffer;
  
      if (!dst)
          return NULL;
@@@ -1388,11 -1383,9 +1388,11 @@@ static int get_last_needed_nal(H264Cont
              buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
              if (buf_index >= buf_size)
                  break;
 +            if (buf_index >= next_avc)
 +                continue;
          }
  
-         ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length, &consumed,
+         ptr = ff_h264_decode_nal(h, &h->slice_ctx[0], buf + buf_index, &dst_length, &consumed,
                                   next_avc - buf_index);
  
          if (!ptr || dst_length < 0)
Simple merge
@@@ -272,8 -226,7 +272,8 @@@ static inline int parse_nal_units(AVCod
              }
              break;
          }
-         ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length,
 -        ptr = ff_h264_decode_nal(h, sl, buf, &dst_length, &consumed, src_length);
++        ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
 +                                 &consumed, src_length);
          if (!ptr || dst_length < 0)
              break;
  
@@@ -538,15 -501,14 +538,14 @@@ int ff_h264_update_thread_context(AVCod
          for (i = 0; i < MAX_PPS_COUNT; i++)
              av_freep(h->pps_buffers + i);
  
-         av_freep(&h->rbsp_buffer);
 -        memcpy(h, h1, sizeof(*h1));
 +        ff_h264_unref_picture(h, &h->last_pic_for_ec);
 +        memcpy(h, h1, sizeof(H264Context));
 +
          memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
          memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
 -        h->context_initialized = 0;
  
          memset(&h->cur_pic, 0, sizeof(h->cur_pic));
 -        av_frame_unref(&h->cur_pic.f);
 -        h->cur_pic.tf.f = &h->cur_pic.f;
 +        memset(&h->last_pic_for_ec, 0, sizeof(h->last_pic_for_ec));
  
          h->slice_ctx = orig_slice_ctx;
  
          h->mb_type_pool      = NULL;
          h->ref_index_pool    = NULL;
          h->motion_val_pool   = NULL;
-         h->rbsp_buffer       = NULL;
-         h->rbsp_buffer_size  = 0;
 +        h->intra4x4_pred_mode= NULL;
 +        h->non_zero_count    = NULL;
 +        h->slice_table_base  = NULL;
 +        h->slice_table       = NULL;
 +        h->cbp_table         = NULL;
 +        h->chroma_pred_mode_table = NULL;
 +        memset(h->mvd_table, 0, sizeof(h->mvd_table));
 +        h->direct_table      = NULL;
 +        h->list_counts       = NULL;
 +        h->mb2b_xy           = NULL;
 +        h->mb2br_xy          = NULL;
 +
 +        if (h1->context_initialized) {
 +        h->context_initialized = 0;
 +
 +        memset(&h->cur_pic, 0, sizeof(h->cur_pic));
 +        av_frame_unref(&h->cur_pic.f);
 +        h->cur_pic.tf.f = &h->cur_pic.f;
  
          ret = ff_h264_alloc_tables(h);
          if (ret < 0) {
              av_log(dst, AV_LOG_ERROR, "context_init() failed.\n");
              return ret;
          }
 +        }
  
          h->thread_context[0] = h;
 -
 -        h->context_initialized = 1;
 +        h->context_initialized = h1->context_initialized;
      }
  
      h->avctx->coded_height  = h1->avctx->coded_height;