Revision f3618b01

View differences:

libavcodec/vmdav.c
421 421
typedef struct VmdAudioContext {
422 422
    AVCodecContext *avctx;
423 423
    int out_bps;
424
    int channels;
425
    int bits;
426
    int block_align;
427 424
    int predictors[2];
428 425
} VmdAudioContext;
429 426

  
......
448 445
    VmdAudioContext *s = avctx->priv_data;
449 446

  
450 447
    s->avctx = avctx;
451
    s->channels = avctx->channels;
452
    s->bits = avctx->bits_per_coded_sample;
453
    s->block_align = avctx->block_align;
454 448
    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
455 449
    s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3;
456 450

  
457
    av_log(s->avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, block align = %d, sample rate = %d\n",
458
            s->channels, s->bits, s->block_align, avctx->sample_rate);
451
    av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
452
           "block align = %d, sample rate = %d\n",
453
           avctx->channels, avctx->bits_per_coded_sample, avctx->block_align,
454
           avctx->sample_rate);
459 455

  
460 456
    return 0;
461 457
}
......
482 478
    const uint8_t *buf, int silent_chunks, int data_size)
483 479
{
484 480
    int i;
485
    int silent_size = s->block_align * silent_chunks * s->out_bps;
481
    int silent_size = s->avctx->block_align * silent_chunks * s->out_bps;
486 482

  
487 483
    if (silent_chunks) {
488 484
        memset(data, 0, silent_size);
489 485
        data += silent_size;
490 486
    }
491
    if (s->bits == 16)
492
        vmdaudio_decode_audio(s, data, buf, data_size, s->channels == 2);
487
    if (s->avctx->bits_per_coded_sample == 16)
488
        vmdaudio_decode_audio(s, data, buf, data_size, s->avctx->channels == 2);
493 489
    else {
494 490
        /* copy the data but convert it to signed */
495 491
        for (i = 0; i < data_size; i++){
......
537 533
    }
538 534

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

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

Also available in: Unified diff