comparison vp8.c @ 12362:4dc177e736f6 libavcodec

VP8: partially inline decode_block_coeffs Avoids a function call in the case of empty DCT blocks (most of the time).
author darkshikari
date Wed, 04 Aug 2010 02:23:25 +0000
parents a66d6456df90
children 7c54834209f6
comparison
equal deleted inserted replaced
12361:a66d6456df90 12362:4dc177e736f6
819 * all-zero blocks (only left/top, so 0-2) 819 * all-zero blocks (only left/top, so 0-2)
820 * @param qmul array holding the dc/ac dequant factor at position 0/1 820 * @param qmul array holding the dc/ac dequant factor at position 0/1
821 * @return 0 if no coeffs were decoded 821 * @return 0 if no coeffs were decoded
822 * otherwise, the index of the last coeff decoded plus one 822 * otherwise, the index of the last coeff decoded plus one
823 */ 823 */
824 static int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16], 824 static int decode_block_coeffs_internal(VP56RangeCoder *c, DCTELEM block[16],
825 uint8_t probs[8][3][NUM_DCT_TOKENS-1], 825 uint8_t probs[8][3][NUM_DCT_TOKENS-1],
826 int i, int zero_nhood, int16_t qmul[2]) 826 int i, uint8_t *token_prob, int16_t qmul[2])
827 { 827 {
828 uint8_t *token_prob = probs[i][zero_nhood];
829 int coeff;
830
831 if (!vp56_rac_get_prob_branchy(c, token_prob[0]))
832 return 0;
833 goto skip_eob; 828 goto skip_eob;
834
835 do { 829 do {
830 int coeff;
836 if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB 831 if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
837 return i; 832 return i;
838 833
839 skip_eob: 834 skip_eob:
840 if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0 835 if (!vp56_rac_get_prob_branchy(c, token_prob[1])) { // DCT_0
875 } 870 }
876 block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i]; 871 block[zigzag_scan[i]] = (vp8_rac_get(c) ? -coeff : coeff) * qmul[!!i];
877 } while (++i < 16); 872 } while (++i < 16);
878 873
879 return i; 874 return i;
875 }
876
877 static av_always_inline
878 int decode_block_coeffs(VP56RangeCoder *c, DCTELEM block[16],
879 uint8_t probs[8][3][NUM_DCT_TOKENS-1],
880 int i, int zero_nhood, int16_t qmul[2])
881 {
882 uint8_t *token_prob = probs[i][zero_nhood];
883 if (!vp56_rac_get_prob_branchy(c, token_prob[0])) // DCT_EOB
884 return 0;
885 return decode_block_coeffs_internal(c, block, probs, i, token_prob, qmul);
880 } 886 }
881 887
882 static av_always_inline 888 static av_always_inline
883 void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb, 889 void decode_mb_coeffs(VP8Context *s, VP56RangeCoder *c, VP8Macroblock *mb,
884 uint8_t t_nnz[9], uint8_t l_nnz[9]) 890 uint8_t t_nnz[9], uint8_t l_nnz[9])