comparison h264_cabac.c @ 11541:a3790cd1c9ca libavcodec

h264: Simplify decode_cabac_residual() specialization Gives more consistent inlining with some compilers (such as llvm).
author astrange
date Fri, 26 Mar 2010 03:29:31 +0000
parents c4c8c8c426eb
children 08723d0e5266
comparison
equal deleted inserted replaced
11540:6e1a61e42561 11541:a3790cd1c9ca
1169 h->cabac.bytestream= cc.bytestream; 1169 h->cabac.bytestream= cc.bytestream;
1170 #endif 1170 #endif
1171 1171
1172 } 1172 }
1173 1173
1174 #if !CONFIG_SMALL
1175 static void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { 1174 static void decode_cabac_residual_dc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
1176 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 1); 1175 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 1);
1177 } 1176 }
1178 1177
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 ) { 1178 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 ) {
1180 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0); 1179 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0);
1181 }
1182 #endif
1183
1184 static void decode_cabac_residual( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) {
1185 #if CONFIG_SMALL
1186 decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, cat == 0 || cat == 3);
1187 #else
1188 if( cat == 0 || cat == 3 ) decode_cabac_residual_dc(h, block, cat, n, scantable, qmul, max_coeff);
1189 else decode_cabac_residual_nondc(h, block, cat, n, scantable, qmul, max_coeff);
1190 #endif
1191 } 1180 }
1192 1181
1193 /** 1182 /**
1194 * decodes a macroblock 1183 * decodes a macroblock
1195 * @returns 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed 1184 * @returns 0 if OK, AC_ERROR / DC_ERROR / MV_ERROR if an error is noticed
1651 h->last_qscale_diff=0; 1640 h->last_qscale_diff=0;
1652 1641
1653 if( IS_INTRA16x16( mb_type ) ) { 1642 if( IS_INTRA16x16( mb_type ) ) {
1654 int i; 1643 int i;
1655 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" ); 1644 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 DC\n" );
1656 decode_cabac_residual( h, h->mb, 0, 0, dc_scan, NULL, 16); 1645 decode_cabac_residual_dc( h, h->mb, 0, 0, dc_scan, NULL, 16);
1657 1646
1658 if( cbp&15 ) { 1647 if( cbp&15 ) {
1659 qmul = h->dequant4_coeff[0][s->qscale]; 1648 qmul = h->dequant4_coeff[0][s->qscale];
1660 for( i = 0; i < 16; i++ ) { 1649 for( i = 0; i < 16; i++ ) {
1661 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i ); 1650 //av_log( s->avctx, AV_LOG_ERROR, "INTRA16x16 AC:%d\n", i );
1662 decode_cabac_residual(h, h->mb + 16*i, 1, i, scan + 1, qmul, 15); 1651 decode_cabac_residual_nondc(h, h->mb + 16*i, 1, i, scan + 1, qmul, 15);
1663 } 1652 }
1664 } else { 1653 } else {
1665 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); 1654 fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1);
1666 } 1655 }
1667 } else { 1656 } else {
1668 int i8x8, i4x4; 1657 int i8x8, i4x4;
1669 for( i8x8 = 0; i8x8 < 4; i8x8++ ) { 1658 for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
1670 if( cbp & (1<<i8x8) ) { 1659 if( cbp & (1<<i8x8) ) {
1671 if( IS_8x8DCT(mb_type) ) { 1660 if( IS_8x8DCT(mb_type) ) {
1672 decode_cabac_residual(h, h->mb + 64*i8x8, 5, 4*i8x8, 1661 decode_cabac_residual_nondc(h, h->mb + 64*i8x8, 5, 4*i8x8,
1673 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64); 1662 scan8x8, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 64);
1674 } else { 1663 } else {
1675 qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale]; 1664 qmul = h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale];
1676 for( i4x4 = 0; i4x4 < 4; i4x4++ ) { 1665 for( i4x4 = 0; i4x4 < 4; i4x4++ ) {
1677 const int index = 4*i8x8 + i4x4; 1666 const int index = 4*i8x8 + i4x4;
1678 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index ); 1667 //av_log( s->avctx, AV_LOG_ERROR, "Luma4x4: %d\n", index );
1679 //START_TIMER 1668 //START_TIMER
1680 decode_cabac_residual(h, h->mb + 16*index, 2, index, scan, qmul, 16); 1669 decode_cabac_residual_nondc(h, h->mb + 16*index, 2, index, scan, qmul, 16);
1681 //STOP_TIMER("decode_residual") 1670 //STOP_TIMER("decode_residual")
1682 } 1671 }
1683 } 1672 }
1684 } else { 1673 } else {
1685 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; 1674 uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ];
1690 1679
1691 if( cbp&0x30 ){ 1680 if( cbp&0x30 ){
1692 int c; 1681 int c;
1693 for( c = 0; c < 2; c++ ) { 1682 for( c = 0; c < 2; c++ ) {
1694 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); 1683 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c );
1695 decode_cabac_residual(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4); 1684 decode_cabac_residual_dc(h, h->mb + 256 + 16*4*c, 3, c, chroma_dc_scan, NULL, 4);
1696 } 1685 }
1697 } 1686 }
1698 1687
1699 if( cbp&0x20 ) { 1688 if( cbp&0x20 ) {
1700 int c, i; 1689 int c, i;
1701 for( c = 0; c < 2; c++ ) { 1690 for( c = 0; c < 2; c++ ) {
1702 qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; 1691 qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
1703 for( i = 0; i < 4; i++ ) { 1692 for( i = 0; i < 4; i++ ) {
1704 const int index = 16 + 4 * c + i; 1693 const int index = 16 + 4 * c + i;
1705 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); 1694 //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 );
1706 decode_cabac_residual(h, h->mb + 16*index, 4, index, scan + 1, qmul, 15); 1695 decode_cabac_residual_nondc(h, h->mb + 16*index, 4, index, scan + 1, qmul, 15);
1707 } 1696 }
1708 } 1697 }
1709 } else { 1698 } else {
1710 uint8_t * const nnz= &h->non_zero_count_cache[0]; 1699 uint8_t * const nnz= &h->non_zero_count_cache[0];
1711 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = 1700 nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] =