00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #include "avcodec.h"
00030 #include "get_bits.h"
00031 #include "dsputil.h"
00032 #include "mpegaudiodsp.h"
00033 #include "mpegaudio.h"
00034
00035 #include "mpc.h"
00036 #include "mpcdata.h"
00037
00038 void ff_mpc_init(void)
00039 {
00040 ff_mpa_synth_init_fixed(ff_mpa_synth_window_fixed);
00041 }
00042
00046 static void mpc_synth(MPCContext *c, int16_t *out, int channels)
00047 {
00048 int dither_state = 0;
00049 int i, ch;
00050 OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
00051
00052 for(ch = 0; ch < channels; ch++){
00053 samples_ptr = samples + ch;
00054 for(i = 0; i < SAMPLES_PER_BAND; i++) {
00055 ff_mpa_synth_filter_fixed(&c->mpadsp,
00056 c->synth_buf[ch], &(c->synth_buf_offset[ch]),
00057 ff_mpa_synth_window_fixed, &dither_state,
00058 samples_ptr, channels,
00059 c->sb_samples[ch][i]);
00060 samples_ptr += 32 * channels;
00061 }
00062 }
00063 for(i = 0; i < MPC_FRAME_SIZE*channels; i++)
00064 *out++=samples[i];
00065 }
00066
00067 void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels)
00068 {
00069 int i, j, ch;
00070 Band *bands = c->bands;
00071 int off;
00072 float mul;
00073
00074
00075 memset(c->sb_samples, 0, sizeof(c->sb_samples));
00076 off = 0;
00077 for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){
00078 for(ch = 0; ch < 2; ch++){
00079 if(bands[i].res[ch]){
00080 j = 0;
00081 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF];
00082 for(; j < 12; j++)
00083 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00084 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF];
00085 for(; j < 24; j++)
00086 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00087 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF];
00088 for(; j < 36; j++)
00089 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00090 }
00091 }
00092 if(bands[i].msf){
00093 int t1, t2;
00094 for(j = 0; j < SAMPLES_PER_BAND; j++){
00095 t1 = c->sb_samples[0][j][i];
00096 t2 = c->sb_samples[1][j][i];
00097 c->sb_samples[0][j][i] = t1 + t2;
00098 c->sb_samples[1][j][i] = t1 - t2;
00099 }
00100 }
00101 }
00102
00103 mpc_synth(c, data, channels);
00104 }