[FFmpeg-devel] [PATCH 4/4] zmbvenc: use unsigned values for score calculations

matthew.w.fearnley at gmail.com matthew.w.fearnley at gmail.com
Thu Dec 20 00:00:03 EET 2018


From: Matthew Fearnley <matthew.w.fearnley at gmail.com>

All the values in score_tab are positive or 0, and so should be the sum
returned by block_cmp().

The logic in zmbv_me() assumes that all 'bv' values will be non-negative,
in order to guarantee an early return if ever bv==0.
---
 libavcodec/zmbvenc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c
index 0ebae1b254..9e1b44f15d 100644
--- a/libavcodec/zmbvenc.c
+++ b/libavcodec/zmbvenc.c
@@ -63,11 +63,11 @@ typedef struct ZmbvEncContext {
  * XXX should be optimized and moved to DSPContext
  * TODO handle out of edge ME
  */
-static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
+static inline unsigned int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
                             uint8_t *src2, int stride2, int bw, int bh,
                             int *xored)
 {
-    int sum = 0;
+    unsigned int sum = 0;
     int i, j;
     uint16_t histogram[256] = {0};
 
@@ -99,7 +99,8 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride,
 static int zmbv_me(ZmbvEncContext *c, uint8_t *src, int sstride, uint8_t *prev,
                    int pstride, int x, int y, int *mx, int *my, int *xored)
 {
-    int dx, dy, tx, ty, tv, bv, bw, bh;
+    int dx, dy, tx, ty, bw, bh;
+    unsigned int tv, bv;
     int txored;
 
     *mx = *my = 0;
-- 
2.17.1



More information about the ffmpeg-devel mailing list