Revision dd1af513 libavcodec/vmdav.c

View differences:

libavcodec/vmdav.c
414 414
 * Audio Decoder
415 415
 */
416 416

  
417
#define BLOCK_TYPE_AUDIO    1
418
#define BLOCK_TYPE_INITIAL  2
419
#define BLOCK_TYPE_SILENCE  3
420

  
417 421
typedef struct VmdAudioContext {
418 422
    AVCodecContext *avctx;
419 423
    int channels;
......
504 508
    const uint8_t *buf = avpkt->data;
505 509
    int buf_size = avpkt->size;
506 510
    VmdAudioContext *s = avctx->priv_data;
511
    int block_type;
507 512
    unsigned char *output_samples = (unsigned char *)data;
508 513

  
509 514
    /* point to the start of the encoded data */
......
512 517
    if (buf_size < 16)
513 518
        return buf_size;
514 519

  
515
    if (buf[6] == 1) {
520
    block_type = buf[6];
521

  
522
    if (block_type == BLOCK_TYPE_AUDIO) {
516 523
        /* the chunk contains audio */
517 524
        *data_size = vmdaudio_loadsound(s, output_samples, p, 0, buf_size - 16);
518
    } else if (buf[6] == 2) {
525
    } else if (block_type == BLOCK_TYPE_INITIAL) {
519 526
        /* initial chunk, may contain audio and silence */
520 527
        uint32_t flags = AV_RB32(p);
521 528
        int raw_block_size = s->block_align *
......
528 535
        output_samples += raw_block_size * silent_chunks;
529 536
        *data_size = raw_block_size * silent_chunks;
530 537
        *data_size += vmdaudio_loadsound(s, output_samples, p + 4, 0, buf_size - 20);
531
    } else if (buf[6] == 3) {
538
    } else if (block_type == BLOCK_TYPE_SILENCE) {
532 539
        /* silent chunk */
533 540
        *data_size = vmdaudio_loadsound(s, output_samples, p, 1, s->block_align);
534 541
    }

Also available in: Unified diff