aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-03-25 03:34:00 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-03-25 03:34:00 +0100
commita81ee2651fafd4412d0f8df159a3a11f6365ba70 (patch)
tree7b2106bb8364d5d72023965ab140ac171afc9c75
parentc25d2cd20b7643ea2c864dea9f25eef322cf3fb2 (diff)
downloadffmpeg-a81ee2651fafd4412d0f8df159a3a11f6365ba70.tar.gz
avcodec/svq1enc: fix undefined pointer operation
Fixes Ticket3152 This also removes the dependance on ff_init_block_index/ff_update_block_index() Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/svq1enc.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
index a4cb279487..9e320403be 100644
--- a/libavcodec/svq1enc.c
+++ b/libavcodec/svq1enc.c
@@ -258,6 +258,15 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
return best_score;
}
+static void init_block_index(MpegEncContext *s){
+ s->block_index[0]= s->b8_stride*(s->mb_y*2 ) + s->mb_x*2;
+ s->block_index[1]= s->b8_stride*(s->mb_y*2 ) + 1 + s->mb_x*2;
+ s->block_index[2]= s->b8_stride*(s->mb_y*2 + 1) + s->mb_x*2;
+ s->block_index[3]= s->b8_stride*(s->mb_y*2 + 1) + 1 + s->mb_x*2;
+ s->block_index[4]= s->mb_stride*(s->mb_y + 1) + s->b8_stride*s->mb_height*2 + s->mb_x;
+ s->block_index[5]= s->mb_stride*(s->mb_y + s->mb_height + 2) + s->b8_stride*s->mb_height*2 + s->mb_x;
+}
+
static int svq1_encode_plane(SVQ1Context *s, int plane,
unsigned char *src_plane,
unsigned char *ref_plane,
@@ -353,8 +362,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
for (x = 0; x < block_width; x++) {
s->m.mb_x = x;
- ff_init_block_index(&s->m);
- ff_update_block_index(&s->m);
+ init_block_index(&s->m);
ff_estimate_p_frame_motion(&s->m, x, y);
}
@@ -394,8 +402,7 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
}
s->m.mb_x = x;
- ff_init_block_index(&s->m);
- ff_update_block_index(&s->m);
+ init_block_index(&s->m);
if (f->pict_type == AV_PICTURE_TYPE_I ||
(s->m.mb_type[x + y * s->m.mb_stride] &