Merge commit '30da98adbda6de1f55188f9058a3a5c715049633'
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 14:45:44 +0000 (15:45 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Mar 2015 14:45:44 +0000 (15:45 +0100)
* commit '30da98adbda6de1f55188f9058a3a5c715049633':
  h264: move cabac[_state] into the per-slice context

Conflicts:
libavcodec/h264_cabac.c
libavcodec/h264_slice.c

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

Simple merge
@@@ -1491,11 -1496,12 +1496,12 @@@ static int decode_cabac_mb_ref(H264Cont
      return ref;
  }
  
- static int decode_cabac_mb_mvd( H264Context *h, int ctxbase, int amvd, int *mvda) {
+ static int decode_cabac_mb_mvd(H264Context *h, H264SliceContext *sl, int ctxbase, int amvd, int *mvda)
+ {
      int mvd;
  
-     if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+((amvd-3)>>(INT_BIT-1))+((amvd-33)>>(INT_BIT-1))+2])){
- //    if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){
+     if(!get_cabac(&sl->cabac, &sl->cabac_state[ctxbase+((amvd-3)>>(INT_BIT-1))+((amvd-33)>>(INT_BIT-1))+2])){
 -//    if(!get_cabac(&h->cabac, &h->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){
++//    if(!get_cabac(&sl->cabac, &sl->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){
          *mvda= 0;
          return 0;
      }
@@@ -1631,21 -1637,19 +1637,21 @@@ decode_cabac_residual_internal(H264Cont
  #ifdef CABAC_ON_STACK
  #define CC &cc
      CABACContext cc;
-     cc.range     = h->cabac.range;
-     cc.low       = h->cabac.low;
-     cc.bytestream= h->cabac.bytestream;
+     cc.range     = sl->cabac.range;
+     cc.low       = sl->cabac.low;
+     cc.bytestream= sl->cabac.bytestream;
 +#if !UNCHECKED_BITSTREAM_READER || ARCH_AARCH64
-     cc.bytestream_end = h->cabac.bytestream_end;
+     cc.bytestream_end = sl->cabac.bytestream_end;
 +#endif
  #else
- #define CC &h->cabac
+ #define CC &sl->cabac
  #endif
  
-     significant_coeff_ctx_base = h->cabac_state
+     significant_coeff_ctx_base = sl->cabac_state
          + significant_coeff_flag_offset[MB_FIELD(h)][cat];
-     last_coeff_ctx_base = h->cabac_state
+     last_coeff_ctx_base = sl->cabac_state
          + last_coeff_flag_offset[MB_FIELD(h)][cat];
-     abs_level_m1_ctx_base = h->cabac_state
+     abs_level_m1_ctx_base = sl->cabac_state
          + coeff_abs_level_m1_offset[cat];
  
      if( !is_dc && max_coeff == 64 ) {
@@@ -2069,10 -2069,10 +2075,10 @@@ decode_intra_mb
              } else {
                  for( i = 0; i < 16; i++ ) {
                      int pred = pred_intra_mode(h, sl, i);
-                     sl->intra4x4_pred_mode_cache[scan8[i]] = decode_cabac_mb_intra4x4_pred_mode(h, pred);
+                     sl->intra4x4_pred_mode_cache[scan8[i]] = decode_cabac_mb_intra4x4_pred_mode(h, sl, pred);
  
                      av_dlog(h->avctx, "i4x4 pred=%d mode=%d\n", pred,
 -                            h->intra4x4_pred_mode_cache[scan8[i]]);
 +                            sl->intra4x4_pred_mode_cache[scan8[i]]);
                  }
              }
              write_back_intra_pred_mode(h, sl);
     }
  
      if( !IS_INTRA16x16( mb_type ) ) {
-         cbp  = decode_cabac_mb_cbp_luma( h );
+         cbp  = decode_cabac_mb_cbp_luma(h, sl);
          if(decode_chroma)
-             cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
+             cbp |= decode_cabac_mb_cbp_chroma(h, sl) << 4;
 +    } else {
 +        if (!decode_chroma && cbp>15) {
 +            av_log(h->avctx, AV_LOG_ERROR, "gray chroma\n");
 +            return AVERROR_INVALIDDATA;
 +        }
      }
  
      h->cbp_table[mb_xy] = h->cbp = cbp;
@@@ -2458,13 -2229,11 +2458,13 @@@ static int decode_slice(struct AVCodecC
                      loop_filter(h, sl, lf_x_start, h->mb_x + 1);
                  return 0;
              }
-             if (h->cabac.bytestream > h->cabac.bytestream_end + 2 )
-                 av_log(h->avctx, AV_LOG_DEBUG, "bytestream overread %"PTRDIFF_SPECIFIER"\n", h->cabac.bytestream_end - h->cabac.bytestream);
-             if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 4) {
 -            if (ret < 0 || sl->cabac.bytestream > sl->cabac.bytestream_end + 2) {
++            if (sl->cabac.bytestream > sl->cabac.bytestream_end + 2 )
++                av_log(h->avctx, AV_LOG_DEBUG, "bytestream overread %"PTRDIFF_SPECIFIER"\n", sl->cabac.bytestream_end - sl->cabac.bytestream);
++            if (ret < 0 || sl->cabac.bytestream > sl->cabac.bytestream_end + 4) {
                  av_log(h->avctx, AV_LOG_ERROR,
 -                       "error while decoding MB %d %d, bytestream %td\n",
 +                       "error while decoding MB %d %d, bytestream %"PTRDIFF_SPECIFIER"\n",
                         h->mb_x, h->mb_y,
-                        h->cabac.bytestream_end - h->cabac.bytestream);
+                        sl->cabac.bytestream_end - sl->cabac.bytestream);
                  er_add_slice(h, sl, h->resync_mb_x, h->resync_mb_y, h->mb_x,
                               h->mb_y, ER_MB_ERROR);
                  return AVERROR_INVALIDDATA;