diff mbox series

[FFmpeg-devel] remove useless mv The function which add motion info, but do not need motionless vectors, its useless. And, when u export mvs , loop oper will spend many times for useless vectors.

Message ID 20200313142459.1472-1-porschegt23@foxmail.com
State Superseded
Headers show
Series [FFmpeg-devel] remove useless mv The function which add motion info, but do not need motionless vectors, its useless. And, when u export mvs , loop oper will spend many times for useless vectors.
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork fail Make fate failed

Commit Message

numberwolf March 13, 2020, 2:24 p.m. UTC
Signed-off-by: numberwolf <porschegt23@foxmail.com>
---
 libavcodec/mpegutils.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c
index c0ee3aa..148d3e7 100644
--- a/libavcodec/mpegutils.c
+++ b/libavcodec/mpegutils.c
@@ -34,6 +34,12 @@  static int add_mb(AVMotionVector *mb, uint32_t mb_type,
                   int motion_x, int motion_y, int motion_scale,
                   int direction)
 {
+    int src_x = dst_x + motion_x / motion_scale;
+    int src_y = dst_y + motion_y / motion_scale;
+
+    if (src_x == dst_x && src_y == dst_y) {
+        return 0;
+    }
     mb->w = IS_8X8(mb_type) || IS_8X16(mb_type) ? 8 : 16;
     mb->h = IS_8X8(mb_type) || IS_16X8(mb_type) ? 8 : 16;
     mb->motion_x = motion_x;
@@ -41,8 +47,8 @@  static int add_mb(AVMotionVector *mb, uint32_t mb_type,
     mb->motion_scale = motion_scale;
     mb->dst_x = dst_x;
     mb->dst_y = dst_y;
-    mb->src_x = dst_x + motion_x / motion_scale;
-    mb->src_y = dst_y + motion_y / motion_scale;
+    mb->src_x = src_x;
+    mb->src_y = src_y;
     mb->source = direction ? 1 : -1;
     mb->flags = 0; // XXX: does mb_type contain extra information that could be exported here?
     return 1;