comparison mace.c @ 7795:7f81fb0dd829 libavcodec

Simplify: use two distinct functions to decode MACE3 and MACE6, since the previous mace_decode_init() function was almost just a switch statement.
author vitor
date Thu, 04 Sep 2008 23:18:28 +0000
parents 315d2a6c6a1e
children a7caaa2b56e9
comparison
equal deleted inserted replaced
7794:315d2a6c6a1e 7795:7f81fb0dd829
389 return -1; 389 return -1;
390 avctx->sample_fmt = SAMPLE_FMT_S16; 390 avctx->sample_fmt = SAMPLE_FMT_S16;
391 return 0; 391 return 0;
392 } 392 }
393 393
394 static int mace_decode_frame(AVCodecContext *avctx, 394 static int mace3_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 = data; 398 short *samples = data;
399 MACEContext *c = avctx->priv_data; 399 MACEContext *c = avctx->priv_data;
400 int i; 400 int i;
401 401
402 switch (avctx->codec->id) { 402 for(i = 0; i < avctx->channels; i++)
403 case CODEC_ID_MACE3: 403 Exp1to3(c, buf, samples + i, buf_size / 2 / avctx->channels,
404 dprintf(avctx, "mace_decode_frame[3]()"); 404 avctx->channels, i + 1);
405 for(i = 0; i < avctx->channels; i++) 405
406 Exp1to3(c, buf, samples + i, buf_size / 2 / avctx->channels, 406 *data_size = 2 * 3 * buf_size;
407 avctx->channels, i + 1); 407
408 408 return buf_size;
409 *data_size = 2 * 3 * buf_size; 409 }
410 break; 410
411 case CODEC_ID_MACE6: 411 static int mace6_decode_frame(AVCodecContext *avctx,
412 dprintf(avctx, "mace_decode_frame[6]()"); 412 void *data, int *data_size,
413 413 const uint8_t *buf, int buf_size)
414 for(i = 0; i < avctx->channels; i++) 414 {
415 Exp1to6(c, buf, samples + i, buf_size / avctx->channels, 415 short *samples = data;
416 avctx->channels, i + 1); 416 MACEContext *c = avctx->priv_data;
417 417 int i;
418 *data_size = 2 * 6 * buf_size; 418
419 break; 419 for(i = 0; i < avctx->channels; i++)
420 default: 420 Exp1to6(c, buf, samples + i, buf_size / avctx->channels,
421 return -1; 421 avctx->channels, i + 1);
422 } 422
423 *data_size = 2 * 6 * buf_size;
424
423 return buf_size; 425 return buf_size;
424 } 426 }
425 427
426 AVCodec mace3_decoder = { 428 AVCodec mace3_decoder = {
427 "mace3", 429 "mace3",
429 CODEC_ID_MACE3, 431 CODEC_ID_MACE3,
430 sizeof(MACEContext), 432 sizeof(MACEContext),
431 mace_decode_init, 433 mace_decode_init,
432 NULL, 434 NULL,
433 NULL, 435 NULL,
434 mace_decode_frame, 436 mace3_decode_frame,
435 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"), 437 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
436 }; 438 };
437 439
438 AVCodec mace6_decoder = { 440 AVCodec mace6_decoder = {
439 "mace6", 441 "mace6",
441 CODEC_ID_MACE6, 443 CODEC_ID_MACE6,
442 sizeof(MACEContext), 444 sizeof(MACEContext),
443 mace_decode_init, 445 mace_decode_init,
444 NULL, 446 NULL,
445 NULL, 447 NULL,
446 mace_decode_frame, 448 mace6_decode_frame,
447 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"), 449 .long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),
448 }; 450 };
449 451