Clang: “warning: variable 'b' is uninitialized when used”
This is based on the v1.0.8 sources. I see the following warning when compiling libde265-1.0.8:
libde265/encoder/algo/pb-mv.cc:228:24: warning: variable 'b' is uninitialized when used here
[-Wuninitialized]
else { b=abs_value(b+2); }
^
libde265/util.h:115:25: note: expanded from macro 'abs_value'
#define abs_value(a) (((a)<0) ? -(a) : (a))
^
libde265/encoder/algo/pb-mv.cc:224:10: note: initialize the variable 'b' to silence this warning
int b;
^
= 0
libde265/encoder/algo/pb-mv.cc:217:24: warning: variable 'b' is uninitialized when used here
[-Wuninitialized]
else { b=abs_value(b+2); }
^
libde265/util.h:115:25: note: expanded from macro 'abs_value'
#define abs_value(a) (((a)<0) ? -(a) : (a))
^
libde265/encoder/algo/pb-mv.cc:213:10: note: initialize the variable 'b' to silence this warning
int b;
^
= 0
In the function Algo_PB_MV_Search::analyze in file encoder/algo/pb-mv.cc, lines 217 & 228 (else { b=abs_value(b+2); }) are incorrect as b is uninitialized.
If b is assumed to be 0 then this should be else { b = 2; }. But, in the context of the function, that doesn’t look right.
Also, it would be good to replace all usage of the abomination that is abs_value with std::abs :-).
Additionally at line 206 in the same function you have:
double lambda = 10.0;
double *bits_h = new double[2*hrange+1];
double *bits_v = new double[2*vrange+1];
The use of double is unnecessary. This could be replaced with:
constexpr int lambda = 10;
auto const bits_h = new int[2 * (hrange + vrange) + 2],
bits_v = bits_h + 2 * hrange + 1;
and line 315 (delete[] bits_v;) removed.
This would save memory, time & many redundant int → double → int conversions.
Ping!
This is in the encoder source. The encoder is basically dead code. Nobody is using it.