ffmpeg | branch: master | Michael Niedermayer <michae...@gmx.at> | Sat Feb 16 
10:44:38 2013 +0100| [2a06c2a03e1205aaeede5af850b9271752ddd4cf] | committer: 
Martin Storsjö

mpegvideo_enc: Draw edges on input for non-multiple of 16 resolutions

This improves motion estimation and avoids using uninitialized data
for resolutions that aren't a multiple of 16.

Prior to d2a25c40, the edges used to be initialized so that encoding
was deterministic, but after that commit it started using uninitialized
data (for non multiple of 16 resolutions).

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö <mar...@martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2a06c2a03e1205aaeede5af850b9271752ddd4cf
---

 libavcodec/mpegvideo_enc.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 535978d..be6fb08 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -990,6 +990,8 @@ static int load_input_picture(MpegEncContext *s, const 
AVFrame *pic_arg)
             pic_arg->linesize[1] != s->uvlinesize ||
             pic_arg->linesize[2] != s->uvlinesize)
             direct = 0;
+        if ((s->width & 15) || (s->height & 15))
+            direct = 0;
 
         av_dlog(s->avctx, "%d %d %td %td\n", pic_arg->linesize[0],
                 pic_arg->linesize[1], s->linesize, s->uvlinesize);
@@ -1038,12 +1040,21 @@ static int load_input_picture(MpegEncContext *s, const 
AVFrame *pic_arg)
                     if (src_stride == dst_stride)
                         memcpy(dst, src, src_stride * h);
                     else {
-                        while (h--) {
-                            memcpy(dst, src, w);
-                            dst += dst_stride;
+                        int h2 = h;
+                        uint8_t *dst2 = dst;
+                        while (h2--) {
+                            memcpy(dst2, src, w);
+                            dst2 += dst_stride;
                             src += src_stride;
                         }
                     }
+                    if ((s->width & 15) || (s->height & 15)) {
+                        s->mpvencdsp.draw_edges(dst, dst_stride,
+                                                w, h,
+                                                16 >> h_shift,
+                                                16 >> v_shift,
+                                                EDGE_BOTTOM);
+                    }
                 }
             }
         }

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

Reply via email to