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

libavcodec/acelp_vectors.c

Go to the documentation of this file.
00001 /*
00002  * adaptive and fixed codebook vector operations for ACELP-based codecs
00003  *
00004  * Copyright (c) 2008 Vladimir Voroshilov
00005  *
00006  * This file is part of FFmpeg.
00007  *
00008  * FFmpeg is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * FFmpeg is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with FFmpeg; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 #include <inttypes.h>
00024 #include "avcodec.h"
00025 #include "acelp_vectors.h"
00026 
00027 const uint8_t ff_fc_2pulses_9bits_track1[16] =
00028 {
00029     1,  3,
00030     6,  8,
00031     11, 13,
00032     16, 18,
00033     21, 23,
00034     26, 28,
00035     31, 33,
00036     36, 38
00037 };
00038 const uint8_t ff_fc_2pulses_9bits_track1_gray[16] =
00039 {
00040   1,  3,
00041   8,  6,
00042   18, 16,
00043   11, 13,
00044   38, 36,
00045   31, 33,
00046   21, 23,
00047   28, 26,
00048 };
00049 
00050 const uint8_t ff_fc_2pulses_9bits_track2_gray[32] =
00051 {
00052   0,  2,
00053   5,  4,
00054   12, 10,
00055   7,  9,
00056   25, 24,
00057   20, 22,
00058   14, 15,
00059   19, 17,
00060   36, 31,
00061   21, 26,
00062   1,  6,
00063   16, 11,
00064   27, 29,
00065   32, 30,
00066   39, 37,
00067   34, 35,
00068 };
00069 
00070 const uint8_t ff_fc_4pulses_8bits_tracks_13[16] =
00071 {
00072   0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75,
00073 };
00074 
00075 const uint8_t ff_fc_4pulses_8bits_track_4[32] =
00076 {
00077     3,  4,
00078     8,  9,
00079     13, 14,
00080     18, 19,
00081     23, 24,
00082     28, 29,
00083     33, 34,
00084     38, 39,
00085     43, 44,
00086     48, 49,
00087     53, 54,
00088     58, 59,
00089     63, 64,
00090     68, 69,
00091     73, 74,
00092     78, 79,
00093 };
00094 
00095 #if 0
00096 static uint8_t gray_decode[32] =
00097 {
00098     0,  1,  3,  2,  7,  6,  4,  5,
00099    15, 14, 12, 13,  8,  9, 11, 10,
00100    31, 30, 28, 29, 24, 25, 27, 26,
00101    16, 17, 19, 18, 23, 22, 20, 21
00102 };
00103 #endif
00104 
00105 void ff_acelp_fc_pulse_per_track(
00106         int16_t* fc_v,
00107         const uint8_t *tab1,
00108         const uint8_t *tab2,
00109         int pulse_indexes,
00110         int pulse_signs,
00111         int pulse_count,
00112         int bits)
00113 {
00114     int mask = (1 << bits) - 1;
00115     int i;
00116 
00117     for(i=0; i<pulse_count; i++)
00118     {
00119         fc_v[i + tab1[pulse_indexes & mask]] +=
00120                 (pulse_signs & 1) ? 8191 : -8192; // +/-1 in (2.13)
00121 
00122         pulse_indexes >>= bits;
00123         pulse_signs >>= 1;
00124     }
00125 
00126     fc_v[tab2[pulse_indexes]] += (pulse_signs & 1) ? 8191 : -8192;
00127 }
00128 
00129 void ff_acelp_weighted_vector_sum(
00130         int16_t* out,
00131         const int16_t *in_a,
00132         const int16_t *in_b,
00133         int16_t weight_coeff_a,
00134         int16_t weight_coeff_b,
00135         int16_t rounder,
00136         int shift,
00137         int length)
00138 {
00139     int i;
00140 
00141     // Clipping required here; breaks OVERFLOW test.
00142     for(i=0; i<length; i++)
00143         out[i] = av_clip_int16((
00144                  in_a[i] * weight_coeff_a +
00145                  in_b[i] * weight_coeff_b +
00146                  rounder) >> shift);
00147 }

Generated on Tue Nov 4 2014 12:59:21 for ffmpeg by  doxygen 1.7.1