static void decode_mb_cabac(H264Context *h){
static int decode_mb_cabac(H264Context *h) { MpegEncContext * const s = &h->s; const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; int mb_type, partition_count, cbp = 0;  s->dsp.clear_blocks(h->mb);  if( h->slice_type == B_TYPE ) { av_log( h->s.avctx, AV_LOG_ERROR, "B-frame not supported with CABAC\n" ); return -1; } if( h->sps.mb_aff ) { av_log( h->s.avctx, AV_LOG_ERROR, "Fields not supported with CABAC\n" ); return -1; }  if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE ) {  if( decode_cabac_mb_skip( h ) ) { int mx, my;   mb_type= MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_SKIP;  memset(h->non_zero_count[mb_xy], 0, 16); memset(h->non_zero_count_cache + 8, 0, 8*5); #if 0 if(h->sps.mb_aff && s->mb_skip_run==0 && (s->mb_y&1)==0){ h->mb_field_decoding_flag= get_bits1(&s->gb); } if(h->mb_field_decoding_flag) mb_type|= MB_TYPE_INTERLACED; #endif  fill_caches(h, mb_type); pred_pskip_motion(h, &mx, &my); fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, 0, 1); fill_rectangle(  h->mv_cache[0][scan8[0]], 4, 4, 8, pack16to32(mx,my), 4); write_back_motion(h, mb_type);  s->current_picture.mb_type[mb_xy]= mb_type; s->current_picture.qscale_table[mb_xy]= s->qscale; h->slice_table[ mb_xy ]= h->slice_num; h->cbp_table[mb_xy] = 0; h->last_qscale_diff = 0;  h->prev_mb_skiped= 1;  return 0;  } } h->prev_mb_skiped = 0;  if( ( mb_type = decode_cabac_mb_type( h ) ) < 0 ) { av_log( h->s.avctx, AV_LOG_ERROR, "decode_cabac_mb_type failed\n" ); return -1; }   if( h->slice_type == P_TYPE ) { if( mb_type < 5) { partition_count= p_mb_type_info[mb_type].partition_count; mb_type=         p_mb_type_info[mb_type].type; av_log( h->s.avctx, AV_LOG_ERROR, "gni P-type not yet supported\n" ); return -1; } else { mb_type -= 5; goto decode_intra_mb; } } else { assert(h->slice_type == I_TYPE); decode_intra_mb: partition_count = 0; cbp= i_mb_type_info[mb_type].cbp; h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; mb_type= i_mb_type_info[mb_type].type; } #if 0 if(h->mb_field_decoding_flag) mb_type |= MB_TYPE_INTERLACED; #endif  s->current_picture.mb_type[mb_xy]= mb_type; h->slice_table[ mb_xy ]= h->slice_num;  if(IS_INTRA_PCM(mb_type)) {  h->cbp_table[mb_xy] = 0xf +4*2; s->current_picture.qscale_table[mb_xy]= s->qscale; return -1; }  fill_caches(h, mb_type);  if( IS_INTRA( mb_type ) ) { if( IS_INTRA4x4( mb_type ) ) { int i; for( i = 0; i < 16; i++ ) { int pred = pred_intra_mode( h, i ); h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );   } write_back_intra_pred_mode(h); if( check_intra4x4_pred_mode(h) < 0 ) return -1; } else { h->intra16x16_pred_mode= check_intra_pred_mode( h, h->intra16x16_pred_mode ); if( h->intra16x16_pred_mode < 0 ) return -1; } h->chroma_pred_mode_table[mb_xy] = h->chroma_pred_mode          = decode_cabac_mb_chroma_pre_mode( h );  h->chroma_pred_mode= check_intra_pred_mode( h, h->chroma_pred_mode ); if( h->chroma_pred_mode < 0 ) return -1; } else if( partition_count == 4 ) {  return -1; } else if( !IS_DIRECT(mb_type) ) {  return -1; }  if( IS_INTER( mb_type ) ) write_back_motion( h, mb_type );  if( !IS_INTRA16x16( mb_type ) ) { cbp  = decode_cabac_mb_cbp_luma( h ); cbp |= decode_cabac_mb_cbp_chroma( h ) << 4; }   h->cbp_table[mb_xy] = cbp;  if( cbp || IS_INTRA16x16( mb_type ) ) { const uint8_t *scan, *dc_scan; int dqp;  if(IS_INTERLACED(mb_type)){ scan= field_scan; dc_scan= luma_dc_field_scan; }else{ scan= zigzag_scan; dc_scan= luma_dc_zigzag_scan; }  h->last_qscale_diff = dqp = decode_cabac_mb_dqp( h ); s->qscale += dqp; if(((unsigned)s->qscale) > 51){ if(s->qscale<0) s->qscale+= 52; else            s->qscale-= 52; } h->chroma_qp = get_chroma_qp(h, s->qscale);  if( IS_INTRA16x16( mb_type ) ) { int i;  if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, s->qscale, 16) < 0) return -1; if( cbp&15 ) { for( i = 0; i < 16; i++ ) {  if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, s->qscale, 15) < 0 ) return -1; } } else { fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); } } else { int i8x8, i4x4; for( i8x8 = 0; i8x8 < 4; i8x8++ ) { if( cbp & (1<<i8x8) ) { for( i4x4 = 0; i4x4 < 4; i4x4++ ) { const int index = 4*i8x8 + i4x4;  if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, s->qscale, 16) < 0 ) return -1; } } else { uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; } } }  if( cbp&0x30 ){ int c; for( c = 0; c < 2; c++ ) {  if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, h->chroma_qp, 4) < 0) return -1; } }  if( cbp&0x20 ) { int c, i; for( c = 0; c < 2; c++ ) { for( i = 0; i < 4; i++ ) { const int index = 16 + 4 * c + i;  if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, h->chroma_qp, 15) < 0) return -1; } } } else { uint8_t * const nnz= &h->non_zero_count_cache[0]; nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } } else { memset( &h->non_zero_count_cache[8], 0, 8*5 ); }  s->current_picture.qscale_table[mb_xy]= s->qscale; write_back_non_zero_count(h);  return 0;
static void decode_mb_cabac(H264Context *h){//    MpegEncContext * const s = &h->s;}