Skip to contentSkip to conversation

tests: Add SPDX headers to vsp-unit-test-0026.sh

PATCH In review Laurent Pinchart 2 participants 7 messages Feb 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tests: Add SPDX headers to vsp-unit-test-0026.sh

vsp-unit-test-0026.sh is missing SPDX headers. Add them.

---
 tests/vsp-unit-test-0026.sh | 2 ++
 1 file changed, 2 insertions(+)
tests/vsp-unit-test-0026.sh +2 -0
index 0e013cec881b..36ed0b03469b 100755
@@ -1,4 +1,6 @@
 #!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2020 Renesas Electronics Corporation
 
 #
 # Test unbinding and binding all VSP1 devices, performing a simple

base-commit: 2e98a1bf774bc8516aa8027411a2fd511e52561c

Signature · 3 lines
Regards,

Laurent Pinchart
#1 lore raw

PATCH 2/3 gen-image: Crop input image before format conversion to YUV

When converting the input image to a subsampled YUV format, chroma components are averaged horizontally to emulate the VSP internal conversion to YUV444. If the image is subsequently cropped to emulate the RPF cropping, the edge chroma values end up effectively taking into account pixels outside of the crop rectangle. This doesn't match the hardware mode of operation which crops the image when reading it through DMA, before performing any other operation.

Fix this by cropping the image just after reading it, before format conversion.

---
 src/gen-image.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
src/gen-image.c +17 -16
index d9f92253af46..170d69490399 100644
@@ -1531,6 +1531,23 @@ static int process(const struct options *options)
 		goto done;
 	}
 
+	/* Crop */
+	if (options->crop) {
+		struct image *cropped;
+
+		cropped = image_new(format_by_name("RGB24"),
+				    options->inputcrop.width,
+				    options->inputcrop.height);
+		if (!cropped) {
+			ret = -ENOMEM;
+			goto done;
+		}
+
+		image_crop(input, cropped, &options->inputcrop);
+		image_delete(input);
+		input = cropped;
+	}
+
 	/* Convert colorspace */
 	if (options->input_format->type == FORMAT_YUV) {
 		struct image *yuv;
@@ -1561,22 +1578,6 @@ static int process(const struct options *options)
 		input = rgb;
 	}
 
-	/* Crop */
-	if (options->crop) {
-		struct image *cropped;
-
-		cropped = image_new(input->format, options->inputcrop.width,
-				options->inputcrop.height);
-		if (!cropped) {
-			ret = -ENOMEM;
-			goto done;
-		}
-
-		image_crop(input, cropped, &options->inputcrop);
-		image_delete(input);
-		input = cropped;
-	}
-
 	/* Scale */
 	if (options->output_width && options->output_height) {
 		output_width = options->output_width;
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] gen-image: Crop input image before format conversion to YUV

Quoting Laurent Pinchart (2022-02-28 11:29:00)

Quoted 8 lines

When converting the input image to a subsampled YUV format, chroma components are averaged horizontally to emulate the VSP internal conversion to YUV444. If the image is subsequently cropped to emulate the RPF cropping, the edge chroma values end up effectively taking into account pixels outside of the crop rectangle. This doesn't match the hardware mode of operation which crops the image when reading it through DMA, before performing any other operation.

Quoted 4 lines

Fix this by cropping the image just after reading it, before format conversion.

Seems fine. And there's only one input format so:

Quoted 60 lines
---
 src/gen-image.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)
src/gen-image.c +17 -16
index d9f92253af46..170d69490399 100644
@@ -1531,6 +1531,23 @@ static int process(const struct options *options)
                goto done;
        }
 
+       /* Crop */
+       if (options->crop) {
+               struct image *cropped;
+
+               cropped = image_new(format_by_name("RGB24"),
+                                   options->inputcrop.width,
+                                   options->inputcrop.height);
+               if (!cropped) {
+                       ret = -ENOMEM;
+                       goto done;
+               }
+
+               image_crop(input, cropped, &options->inputcrop);
+               image_delete(input);
+               input = cropped;
+       }
+
        /* Convert colorspace */
        if (options->input_format->type == FORMAT_YUV) {
                struct image *yuv;
@@ -1561,22 +1578,6 @@ static int process(const struct options *options)
                input = rgb;
        }
 
