aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-05-26 21:09:22 +0200
committerAnton Khirnov <anton@khirnov.net>2013-05-28 08:14:05 +0200
commit5074f4545c439420daebe4c2f28ed216440b6ec7 (patch)
treef8bcbed26570d6a6fd52aef3584c51c573c0e90d /libavcodec
parent72dee5f40b236c5eb9e68df39df80c68392269e3 (diff)
downloadffmpeg-5074f4545c439420daebe4c2f28ed216440b6ec7.tar.gz
wavpack demuxer: export full wavpack blocks.
Currently the demuxer shaves the blocks and exports only the information that is useful to the decoder. Exporting the blocks just as they are stored is simpler to understand and will make remuxing wavpack easier.
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/wavpack.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c
index 1b2e62ef4f..3a0fe272a8 100644
--- a/libavcodec/wavpack.c
+++ b/libavcodec/wavpack.c
@@ -33,6 +33,8 @@
* WavPack lossless audio decoder
*/
+#define WV_HEADER_SIZE 32
+
#define WV_MONO 0x00000004
#define WV_JOINT_STEREO 0x00000010
#define WV_FALSE_STEREO 0x40000000
@@ -1145,7 +1147,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
AVFrame *frame = data;
int frame_size, ret, frame_flags;
- if (avpkt->size < 12 + s->multichannel * 4)
+ if (avpkt->size <= WV_HEADER_SIZE)
return AVERROR_INVALIDDATA;
s->block = 0;
@@ -1157,13 +1159,8 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
buf += 4;
frame_flags = AV_RL32(buf);
} else {
- if (s->multichannel) {
- s->samples = AV_RL32(buf + 4);
- frame_flags = AV_RL32(buf + 8);
- } else {
- s->samples = AV_RL32(buf);
- frame_flags = AV_RL32(buf + 4);
- }
+ s->samples = AV_RL32(buf + 20);
+ frame_flags = AV_RL32(buf + 24);
}
if (s->samples <= 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid number of samples: %d\n",
@@ -1188,18 +1185,16 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data,
}
while (buf_size > 0) {
- if (!s->multichannel) {
- frame_size = buf_size;
+ if (!s->mkv_mode) {
+ if (buf_size <= WV_HEADER_SIZE)
+ break;
+ frame_size = AV_RL32(buf + 4) - 12;
+ buf += 20;
+ buf_size -= 20;
} else {
- if (!s->mkv_mode) {
- frame_size = AV_RL32(buf) - 12;
- buf += 4;
- buf_size -= 4;
- } else {
- if (buf_size < 12) // MKV files can have zero flags after last block
- break;
- frame_size = AV_RL32(buf + 8) + 12;
- }
+ if (buf_size < 12) // MKV files can have zero flags after last block
+ break;
+ frame_size = AV_RL32(buf + 8) + 12;
}
if (frame_size <= 0 || frame_size > buf_size) {
av_log(avctx, AV_LOG_ERROR,