summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorAndreas Öman <andreas@olebyn.nu>2007-09-21 00:26:31 +0000
committerDiego Biurrun <diego@biurrun.de>2007-09-21 00:26:31 +0000
commita27d6e714f850ead1505a805cacc5d6479b2de76 (patch)
treed7bb2b6b8877ad332476233ab2c6a9b1953f8004 /libavcodec
parentdee15eceae49bb0a09573523a1a8d3f6578df9fe (diff)
Simplify H.264 decode_cabac_mb_cbp_luma(), giving a ~0.5% speedup.
patch by Andreas Öman, andreas olebyn nu Date: Thu, 20 Sep 2007 12:59:19 +0200 Subject: [FFmpeg-devel] [PATCH] simplify h264's decode_cabac_mb_cbp_luma() Originally committed as revision 10537 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c71
1 files changed, 13 insertions, 58 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 26a6d407d0..5961acae0b 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -4795,65 +4795,20 @@ static int decode_cabac_mb_chroma_pre_mode( H264Context *h) {
return 3;
}
-static const uint8_t block_idx_x[16] = {
- 0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
-};
-static const uint8_t block_idx_y[16] = {
- 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
-};
-static const uint8_t block_idx_xy[4][4] = {
- { 0, 2, 8, 10},
- { 1, 3, 9, 11},
- { 4, 6, 12, 14},
- { 5, 7, 13, 15}
-};
-
static int decode_cabac_mb_cbp_luma( H264Context *h) {
- int cbp = 0;
- int cbp_b = -1;
- int i8x8;
-
- if( h->slice_table[h->top_mb_xy] == h->slice_num ) {
- cbp_b = h->top_cbp;
- tprintf(h->s.avctx, "cbp_b = top_cbp = %x\n", cbp_b);
- }
-
- for( i8x8 = 0; i8x8 < 4; i8x8++ ) {
- int cbp_a = -1;
- int x, y;
- int ctx = 0;
-
- x = block_idx_x[4*i8x8];
- y = block_idx_y[4*i8x8];
-
- if( x > 0 )
- cbp_a = cbp;
- else if( h->slice_table[h->left_mb_xy[0]] == h->slice_num ) {
- cbp_a = h->left_cbp;
- tprintf(h->s.avctx, "cbp_a = left_cbp = %x\n", cbp_a);
- }
-
- if( y > 0 )
- cbp_b = cbp;
-
- /* No need to test for skip as we put 0 for skip block */
- /* No need to test for IPCM as we put 1 for IPCM block */
- if( cbp_a >= 0 ) {
- int i8x8a = block_idx_xy[(x-1)&0x03][y]/4;
- if( ((cbp_a >> i8x8a)&0x01) == 0 )
- ctx++;
- }
-
- if( cbp_b >= 0 ) {
- int i8x8b = block_idx_xy[x][(y-1)&0x03]/4;
- if( ((cbp_b >> i8x8b)&0x01) == 0 )
- ctx += 2;
- }
-
- if( get_cabac( &h->cabac, &h->cabac_state[73 + ctx] ) ) {
- cbp |= 1 << i8x8;
- }
- }
+ int cbp_b, cbp_a, ctx, cbp = 0;
+
+ cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1;
+ cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1;
+
+ ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);
+ cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);
+ ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);
+ cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;
+ ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);
+ cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;
+ ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);
+ cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;
return cbp;
}
static int decode_cabac_mb_cbp_chroma( H264Context *h) {