Mercurial > libavcodec.hg
comparison imc.c @ 12172:93ba40eb28b9 libavcodec
Make Intel Music Coder output SAMPLE_FMT_FLT
author | vitor |
---|---|
date | Fri, 16 Jul 2010 16:50:56 +0000 |
parents | 8b28e74de2c0 |
children | 4be72e19ab0e |
comparison
equal
deleted
inserted
replaced
12171:77b51328fc59 | 12172:93ba40eb28b9 |
---|---|
85 float one_div_log2; | 85 float one_div_log2; |
86 | 86 |
87 DSPContext dsp; | 87 DSPContext dsp; |
88 FFTContext fft; | 88 FFTContext fft; |
89 DECLARE_ALIGNED(16, FFTComplex, samples)[COEFFS/2]; | 89 DECLARE_ALIGNED(16, FFTComplex, samples)[COEFFS/2]; |
90 DECLARE_ALIGNED(16, float, out_samples)[COEFFS]; | 90 float *out_samples; |
91 } IMCContext; | 91 } IMCContext; |
92 | 92 |
93 static VLC huffman_vlc[4][4]; | 93 static VLC huffman_vlc[4][4]; |
94 | 94 |
95 #define VLC_TABLES_SIZE 9512 | 95 #define VLC_TABLES_SIZE 9512 |
114 /* Build mdct window, a simple sine window normalized with sqrt(2) */ | 114 /* Build mdct window, a simple sine window normalized with sqrt(2) */ |
115 ff_sine_window_init(q->mdct_sine_window, COEFFS); | 115 ff_sine_window_init(q->mdct_sine_window, COEFFS); |
116 for(i = 0; i < COEFFS; i++) | 116 for(i = 0; i < COEFFS; i++) |
117 q->mdct_sine_window[i] *= sqrt(2.0); | 117 q->mdct_sine_window[i] *= sqrt(2.0); |
118 for(i = 0; i < COEFFS/2; i++){ | 118 for(i = 0; i < COEFFS/2; i++){ |
119 q->post_cos[i] = cos(i / 256.0 * M_PI); | 119 q->post_cos[i] = (1.0f / 32768) * cos(i / 256.0 * M_PI); |
120 q->post_sin[i] = sin(i / 256.0 * M_PI); | 120 q->post_sin[i] = (1.0f / 32768) * sin(i / 256.0 * M_PI); |
121 | 121 |
122 r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI); | 122 r1 = sin((i * 4.0 + 1.0) / 1024.0 * M_PI); |
123 r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI); | 123 r2 = cos((i * 4.0 + 1.0) / 1024.0 * M_PI); |
124 | 124 |
125 if (i & 0x1) | 125 if (i & 0x1) |
154 } | 154 } |
155 q->one_div_log2 = 1/log(2); | 155 q->one_div_log2 = 1/log(2); |
156 | 156 |
157 ff_fft_init(&q->fft, 7, 1); | 157 ff_fft_init(&q->fft, 7, 1); |
158 dsputil_init(&q->dsp, avctx); | 158 dsputil_init(&q->dsp, avctx); |
159 avctx->sample_fmt = SAMPLE_FMT_S16; | 159 avctx->sample_fmt = SAMPLE_FMT_FLT; |
160 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO; | 160 avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO; |
161 return 0; | 161 return 0; |
162 } | 162 } |
163 | 163 |
164 static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeffs2, int* bandWidthT, | 164 static void imc_calculate_coeffs(IMCContext* q, float* flcoeffs1, float* flcoeffs2, int* bandWidthT, |
660 return -1; | 660 return -1; |
661 } | 661 } |
662 for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) | 662 for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) |
663 buf16[i] = av_bswap16(((const uint16_t*)buf)[i]); | 663 buf16[i] = av_bswap16(((const uint16_t*)buf)[i]); |
664 | 664 |
665 q->out_samples = data; | |
665 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); | 666 init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); |
666 | 667 |
667 /* Check the frame header */ | 668 /* Check the frame header */ |
668 imc_hdr = get_bits(&q->gb, 9); | 669 imc_hdr = get_bits(&q->gb, 9); |
669 if (imc_hdr != IMC_FRAME_ID) { | 670 if (imc_hdr != IMC_FRAME_ID) { |
803 | 804 |
804 memset(q->skipFlags, 0, sizeof(q->skipFlags)); | 805 memset(q->skipFlags, 0, sizeof(q->skipFlags)); |
805 | 806 |
806 imc_imdct256(q); | 807 imc_imdct256(q); |
807 | 808 |
808 q->dsp.float_to_int16(data, q->out_samples, COEFFS); | 809 *data_size = COEFFS * sizeof(float); |
809 | |
810 *data_size = COEFFS * sizeof(int16_t); | |
811 | 810 |
812 return IMC_BLOCK_SIZE; | 811 return IMC_BLOCK_SIZE; |
813 } | 812 } |
814 | 813 |
815 | 814 |