[FFmpeg-devel] [PATCH/RFC] Fix unaligned accesses in RV3/4 decoders

Mans Rullgard mans
Mon Jun 29 12:15:12 CEST 2009


rv34_decode_mb_header() calls fill_rectangle() with an unaligned
destination, causing errors on some platforms.

This change, suggested by Kostya, fixes it, and regression tests pass.
---
 libavcodec/mpegvideo.c |    2 +-
 libavcodec/rv34.c      |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 35cde71..6215c72 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -471,7 +471,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
     s->mb_width  = (s->width  + 15) / 16;
     s->mb_stride = s->mb_width + 1;
     s->b8_stride = s->mb_width*2 + 1;
-    s->b4_stride = s->mb_width*4 + 1;
+    s->b4_stride = s->mb_width*4 + 4;
     mb_array_size= s->mb_height * s->mb_stride;
     mv_table_size= (s->mb_height+2) * s->mb_stride + 1;
 
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 1c077e8..5a55acf 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1323,7 +1323,7 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int
         ff_update_block_index(s);
         s->dsp.clear_blocks(s->block[0]);
 
-        if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 1) < 0){
+        if(rv34_decode_macroblock(r, r->intra_types + s->mb_x * 4 + 4) < 0){
             ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
             return -1;
         }
-- 
1.6.3.1




More information about the ffmpeg-devel mailing list