Mercurial > libavcodec.hg
comparison h264.c @ 8394:a9132c1bd56a libavcodec
Simplify chroma AC in CABAC residual decoding.
author | darkshikari |
---|---|
date | Fri, 19 Dec 2008 00:43:30 +0000 |
parents | 64a0415da32f |
children | 195cba8f6257 |
comparison
equal
deleted
inserted
replaced
8393:64a0415da32f | 8394:a9132c1bd56a |
---|---|
5082 } else { | 5082 } else { |
5083 nza = (h->left_cbp>>(6+idx))&0x01; | 5083 nza = (h->left_cbp>>(6+idx))&0x01; |
5084 nzb = (h-> top_cbp>>(6+idx))&0x01; | 5084 nzb = (h-> top_cbp>>(6+idx))&0x01; |
5085 } | 5085 } |
5086 } else { | 5086 } else { |
5087 if( cat == 4 ) { | 5087 assert(cat == 1 || cat == 2 || cat == 4); |
5088 nza = h->non_zero_count_cache[scan8[16+idx] - 1]; | 5088 nza = h->non_zero_count_cache[scan8[idx] - 1]; |
5089 nzb = h->non_zero_count_cache[scan8[16+idx] - 8]; | 5089 nzb = h->non_zero_count_cache[scan8[idx] - 8]; |
5090 } else { | |
5091 assert(cat == 1 || cat == 2); | |
5092 nza = h->non_zero_count_cache[scan8[idx] - 1]; | |
5093 nzb = h->non_zero_count_cache[scan8[idx] - 8]; | |
5094 } | |
5095 } | 5090 } |
5096 | 5091 |
5097 if( nza > 0 ) | 5092 if( nza > 0 ) |
5098 ctx++; | 5093 ctx++; |
5099 | 5094 |
5171 | 5166 |
5172 /* cat: 0-> DC 16x16 n = 0 | 5167 /* cat: 0-> DC 16x16 n = 0 |
5173 * 1-> AC 16x16 n = luma4x4idx | 5168 * 1-> AC 16x16 n = luma4x4idx |
5174 * 2-> Luma4x4 n = luma4x4idx | 5169 * 2-> Luma4x4 n = luma4x4idx |
5175 * 3-> DC Chroma n = iCbCr | 5170 * 3-> DC Chroma n = iCbCr |
5176 * 4-> AC Chroma n = 4 * iCbCr + chroma4x4idx | 5171 * 4-> AC Chroma n = 16 + 4 * iCbCr + chroma4x4idx |
5177 * 5-> Luma8x8 n = 4 * luma8x8idx | 5172 * 5-> Luma8x8 n = 4 * luma8x8idx |
5178 */ | 5173 */ |
5179 | 5174 |
5180 /* read coded block flag */ | 5175 /* read coded block flag */ |
5181 if( is_dc || cat != 5 ) { | 5176 if( is_dc || cat != 5 ) { |
5182 if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, is_dc ) ] ) == 0 ) { | 5177 if( get_cabac( CC, &h->cabac_state[85 + get_cabac_cbf_ctx( h, cat, n, is_dc ) ] ) == 0 ) { |
5183 if( !is_dc ) { | 5178 if( !is_dc ) |
5184 if( cat == 4 ) | 5179 h->non_zero_count_cache[scan8[n]] = 0; |
5185 h->non_zero_count_cache[scan8[16+n]] = 0; | |
5186 else | |
5187 h->non_zero_count_cache[scan8[n]] = 0; | |
5188 } | |
5189 | 5180 |
5190 #ifdef CABAC_ON_STACK | 5181 #ifdef CABAC_ON_STACK |
5191 h->cabac.range = cc.range ; | 5182 h->cabac.range = cc.range ; |
5192 h->cabac.low = cc.low ; | 5183 h->cabac.low = cc.low ; |
5193 h->cabac.bytestream= cc.bytestream; | 5184 h->cabac.bytestream= cc.bytestream; |
5238 else | 5229 else |
5239 h->cbp_table[h->mb_xy] |= 0x40 << n; | 5230 h->cbp_table[h->mb_xy] |= 0x40 << n; |
5240 } else { | 5231 } else { |
5241 if( cat == 5 ) | 5232 if( cat == 5 ) |
5242 fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1); | 5233 fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1); |
5243 else if( cat == 4 ) | |
5244 h->non_zero_count_cache[scan8[16+n]] = coeff_count; | |
5245 else { | 5234 else { |
5246 assert( cat == 1 || cat == 2 ); | 5235 assert( cat == 1 || cat == 2 || cat == 4 ); |
5247 h->non_zero_count_cache[scan8[n]] = coeff_count; | 5236 h->non_zero_count_cache[scan8[n]] = coeff_count; |
5248 } | 5237 } |
5249 } | 5238 } |
5250 | 5239 |
5251 do { | 5240 do { |
5823 for( c = 0; c < 2; c++ ) { | 5812 for( c = 0; c < 2; c++ ) { |
5824 qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; | 5813 qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; |
5825 for( i = 0; i < 4; i++ ) { | 5814 for( i = 0; i < 4; i++ ) { |
5826 const int index = 16 + 4 * c + i; | 5815 const int index = 16 + 4 * c + i; |
5827 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); | 5816 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); |
5828 decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, qmul, 15); | 5817 decode_cabac_residual(h, h->mb + 16*index, 4, index, scan + 1, qmul, 15); |
5829 } | 5818 } |
5830 } | 5819 } |
5831 } else { | 5820 } else { |
5832 uint8_t * const nnz= &h->non_zero_count_cache[0]; | 5821 uint8_t * const nnz= &h->non_zero_count_cache[0]; |
5833 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = | 5822 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = |