[libcamera-devel,5/6] libcamera: pipeline: raspberrypi: Simplify format fetching

Message ID 20200629151411.216477-6-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Move formats from v4l2-compat into libcamera
Related show

Commit Message

Paul Elder June 29, 2020, 3:14 p.m. UTC
Simplify code for fetching PixelFormatInfo using a V4L2 format by
using the new PixelFormatInfo constructor based on V4L2 format.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Laurent Pinchart June 29, 2020, 9:56 p.m. UTC | #1
Hi Paul,

Thank you for the patch.

On Tue, Jun 30, 2020 at 12:14:10AM +0900, Paul Elder wrote:
> Simplify code for fetching PixelFormatInfo using a V4L2 format by

s/fetching/looking up/ ?

> using the new PixelFormatInfo constructor based on V4L2 format.

s/constructor/lookup function/ :-)

> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

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

> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index 9d887b7..4d9ec9c 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -81,8 +81,7 @@ V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)
>  	/* Calculate the closest/best mode from the user requested size. */
>  	for (const auto &iter : formatsMap) {
>  		V4L2PixelFormat v4l2Format = iter.first;
> -		PixelFormat pixelFormat = v4l2Format.toPixelFormat();
> -		const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat);
> +		const PixelFormatInfo &info = PixelFormatInfo::info(v4l2Format);
>  
>  		for (const SizeRange &sz : iter.second) {
>  			double modeWidth = sz.contains(req) ? req.width : sz.max.width;

Patch

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 9d887b7..4d9ec9c 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -81,8 +81,7 @@  V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)
 	/* Calculate the closest/best mode from the user requested size. */
 	for (const auto &iter : formatsMap) {
 		V4L2PixelFormat v4l2Format = iter.first;
-		PixelFormat pixelFormat = v4l2Format.toPixelFormat();
-		const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat);
+		const PixelFormatInfo &info = PixelFormatInfo::info(v4l2Format);
 
 		for (const SizeRange &sz : iter.second) {
 			double modeWidth = sz.contains(req) ? req.width : sz.max.width;