[libcamera-devel] ipa: rkisp1: lsc: Use double instead of float to accumulate vector of doubles
diff mbox series

Message ID 20220829182846.1227824-1-marvin.schmidt1987@gmail.com
State Accepted
Commit 68683d3811a803aa087c38a2063cf64c8d084d49
Headers show
Series
  • [libcamera-devel] ipa: rkisp1: lsc: Use double instead of float to accumulate vector of doubles
Related show

Commit Message

Marvin Schmidt Aug. 29, 2022, 6:28 p.m. UTC
clang-tidy's bugprone-fold-init-type check warns about this:

> ../src/ipa/rkisp1/algorithms/lsc.cpp:61:14: warning: folding type 'double' into type 'float' might result in loss of precision [bugprone-fold-init-type]
>         float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
>                     ^

Fixes: b3e96411 ("ipa: rkisp1: Add support of Lens Shading Correction control")

Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
---
 src/ipa/rkisp1/algorithms/lsc.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Umang Jain Aug. 30, 2022, 10:32 a.m. UTC | #1
Hi Marvin

Thank you for the patch

On 8/29/22 11:58 PM, Marvin Schmidt via libcamera-devel wrote:
> clang-tidy's bugprone-fold-init-type check warns about this:
>
>> ../src/ipa/rkisp1/algorithms/lsc.cpp:61:14: warning: folding type 'double' into type 'float' might result in loss of precision [bugprone-fold-init-type]
>>          float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
>>                      ^
> Fixes: b3e96411 ("ipa: rkisp1: Add support of Lens Shading Correction control")

12-letters commit-id, can be fixed up while applying
>
> Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>

  Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
> ---
>   src/ipa/rkisp1/algorithms/lsc.cpp | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
> index da287ac7..b9efc063 100644
> --- a/src/ipa/rkisp1/algorithms/lsc.cpp
> +++ b/src/ipa/rkisp1/algorithms/lsc.cpp
> @@ -58,7 +58,7 @@ static std::vector<double> parseSizes(const YamlObject &tuningData,
>   	 * prevent an exact match (further adjustments will be performed in
>   	 * LensShadingCorrection::prepare()).
>   	 */
> -	float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
> +	double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
>   	if (sum < 0.495 || sum > 0.505) {
>   		LOG(RkISP1Lsc, Error)
>   			<< "Invalid '" << prop << "' values: sum of the elements"
Laurent Pinchart Aug. 30, 2022, 7:07 p.m. UTC | #2
On Tue, Aug 30, 2022 at 04:02:57PM +0530, Umang Jain via libcamera-devel wrote:
> Hi Marvin
> 
> Thank you for the patch
> 
> On 8/29/22 11:58 PM, Marvin Schmidt via libcamera-devel wrote:
> > clang-tidy's bugprone-fold-init-type check warns about this:
> >
> >> ../src/ipa/rkisp1/algorithms/lsc.cpp:61:14: warning: folding type 'double' into type 'float' might result in loss of precision [bugprone-fold-init-type]
> >>          float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
> >>                      ^
> > Fixes: b3e96411 ("ipa: rkisp1: Add support of Lens Shading Correction control")
> 
> 12-letters commit-id, can be fixed up while applying

Will do

> > Signed-off-by: Marvin Schmidt <marvin.schmidt1987@gmail.com>
> 
> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

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

> > ---
> >   src/ipa/rkisp1/algorithms/lsc.cpp | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
> > index da287ac7..b9efc063 100644
> > --- a/src/ipa/rkisp1/algorithms/lsc.cpp
> > +++ b/src/ipa/rkisp1/algorithms/lsc.cpp
> > @@ -58,7 +58,7 @@ static std::vector<double> parseSizes(const YamlObject &tuningData,
> >   	 * prevent an exact match (further adjustments will be performed in
> >   	 * LensShadingCorrection::prepare()).
> >   	 */
> > -	float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
> > +	double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
> >   	if (sum < 0.495 || sum > 0.505) {
> >   		LOG(RkISP1Lsc, Error)
> >   			<< "Invalid '" << prop << "' values: sum of the elements"
>

Patch
diff mbox series

diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp
index da287ac7..b9efc063 100644
--- a/src/ipa/rkisp1/algorithms/lsc.cpp
+++ b/src/ipa/rkisp1/algorithms/lsc.cpp
@@ -58,7 +58,7 @@  static std::vector<double> parseSizes(const YamlObject &tuningData,
 	 * prevent an exact match (further adjustments will be performed in
 	 * LensShadingCorrection::prepare()).
 	 */
-	float sum = std::accumulate(sizes.begin(), sizes.end(), 0.0f);
+	double sum = std::accumulate(sizes.begin(), sizes.end(), 0.0);
 	if (sum < 0.495 || sum > 0.505) {
 		LOG(RkISP1Lsc, Error)
 			<< "Invalid '" << prop << "' values: sum of the elements"