From patchwork Sun Jan 12 19:48:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 17305 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 ABA8D44B0B1 for ; Sun, 12 Jan 2020 21:49:03 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9100168B034; Sun, 12 Jan 2020 21:49:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0CE3A6881F2 for ; Sun, 12 Jan 2020 21:48:57 +0200 (EET) Received: by mail-wr1-f65.google.com with SMTP id d16so6528165wre.10 for ; Sun, 12 Jan 2020 11:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=mK9UKNP+/ahZxNUYQEvKYl0KcaAm0yxutXVu80ubR1Y=; b=mebTSiR2fodu+qjqc8D0w6qepOGW5Xced2CPPFuqckdgAFkUpVXDccxPrAKIQ70KUf pgiu2Dg+6VLyRZjpazNJX08hxLsX7+dP+9jbHf8lA8K2kdl8l5JV6df3fmW0zP7BpGi6 FD7Ifogh6BZIOz9s4JGgobsPBf4t6ywkj8vY0awZpOMJJQUbqGNiNuHJ3VjIfl5aYW/J O1Q+tA6b8QsAM2fbIR881e67gIB0UYFmP0yRoTpcXL8cMLkH6kaJQsxM1P7WwtChVamE cgDzZDn9XVC35SJk6+ptYv6zzp0/TOEXXCIrS5y/wNM8dBNXkx7DptsWuj/x/ZjjdKJN 2+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=mK9UKNP+/ahZxNUYQEvKYl0KcaAm0yxutXVu80ubR1Y=; b=sodfni4xlNE27SDC5RhLg5zKEswpnF/teUWT6DDGgkLTZACF9UR5zsI+jV7hu97QMX dyp2EMILTDMCujDELSBYSwYMRqhqLjxgU00oSs+t8+dWkLhnsObh5t2MYoVgzKk6agHM YrlRbDwrtaqydxduGxnRBI8YbCHpAUBjleKzZMqW7xKGqEyLzuUcse3K5a8KpjGVfWhB fA7qHI0Xj+/xWSNsIbi3MOO9CHH680pECXSDDxX5fyMJq3P92hdzg9aL28dfz3iWlmaE qMtU98vktBrreRqeX1B4p3K0BWQxMfvrcTcCwOIfKs8Ky+u1xsumBqAAnlg2Lo3R8b2v wD3w== X-Gm-Message-State: APjAAAWBsJrsT90pj88erpRsZFL4uzFtXJVm/KdWjX5YVeyzUw2+zpdk Cx8D8sBTQLFIHTmtaeW4nmFRzaSuA2U= X-Google-Smtp-Source: APXvYqwbNG7q+CV77jD0ay782Gb1/vsb94ZSP29sC3gm321sZ1x3vdXtKFFalNxvvzCUqYJJuJ6OVw== X-Received: by 2002:a5d:62c8:: with SMTP id o8mr14606792wrv.316.1578858536165; Sun, 12 Jan 2020 11:48:56 -0800 (PST) Received: from localhost.localdomain ([109.227.51.81]) by smtp.gmail.com with ESMTPSA id r62sm11930484wma.32.2020.01.12.11.48.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 11:48:55 -0800 (PST) From: Paul B Mahol To: ffmpeg-devel@ffmpeg.org Date: Sun, 12 Jan 2020 20:48:44 +0100 Message-Id: <20200112194847.15750-1-onemda@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/4] avfilter/vf_normalize: move luts into private context 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: Paul B Mahol --- libavfilter/vf_normalize.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_normalize.c b/libavfilter/vf_normalize.c index 2e1b274f8c..ef97aecc0e 100644 --- a/libavfilter/vf_normalize.c +++ b/libavfilter/vf_normalize.c @@ -112,6 +112,7 @@ typedef struct NormalizeContext { NormalizeHistory min[3], max[3]; // Min and max for each channel in {R,G,B}. uint8_t *history_mem; // Single allocation for above history entries + uint8_t lut[3][256]; // Lookup table } NormalizeContext; #define OFFSET(x) offsetof(NormalizeContext, x) @@ -139,7 +140,6 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out) float rgb_min_smoothed; // Min input range for linked normalization float rgb_max_smoothed; // Max input range for linked normalization - uint8_t lut[3][256]; // Lookup table int x, y, c; // First, scan the input frame to find, for each channel, the minimum @@ -216,7 +216,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out) if (min[c].smoothed == max[c].smoothed) { // There is no dynamic range to expand. No mapping for this channel. for (in_val = min[c].in; in_val <= max[c].in; in_val++) - lut[c][in_val] = min[c].out; + s->lut[c][in_val] = min[c].out; } else { // We must set lookup values for all values in the original input // range [min.in,max.in]. Since the original input range may be @@ -227,7 +227,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out) int out_val = (in_val - min[c].smoothed) * scale + min[c].out + 0.5f; out_val = FFMAX(out_val, 0); out_val = FFMIN(out_val, 255); - lut[c][in_val] = out_val; + s->lut[c][in_val] = out_val; } } } @@ -238,7 +238,7 @@ static void normalize(NormalizeContext *s, AVFrame *in, AVFrame *out) uint8_t *outp = out->data[0] + y * out->linesize[0]; for (x = 0; x < in->width; x++) { for (c = 0; c < 3; c++) - outp[s->co[c]] = lut[c][inp[s->co[c]]]; + outp[s->co[c]] = s->lut[c][inp[s->co[c]]]; if (s->num_components == 4) // Copy alpha as-is. outp[s->co[3]] = inp[s->co[3]];