Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: source/patched-ffmpeg-mt/libavcodec/lsp.c

Issue 3384002: ffmpeg source update for sep 09 (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * LSP routines for ACELP-based codecs 2 * LSP routines for ACELP-based codecs
3 * 3 *
4 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder) 4 * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet (QCELP decoder)
5 * Copyright (c) 2008 Vladimir Voroshilov 5 * Copyright (c) 2008 Vladimir Voroshilov
6 * 6 *
7 * This file is part of FFmpeg. 7 * This file is part of FFmpeg.
8 * 8 *
9 * FFmpeg is free software; you can redistribute it and/or 9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order) 58 void ff_acelp_lsf2lsp(int16_t *lsp, const int16_t *lsf, int lp_order)
59 { 59 {
60 int i; 60 int i;
61 61
62 /* Convert LSF to LSP, lsp=cos(lsf) */ 62 /* Convert LSF to LSP, lsp=cos(lsf) */
63 for(i=0; i<lp_order; i++) 63 for(i=0; i<lp_order; i++)
64 // 20861 = 2.0 / PI in (0.15) 64 // 20861 = 2.0 / PI in (0.15)
65 lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0, 14) 65 lsp[i] = ff_cos(lsf[i] * 20861 >> 15); // divide by PI and (0,13) -> (0, 14)
66 } 66 }
67 67
68 void ff_acelp_lsf2lspd(double *lsp, const float *lsf, int lp_order)
69 {
70 int i;
71
72 for(i = 0; i < lp_order; i++)
73 lsp[i] = cos(2.0 * M_PI * lsf[i]);
74 }
75
68 /** 76 /**
69 * \brief decodes polynomial coefficients from LSP 77 * \brief decodes polynomial coefficients from LSP
70 * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1f ffffff) 78 * \param f [out] decoded polynomial coefficients (-0x20000000 <= (3.22) <= 0x1f ffffff)
71 * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff) 79 * \param lsp LSP coefficients (-0x8000 <= (0.15) <= 0x7fff)
72 */ 80 */
73 static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) 81 static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
74 { 82 {
75 int i, j; 83 int i, j;
76 84
77 f[0] = 0x400000; // 1.0 in (3.22) 85 f[0] = 0x400000; // 1.0 in (3.22)
(...skipping 24 matching lines...) Expand all
102 { 110 {
103 int ff1 = f1[i] + f1[i-1]; // (3.22) 111 int ff1 = f1[i] + f1[i-1]; // (3.22)
104 int ff2 = f2[i] - f2[i-1]; // (3.22) 112 int ff2 = f2[i] - f2[i-1]; // (3.22)
105 113
106 ff1 += 1 << 10; // for rounding 114 ff1 += 1 << 10; // for rounding
107 lp[i] = (ff1 + ff2) >> 11; // divide by 2 and (3.22) -> (3.12) 115 lp[i] = (ff1 + ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
108 lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12) 116 lp[(lp_half_order << 1) + 1 - i] = (ff1 - ff2) >> 11; // divide by 2 and (3.22) -> (3.12)
109 } 117 }
110 } 118 }
111 119
120 void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
121 {
122 int lp_half_order = lp_order >> 1;
123 double buf[lp_half_order + 1];
124 double pa[lp_half_order + 1];
125 double *qa = buf + 1;
126 int i,j;
127
128 qa[-1] = 0.0;
129
130 ff_lsp2polyf(lsp , pa, lp_half_order );
131 ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
132
133 for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
134 double paf = pa[i] * (1 + lsp[lp_order - 1]);
135 double qaf = (qa[i] - qa[i-2]) * (1 - lsp[lp_order - 1]);
136 lp[i-1] = (paf + qaf) * 0.5;
137 lp[j-1] = (paf - qaf) * 0.5;
138 }
139
140 lp[lp_half_order - 1] = (1.0 + lsp[lp_order - 1]) *
141 pa[lp_half_order] * 0.5;
142
143 lp[lp_order - 1] = lsp[lp_order - 1];
144 }
145
112 void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd , const int16_t* lsp_prev, int lp_order) 146 void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd , const int16_t* lsp_prev, int lp_order)
113 { 147 {
114 int16_t lsp_1st[MAX_LP_ORDER]; // (0.15) 148 int16_t lsp_1st[MAX_LP_ORDER]; // (0.15)
115 int i; 149 int i;
116 150
117 /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/ 151 /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/
118 for(i=0; i<lp_order; i++) 152 for(i=0; i<lp_order; i++)
119 #ifdef G729_BITEXACT 153 #ifdef G729_BITEXACT
120 lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1); 154 lsp_1st[i] = (lsp_2nd[i] >> 1) + (lsp_prev[i] >> 1);
121 #else 155 #else
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 199 }
166 200
167 void ff_sort_nearly_sorted_floats(float *vals, int len) 201 void ff_sort_nearly_sorted_floats(float *vals, int len)
168 { 202 {
169 int i,j; 203 int i,j;
170 204
171 for (i = 0; i < len - 1; i++) 205 for (i = 0; i < len - 1; i++)
172 for (j = i; j >= 0 && vals[j] > vals[j+1]; j--) 206 for (j = i; j >= 0 && vals[j] > vals[j+1]; j--)
173 FFSWAP(float, vals[j], vals[j+1]); 207 FFSWAP(float, vals[j], vals[j+1]);
174 } 208 }
OLDNEW
« no previous file with comments | « source/patched-ffmpeg-mt/libavcodec/lsp.h ('k') | source/patched-ffmpeg-mt/libavcodec/mjpegdec.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698