summaryrefslogtreecommitdiff
path: root/libavcodec/interplayvideo.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2015-11-01 17:02:26 +0100
committerPaul B Mahol <onemda@gmail.com>2015-11-02 08:44:05 +0100
commitc293ef258cbb2c058e23651a26edf46e3bc05050 (patch)
tree2e3fccb306b4fb0ed855295c6caf6e466d67360a /libavcodec/interplayvideo.c
parentdee74405312a13a96ae8259221a79a0e78ea7789 (diff)
downloadffmpeg-c293ef258cbb2c058e23651a26edf46e3bc05050.tar.gz
avformat/ipmovie: put video decoding_map_size into packet and use it in decoder
The size of decoding map can differ from one calculated internally, producing artifacts while decoding video. Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavcodec/interplayvideo.c')
-rw-r--r--libavcodec/interplayvideo.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index a29b5fe8da..1460741a53 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include <string.h>
+#include "libavutil/intreadwrite.h"
#include "avcodec.h"
#include "bytestream.h"
#include "hpeldsp.h"
@@ -949,7 +950,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s, AVFrame *frame)
}
}
if (bytestream2_get_bytes_left(&s->stream_ptr) > 1) {
- av_log(s->avctx, AV_LOG_ERROR,
+ av_log(s->avctx, AV_LOG_DEBUG,
"decode finished with %d bytes left over\n",
bytestream2_get_bytes_left(&s->stream_ptr));
}
@@ -987,12 +988,15 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
AVFrame *frame = data;
int ret;
+ if (buf_size < 2)
+ return AVERROR_INVALIDDATA;
+
/* decoding map contains 4 bits of information per 8x8 block */
- s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
+ s->decoding_map_size = AV_RL16(avpkt->data);
/* compressed buffer needs to be large enough to at least hold an entire
* decoding map */
- if (buf_size < s->decoding_map_size)
+ if (buf_size < s->decoding_map_size + 2)
return buf_size;
if (av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, NULL)) {
@@ -1000,8 +1004,8 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
av_frame_unref(s->second_last_frame);
}
- s->decoding_map = buf;
- bytestream2_init(&s->stream_ptr, buf + s->decoding_map_size,
+ s->decoding_map = buf + 2;
+ bytestream2_init(&s->stream_ptr, buf + 2 + s->decoding_map_size,
buf_size - s->decoding_map_size);
if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)