Mercurial > libavcodec.hg
comparison mpegaudiodec.c @ 3622:e88a3910f855 libavcodec
try to avoid l3_unscale() by using a table
author | michael |
---|---|
date | Fri, 25 Aug 2006 11:55:20 +0000 |
parents | d4896ea0305b |
children | d0242f36a793 |
comparison
equal
deleted
inserted
replaced
3621:d4896ea0305b | 3622:e88a3910f855 |
---|---|
172 /* XXX: free when all decoders are closed */ | 172 /* XXX: free when all decoders are closed */ |
173 #define TABLE_4_3_SIZE (8191 + 16)*4 | 173 #define TABLE_4_3_SIZE (8191 + 16)*4 |
174 static int8_t *table_4_3_exp; | 174 static int8_t *table_4_3_exp; |
175 static uint32_t *table_4_3_value; | 175 static uint32_t *table_4_3_value; |
176 static uint32_t exp_table[512]; | 176 static uint32_t exp_table[512]; |
177 static uint32_t expval_table[512][16]; | |
177 /* intensity stereo coef table */ | 178 /* intensity stereo coef table */ |
178 static int32_t is_table[2][16]; | 179 static int32_t is_table[2][16]; |
179 static int32_t is_table_lsf[2][2][16]; | 180 static int32_t is_table_lsf[2][2][16]; |
180 static int32_t csa_table[8][4]; | 181 static int32_t csa_table[8][4]; |
181 static float csa_table_float[8][4]; | 182 static float csa_table_float[8][4]; |
427 /* normalized to FRAC_BITS */ | 428 /* normalized to FRAC_BITS */ |
428 table_4_3_value[i] = m; | 429 table_4_3_value[i] = m; |
429 // av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0)); | 430 // av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0)); |
430 table_4_3_exp[i] = -e; | 431 table_4_3_exp[i] = -e; |
431 } | 432 } |
432 for(i=0; i<512; i++){ | 433 for(i=0; i<512*16; i++){ |
433 int exponent= i-400; | 434 int exponent= (i>>4)-400; |
434 double f= pow(1, 4.0 / 3.0) * pow(2, exponent*0.25 + FRAC_BITS + 5); | 435 double f= pow(i&15, 4.0 / 3.0) * pow(2, exponent*0.25 + FRAC_BITS + 5); |
435 exp_table[i]= lrintf(f); | 436 expval_table[exponent+400][i&15]= lrintf(f); |
437 if((i&15)==1) | |
438 exp_table[exponent+400]= lrintf(f); | |
436 } | 439 } |
437 | 440 |
438 for(i=0;i<7;i++) { | 441 for(i=0;i<7;i++) { |
439 float f; | 442 float f; |
440 int v; | 443 int v; |
1715 y = y & 0x0f; | 1718 y = y & 0x0f; |
1716 | 1719 |
1717 dprintf("region=%d n=%d x=%d y=%d exp=%d\n", | 1720 dprintf("region=%d n=%d x=%d y=%d exp=%d\n", |
1718 i, g->region_size[i] - j, x, y, exponents[s_index]); | 1721 i, g->region_size[i] - j, x, y, exponents[s_index]); |
1719 if (x) { | 1722 if (x) { |
1723 #if 0 | |
1720 if (x == 15) | 1724 if (x == 15) |
1721 x += get_bitsz(&s->gb, linbits); | 1725 x += get_bitsz(&s->gb, linbits); |
1722 v = l3_unscale(x, exponents[s_index]); | 1726 v = l3_unscale(x, exponents[s_index]); |
1727 #else | |
1728 if (x < 15){ | |
1729 v = expval_table[ exponents[s_index] + 400 ][ x ]; | |
1730 }else{ | |
1731 x += get_bitsz(&s->gb, linbits); | |
1732 v = l3_unscale(x, exponents[s_index]); | |
1733 } | |
1734 #endif | |
1723 if (get_bits1(&s->gb)) | 1735 if (get_bits1(&s->gb)) |
1724 v = -v; | 1736 v = -v; |
1725 } else { | 1737 } else { |
1726 v = 0; | 1738 v = 0; |
1727 } | 1739 } |
1728 g->sb_hybrid[s_index++] = v; | 1740 g->sb_hybrid[s_index++] = v; |
1729 if (y) { | 1741 if (y) { |
1742 #if 0 | |
1730 if (y == 15) | 1743 if (y == 15) |
1731 y += get_bitsz(&s->gb, linbits); | 1744 y += get_bitsz(&s->gb, linbits); |
1732 v = l3_unscale(y, exponents[s_index]); | 1745 v = l3_unscale(y, exponents[s_index]); |
1746 #else | |
1747 if (y < 15){ | |
1748 v = expval_table[ exponents[s_index] + 400 ][ y ]; | |
1749 }else{ | |
1750 y += get_bitsz(&s->gb, linbits); | |
1751 v = l3_unscale(y, exponents[s_index]); | |
1752 } | |
1753 #endif | |
1733 if (get_bits1(&s->gb)) | 1754 if (get_bits1(&s->gb)) |
1734 v = -v; | 1755 v = -v; |
1735 } else { | 1756 } else { |
1736 v = 0; | 1757 v = 0; |
1737 } | 1758 } |