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
00051 for(ch = 0; ch < channels; ch++){
00052 for(i = 0; i < SAMPLES_PER_BAND; i++) {
00053 ff_mpa_synth_filter_fixed(&c->mpadsp,
00054 c->synth_buf[ch], &(c->synth_buf_offset[ch]),
00055 ff_mpa_synth_window_fixed, &dither_state,
00056 out[ch] + 32 * i, 1,
00057 c->sb_samples[ch][i]);
00058 }
00059 }
00060 }
00061
00062 void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, int16_t **out,
00063 int channels)
00064 {
00065 int i, j, ch;
00066 Band *bands = c->bands;
00067 int off;
00068 float mul;
00069
00070
00071 memset(c->sb_samples, 0, sizeof(c->sb_samples));
00072 off = 0;
00073 for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){
00074 for(ch = 0; ch < 2; ch++){
00075 if(bands[i].res[ch]){
00076 j = 0;
00077 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0] & 0xFF];
00078 for(; j < 12; j++)
00079 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00080 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1] & 0xFF];
00081 for(; j < 24; j++)
00082 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00083 mul = (mpc_CC+1)[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2] & 0xFF];
00084 for(; j < 36; j++)
00085 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00086 }
00087 }
00088 if(bands[i].msf){
00089 int t1, t2;
00090 for(j = 0; j < SAMPLES_PER_BAND; j++){
00091 t1 = c->sb_samples[0][j][i];
00092 t2 = c->sb_samples[1][j][i];
00093 c->sb_samples[0][j][i] = t1 + t2;
00094 c->sb_samples[1][j][i] = t1 - t2;
00095 }
00096 }
00097 }
00098
00099 mpc_synth(c, out, channels);
00100 }