Revision 5e7c422d

View differences:

libavcodec/vmdav.c
420 420

  
421 421
typedef struct VmdAudioContext {
422 422
    AVCodecContext *avctx;
423
    int out_bps;
423 424
    int channels;
424 425
    int bits;
425 426
    int block_align;
......
451 452
    s->bits = avctx->bits_per_coded_sample;
452 453
    s->block_align = avctx->block_align;
453 454
    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
455
    s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3;
454 456

  
455 457
    av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n",
456 458
            s->channels, s->bits, s->block_align, avctx->sample_rate);
......
480 482
    const uint8_t *buf, int silent_chunks, int data_size)
481 483
{
482 484
    int i;
483
    int silent_size = s->block_align * silent_chunks * 2;
485
    int silent_size = s->block_align * silent_chunks * s->out_bps;
484 486

  
485 487
    if (silent_chunks) {
486 488
        memset(data, 0, silent_size);
......
496 498
        }
497 499
    }
498 500

  
499
    return silent_size + data_size * 2;
501
    return silent_size + data_size * s->out_bps;
500 502
}
501 503

  
502 504
static int vmdaudio_decode_frame(AVCodecContext *avctx,
......
535 537
    }
536 538

  
537 539
    /* ensure output buffer is large enough */
538
    if (*data_size < (s->block_align*silent_chunks + buf_size) * 2)
540
    if (*data_size < (s->block_align*silent_chunks + buf_size) * s->out_bps)
539 541
        return -1;
540 542

  
541 543
    *data_size = vmdaudio_loadsound(s, output_samples, buf, silent_chunks, buf_size);

Also available in: Unified diff