diff --git a/libavcodec/wavarc.c b/libavcodec/wavarc.c index caab08cb24..b18a88000b 100644 --- a/libavcodec/wavarc.c +++ b/libavcodec/wavarc.c @@ -68,9 +68,9 @@ static av_cold int wavarc_init(AVCodecContext *avctx) av_channel_layout_default(&avctx->ch_layout, AV_RL16(avctx->extradata + 38)); avctx->sample_rate = AV_RL32(avctx->extradata + 40); - switch (avctx->extradata[36]) { - case 0: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break; - case 1: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; + switch (AV_RL16(avctx->extradata + 38)) { + case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break; + case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break; } s->shift = 0; @@ -411,7 +411,7 @@ fail: const int *src = s->samples[ch] + s->offset; for (int n = 0; n < frame->nb_samples; n++) - dst[n] = src[n] * (1 << s->shift); + dst[n] = src[n] * (1 << s->shift) + 0x80U; } break; case AV_SAMPLE_FMT_S16P: diff --git a/libavformat/wavarc.c b/libavformat/wavarc.c index 41ee817a1e..13e56026a7 100644 --- a/libavformat/wavarc.c +++ b/libavformat/wavarc.c @@ -89,7 +89,7 @@ static int wavarc_read_header(AVFormatContext *s) id = avio_rl32(pb); if (id != MKTAG('d','a','t','a')) avio_skip(pb, avio_rl32(pb)); - } while (id != MKTAG('d','a','t','a')); + } while (id != MKTAG('d','a','t','a') && !avio_feof(pb)); avio_skip(pb, 4); if (AV_RL32(par->extradata + 16) != MKTAG('R','I','F','F')) @@ -104,11 +104,6 @@ static int wavarc_read_header(AVFormatContext *s) avpriv_set_pts_info(st, 64, 1, par->sample_rate); st->start_time = 0; - switch (par->extradata[36]) { - case 0: par->format = AV_SAMPLE_FMT_U8P; break; - case 1: par->format = AV_SAMPLE_FMT_S16P; break; - } - return 0; }