aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/indeo4.c
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-07-12 14:32:03 +0200
committerSean McGovern <gseanmcg@gmail.com>2013-09-23 18:52:16 -0400
commitba5dfc25ee0afeb4b690de873ee17f0960160619 (patch)
tree3d4b9b15e823c7450c46d09d056517eaf754f971 /libavcodec/indeo4.c
parent68b100871961c3e6450871367630e5bf830f6cfd (diff)
downloadffmpeg-ba5dfc25ee0afeb4b690de873ee17f0960160619.tar.gz
indeo4: Do not access missing reference MV
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit 8435bca087c0e79385763c51de009fd89390b6a5) Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Conflicts: libavcodec/indeo4.c
Diffstat (limited to 'libavcodec/indeo4.c')
-rw-r--r--libavcodec/indeo4.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index c8ee0becbd..24f5ce6096 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -458,7 +458,7 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
}
mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
- if (band->inherit_mv) {
+ if (band->inherit_mv && ref_mb) {
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
@@ -470,7 +470,10 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
}
} else {
if (band->inherit_mv) {
- mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
+ /* copy mb_type from corresponding reference mb */
+ if (!ref_mb)
+ return AVERROR_INVALIDDATA;
+ mb->type = ref_mb->type;
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0; /* mb_type is always INTRA for intra-frames */
} else {
@@ -493,14 +496,15 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
} else {
if (band->inherit_mv) {
- /* motion vector inheritance */
- if (mv_scale) {
- mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
- mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
- } else {
- mb->mv_x = ref_mb->mv_x;
- mb->mv_y = ref_mb->mv_y;
- }
+ if (ref_mb)
+ /* motion vector inheritance */
+ if (mv_scale) {
+ mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+ mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+ } else {
+ mb->mv_x = ref_mb->mv_x;
+ mb->mv_y = ref_mb->mv_y;
+ }
} else {
/* decode motion vector deltas */
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,