[libcamera-devel] libcamera: pipeline: raspberrypi: Fix initial value for scoring routine

Message ID 20200706135254.1631048-1-naush@raspberrypi.com
State Accepted
Commit d76acac30dc714e63057ee0cc424b12624994072
Headers show
Series
  • [libcamera-devel] libcamera: pipeline: raspberrypi: Fix initial value for scoring routine
Related show

Commit Message

Naushir Patuck July 6, 2020, 1:52 p.m. UTC
Use std::numerical_limits to initialise the best score instead of an
arbitrary value. This fixes a failure in v4l2-conformance when using
the Raspberry Pi pipeline handler and v4l2-compatibility libcamera
layer.

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

Comments

Paul Elder July 7, 2020, 12:30 p.m. UTC | #1
Hi Naush,

Thank you for the patch.

On Mon, Jul 06, 2020 at 02:52:54PM +0100, Naushir Patuck wrote:
> Use std::numerical_limits to initialise the best score instead of an
> arbitrary value. This fixes a failure in v4l2-conformance when using
> the Raspberry Pi pipeline handler and v4l2-compatibility libcamera
> layer.
> 
> Reported-by: Paul Elder <paul.elder@ideasonboard.com>
> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
> ---
>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> index f4966f86..bd2ed671 100644
> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
> @@ -69,7 +69,7 @@ double scoreFormat(double desired, double actual)
>  
>  V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)
>  {
> -	double bestScore = 9e9, score;
> +	double bestScore = std::numeric_limits<double>::max(), score;
>  	V4L2DeviceFormat bestMode = {};
>  
>  #define PENALTY_AR		1500.0

This doesn't quite fix the issue I was having (I'll follow you up on
that), but I think this fix is still necessary.

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

Patch

diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index f4966f86..bd2ed671 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -69,7 +69,7 @@  double scoreFormat(double desired, double actual)
 
 V4L2DeviceFormat findBestMode(V4L2PixFmtMap &formatsMap, const Size &req)
 {
-	double bestScore = 9e9, score;
+	double bestScore = std::numeric_limits<double>::max(), score;
 	V4L2DeviceFormat bestMode = {};
 
 #define PENALTY_AR		1500.0