comparison h264.c @ 5694:7c2ce28a0314 libavcodec

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()
author diego
date Fri, 21 Sep 2007 00:26:31 +0000
parents 070a376d496b
children 9a26cb6747a9
comparison
equal deleted inserted replaced
5693:2c5d1270e7aa 5694:7c2ce28a0314
4793 return 2; 4793 return 2;
4794 else 4794 else
4795 return 3; 4795 return 3;
4796 } 4796 }
4797 4797
4798 static const uint8_t block_idx_x[16] = {
4799 0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
4800 };
4801 static const uint8_t block_idx_y[16] = {
4802 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
4803 };
4804 static const uint8_t block_idx_xy[4][4] = {
4805 { 0, 2, 8, 10},
4806 { 1, 3, 9, 11},
4807 { 4, 6, 12, 14},
4808 { 5, 7, 13, 15}
4809 };
4810
4811 static int decode_cabac_mb_cbp_luma( H264Context *h) { 4798 static int decode_cabac_mb_cbp_luma( H264Context *h) {
4812 int cbp = 0; 4799 int cbp_b, cbp_a, ctx, cbp = 0;
4813 int cbp_b = -1; 4800
4814 int i8x8; 4801 cbp_a = h->slice_table[h->left_mb_xy[0]] == h->slice_num ? h->left_cbp : -1;
4815 4802 cbp_b = h->slice_table[h->top_mb_xy] == h->slice_num ? h->top_cbp : -1;
4816 if( h->slice_table[h->top_mb_xy] == h->slice_num ) { 4803
4817 cbp_b = h->top_cbp; 4804 ctx = !(cbp_a & 0x02) + 2 * !(cbp_b & 0x04);
4818 tprintf(h->s.avctx, "cbp_b = top_cbp = %x\n", cbp_b); 4805 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]);
4819 } 4806 ctx = !(cbp & 0x01) + 2 * !(cbp_b & 0x08);
4820 4807 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 1;
4821 for( i8x8 = 0; i8x8 < 4; i8x8++ ) { 4808 ctx = !(cbp_a & 0x08) + 2 * !(cbp & 0x01);
4822 int cbp_a = -1; 4809 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 2;
4823 int x, y; 4810 ctx = !(cbp & 0x04) + 2 * !(cbp & 0x02);
4824 int ctx = 0; 4811 cbp |= get_cabac_noinline(&h->cabac, &h->cabac_state[73 + ctx]) << 3;
4825
4826 x = block_idx_x[4*i8x8];
4827 y = block_idx_y[4*i8x8];
4828
4829 if( x > 0 )
4830 cbp_a = cbp;
4831 else if( h->slice_table[h->left_mb_xy[0]] == h->slice_num ) {
4832 cbp_a = h->left_cbp;
4833 tprintf(h->s.avctx, "cbp_a = left_cbp = %x\n", cbp_a);
4834 }
4835
4836 if( y > 0 )
4837 cbp_b = cbp;
4838
4839 /* No need to test for skip as we put 0 for skip block */
4840 /* No need to test for IPCM as we put 1 for IPCM block */
4841 if( cbp_a >= 0 ) {
4842 int i8x8a = block_idx_xy[(x-1)&0x03][y]/4;
4843 if( ((cbp_a >> i8x8a)&0x01) == 0 )
4844 ctx++;
4845 }
4846
4847 if( cbp_b >= 0 ) {
4848 int i8x8b = block_idx_xy[x][(y-1)&0x03]/4;
4849 if( ((cbp_b >> i8x8b)&0x01) == 0 )
4850 ctx += 2;
4851 }
4852
4853 if( get_cabac( &h->cabac, &h->cabac_state[73 + ctx] ) ) {
4854 cbp |= 1 << i8x8;
4855 }
4856 }
4857 return cbp; 4812 return cbp;
4858 } 4813 }
4859 static int decode_cabac_mb_cbp_chroma( H264Context *h) { 4814 static int decode_cabac_mb_cbp_chroma( H264Context *h) {
4860 int ctx; 4815 int ctx;
4861 int cbp_a, cbp_b; 4816 int cbp_a, cbp_b;