From 832a03821d1ef14e3588abc98f9bfb0231665309 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Tue, 8 Dec 2015 17:47:06 +0300 Subject: [PATCH] Valgrind: do not use uninitialized data in optflow --- modules/video/src/tvl1flow.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index 429f9141cd..b10dc3f344 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -1133,18 +1133,22 @@ void EstimateDualVariablesBody::operator() (const Range& range) const { const float g1 = static_cast(hypot(u1xRow[x], u1yRow[x])); const float g2 = static_cast(hypot(u2xRow[x], u2yRow[x])); - const float g3 = static_cast(hypot(u3xRow[x], u3yRow[x])); const float ng1 = 1.0f + taut * g1; const float ng2 = 1.0f + taut * g2; - const float ng3 = 1.0f + taut * g3; p11Row[x] = (p11Row[x] + taut * u1xRow[x]) / ng1; p12Row[x] = (p12Row[x] + taut * u1yRow[x]) / ng1; p21Row[x] = (p21Row[x] + taut * u2xRow[x]) / ng2; p22Row[x] = (p22Row[x] + taut * u2yRow[x]) / ng2; - if (use_gamma) p31Row[x] = (p31Row[x] + taut * u3xRow[x]) / ng3; - if (use_gamma) p32Row[x] = (p32Row[x] + taut * u3yRow[x]) / ng3; + + if (use_gamma) + { + const float g3 = static_cast(hypot(u3xRow[x], u3yRow[x])); + const float ng3 = 1.0f + taut * g3; + p31Row[x] = (p31Row[x] + taut * u3xRow[x]) / ng3; + p32Row[x] = (p32Row[x] + taut * u3yRow[x]) / ng3; + } } } }