Merge commit 'bf03a878a76dea29b36f368759e9f66102b39a5f'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 14:30:10 +0000 (15:30 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 14:36:57 +0000 (15:36 +0100)
* commit 'bf03a878a76dea29b36f368759e9f66102b39a5f':
  h264: move mb[_{padding,luma_dc}] into the per-slice context

Conflicts:
libavcodec/h264.h
libavcodec/h264_cavlc.c
libavcodec/h264_mb.c
libavcodec/h264_slice.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/h264.h
libavcodec/h264_cabac.c
libavcodec/h264_cavlc.c
libavcodec/h264_mb.c
libavcodec/h264_mb_template.c
libavcodec/h264_slice.c
libavcodec/svq3.c

@@@ -426,6 -389,13 +426,13 @@@ typedef struct H264SliceContext 
      DECLARE_ALIGNED(8,  int8_t, ref_cache)[2][5 * 8];
  
      DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
 -    ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space.
++    ///< as a dct coefficient is int32_t in high depth, we need to reserve twice the space.
+     DECLARE_ALIGNED(16, int16_t, mb)[16 * 48 * 2];
+     DECLARE_ALIGNED(16, int16_t, mb_luma_dc)[3][16 * 2];
+     ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either
+     ///< check that i is not too large or ensure that there is some unused stuff after mb
+     int16_t mb_padding[256 * 2];
  } H264SliceContext;
  
  /**
Simple merge
@@@ -1135,15 -1122,12 +1135,15 @@@ decode_intra_mb
              if (decode_luma_residual(h, sl, gb, scan, scan8x8, pixel_shift, mb_type, cbp, 2) < 0 ) {
                  return -1;
              }
 -        } else if (CHROMA422(h)) {
 +        } else {
 +            const int num_c8x8 = h->sps.chroma_format_idc;
 +
              if(cbp&0x30){
                  for(chroma_idx=0; chroma_idx<2; chroma_idx++)
-                     if (decode_residual(h, sl, gb, h->mb + ((256 + 16*16*chroma_idx) << pixel_shift),
+                     if (decode_residual(h, sl, gb, sl->mb + ((256 + 16*16*chroma_idx) << pixel_shift),
 -                                        CHROMA_DC_BLOCK_INDEX+chroma_idx, chroma422_dc_scan,
 -                                        NULL, 8) < 0) {
 +                                        CHROMA_DC_BLOCK_INDEX+chroma_idx,
 +                                        CHROMA422(h) ? chroma422_dc_scan : chroma_dc_scan,
 +                                        NULL, 4*num_c8x8) < 0) {
                          return -1;
                      }
              }
              if(cbp&0x20){
                  for(chroma_idx=0; chroma_idx<2; chroma_idx++){
                      const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][sl->chroma_qp[chroma_idx]];
-                     int16_t *mb = h->mb + (16*(16 + 16*chroma_idx) << pixel_shift);
+                     int16_t *mb = sl->mb + (16*(16 + 16*chroma_idx) << pixel_shift);
 -                    for (i8x8 = 0; i8x8 < 2; i8x8++) {
 +                    for (i8x8 = 0; i8x8<num_c8x8; i8x8++) {
                          for (i4x4 = 0; i4x4 < 4; i4x4++) {
                              const int index = 16 + 16*chroma_idx + 8*i8x8 + i4x4;
                              if (decode_residual(h, sl, gb, mb, index, scan + 1, qmul, 15) < 0)
@@@ -638,12 -638,7 +638,12 @@@ static av_always_inline void hl_decode_
                  uint8_t *const ptr = dest_y + block_offset[i];
                  const int dir      = sl->intra4x4_pred_mode_cache[scan8[i]];
                  if (transform_bypass && h->sps.profile_idc == 244 && dir <= 1) {
 -                    h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
 +                    if (h->x264_build != -1) {
-                         h->hpc.pred8x8l_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift), linesize);
++                        h->hpc.pred8x8l_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift), linesize);
 +                    } else
-                         h->hpc.pred8x8l_filter_add[dir](ptr, h->mb + (i * 16 + p * 256 << pixel_shift),
++                        h->hpc.pred8x8l_filter_add[dir](ptr, sl->mb + (i * 16 + p * 256 << pixel_shift),
 +                                                        (sl-> topleft_samples_available << i) & 0x8000,
 +                                                        (sl->topright_samples_available << i) & 0x4000, linesize);
                  } else {
                      const int nnz = sl->non_zero_count_cache[scan8[i + p * 16]];
                      h->hpc.pred8x8l[dir](ptr, (sl->topleft_samples_available << i) & 0x8000,
Simple merge
@@@ -531,23 -494,15 +531,20 @@@ int ff_h264_update_thread_context(AVCod
          for (i = 0; i < MAX_PPS_COUNT; i++)
              av_freep(h->pps_buffers + i);
  
 -        memcpy(h, h1, sizeof(*h1));
 +        av_freep(&h->rbsp_buffer[0]);
 +        av_freep(&h->rbsp_buffer[1]);
 +        ff_h264_unref_picture(h, &h->last_pic_for_ec);
-         memcpy(h, h1, offsetof(H264Context, mb));
++        memcpy(h, h1, offsetof(H264Context, cabac));
 +        memcpy(&h->cabac, &h1->cabac,
 +               sizeof(H264Context) - offsetof(H264Context, cabac));
-         av_assert0((void*)&h->cabac == &h->mb_padding + 1);
++
 +
          memset(h->sps_buffers, 0, sizeof(h->sps_buffers));
          memset(h->pps_buffers, 0, sizeof(h->pps_buffers));
 -        memset(&h->er, 0, sizeof(h->er));
 -        h->context_initialized = 0;
  
-         memset(&h->mb, 0, sizeof(h->mb));
-         memset(&h->mb_luma_dc, 0, sizeof(h->mb_luma_dc));
-         memset(&h->mb_padding, 0, sizeof(h->mb_padding));
 +        memset(&h->er, 0, sizeof(h->er));
          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;
  
Simple merge