Mercurial > libavcodec.hg
comparison g726.c @ 7047:4b5b586a3dd0 libavcodec
Support decoding of sample_g726.asf.
author | michael |
---|---|
date | Mon, 16 Jun 2008 23:12:50 +0000 |
parents | 589806348538 |
children | 167726a95509 |
comparison
equal
deleted
inserted
replaced
7046:589806348538 | 7047:4b5b586a3dd0 |
---|---|
264 c->se >>= 1; | 264 c->se >>= 1; |
265 | 265 |
266 return av_clip(re_signal << 2, -0xffff, 0xffff); | 266 return av_clip(re_signal << 2, -0xffff, 0xffff); |
267 } | 267 } |
268 | 268 |
269 static av_cold int g726_reset(G726Context* c, int bit_rate) | 269 static av_cold int g726_reset(G726Context* c, int index) |
270 { | 270 { |
271 int i; | 271 int i; |
272 | 272 |
273 c->tbls = &G726Tables_pool[bit_rate/8000 - 2]; | 273 c->tbls = &G726Tables_pool[index]; |
274 for (i=0; i<2; i++) { | 274 for (i=0; i<2; i++) { |
275 i2f(0, &c->sr[i]); | 275 i2f(0, &c->sr[i]); |
276 c->a[i] = 0; | 276 c->a[i] = 0; |
277 c->pk[i] = 1; | 277 c->pk[i] = 1; |
278 } | 278 } |
320 } AVG726Context; | 320 } AVG726Context; |
321 | 321 |
322 static av_cold int g726_init(AVCodecContext * avctx) | 322 static av_cold int g726_init(AVCodecContext * avctx) |
323 { | 323 { |
324 AVG726Context* c = (AVG726Context*)avctx->priv_data; | 324 AVG726Context* c = (AVG726Context*)avctx->priv_data; |
325 unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; | |
325 | 326 |
326 if (avctx->channels != 1 || | 327 if (avctx->channels != 1 || |
327 (avctx->bit_rate != 16000 && avctx->bit_rate != 24000 && | 328 (avctx->bit_rate != 16000 && avctx->bit_rate != 24000 && |
328 avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) { | 329 avctx->bit_rate != 32000 && avctx->bit_rate != 40000)) { |
329 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); | 330 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); |
331 } | 332 } |
332 if (avctx->sample_rate != 8000 && avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL) { | 333 if (avctx->sample_rate != 8000 && avctx->strict_std_compliance>FF_COMPLIANCE_INOFFICIAL) { |
333 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); | 334 av_log(avctx, AV_LOG_ERROR, "G726: unsupported audio format\n"); |
334 return -1; | 335 return -1; |
335 } | 336 } |
336 g726_reset(&c->c, avctx->bit_rate); | 337 g726_reset(&c->c, index); |
337 c->code_size = c->c.tbls->bits; | 338 c->code_size = c->c.tbls->bits; |
338 c->bit_buffer = 0; | 339 c->bit_buffer = 0; |
339 c->bits_left = 0; | 340 c->bits_left = 0; |
340 | 341 |
341 avctx->coded_frame = avcodec_alloc_frame(); | 342 avctx->coded_frame = avcodec_alloc_frame(); |