Lines Matching refs:sl

1262 void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl)
1266 const int slice_qp = av_clip(sl->qscale - 6*(h->ps.sps->bit_depth_luma-8), 0, 51);
1268 if (sl->slice_type_nos == AV_PICTURE_TYPE_I) tab = cabac_context_init_I;
1269 else tab = cabac_context_init_PB[sl->cabac_init_idc];
1279 sl->cabac_state[i] = pre;
1292 static int decode_cabac_field_decoding_flag(const H264Context *h, H264SliceContext *sl)
1294 const int mbb_xy = sl->mb_xy - 2*h->mb_stride;
1298 ctx += sl->mb_field_decoding_flag & !!sl->mb_x; //for FMO:(s->current_picture.mb_type[mba_xy] >> 7) & (h->slice_table[mba_xy] == h->slice_num);
1299 ctx += (h->cur_pic.mb_type[mbb_xy] >> 7) & (h->slice_table[mbb_xy] == sl->slice_num);
1301 return get_cabac_noinline( &sl->cabac, &(sl->cabac_state+70)[ctx] );
1304 static int decode_cabac_intra_mb_type(H264SliceContext *sl,
1307 uint8_t *state= &sl->cabac_state[ctx_base];
1312 if (sl->left_type[LTOP] & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
1314 if (sl->top_type & (MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM))
1316 if( get_cabac_noinline( &sl->cabac, &state[ctx] ) == 0 )
1320 if( get_cabac_noinline( &sl->cabac, state ) == 0 )
1324 if( get_cabac_terminate( &sl->cabac ) )
1328 mb_type += 12 * get_cabac_noinline( &sl->cabac, &state[1] ); /* cbp_luma != 0 */
1329 if( get_cabac_noinline( &sl->cabac, &state[2] ) ) /* cbp_chroma */
1330 mb_type += 4 + 4 * get_cabac_noinline( &sl->cabac, &state[2+intra_slice] );
1331 mb_type += 2 * get_cabac_noinline( &sl->cabac, &state[3+intra_slice] );
1332 mb_type += 1 * get_cabac_noinline( &sl->cabac, &state[3+2*intra_slice] );
1336 static int decode_cabac_mb_skip(const H264Context *h, H264SliceContext *sl,
1346 && h->slice_table[mba_xy] == sl->slice_num
1347 && MB_FIELD(sl) == !!IS_INTERLACED( h->cur_pic.mb_type[mba_xy] ) )
1349 if (MB_FIELD(sl)) {
1352 && h->slice_table[mbb_xy] == sl->slice_num
1358 int mb_xy = sl->mb_xy;
1363 if( h->slice_table[mba_xy] == sl->slice_num && !IS_SKIP(h->cur_pic.mb_type[mba_xy] ))
1365 if( h->slice_table[mbb_xy] == sl->slice_num && !IS_SKIP(h->cur_pic.mb_type[mbb_xy] ))
1368 if (sl->slice_type_nos == AV_PICTURE_TYPE_B)
1370 return get_cabac_noinline( &sl->cabac, &sl->cabac_state[11+ctx] );
1373 static int decode_cabac_mb_intra4x4_pred_mode(H264SliceContext *sl, int pred_mode)
1377 if( get_cabac( &sl->cabac, &sl->cabac_state[68] ) )
1380 mode += 1 * get_cabac( &sl->cabac, &sl->cabac_state[69] );
1381 mode += 2 * get_cabac( &sl->cabac, &sl->cabac_state[69] );
1382 mode += 4 * get_cabac( &sl->cabac, &sl->cabac_state[69] );
1387 static int decode_cabac_mb_chroma_pre_mode(const H264Context *h, H264SliceContext *sl)
1389 const int mba_xy = sl->left_mb_xy[0];
1390 const int mbb_xy = sl->top_mb_xy;
1395 if (sl->left_type[LTOP] && h->chroma_pred_mode_table[mba_xy] != 0)
1398 if (sl->top_type && h->chroma_pred_mode_table[mbb_xy] != 0)
1401 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[64+ctx] ) == 0 )
1404 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[64+3] ) == 0 )
1406 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[64+3] ) == 0 )
1412 static int decode_cabac_mb_cbp_luma(H264SliceContext *sl)
1416 cbp_a = sl->left_cbp;
1417 cbp_b = sl->top_cbp;
1420 cbp += get_cabac_noinline(&sl->cabac, &sl->cabac_state[73 + ctx]);
1422 cbp += get_cabac_noinline(&sl->cabac, &sl->cabac_state[73 + ctx]) << 1;
1424 cbp += get_cabac_noinline(&sl->cabac, &sl->cabac_state[73 + ctx]) << 2;
1426 cbp += get_cabac_noinline(&sl->cabac, &sl->cabac_state[73 + ctx]) << 3;
1429 static int decode_cabac_mb_cbp_chroma(H264SliceContext *sl)
1434 cbp_a = (sl->left_cbp>>4)&0x03;
1435 cbp_b = (sl-> top_cbp>>4)&0x03;
1440 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[77 + ctx] ) == 0 )
1446 return 1 + get_cabac_noinline( &sl->cabac, &sl->cabac_state[77 + ctx] );
1449 static int decode_cabac_p_mb_sub_type(H264SliceContext *sl)
1451 if( get_cabac( &sl->cabac, &sl->cabac_state[21] ) )
1453 if( !get_cabac( &sl->cabac, &sl->cabac_state[22] ) )
1455 if( get_cabac( &sl->cabac, &sl->cabac_state[23] ) )
1459 static int decode_cabac_b_mb_sub_type(H264SliceContext *sl)
1462 if( !get_cabac( &sl->cabac, &sl->cabac_state[36] ) )
1464 if( !get_cabac( &sl->cabac, &sl->cabac_state[37] ) )
1465 return 1 + get_cabac( &sl->cabac, &sl->cabac_state[39] ); /* B_L0_8x8, B_L1_8x8 */
1467 if( get_cabac( &sl->cabac, &sl->cabac_state[38] ) ) {
1468 if( get_cabac( &sl->cabac, &sl->cabac_state[39] ) )
1469 return 11 + get_cabac( &sl->cabac, &sl->cabac_state[39] ); /* B_L1_4x4, B_Bi_4x4 */
1472 type += 2*get_cabac( &sl->cabac, &sl->cabac_state[39] );
1473 type += get_cabac( &sl->cabac, &sl->cabac_state[39] );
1477 static int decode_cabac_mb_ref(H264SliceContext *sl, int list, int n)
1479 int refa = sl->ref_cache[list][scan8[n] - 1];
1480 int refb = sl->ref_cache[list][scan8[n] - 8];
1484 if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
1485 if( refa > 0 && !(sl->direct_cache[scan8[n] - 1]&(MB_TYPE_DIRECT2>>1)) )
1487 if( refb > 0 && !(sl->direct_cache[scan8[n] - 8]&(MB_TYPE_DIRECT2>>1)) )
1496 while( get_cabac( &sl->cabac, &sl->cabac_state[54+ctx] ) ) {
1506 static int decode_cabac_mb_mvd(H264SliceContext *sl, int ctxbase, int amvd, int *mvda)
1510 if(!get_cabac(&sl->cabac, &sl->cabac_state[ctxbase+((amvd-3)>>(INT_BIT-1))+((amvd-33)>>(INT_BIT-1))+2])){
1511 // if(!get_cabac(&sl->cabac, &sl->cabac_state[ctxbase+(amvd>2)+(amvd>32)])){
1518 while( mvd < 9 && get_cabac( &sl->cabac, &sl->cabac_state[ctxbase] ) ) {
1526 while( get_cabac_bypass( &sl->cabac ) ) {
1530 av_log(sl->h264->avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mvd\n");
1535 mvd += get_cabac_bypass( &sl->cabac )<<k;
1540 return get_cabac_bypass_sign( &sl->cabac, -mvd );
1543 #define DECODE_CABAC_MB_MVD(sl, list, n )\
1545 int amvd0 = sl->mvd_cache[list][scan8[n] - 1][0] +\
1546 sl->mvd_cache[list][scan8[n] - 8][0];\
1547 int amvd1 = sl->mvd_cache[list][scan8[n] - 1][1] +\
1548 sl->mvd_cache[list][scan8[n] - 8][1];\
1550 int mxd = decode_cabac_mb_mvd(sl, 40, amvd0, &mpx);\
1551 int myd = decode_cabac_mb_mvd(sl, 47, amvd1, &mpy);\
1558 static av_always_inline int get_cabac_cbf_ctx(H264SliceContext *sl,
1569 nza = (sl->left_cbp>>(6+idx))&0x01;
1570 nzb = (sl-> top_cbp>>(6+idx))&0x01;
1573 nza = sl->left_cbp&(0x100<<idx);
1574 nzb = sl-> top_cbp&(0x100<<idx);
1577 nza = sl->non_zero_count_cache[scan8[idx] - 1];
1578 nzb = sl->non_zero_count_cache[scan8[idx] - 8];
1591 decode_cabac_residual_internal(const H264Context *h, H264SliceContext *sl,
1651 cc.range = sl->cabac.range;
1652 cc.low = sl->cabac.low;
1653 cc.bytestream= sl->cabac.bytestream;
1655 cc.bytestream_end = sl->cabac.bytestream_end;
1658 #define CC &sl->cabac
1661 significant_coeff_ctx_base = sl->cabac_state
1662 + significant_coeff_flag_offset[MB_FIELD(sl)][cat];
1663 last_coeff_ctx_base = sl->cabac_state
1664 + last_coeff_flag_offset[MB_FIELD(sl)][cat];
1665 abs_level_m1_ctx_base = sl->cabac_state
1684 const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD(sl)];
1709 h->cbp_table[sl->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX);
1711 h->cbp_table[sl->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX);
1712 sl->non_zero_count_cache[scan8[n]] = coeff_count;
1715 fill_rectangle(&sl->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1);
1718 sl->non_zero_count_cache[scan8[n]] = coeff_count;
1771 sl->cabac.range = cc.range ;
1772 sl->cabac.low = cc.low ;
1773 sl->cabac.bytestream= cc.bytestream;
1779 H264SliceContext *sl,
1785 decode_cabac_residual_internal(h, sl, block, cat, n, scantable, NULL, max_coeff, 1, 0);
1789 H264SliceContext *sl,
1795 decode_cabac_residual_internal(h, sl, block, cat, n, scantable, NULL, max_coeff, 1, 1);
1799 H264SliceContext *sl,
1806 decode_cabac_residual_internal(h, sl, block, cat, n, scantable, qmul, max_coeff, 0, 0);
1822 H264SliceContext *sl,
1829 if( get_cabac( &sl->cabac, &sl->cabac_state[get_cabac_cbf_ctx(sl, cat, n, max_coeff, 1)]) == 0 ) {
1830 sl->non_zero_count_cache[scan8[n]] = 0;
1833 decode_cabac_residual_dc_internal(h, sl, block, cat, n, scantable, max_coeff);
1837 decode_cabac_residual_dc_422(const H264Context *h, H264SliceContext *sl,
1843 if (get_cabac(&sl->cabac, &sl->cabac_state[get_cabac_cbf_ctx(sl, cat, n, max_coeff, 1)]) == 0) {
1844 sl->non_zero_count_cache[scan8[n]] = 0;
1847 decode_cabac_residual_dc_internal_422(h, sl, block, cat, n, scantable, max_coeff);
1851 H264SliceContext *sl,
1859 if( (cat != 5 || CHROMA444(h)) && get_cabac( &sl->cabac, &sl->cabac_state[get_cabac_cbf_ctx(sl, cat, n, max_coeff, 0)]) == 0) {
1861 fill_rectangle(&sl->non_zero_count_cache[scan8[n]], 2, 2, 8, 0, 1);
1863 sl->non_zero_count_cache[scan8[n]] = 0;
1867 decode_cabac_residual_nondc_internal(h, sl, block, cat, n, scantable, qmul, max_coeff);
1870 static av_always_inline void decode_cabac_luma_residual(const H264Context *h, H264SliceContext *sl,
1877 int qscale = p == 0 ? sl->qscale : sl->chroma_qp[p - 1];
1879 AV_ZERO128(sl->mb_luma_dc[p]+0);
1880 AV_ZERO128(sl->mb_luma_dc[p]+8);
1881 AV_ZERO128(sl->mb_luma_dc[p]+16);
1882 AV_ZERO128(sl->mb_luma_dc[p]+24);
1883 decode_cabac_residual_dc(h, sl, sl->mb_luma_dc[p], ctx_cat[0][p], LUMA_DC_BLOCK_INDEX+p, scan, 16);
1889 decode_cabac_residual_nondc(h, sl, sl->mb + (16*index << pixel_shift), ctx_cat[1][p], index, scan + 1, qmul, 15);
1892 fill_rectangle(&sl->non_zero_count_cache[scan8[16*p]], 4, 4, 8, 0, 1);
1900 decode_cabac_residual_nondc(h, sl, sl->mb + (16*index << pixel_shift), ctx_cat[3][p], index,
1906 decode_cabac_residual_nondc(h, sl, sl->mb + (16*index << pixel_shift), ctx_cat[2][p], index, scan, qmul, 16);
1910 fill_rectangle(&sl->non_zero_count_cache[scan8[4*i8x8+16*p]], 2, 2, 8, 0, 1);
1920 int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
1929 mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;
1931 ff_tlog(h->avctx, "pic:%d mb:%d/%d\n", h->poc.frame_num, sl->mb_x, sl->mb_y);
1932 if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
1935 if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 1 && sl->prev_mb_skipped)
1936 skip = sl->next_mb_skipped;
1938 skip = decode_cabac_mb_skip(h, sl, sl->mb_x, sl->mb_y );
1941 if (FRAME_MBAFF(h) && (sl->mb_y & 1) == 0) {
1943 sl->next_mb_skipped = decode_cabac_mb_skip(h, sl, sl->mb_x, sl->mb_y+1 );
1944 if(!sl->next_mb_skipped)
1945 sl->mb_mbaff = sl->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl);
1948 decode_mb_skip(h, sl);
1952 sl->last_qscale_diff = 0;
1959 if ((sl->mb_y & 1) == 0)
1960 sl->mb_mbaff =
1961 sl->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h, sl);
1964 sl->prev_mb_skipped = 0;
1966 fill_decode_neighbors(h, sl, -(MB_FIELD(sl)));
1968 if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
1970 av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_B);
1972 if (!IS_DIRECT(sl->left_type[LTOP] - 1))
1974 if (!IS_DIRECT(sl->top_type - 1))
1977 if( !get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+ctx] ) ){
1979 }else if( !get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+3] ) ) {
1980 mb_type= 1 + get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+5] ); /* B_L[01]_16x16 */
1983 bits = get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+4] ) << 3;
1984 bits+= get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+5] ) << 2;
1985 bits+= get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+5] ) << 1;
1986 bits+= get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+5] );
1990 mb_type = decode_cabac_intra_mb_type(sl, 32, 0);
1997 bits= ( bits<<1 ) + get_cabac_noinline( &sl->cabac, &sl->cabac_state[27+5] );
2003 } else if (sl->slice_type_nos == AV_PICTURE_TYPE_P) {
2004 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[14] ) == 0 ) {
2006 if( get_cabac_noinline( &sl->cabac, &sl->cabac_state[15] ) == 0 ) {
2008 mb_type= 3 * get_cabac_noinline( &sl->cabac, &sl->cabac_state[16] );
2011 mb_type= 2 - get_cabac_noinline( &sl->cabac, &sl->cabac_state[17] );
2016 mb_type = decode_cabac_intra_mb_type(sl, 17, 0);
2020 mb_type = decode_cabac_intra_mb_type(sl, 3, 1);
2021 if (sl->slice_type == AV_PICTURE_TYPE_SI && mb_type)
2023 av_assert2(sl->slice_type_nos == AV_PICTURE_TYPE_I);
2027 sl->intra16x16_pred_mode = ff_h264_i_mb_type_info[mb_type].pred_mode;
2030 if (MB_FIELD(sl))
2033 h->slice_table[mb_xy] = sl->slice_num;
2044 ptr= sl->cabac.bytestream;
2045 if(sl->cabac.low&0x1) ptr--;
2047 if(sl->cabac.low&0x1FF) ptr--;
2051 if ((int) (sl->cabac.bytestream_end - ptr) < mb_size)
2053 sl->intra_pcm_ptr = ptr;
2056 ret = ff_init_cabac_decoder(&sl->cabac, ptr, sl->cabac.bytestream_end - ptr);
2068 sl->last_qscale_diff = 0;
2072 fill_decode_caches(h, sl, mb_type);
2077 if (dct8x8_allowed && get_cabac_noinline(&sl->cabac, &sl->cabac_state[399 + sl->neighbor_transform_size])) {
2080 int pred = pred_intra_mode(h, sl, i);
2081 int mode = decode_cabac_mb_intra4x4_pred_mode(sl, pred);
2082 fill_rectangle(&sl->intra4x4_pred_mode_cache[scan8[i]], 2, 2, 8, mode, 1);
2086 int pred = pred_intra_mode(h, sl, i);
2087 sl->intra4x4_pred_mode_cache[scan8[i]] = decode_cabac_mb_intra4x4_pred_mode(sl, pred);
2090 sl->intra4x4_pred_mode_cache[scan8[i]]);
2093 write_back_intra_pred_mode(h, sl);
2094 if (ff_h264_check_intra4x4_pred_mode(sl->intra4x4_pred_mode_cache, h->avctx,
2095 sl->top_samples_available, sl->left_samples_available) < 0 )
2098 sl->intra16x16_pred_mode = ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
2099 sl->left_samples_available, sl->intra16x16_pred_mode, 0);
2100 if (sl->intra16x16_pred_mode < 0) return -1;
2104 pred_mode = decode_cabac_mb_chroma_pre_mode(h, sl);
2106 pred_mode= ff_h264_check_intra_pred_mode(h->avctx, sl->top_samples_available,
2107 sl->left_samples_available, pred_mode, 1 );
2109 sl->chroma_pred_mode = pred_mode;
2111 sl->chroma_pred_mode = DC_128_PRED8x8;
2116 if (sl->slice_type_nos == AV_PICTURE_TYPE_B ) {
2118 sl->sub_mb_type[i] = decode_cabac_b_mb_sub_type(sl);
2119 sub_partition_count[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
2120 sl->sub_mb_type[i] = ff_h264_b_sub_mb_type_info[sl->sub_mb_type[i]].type;
2122 if (IS_DIRECT(sl->sub_mb_type[0] | sl->sub_mb_type[1] |
2123 sl->sub_mb_type[2] | sl->sub_mb_type[3])) {
2124 ff_h264_pred_direct_motion(h, sl, &mb_type);
2125 sl->ref_cache[0][scan8[4]] =
2126 sl->ref_cache[1][scan8[4]] =
2127 sl->ref_cache[0][scan8[12]] =
2128 sl->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
2130 fill_rectangle(&sl->direct_cache[scan8[4*i]], 2, 2, 8, (sl->sub_mb_type[i] >> 1) & 0xFF, 1);
2134 sl->sub_mb_type[i] = decode_cabac_p_mb_sub_type(sl);
2135 sub_partition_count[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].partition_count;
2136 sl->sub_mb_type[i] = ff_h264_p_sub_mb_type_info[sl->sub_mb_type[i]].type;
2140 for( list = 0; list < sl->list_count; list++ ) {
2142 if(IS_DIRECT(sl->sub_mb_type[i])) continue;
2143 if(IS_DIR(sl->sub_mb_type[i], 0, list)){
2144 unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
2146 ref[list][i] = decode_cabac_mb_ref(sl, list, 4 * i);
2156 sl->ref_cache[list][scan8[4 * i] + 1] =
2157 sl->ref_cache[list][scan8[4 * i] + 8] = sl->ref_cache[list][scan8[4 * i] + 9] = ref[list][i];
2162 dct8x8_allowed = get_dct8x8_allowed(h, sl);
2164 for (list = 0; list < sl->list_count; list++) {
2166 sl->ref_cache[list][scan8[4 * i]] = sl->ref_cache[list][scan8[4 * i] + 1];
2167 if(IS_DIRECT(sl->sub_mb_type[i])){
2168 fill_rectangle(sl->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 2);
2172 if(IS_DIR(sl->sub_mb_type[i], 0, list) && !IS_DIRECT(sl->sub_mb_type[i])){
2173 const int sub_mb_type= sl->sub_mb_type[i];
2179 int16_t (* mv_cache)[2] = &sl->mv_cache[list][ scan8[index] ];
2180 uint8_t (* mvd_cache)[2]= &sl->mvd_cache[list][ scan8[index] ];
2181 pred_motion(h, sl, index, block_width, list, sl->ref_cache[list][ scan8[index] ], &mx, &my);
2182 DECODE_CABAC_MB_MVD(sl, list, index)
2215 fill_rectangle(sl->mv_cache [list][ scan8[4*i] ], 2, 2, 8, 0, 4);
2216 fill_rectangle(sl->mvd_cache[list][ scan8[4*i] ], 2, 2, 8, 0, 2);
2221 ff_h264_pred_direct_motion(h, sl, &mb_type);
2222 fill_rectangle(sl->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 2);
2223 fill_rectangle(sl->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 2);
2228 for (list = 0; list < sl->list_count; list++) {
2231 unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
2233 ref= decode_cabac_mb_ref(sl, list, 0);
2240 fill_rectangle(&sl->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
2243 for (list = 0; list < sl->list_count; list++) {
2246 pred_motion(h, sl, 0, 4, list, sl->ref_cache[list][ scan8[0] ], &mx, &my);
2247 DECODE_CABAC_MB_MVD(sl, list, 0)
2250 fill_rectangle(sl->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack8to16(mpx,mpy), 2);
2251 fill_rectangle(sl->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
2256 for (list = 0; list < sl->list_count; list++) {
2260 unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
2262 ref= decode_cabac_mb_ref(sl, list, 8 * i);
2269 fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
2271 fill_rectangle(&sl->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
2274 for (list = 0; list < sl->list_count; list++) {
2278 pred_16x8_motion(h, sl, 8*i, list, sl->ref_cache[list][scan8[0] + 16*i], &mx, &my);
2279 DECODE_CABAC_MB_MVD(sl, list, 8*i)
2282 fill_rectangle(sl->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack8to16(mpx,mpy), 2);
2283 fill_rectangle(sl->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
2285 fill_rectangle(sl->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 2);
2286 fill_rectangle(sl->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
2292 for (list = 0; list < sl->list_count; list++) {
2296 unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
2298 ref = decode_cabac_mb_ref(sl, list, 4 * i);
2305 fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
2307 fill_rectangle(&sl->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
2310 for (list = 0; list < sl->list_count; list++) {
2314 pred_8x16_motion(h, sl, i*4, list, sl->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
2315 DECODE_CABAC_MB_MVD(sl, list, 4*i)
2318 fill_rectangle(sl->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack8to16(mpx,mpy), 2);
2319 fill_rectangle(sl->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
2321 fill_rectangle(sl->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 2);
2322 fill_rectangle(sl->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
2331 write_back_motion(h, sl, mb_type);
2335 cbp = decode_cabac_mb_cbp_luma(sl);
2337 cbp |= decode_cabac_mb_cbp_chroma(sl) << 4;
2345 h->cbp_table[mb_xy] = sl->cbp = cbp;
2348 mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline(&sl->cabac, &sl->cabac_state[399 + sl->neighbor_transform_size]);
2355 uint8_t *nnz_cache = sl->non_zero_count_cache;
2358 if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
2367 if (sl->top_type && !IS_8x8DCT(sl->top_type)){
2375 if (sl->left_type[LEFT(i)] && !IS_8x8DCT(sl->left_type[LEFT(i)])) {
2381 nnz_cache[3+8*12 + 2*8*i]= !IS_INTRA_PCM(sl->left_type[LEFT(i)]) ? 0 : 64;
2384 if (sl->top_type && !IS_8x8DCT(sl->top_type)){
2385 uint32_t top_empty = !IS_INTRA_PCM(sl->top_type) ? 0 : 0x40404040;
2399 if(get_cabac_noinline( &sl->cabac, &sl->cabac_state[60 + (sl->last_qscale_diff != 0)])){
2404 while( get_cabac_noinline( &sl->cabac, &sl->cabac_state[60 + ctx] ) ) {
2408 av_log(h->avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", sl->mb_x, sl->mb_y);
2417 sl->last_qscale_diff = val;
2418 sl->qscale += val;
2419 if (((unsigned)sl->qscale) > max_qp){
2420 if (sl->qscale < 0) sl->qscale += max_qp + 1;
2421 else sl->qscale -= max_qp + 1;
2423 sl->chroma_qp[0] = get_chroma_qp(h->ps.pps, 0, sl->qscale);
2424 sl->chroma_qp[1] = get_chroma_qp(h->ps.pps, 1, sl->qscale);
2426 sl->last_qscale_diff=0;
2429 scan8x8 = sl->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
2430 scan = sl->qscale ? h->field_scan : h->field_scan_q0;
2432 scan8x8 = sl->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
2433 scan = sl->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
2436 decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
2438 decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
2439 decode_cabac_luma_residual(h, sl, scan, scan8x8, pixel_shift, mb_type, cbp, 2);
2444 decode_cabac_residual_dc_422(h, sl, sl->mb + ((256 + 16*16*c) << pixel_shift), 3,
2452 int16_t *mb = sl->mb + (16*(16 + 16*c) << pixel_shift);
2453 qmul = h->ps.pps->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][sl->chroma_qp[c]];
2457 decode_cabac_residual_nondc(h, sl, mb, 4, index, scan + 1, qmul, 15);
2463 fill_rectangle(&sl->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
2464 fill_rectangle(&sl->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
2470 decode_cabac_residual_dc(h, sl, sl->mb + ((256 + 16 * 16 * c) << pixel_shift),
2477 qmul = h->ps.pps->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][sl->chroma_qp[c]];
2480 decode_cabac_residual_nondc(h, sl, sl->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
2484 fill_rectangle(&sl->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
2485 fill_rectangle(&sl->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
2489 fill_rectangle(&sl->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1);
2490 fill_rectangle(&sl->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
2491 fill_rectangle(&sl->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
2492 sl->last_qscale_diff = 0;
2495 h->cur_pic.qscale_table[mb_xy] = sl->qscale;
2496 write_back_non_zero_count(h, sl);