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

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

Issue 789004: ffmpeg roll of source to mar 9 version... (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/ffmpeg/
Patch Set: '' Created 10 years, 9 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 * Real Audio 1.0 (14.4K) 2 * Real Audio 1.0 (14.4K)
3 * 3 *
4 * Copyright (c) 2008 Vitor Sessak 4 * Copyright (c) 2008 Vitor Sessak
5 * Copyright (c) 2003 Nick Kurshev 5 * Copyright (c) 2003 Nick Kurshev
6 * Based on public domain decoder at http://www.honeypot.net/audio 6 * Based on public domain decoder at http://www.honeypot.net/audio
7 * 7 *
8 * This file is part of FFmpeg. 8 * This file is part of FFmpeg.
9 * 9 *
10 * FFmpeg is free software; you can redistribute it and/or 10 * FFmpeg is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public 11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either 12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version. 13 * version 2.1 of the License, or (at your option) any later version.
14 * 14 *
15 * FFmpeg is distributed in the hope that it will be useful, 15 * FFmpeg is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details. 18 * Lesser General Public License for more details.
19 * 19 *
20 * You should have received a copy of the GNU Lesser General Public 20 * You should have received a copy of the GNU Lesser General Public
21 * License along with FFmpeg; if not, write to the Free Software 21 * License along with FFmpeg; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */ 23 */
24 24
25 #include "libavutil/intmath.h"
25 #include "avcodec.h" 26 #include "avcodec.h"
26 #include "get_bits.h" 27 #include "get_bits.h"
27 #include "ra144.h" 28 #include "ra144.h"
28 #include "celp_filters.h" 29 #include "celp_filters.h"
29 30
30 #define NBLOCKS 4 ///< number of subblocks within a block 31 #define NBLOCKS 4 ///< number of subblocks within a block
31 #define BLOCKSIZE 40 ///< subblock size in 16-bit words 32 #define BLOCKSIZE 40 ///< subblock size in 16-bit words
32 #define BUFFERSIZE 146 ///< the size of the adaptive codebook 33 #define BUFFERSIZE 146 ///< the size of the adaptive codebook
33 34
34 35
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 213
213 if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs, 214 if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs,
214 block, BLOCKSIZE, 10, 1, 0xfff)) 215 block, BLOCKSIZE, 10, 1, 0xfff))
215 memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); 216 memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock));
216 } 217 }
217 218
218 static void int_to_int16(int16_t *out, const int *inp) 219 static void int_to_int16(int16_t *out, const int *inp)
219 { 220 {
220 int i; 221 int i;
221 222
222 for (i=0; i < 30; i++) 223 for (i=0; i < 10; i++)
223 *out++ = *inp++; 224 *out++ = *inp++;
224 } 225 }
225 226
226 /** 227 /**
227 * Evaluate the reflection coefficients from the filter coefficients. 228 * Evaluate the reflection coefficients from the filter coefficients.
228 * Does the inverse of the eval_coefs() function. 229 * Does the inverse of the eval_coefs() function.
229 * 230 *
230 * @return 1 if one of the reflection coefficients is greater than 231 * @return 1 if one of the reflection coefficients is greater than
231 * 4095, 0 if not. 232 * 4095, 0 if not.
232 */ 233 */
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 270
270 static int interp(RA144Context *ractx, int16_t *out, int a, 271 static int interp(RA144Context *ractx, int16_t *out, int a,
271 int copyold, int energy) 272 int copyold, int energy)
272 { 273 {
273 int work[10]; 274 int work[10];
274 int b = NBLOCKS - a; 275 int b = NBLOCKS - a;
275 int i; 276 int i;
276 277
277 // Interpolate block coefficients from the this frame's forth block and 278 // Interpolate block coefficients from the this frame's forth block and
278 // last frame's forth block. 279 // last frame's forth block.
279 for (i=0; i<30; i++) 280 for (i=0; i<10; i++)
280 out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; 281 out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2;
281 282
282 if (eval_refl(work, out, ractx->avctx)) { 283 if (eval_refl(work, out, ractx->avctx)) {
283 // The interpolated coefficients are unstable, copy either new or old 284 // The interpolated coefficients are unstable, copy either new or old
284 // coefficients. 285 // coefficients.
285 int_to_int16(out, ractx->lpc_coef[copyold]); 286 int_to_int16(out, ractx->lpc_coef[copyold]);
286 return rescale_rms(ractx->lpc_refl_rms[copyold], energy); 287 return rescale_rms(ractx->lpc_refl_rms[copyold], energy);
287 } else { 288 } else {
288 return rescale_rms(rms(work), energy); 289 return rescale_rms(rms(work), energy);
289 } 290 }
290 } 291 }
291 292
292 /** Uncompress one block (20 bytes -> 160*2 bytes). */ 293 /** Uncompress one block (20 bytes -> 160*2 bytes). */
293 static int ra144_decode_frame(AVCodecContext * avctx, void *vdata, 294 static int ra144_decode_frame(AVCodecContext * avctx, void *vdata,
294 int *data_size, AVPacket *avpkt) 295 int *data_size, AVPacket *avpkt)
295 { 296 {
296 const uint8_t *buf = avpkt->data; 297 const uint8_t *buf = avpkt->data;
297 int buf_size = avpkt->size; 298 int buf_size = avpkt->size;
298 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; 299 static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2};
299 unsigned int refl_rms[4]; // RMS of the reflection coefficients 300 unsigned int refl_rms[4]; // RMS of the reflection coefficients
300 uint16_t block_coefs[4][30]; // LPC coefficients of each sub-block 301 uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block
301 unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame 302 unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame
302 int i, j; 303 int i, j;
303 int16_t *data = vdata; 304 int16_t *data = vdata;
304 unsigned int energy; 305 unsigned int energy;
305 306
306 RA144Context *ractx = avctx->priv_data; 307 RA144Context *ractx = avctx->priv_data;
307 GetBitContext gb; 308 GetBitContext gb;
308 309
309 if (*data_size < 2*160) 310 if (*data_size < 2*160)
310 return -1; 311 return -1;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 "real_144", 355 "real_144",
355 CODEC_TYPE_AUDIO, 356 CODEC_TYPE_AUDIO,
356 CODEC_ID_RA_144, 357 CODEC_ID_RA_144,
357 sizeof(RA144Context), 358 sizeof(RA144Context),
358 ra144_decode_init, 359 ra144_decode_init,
359 NULL, 360 NULL,
360 NULL, 361 NULL,
361 ra144_decode_frame, 362 ra144_decode_frame,
362 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), 363 .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
363 }; 364 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698