Re: [VSP-Tests PATCH 1/3] gen-lut: Update for python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kieran,

Thank you for the patch.

On Wed, Sep 16, 2020 at 03:43:00PM +0100, Kieran Bingham wrote:
> Python2 has now gone end-of-life and is discontinued.
> 
> Update the gen-lut utility to use python3 directly, converting xrange
> usages to range, and using bytearray to store the tables and write them
> directly removing the discontinued file object.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@xxxxxxxxxxxxxxxx>

Reviewed-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

> ---
>  data/frames/gen-lut.py | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/data/frames/gen-lut.py b/data/frames/gen-lut.py
> index 07889b11f4ac..335b9f1613bc 100755
> --- a/data/frames/gen-lut.py
> +++ b/data/frames/gen-lut.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/python3
>  # SPDX-License-Identifier: GPL-2.0-or-later
>  # SPDX-FileCopyrightText: 2016 Renesas Electronics Corporation
>  
> @@ -49,26 +49,26 @@ def clu_value(x, y, z, scale, a, freq, weights):
>  	return (z, y, x, 0)
>  
>  def generate_clu(config):
> -	clu = []
> +	clu = bytearray()
>  
> -	for z in xrange(17):
> -		for y in xrange(17):
> -			for x in xrange(17):
> +	for z in range(17):
> +		for y in range(17):
> +			for x in range(17):
>  				clu.extend(clu_value(x, y, z, **config[1]))
>  
> -	file('clu-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in clu]))
> +	open('clu-%s.bin' % config[0], 'wb').write(clu)
>  
>  
>  def gamma(vin, gamma, scale):
>  	return int(255 * scale * math.pow(vin / 255., gamma))
>  
>  def generate_lut(config):
> -	lut = []
> -	for i in xrange(256):
> +	lut = bytearray()
> +	for i in range(256):
>  		lut.extend([gamma(i, g, config[1]) for g in config[2:]])
>  		lut.append(0)
>  
> -	file('lut-%s.bin' % config[0], 'wb').write(''.join([chr(c) for c in lut]))
> +	open('lut-%s.bin' % config[0], 'wb').write(lut)
>  
>  
>  def main(argv):

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux