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