From patchwork Wed Dec 19 22:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: matthew.w.fearnley@gmail.com X-Patchwork-Id: 11480 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2E6C944C442 for ; Thu, 20 Dec 2018 00:00:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5B2A268AC28; Thu, 20 Dec 2018 00:00:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3E2168ABE7 for ; Thu, 20 Dec 2018 00:00:38 +0200 (EET) Received: by mail-wr1-f50.google.com with SMTP id r10so21040338wrs.10 for ; Wed, 19 Dec 2018 14:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=US+mdDl9XoXeP1NMgWWNGImvJIYrNoWDiX+TiYB7aYE=; b=DcZqKLX/f1vGZqR+XwQ/h6VmHmLft+QJ6axc5X3shh3qvYVKcqZHUEBT2fVBxysgMe FbqLlp9H59kE2m+c/CbBXplQhSBNghNNQo+nuXwicC6nlZfAKVkoN1Xt0Ug+MiyZiN8X EfWXtsLNWAJ6/pATDWNQJmSjLGtX1XqUkKu49B80AjQ+vKxMschAybBhHbZkbFraZPAU /+kqMMJkEqkw1jlj4c6o3tMvHHX+VQ46w0WFQ9mwHf9z1L/A4fQ3Tn7wcG1yDcCMX8yp cusVS0CNLNUjzyzmLhDEhXiRbYNsfCRMn4xcfX+jw99QuTz6EtbWazQTAuXP32H3SLO3 EKmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=US+mdDl9XoXeP1NMgWWNGImvJIYrNoWDiX+TiYB7aYE=; b=qi0Li9Bjax5YVIRb1VKnTAkkdPMKxJu6xGLvwYo9tvlo3n0x0ib+6awLOf7pT7tY8E A3B5alsceg4gN3Hrz/7hxcR22Hs1iB0FoBnTgeqLAtWZSY0lfWbCxsnYPYBkvydozc0A BJrgkTWsStcyRSVjts5AHyfgqeCp714Vd8l4yKoH4NPm5SZTUhOBmHLmipKCHis0sM8L JMMuhavtPa5ZzdQsqMe8+INXA9cvJHTrGLhFGl/XSjq554qAOIxDn8IHgd2iWX+xMYLg 8QpgWKBZ+VHxuQASYe3vn3hyFPhYmk8W1hOPE27zVj1Lb8wS8RDtNZAYCA/lTBckP0Md sD/g== X-Gm-Message-State: AA+aEWZUZnYrKxlHXBAQ0OQvCc4+i20THTA4qjpZpMNiq352m9EbuPlC lpkZfCqeQPUk7XzDUaYHBet2MXJp X-Google-Smtp-Source: AFSGD/VW4vMpPJRyJRbCZAYmzVGVkg2EKzyzFI4w2ISIFZS9agCgJiz5Q6oU5yOiZ3U6zgrCpVKT3Q== X-Received: by 2002:adf:fd03:: with SMTP id e3mr19341645wrr.280.1545256840644; Wed, 19 Dec 2018 14:00:40 -0800 (PST) Received: from localhost.localdomain (cpc131498-bagu18-2-0-cust88.know.cable.virginm.net. [86.9.33.89]) by smtp.gmail.com with ESMTPSA id k135sm8967078wmd.42.2018.12.19.14.00.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Dec 2018 14:00:39 -0800 (PST) From: matthew.w.fearnley@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 19 Dec 2018 22:00:03 +0000 Message-Id: <20181219220003.27225-4-matthew.w.fearnley@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181219220003.27225-1-matthew.w.fearnley@gmail.com> References: <20181219220003.27225-1-matthew.w.fearnley@gmail.com> Subject: [FFmpeg-devel] [PATCH 4/4] zmbvenc: use unsigned values for score calculations X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Matthew Fearnley MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Matthew Fearnley 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;