[FFmpeg-cvslog] avcodec/wavarc: fix 8bit decoding
Paul B Mahol
git at videolan.org
Mon Feb 6 19:09:32 EET 2023
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Mon Feb 6 18:07:35 2023 +0100| [64b242d03078630bbe7570d0775d3a68f166306c] | committer: Paul B Mahol
avcodec/wavarc: fix 8bit decoding
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64b242d03078630bbe7570d0775d3a68f166306c
---
libavcodec/wavarc.c | 8 ++++----
libavformat/wavarc.c | 7 +------
2 files changed, 5 insertions(+), 10 deletions(-)
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;
}
More information about the ffmpeg-cvslog
mailing list