Revision 1e898e7d libavcodec/vmdav.c

View differences:

libavcodec/vmdav.c
445 445
    VmdAudioContext *s = avctx->priv_data;
446 446

  
447 447
    s->avctx = avctx;
448
    avctx->sample_fmt = AV_SAMPLE_FMT_S16;
448
    if (avctx->bits_per_coded_sample == 16)
449
        avctx->sample_fmt = AV_SAMPLE_FMT_S16;
450
    else
451
        avctx->sample_fmt = AV_SAMPLE_FMT_U8;
449 452
    s->out_bps = av_get_bits_per_sample_fmt(avctx->sample_fmt) >> 3;
450 453

  
451 454
    av_log(avctx, AV_LOG_DEBUG, "%d channels, %d bits/sample, "
......
477 480
static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
478 481
    const uint8_t *buf, int silent_chunks, int data_size)
479 482
{
480
    int i;
481 483
    int silent_size = s->avctx->block_align * silent_chunks * s->out_bps;
482 484

  
483 485
    if (silent_chunks) {
484
        memset(data, 0, silent_size);
486
        memset(data, s->out_bps == 2 ? 0x00 : 0x80, silent_size);
485 487
        data += silent_size;
486 488
    }
487 489
    if (s->avctx->bits_per_coded_sample == 16)
488 490
        vmdaudio_decode_audio(s, data, buf, data_size, s->avctx->channels == 2);
489 491
    else {
490
        /* copy the data but convert it to signed */
491
        for (i = 0; i < data_size; i++){
492
            *data++ = buf[i] + 0x80;
493
            *data++ = buf[i] + 0x80;
494
        }
492
        /* just copy the data */
493
        memcpy(data, buf, data_size);
495 494
    }
496 495

  
497 496
    return silent_size + data_size * s->out_bps;

Also available in: Unified diff