diff options
Diffstat (limited to 'utils/rkisp1')
-rwxr-xr-x | utils/rkisp1/gen-csc-table.py | 24 | ||||
-rwxr-xr-x | utils/rkisp1/rkisp1-capture.sh | 3 |
2 files changed, 19 insertions, 8 deletions
diff --git a/utils/rkisp1/gen-csc-table.py b/utils/rkisp1/gen-csc-table.py index ffc0370a..2db84feb 100755 --- a/utils/rkisp1/gen-csc-table.py +++ b/utils/rkisp1/gen-csc-table.py @@ -147,6 +147,8 @@ def main(argv): description='Generate color space conversion table coefficients with ' 'configurable fixed-point precision.' ) + parser.add_argument('--format', '-f', choices=['dec', 'hex'], default='hex', + help='Number format') parser.add_argument('--invert', '-i', action='store_true', help='Invert the color space conversion (YUV -> RGB)') parser.add_argument('--precision', '-p', default='Q1.7', @@ -190,19 +192,29 @@ def main(argv): else: line = round_array(line) - # Convert coefficients to the number of bits selected by the precision. - # Negative values will be turned into positive integers using 2's - # complement. - line = [coeff & ((1 << precision.total) - 1) for coeff in line] + if args.format == 'hex': + # Convert coefficients to the number of bits selected by the precision. + # Negative values will be turned into positive integers using 2's + # complement. + line = [coeff & ((1 << precision.total) - 1) for coeff in line] + rounded_coeffs.append(line) # Print the result as C code. nbits = 1 << (precision.total - 1).bit_length() nbytes = nbits // 4 - print(f'static const u{nbits} {"yuv2rgb" if args.invert else "rgb2yuv"}_{args.encoding}_{quantization.name.lower()}_coeffs[] = {{') + + if args.format == 'hex': + coeff_fmt = '0x{0:0' + str(nbytes) + 'x}' + sign = 'u' + else: + coeff_fmt = '{0}' + sign = 's' + + print(f'static const {sign}{nbits} {"yuv2rgb" if args.invert else "rgb2yuv"}_{args.encoding}_{quantization.name.lower()}_coeffs[] = {{') for line in rounded_coeffs: - line = [f'0x{coeff:0{nbytes}x}' for coeff in line] + line = [coeff_fmt.format(coeff) for coeff in line] print(f'\t{", ".join(line)},') diff --git a/utils/rkisp1/rkisp1-capture.sh b/utils/rkisp1/rkisp1-capture.sh index c5f859f2..d767e31d 100755 --- a/utils/rkisp1/rkisp1-capture.sh +++ b/utils/rkisp1/rkisp1-capture.sh @@ -4,8 +4,7 @@ # # Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com> # -# rkisp-capture.sh - Capture processed frames from cameras based on the -# Rockchip ISP1 +# Capture processed frames from cameras based on the Rockchip ISP1 # # The scripts makes use of the following tools, which are expected to be # executable from the system-wide path or from the local directory: |