comparison cook.c @ 6861:64998f9abdb6 libavcodec

Move const *pow2tab out of context.
author michael
date Sat, 24 May 2008 22:31:44 +0000
parents 75aa9d6df9ac
children 0f63fc62ea8b
comparison
equal deleted inserted replaced
6860:75aa9d6df9ac 6861:64998f9abdb6
130 VLC ccpl; //channel coupling 130 VLC ccpl; //channel coupling
131 131
132 /* generatable tables and related variables */ 132 /* generatable tables and related variables */
133 int gain_size_factor; 133 int gain_size_factor;
134 float gain_table[23]; 134 float gain_table[23];
135 float pow2tab[127];
136 float rootpow2tab[127];
137 135
138 /* data buffers */ 136 /* data buffers */
139 137
140 uint8_t* decoded_bytes_buffer; 138 uint8_t* decoded_bytes_buffer;
141 DECLARE_ALIGNED_16(float,mono_mdct_output[2048]); 139 DECLARE_ALIGNED_16(float,mono_mdct_output[2048]);
146 float decode_buffer_0[1060]; /* static allocation for joint decode */ 144 float decode_buffer_0[1060]; /* static allocation for joint decode */
147 145
148 const float *cplscales[5]; 146 const float *cplscales[5];
149 } COOKContext; 147 } COOKContext;
150 148
149 static float pow2tab[127];
150 static float rootpow2tab[127];
151
151 /* debug functions */ 152 /* debug functions */
152 153
153 #ifdef COOKDEBUG 154 #ifdef COOKDEBUG
154 static void dump_float_table(float* table, int size, int delimiter) { 155 static void dump_float_table(float* table, int size, int delimiter) {
155 int i=0; 156 int i=0;
181 #endif 182 #endif
182 183
183 /*************** init functions ***************/ 184 /*************** init functions ***************/
184 185
185 /* table generator */ 186 /* table generator */
186 static void init_pow2table(COOKContext *q){ 187 static void init_pow2table(void){
187 int i; 188 int i;
188 for (i=-63 ; i<64 ; i++){ 189 for (i=-63 ; i<64 ; i++){
189 q-> pow2tab[63+i]= pow(2, i); 190 pow2tab[63+i]= pow(2, i);
190 q->rootpow2tab[63+i]=sqrt(pow(2, i)); 191 rootpow2tab[63+i]=sqrt(pow(2, i));
191 } 192 }
192 } 193 }
193 194
194 /* table generator */ 195 /* table generator */
195 static void init_gain_table(COOKContext *q) { 196 static void init_gain_table(COOKContext *q) {
196 int i; 197 int i;
197 q->gain_size_factor = q->samples_per_channel/8; 198 q->gain_size_factor = q->samples_per_channel/8;
198 for (i=0 ; i<23 ; i++) { 199 for (i=0 ; i<23 ; i++) {
199 q->gain_table[i] = pow((double)q->pow2tab[i+52] , 200 q->gain_table[i] = pow(pow2tab[i+52] ,
200 (1.0/(double)q->gain_size_factor)); 201 (1.0/(double)q->gain_size_factor));
201 } 202 }
202 } 203 }
203 204
204 205
540 } else { 541 } else {
541 /* noise coding if subband_coef_index[i] == 0 */ 542 /* noise coding if subband_coef_index[i] == 0 */
542 f1 = dither_tab[index]; 543 f1 = dither_tab[index];
543 if (av_random(&q->random_state) < 0x80000000) f1 = -f1; 544 if (av_random(&q->random_state) < 0x80000000) f1 = -f1;
544 } 545 }
545 mlt_p[i] = f1 * q->rootpow2tab[quant_index+63]; 546 mlt_p[i] = f1 * rootpow2tab[quant_index+63];
546 } 547 }
547 } 548 }
548 /** 549 /**
549 * Unpack the subband_coef_index and subband_coef_sign vectors. 550 * Unpack the subband_coef_index and subband_coef_sign vectors.
550 * 551 *
668 669
669 static void interpolate_float(COOKContext *q, float* buffer, 670 static void interpolate_float(COOKContext *q, float* buffer,
670 int gain_index, int gain_index_next){ 671 int gain_index, int gain_index_next){
671 int i; 672 int i;
672 float fc1, fc2; 673 float fc1, fc2;
673 fc1 = q->pow2tab[gain_index+63]; 674 fc1 = pow2tab[gain_index+63];
674 675
675 if(gain_index == gain_index_next){ //static gain 676 if(gain_index == gain_index_next){ //static gain
676 for(i=0 ; i<q->gain_size_factor ; i++){ 677 for(i=0 ; i<q->gain_size_factor ; i++){
677 buffer[i]*=fc1; 678 buffer[i]*=fc1;
678 } 679 }
697 */ 698 */
698 699
699 static void imlt_window_float (COOKContext *q, float *buffer1, 700 static void imlt_window_float (COOKContext *q, float *buffer1,
700 cook_gains *gains_ptr, float *previous_buffer) 701 cook_gains *gains_ptr, float *previous_buffer)
701 { 702 {
702 const float fc = q->pow2tab[gains_ptr->previous[0] + 63]; 703 const float fc = pow2tab[gains_ptr->previous[0] + 63];
703 int i; 704 int i;
704 /* The weird thing here, is that the two halves of the time domain 705 /* The weird thing here, is that the two halves of the time domain
705 * buffer are swapped. Also, the newest data, that we save away for 706 * buffer are swapped. Also, the newest data, that we save away for
706 * next frame, has the wrong sign. Hence the subtraction below. 707 * next frame, has the wrong sign. Hence the subtraction below.
707 * Almost sounds like a complex conjugate/reverse data/FFT effect. 708 * Almost sounds like a complex conjugate/reverse data/FFT effect.
1111 1112
1112 /* Initialize variable relations */ 1113 /* Initialize variable relations */
1113 q->numvector_size = (1 << q->log2_numvector_size); 1114 q->numvector_size = (1 << q->log2_numvector_size);
1114 1115
1115 /* Generate tables */ 1116 /* Generate tables */
1116 init_pow2table(q); 1117 init_pow2table();
1117 init_gain_table(q); 1118 init_gain_table(q);
1118 init_cplscales_table(q); 1119 init_cplscales_table(q);
1119 1120
1120 if (init_cook_vlc_tables(q) != 0) 1121 if (init_cook_vlc_tables(q) != 0)
1121 return -1; 1122 return -1;