-       /* Crop */
-       if (options->crop) {
-               struct image *cropped;
-
-               cropped = image_new(input->format, options->inputcrop.width,
-                               options->inputcrop.height);
-               if (!cropped) {
-                       ret = -ENOMEM;
-                       goto done;
-               }
-
-               image_crop(input, cropped, &options->inputcrop);
-               image_delete(input);
-               input = cropped;
-       }
-
        /* Scale */
        if (options->output_width && options->output_height) {
                output_width = options->output_width;
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

PATCH 3/3 tests: Add RPF cropping test for YUV formats

In reply to Laurent Pinchart

YUV formats can be subsampled, which interact with cropping. Add a test to verify that the VSP driver handles this correctly.

---
 tests/vsp-unit-test-0027.sh | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 tests/vsp-unit-test-0027.sh
tests/vsp-unit-test-0027.sh new file +46 -0
new file mode 100755
index 000000000000..8be8ae736375
@@ -0,0 +1,46 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2017-2022 Renesas Electronics Corporation
+
+#
+# Test RPF crop using multiplanar YUV formats, test buffer offset calculation
+# with subsampling. Use a RPF -> WPF pipeline, passing a selection of cropping
+# windows.
+#
+
+. ./vsp-lib.sh
+
+features="rpf.0 wpf.0"
+crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384"
+formats="NV12M NV16M YUV420M YUV422M YUV444M"
+
+test_rpf_cropping() {
+	local format=$1
+	local crop=$2
+
+	test_start "RPF crop from $crop in $format"
+
+	pipe_configure rpf-wpf 0 0
+	format_configure rpf-wpf 0 0 $format 1024x768 YUV444M --rpfcrop=$crop
+
+	vsp_runner rpf.0 &
+	vsp_runner wpf.0
+
+	local result=$(compare_frames crop=${crop})
+
+	test_complete $result
+}
+
+test_main() {
+	local crop
+	local format
+
+	for format in $formats ; do
+		for crop in $crops ; do
+			test_rpf_cropping $format $crop
+		done
+	done
+}
+
+test_init $0 "$features"
+test_run
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 3/3
#4 lore raw

Re: [PATCH 3/3] tests: Add RPF cropping test for YUV formats

Quoting Laurent Pinchart (2022-02-28 11:29:01)

Quoted 19 lines

YUV formats can be subsampled, which interact with cropping. Add a test to verify that the VSP driver handles this correctly.

---
 tests/vsp-unit-test-0027.sh | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 tests/vsp-unit-test-0027.sh
tests/vsp-unit-test-0027.sh new file +4 -0
new file mode 100755
index 000000000000..8be8ae736375
@@ -0,0 +1,46 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2017-2022 Renesas Electronics Corporation
+

tests/vsp-unit-test-0027.sh line 14

Quoted 10 lines
tests/vsp-unit-test-0027.sh new file +10 -0
+#
+# Test RPF crop using multiplanar YUV formats, test buffer offset calculation
+# with subsampling. Use a RPF -> WPF pipeline, passing a selection of cropping
+# windows.
+#
+
+. ./vsp-lib.sh
+
+features="rpf.0 wpf.0"
+crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384"

I was expecting to see more strenuous variations here. Are the crops limited for now ? Does this already highlight any failures in the driver? or do these pass?

Anyway, Extending the tests is beneficial, even if this can be further extended.

Quoted 37 lines
tests/vsp-unit-test-0027.sh new file +32 -0
+formats="NV12M NV16M YUV420M YUV422M YUV444M"
+
+test_rpf_cropping() {
+       local format=$1
+       local crop=$2
+
+       test_start "RPF crop from $crop in $format"
+
+       pipe_configure rpf-wpf 0 0
+       format_configure rpf-wpf 0 0 $format 1024x768 YUV444M --rpfcrop=$crop
+
+       vsp_runner rpf.0 &
+       vsp_runner wpf.0
+
+       local result=$(compare_frames crop=${crop})
+
+       test_complete $result
+}
+
+test_main() {
+       local crop
+       local format
+
+       for format in $formats ; do
+               for crop in $crops ; do
+                       test_rpf_cropping $format $crop
+               done
+       done
+}
+
+test_init $0 "$features"
+test_run
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [PATCH 3/3] tests: Add RPF cropping test for YUV formats

Hi Kieran,

Quoted 25 lines · Kieran Bingham

Quoting Laurent Pinchart (2022-02-28 11:29:01)

Quoted 24 lines

YUV formats can be subsampled, which interact with cropping. Add a test to verify that the VSP driver handles this correctly.

---
 tests/vsp-unit-test-0027.sh | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100755 tests/vsp-unit-test-0027.sh
tests/vsp-unit-test-0027.sh new file +9 -0
new file mode 100755
index 000000000000..8be8ae736375
@@ -0,0 +1,46 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2017-2022 Renesas Electronics Corporation
+
+#
+# Test RPF crop using multiplanar YUV formats, test buffer offset calculation
+# with subsampling. Use a RPF -> WPF pipeline, passing a selection of cropping
+# windows.
+#
Quoted 8 lines

tests/vsp-unit-test-0027.sh line 14

Quoted 5 lines
tests/vsp-unit-test-0027.sh new file +5 -0
+
+. ./vsp-lib.sh
+
+features="rpf.0 wpf.0"
+crops="(0,0)/512x384 (32,32)/512x384 (32,64)/512x384 (64,32)/512x384"

I was expecting to see more strenuous variations here. Are the crops limited for now ?

I've copied these values from the RGB crop tests. We can add more crop rectangles if there are specific items that need to be tested.

Quoted 2 lines

Does this already highlight any failures in the
driver? or do these pass?

The test fails, the fix is available at
https://lore.kernel.org/linux-media/[email protected]/T/#u

Quoted 37 lines

Anyway, Extending the tests is beneficial, even if this can be further extended.

Quoted 32 lines
tests/vsp-unit-test-0027.sh new file +32 -0
+formats="NV12M NV16M YUV420M YUV422M YUV444M"
+
+test_rpf_cropping() {
+       local format=$1
+       local crop=$2
+
+       test_start "RPF crop from $crop in $format"
+
+       pipe_configure rpf-wpf 0 0
+       format_configure rpf-wpf 0 0 $format 1024x768 YUV444M --rpfcrop=$crop
+
+       vsp_runner rpf.0 &
+       vsp_runner wpf.0
+
+       local result=$(compare_frames crop=${crop})
+
+       test_complete $result
+}
+
+test_main() {
+       local crop
+       local format
+
+       for format in $formats ; do
+               for crop in $crops ; do
+                       test_rpf_cropping $format $crop
+               done
+       done
+}
+
+test_init $0 "$features"
+test_run
Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v1 1/3
#6 lore raw
In reply to Laurent Pinchart

Quoting Laurent Pinchart (2022-02-28 11:28:59)

Quoted 3 lines

vsp-unit-test-0026.sh is missing SPDX headers. Add them.

Quoted 22 lines
---
 tests/vsp-unit-test-0026.sh | 2 ++
 1 file changed, 2 insertions(+)
tests/vsp-unit-test-0026.sh +2 -0
index 0e013cec881b..36ed0b03469b 100755
@@ -1,4 +1,6 @@
 #!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2020 Renesas Electronics Corporation
 
 #
 # Test unbinding and binding all VSP1 devices, performing a simple

base-commit: 2e98a1bf774bc8516aa8027411a2fd511e52561c

Signature · 3 lines
Regards,

Laurent Pinchart