comparison h264.c @ 5528:4c3b1222ff57 libavcodec

Don't check the return value of decode_cabac_residual since it always returns 0. This leads to a 0.4% speed-up. Patch by Alexander Strange astrange at_ ithinksw dot com Original thread: Date: Aug 11, 2007 11:44 PM Subject: [FFmpeg-devel] [PATCH] h264: don't check decode_cabac_residual return
author conrad
date Sun, 12 Aug 2007 00:07:29 +0000
parents 07cd560e9a8c
children 397cb90b66d0
comparison
equal deleted inserted replaced
5527:8b6ffd245ee2 5528:4c3b1222ff57
5687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 5687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
5688 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5688 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
5689 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 5689 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8
5690 }; 5690 };
5691 5691
5692 static int decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) { 5692 static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff) {
5693 const int mb_xy = h->s.mb_x + h->s.mb_y*h->s.mb_stride; 5693 const int mb_xy = h->s.mb_x + h->s.mb_y*h->s.mb_stride;
5694 static const int significant_coeff_flag_offset[2][6] = { 5694 static const int significant_coeff_flag_offset[2][6] = {
5695 { 105+0, 105+15, 105+29, 105+44, 105+47, 402 }, 5695 { 105+0, 105+15, 105+29, 105+44, 105+47, 402 },
5696 { 277+0, 277+15, 277+29, 277+44, 277+47, 436 } 5696 { 277+0, 277+15, 277+29, 277+44, 277+47, 436 }
5697 }; 5697 };
5757 #ifdef CABAC_ON_STACK 5757 #ifdef CABAC_ON_STACK
5758 h->cabac.range = cc.range ; 5758 h->cabac.range = cc.range ;
5759 h->cabac.low = cc.low ; 5759 h->cabac.low = cc.low ;
5760 h->cabac.bytestream= cc.bytestream; 5760 h->cabac.bytestream= cc.bytestream;
5761 #endif 5761 #endif
5762 return 0; 5762 return;
5763 } 5763 }
5764 } 5764 }
5765 5765
5766 significant_coeff_ctx_base = h->cabac_state 5766 significant_coeff_ctx_base = h->cabac_state
5767 + significant_coeff_flag_offset[MB_FIELD][cat]; 5767 + significant_coeff_flag_offset[MB_FIELD][cat];
5858 #ifdef CABAC_ON_STACK 5858 #ifdef CABAC_ON_STACK
5859 h->cabac.range = cc.range ; 5859 h->cabac.range = cc.range ;
5860 h->cabac.low = cc.low ; 5860 h->cabac.low = cc.low ;
5861 h->cabac.bytestream= cc.bytestream; 5861 h->cabac.bytestream= cc.bytestream;
5862 #endif 5862 #endif
5863 return 0; 5863
5864 } 5864 }
5865 5865
5866 static inline void compute_mb_neighbors(H264Context *h) 5866 static inline void compute_mb_neighbors(H264Context *h)
5867 { 5867 {
5868 MpegEncContext * const s = &h->s; 5868 MpegEncContext * const s = &h->s;
6304 h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale); 6304 h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
6305 6305
6306 if( IS_INTRA16x16( mb_type ) ) { 6306 if( IS_INTRA16x16( mb_type ) ) {
6307 int i; 6307 int i;
6308 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); 6308 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
6309 if( decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16) < 0) 6309 decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16);
6310 return -1; 6310
6311 if( cbp&15 ) { 6311 if( cbp&15 ) {
6312 for( i = 0; i < 16; i++ ) { 6312 for( i = 0; i < 16; i++ ) {
6313 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); 6313 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );
6314 if( decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ) 6314 decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, h->dequant4_coeff[0][s->qscale], 15);
6315 return -1;
6316 } 6315 }
6317 } else { 6316 } else {
6318 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); 6317 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
6319 } 6318 }
6320 } else { 6319 } else {
6321 int i8x8, i4x4; 6320 int i8x8, i4x4;
6322 for( i8x8 = 0; i8x8 < 4; i8x8++ ) { 6321 for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
6323 if( cbp & (1<<i8x8) ) { 6322 if( cbp & (1<<i8x8) ) {
6324 if( IS_8x8DCT(mb_type) ) { 6323 if( IS_8x8DCT(mb_type) ) {
6325 if( decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8, 6324 decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8,
6326 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64) < 0 ) 6325 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
6327 return -1;
6328 } else 6326 } else
6329 for( i4x4 = 0; i4x4 < 4; i4x4++ ) { 6327 for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
6330 const int index = 4*i8x8 + i4x4; 6328 const int index = 4*i8x8 + i4x4;
6331 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index ); 6329 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
6332 //START_TIMER 6330 //START_TIMER
6333 if( decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) < 0 ) 6331 decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16);
6334 return -1;
6335 //STOP_TIMER("decode_residual") 6332 //STOP_TIMER("decode_residual")
6336 } 6333 }
6337 } else { 6334 } else {
6338 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; 6335 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
6339 nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; 6336 nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0;
6343 6340
6344 if( cbp&0x30 ){ 6341 if( cbp&0x30 ){
6345 int c; 6342 int c;
6346 for( c = 0; c < 2; c++ ) { 6343 for( c = 0; c < 2; c++ ) {
6347 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); 6344 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
6348 if( decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4) < 0) 6345 decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4);
6349 return -1;
6350 } 6346 }
6351 } 6347 }
6352 6348
6353 if( cbp&0x20 ) { 6349 if( cbp&0x20 ) {
6354 int c, i; 6350 int c, i;
6355 for( c = 0; c < 2; c++ ) { 6351 for( c = 0; c < 2; c++ ) {
6356 const uint32_t *qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; 6352 const uint32_t *qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
6357 for( i = 0; i < 4; i++ ) { 6353 for( i = 0; i < 4; i++ ) {
6358 const int index = 16 + 4 * c + i; 6354 const int index = 16 + 4 * c + i;
6359 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); 6355 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
6360 if( decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, qmul, 15) < 0) 6356 decode_cabac_residual(h, h->mb + 16*index, 4, index - 16, scan + 1, qmul, 15);
6361 return -1;
6362 } 6357 }
6363 } 6358 }
6364 } else { 6359 } else {
6365 uint8_t * const nnz= &h->non_zero_count_cache[0]; 6360 uint8_t * const nnz= &h->non_zero_count_cache[0];
6366 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = 6361 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =