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 "bitstream.h"
00030 #include "dsputil.h"
00031 #include "random.h"
00032
00033 #ifdef CONFIG_MPEGAUDIO_HP
00034 #define USE_HIGHPRECISION
00035 #endif
00036 #include "mpegaudio.h"
00037
00038 #include "mpc.h"
00039 #include "mpcdata.h"
00040
00041 static DECLARE_ALIGNED_16(MPA_INT, mpa_window[512]);
00042
00043 void ff_mpc_init()
00044 {
00045 ff_mpa_synth_init(mpa_window);
00046 }
00047
00051 static void mpc_synth(MPCContext *c, int16_t *out)
00052 {
00053 int dither_state = 0;
00054 int i, ch;
00055 OUT_INT samples[MPA_MAX_CHANNELS * MPA_FRAME_SIZE], *samples_ptr;
00056
00057 for(ch = 0; ch < 2; ch++){
00058 samples_ptr = samples + ch;
00059 for(i = 0; i < SAMPLES_PER_BAND; i++) {
00060 ff_mpa_synth_filter(c->synth_buf[ch], &(c->synth_buf_offset[ch]),
00061 mpa_window, &dither_state,
00062 samples_ptr, 2,
00063 c->sb_samples[ch][i]);
00064 samples_ptr += 64;
00065 }
00066 }
00067 for(i = 0; i < MPC_FRAME_SIZE*2; i++)
00068 *out++=samples[i];
00069 }
00070
00071 void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data)
00072 {
00073 int i, j, ch;
00074 Band *bands = c->bands;
00075 int off;
00076 float mul;
00077
00078
00079 memset(c->sb_samples, 0, sizeof(c->sb_samples));
00080 off = 0;
00081 for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){
00082 for(ch = 0; ch < 2; ch++){
00083 if(bands[i].res[ch]){
00084 j = 0;
00085 mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0]];
00086 for(; j < 12; j++)
00087 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00088 mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1]];
00089 for(; j < 24; j++)
00090 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00091 mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2]];
00092 for(; j < 36; j++)
00093 c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00094 }
00095 }
00096 if(bands[i].msf){
00097 int t1, t2;
00098 for(j = 0; j < SAMPLES_PER_BAND; j++){
00099 t1 = c->sb_samples[0][j][i];
00100 t2 = c->sb_samples[1][j][i];
00101 c->sb_samples[0][j][i] = t1 + t2;
00102 c->sb_samples[1][j][i] = t1 - t2;
00103 }
00104 }
00105 }
00106
00107 mpc_synth(c, data);
00108 }