From patchwork Mon Sep 5 11:18:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Burt P X-Patchwork-Id: 429 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.140.134 with SMTP id o128csp53664vsd; Mon, 5 Sep 2016 04:33:21 -0700 (PDT) X-Received: by 10.28.167.215 with SMTP id q206mr7696664wme.62.1473075201630; Mon, 05 Sep 2016 04:33:21 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id bu7si24481740wjc.65.2016.09.05.04.33.21; Mon, 05 Sep 2016 04:33:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E9837689C66; Mon, 5 Sep 2016 14:33:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f65.google.com (mail-it0-f65.google.com [209.85.214.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29C39689C66 for ; Mon, 5 Sep 2016 14:33:04 +0300 (EEST) Received: by mail-it0-f65.google.com with SMTP id i184so8595688itf.3 for ; Mon, 05 Sep 2016 04:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=ot01OabJoKM0LsY4v6stus/jNI7Ch1f6dmQhoO1Zku4=; b=V/XNDnqo4eEBs1G/r91kRtkQwMquu33g1ZjfFaivgaZFixsNwd2tiGJFufCKLAEX9Z wSZnGNBpIQvlSsI3fMWd8G6qRbwar3tiPUFNcsRLvKYdONH0vWgtbNUC/vAN2gwKxE6l GQLwydg/L3Q9+gr1Tz0BOj1tE9bjR4ia2DCExAVP+R+mIXrcUbCt/XurECrY+uNhhIvB UcZ9ES9WhEULUHrMt3M7O8EOBLx6sNMj/tg9P9i27uIf/d4QVn4SeeVBU3egOWvU1Rq8 64FNhLSutJ30xGNO9bo6ChMvYENdUVZ3WGqKvbTdsOAnjPk8nyVa3gcpAYY3wi7t/mjQ sK3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=ot01OabJoKM0LsY4v6stus/jNI7Ch1f6dmQhoO1Zku4=; b=fSx13aGGnQ/h/qor/RwuWgOLwDVRUo0xK96Vf3OU2PhKfD45h6XG5e2PPB1DDm7ZM9 PSl4sIHAePISejmeqejINygtbVuGFJXAPTjfDE4SQtJ6vuaK9NuwQcwhJcm0+NWLNB+L yTSaiy91cmqVAWvxa1C5KhblXq9kov0zcEFIM6Kr6aTXy9QIrWgjFkQB4K2gX19fVdFm WYFKqqSKOeqdF/rxSjemO83OU1vUy/bfRNENViaf1Nk75iFXYPqg8lOvoPAlS5AV95yU ugfKjlxNWrKOfHHt9cJEd6QH9cGRvbYf2oD1U9K7bJ/oyGN9/p/b3dq9HrJUzY3xAMWR vhWA== X-Gm-Message-State: AE9vXwO3X5b3xOTZsLtUhtun8Wti9xOsAxnALAFQJyPUBn6iMqay2ygIZmKUOvg/9EiKaQ== X-Received: by 10.36.149.5 with SMTP id m5mr24425888itd.20.1473074334571; Mon, 05 Sep 2016 04:18:54 -0700 (PDT) Received: from localhost.localdomain ([216.16.66.181]) by smtp.gmail.com with ESMTPSA id e8sm10024609itc.15.2016.09.05.04.18.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Sep 2016 04:18:54 -0700 (PDT) From: Burt P To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Sep 2016 06:18:42 -0500 Message-Id: <1473074325-20959-3-git-send-email-pburt0@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473074325-20959-1-git-send-email-pburt0@gmail.com> References: <1473074325-20959-1-git-send-email-pburt0@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/5] af_hdcd: hdcd_analyze_gen() using int instead of float 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Burt P --- libavfilter/af_hdcd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c index cde2340..c8bda82 100644 --- a/libavfilter/af_hdcd.c +++ b/libavfilter/af_hdcd.c @@ -1316,11 +1316,10 @@ static void hdcd_analyze_prepare(hdcd_state *state, int32_t *samples, int count, /** encode a value in the given sample by adjusting the amplitude */ static int32_t hdcd_analyze_gen(int32_t sample, unsigned int v, unsigned int maxv) { - float sflt = sample, vv = v; - vv /= maxv; - if (vv > 1.0) vv = 1.0; - sflt *= 1.0 + (vv * 18); - return (int32_t)sflt; + static const int r = 18, m = 1024; + int64_t s64 = sample; + v = m + (v * r * m / maxv); + return (int32_t)(s64 * v / m); } /** behaves like hdcd_envelope(), but encodes processing information in