comparison mace.c @ 7794:315d2a6c6a1e libavcodec

Simplify mace_decode_frame()
author vitor
date Thu, 04 Sep 2008 23:12:20 +0000
parents 0253472b1f25
children 7f81fb0dd829
comparison
equal deleted inserted replaced
7793:0253472b1f25 7794:315d2a6c6a1e
393 393
394 static int mace_decode_frame(AVCodecContext *avctx, 394 static int mace_decode_frame(AVCodecContext *avctx,
395 void *data, int *data_size, 395 void *data, int *data_size,
396 const uint8_t *buf, int buf_size) 396 const uint8_t *buf, int buf_size)
397 { 397 {
398 short *samples; 398 short *samples = data;
399 MACEContext *c = avctx->priv_data; 399 MACEContext *c = avctx->priv_data;
400 400 int i;
401 samples = (short *)data; 401
402 switch (avctx->codec->id) { 402 switch (avctx->codec->id) {
403 case CODEC_ID_MACE3: 403 case CODEC_ID_MACE3:
404 dprintf(avctx, "mace_decode_frame[3]()"); 404 dprintf(avctx, "mace_decode_frame[3]()");
405 Exp1to3(c, buf, samples, buf_size / 2 / avctx->channels, avctx->channels, 1); 405 for(i = 0; i < avctx->channels; i++)
406 if (avctx->channels == 2) 406 Exp1to3(c, buf, samples + i, buf_size / 2 / avctx->channels,
407 Exp1to3(c, buf, samples+1, buf_size / 2 / 2, 2, 2); 407 avctx->channels, i + 1);
408
408 *data_size = 2 * 3 * buf_size; 409 *data_size = 2 * 3 * buf_size;
409 break; 410 break;
410 case CODEC_ID_MACE6: 411 case CODEC_ID_MACE6:
411 dprintf(avctx, "mace_decode_frame[6]()"); 412 dprintf(avctx, "mace_decode_frame[6]()");
412 Exp1to6(c, buf, samples, buf_size / avctx->channels, avctx->channels, 1); 413
413 if (avctx->channels == 2) 414 for(i = 0; i < avctx->channels; i++)
414 Exp1to6(c, buf, samples+1, buf_size / 2, 2, 2); 415 Exp1to6(c, buf, samples + i, buf_size / avctx->channels,
416 avctx->channels, i + 1);
417
415 *data_size = 2 * 6 * buf_size; 418 *data_size = 2 * 6 * buf_size;
416 break; 419 break;
417 default: 420 default:
418 return -1; 421 return -1;
419 } 422 }