Revision f14bdd8e

View differences:

libavcodec/h264_cabac.c
1049 1049
#define CC &h->cabac
1050 1050
#endif
1051 1051

  
1052

  
1053
    /* cat: 0-> DC 16x16  n = 0
1054
     *      1-> AC 16x16  n = luma4x4idx
1055
     *      2-> Luma4x4   n = luma4x4idx
1056
     *      3-> DC Chroma n = iCbCr
1057
     *      4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx
1058
     *      5-> Luma8x8   n = 4 * luma8x8idx
1059
     */
1060

  
1061
    /* read coded block flag */
1062
    if( is_dc || cat != 5 ) {
1063
        if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, is_dc ) ] ) == 0 ) {
1064
            h->non_zero_count_cache[scan8[n]] = 0;
1065

  
1066
#ifdef CABAC_ON_STACK
1067
            h->cabac.range     = cc.range     ;
1068
            h->cabac.low       = cc.low       ;
1069
            h->cabac.bytestream= cc.bytestream;
1070
#endif
1071
            return;
1072
        }
1073
    }
1074

  
1075 1052
    significant_coeff_ctx_base = h->cabac_state
1076 1053
        + significant_coeff_flag_offset[MB_FIELD][cat];
1077 1054
    last_coeff_ctx_base = h->cabac_state
......
1172 1149

  
1173 1150
}
1174 1151

  
1175
static void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
1152
static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
1176 1153
    decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1);
1177 1154
}
1178 1155

  
1179
static void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
1156
static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
1180 1157
    decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0);
1181 1158
}
1182 1159

  
1160
/* cat: 0-> DC 16x16  n = 0
1161
 *      1-> AC 16x16  n = luma4x4idx
1162
 *      2-> Luma4x4   n = luma4x4idx
1163
 *      3-> DC Chroma n = iCbCr
1164
 *      4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx
1165
 *      5-> Luma8x8   n = 4 * luma8x8idx */
1166

  
1167
/* Partially inline the CABAC residual decode: inline the coded block flag.
1168
 * This has very little impact on binary size and improves performance
1169
 * because it allows improved constant propagation into get_cabac_cbf_ctx,
1170
 * as well as because most blocks have zero CBFs. */
1171

  
1172
static av_always_inline void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) {
1173
    /* read coded block flag */
1174
    if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 1 ) ] ) == 0 ) {
1175
        h->non_zero_count_cache[scan8[n]] = 0;
1176
        return;
1177
    }
1178
    decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff );
1179
}
1180

  
1181
static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
1182
    /* read coded block flag */
1183
    if( cat != 5 && get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, 0 ) ] ) == 0 ) {
1184
        h->non_zero_count_cache[scan8[n]] = 0;
1185
        return;
1186
    }
1187
    decode_cabac_residual_nondc_internal( h, block, cat, n, scantable, qmul, max_coeff );
1188
}
1189

  
1183 1190
/**
1184 1191
 * decodes a macroblock
1185 1192
 * @return 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
1186 1193
 */
1187 1194
int ff_h264_decode_mb_cabac(H264Context *h) {
1195
    START_TIMER;
1188 1196
    MpegEncContext * const s = &h->s;
1189 1197
    int mb_xy;
1190 1198
    int mb_type, partition_count, cbp = 0;
......
1717 1725
        h->ref_count[0] >>= 1;
1718 1726
        h->ref_count[1] >>= 1;
1719 1727
    }
1720

  
1728
STOP_TIMER("test");
1721 1729
    return 0;
1722 1730
}

Also available in: Unified diff