From patchwork Tue May 9 11:04:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 41242 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d82wj-0005dD-Og; Tue, 09 May 2017 11:04:49 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-7) with esmtp id 1d82wh-0003rU-1E; Tue, 09 May 2017 13:04:49 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbdEILEo (ORCPT + 1 other); Tue, 9 May 2017 07:04:44 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:37148 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbdEILEm (ORCPT ); Tue, 9 May 2017 07:04:42 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id CDD0581D29; Tue, 9 May 2017 13:04:40 +0200 (CEST) Date: Tue, 9 May 2017 13:04:40 +0200 From: Pavel Machek To: Hans Verkuil Cc: Ivaylo Dimitrov , Mauro Carvalho Chehab , pali.rohar@gmail.com, sre@kernel.org, Sakari Ailus , Sakari Ailus , linux-media@vger.kernel.org, hans.verkuil@cisco.com Subject: [patch, libv4l]: Introduce define for lookup table size Message-ID: <20170509110440.GC28248@amd> References: <20170424093059.GA20427@amd> <20170424103802.00d3b554@vento.lan> <20170424212914.GA20780@amd> <20170424224724.5bb52382@vento.lan> <20170426105300.GA857@amd> <20170426081330.6ca10e42@vento.lan> <20170426132337.GA6482@amd> <20170508222819.GA14833@amd> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.5.9.105415 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' BODY_PARA_IS_SENTENCE_URL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, KNOWN_FREEWEB_URI 0.05, MSGID_ADDED_BY_MTA 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, INVALID_MSGID_NO_FQDN 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_URI_HTTPS 0, REFERENCES 0, URI_ENDS_IN_HTML 0, URI_WITH_PATH_ONLY 0, __ANY_URI 0, __ATTACHMENT_SIZE_0_10K 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CD 0, __CP_URI_IN_BODY 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __HAS_ATTACHMENT 0, __HAS_ATTACHMENT1 0, __HAS_ATTACHMENT2 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __KNOWN_FREEWEB_URI2 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_TEXT_P2 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __MULTIPLE_URI_TEXT 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0, __URI_IN_BODY 0, __URI_NOT_IMG 0, __URI_NS , __URI_WITH_PATH 0, __USER_AGENT 0' Make lookup table size configurable at compile-time. Signed-off-by: Pavel Machek diff --git a/lib/libv4lconvert/processing/libv4lprocessing-priv.h b/lib/libv4lconvert/processing/libv4lprocessing-priv.h index e4a29dd..55e1687 100644 --- a/lib/libv4lconvert/processing/libv4lprocessing-priv.h +++ b/lib/libv4lconvert/processing/libv4lprocessing-priv.h @@ -25,6 +25,8 @@ #include "../libv4lsyscall-priv.h" #define V4L2PROCESSING_UPDATE_RATE 10 +/* Size of lookup tables */ +#define LSIZE 256 struct v4lprocessing_data { struct v4lcontrol_data *control; @@ -32,15 +34,15 @@ struct v4lprocessing_data { int do_process; int controls_changed; /* True if any of the lookup tables does not contain - linear 0-255 */ + linear 0-LSIZE-1 */ int lookup_table_active; /* Counts the number of processed frames until a V4L2PROCESSING_UPDATE_RATE overflow happens */ int lookup_table_update_counter; /* RGB/BGR lookup tables */ - unsigned char comp1[256]; - unsigned char green[256]; - unsigned char comp2[256]; + unsigned char comp1[LSIZE]; + unsigned char green[LSIZE]; + unsigned char comp2[LSIZE]; /* Filter private data for filters which need it */ /* whitebalance.c data */ int green_avg; @@ -48,7 +50,7 @@ struct v4lprocessing_data { int comp2_avg; /* gamma.c data */ int last_gamma; - unsigned char gamma_table[256]; + unsigned char gamma_table[LSIZE]; /* autogain.c data */ int last_gain_correction; }; diff --git a/lib/libv4lconvert/processing/libv4lprocessing.c b/lib/libv4lconvert/processing/libv4lprocessing.c index b061f50..6d0ad20 100644 --- a/lib/libv4lconvert/processing/libv4lprocessing.c +++ b/lib/libv4lconvert/processing/libv4lprocessing.c @@ -74,7 +74,7 @@ static void v4lprocessing_update_lookup_tables(struct v4lprocessing_data *data, { int i; - for (i = 0; i < 256; i++) { + for (i = 0; i < LSIZE; i++) { data->comp1[i] = i; data->green[i] = i; data->comp2[i] = i; diff --git a/lib/libv4lconvert/processing/whitebalance.c b/lib/libv4lconvert/processing/whitebalance.c index c74069a..2dd33c1 100644 --- a/lib/libv4lconvert/processing/whitebalance.c +++ b/lib/libv4lconvert/processing/whitebalance.c @@ -27,7 +27,7 @@ #include "libv4lprocessing-priv.h" #include "../libv4lconvert-priv.h" /* for PIX_FMT defines */ -#define CLIP256(color) (((color) > 0xff) ? 0xff : (((color) < 0) ? 0 : (color))) +#define CLIPLSIZE(color) (((color) > LSIZE) ? LSIZE : (((color) < 0) ? 0 : (color))) #define CLIP(color, min, max) (((color) > (max)) ? (max) : (((color) < (min)) ? (min) : (color))) static int whitebalance_active(struct v4lprocessing_data *data) @@ -111,10 +111,10 @@ static int whitebalance_calculate_lookup_tables_generic( avg_avg = (data->green_avg + data->comp1_avg + data->comp2_avg) / 3; - for (i = 0; i < 256; i++) { - data->comp1[i] = CLIP256(data->comp1[i] * avg_avg / data->comp1_avg); - data->green[i] = CLIP256(data->green[i] * avg_avg / data->green_avg); - data->comp2[i] = CLIP256(data->comp2[i] * avg_avg / data->comp2_avg); + for (i = 0; i < LSIZE; i++) { + data->comp1[i] = CLIPLSIZE(data->comp1[i] * avg_avg / data->comp1_avg); + data->green[i] = CLIPLSIZE(data->green[i] * avg_avg / data->green_avg); + data->comp2[i] = CLIPLSIZE(data->comp2[i] * avg_avg / data->comp2_avg); } return 1;