• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavcodec/mpc.c

Go to the documentation of this file.
00001 /*
00002  * Musepack decoder core
00003  * Copyright (c) 2006 Konstantin Shishkov
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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     /* dequantize */
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[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0]];
00082                 for(; j < 12; 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][1]];
00085                 for(; j < 24; j++)
00086                     c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
00087                 mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2]];
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 }

Generated on Fri Feb 22 2013 07:24:27 for FFmpeg by  doxygen 1.7.1