[FFmpeg-cvslog] deshake: variable used uninitialized
Ray Simard
git at videolan.org
Sat Jan 21 05:40:32 CET 2012
ffmpeg | branch: master | Ray Simard <rhs.ffmpeg at sylvan-glade.com> | Fri Jan 20 18:19:46 2012 -0800| [9ec39937f9c7f28a2279a19f71f290d8161eb52f] | committer: Michael Niedermayer
deshake: variable used uninitialized
Sometimes the scan finds nothing that qualifies for addition to
the array and pos is zero after the loops. The code forces pos to
1 and the array is then processed as if it had one valid element in it,
producing some amusing but not very useful results.
I don't see the rationale for this. If pos is zero coming out of the
loops, the only appropriate thing to do is set t->angle to zero. The
attached patch does that. It's worked properly in several tests so far.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ec39937f9c7f28a2279a19f71f290d8161eb52f
---
libavfilter/vf_deshake.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index b752fbf..bb20551 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -292,14 +292,15 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
}
}
- pos = FFMAX(1, pos);
-
- center_x /= pos;
- center_y /= pos;
-
- t->angle = clean_mean(angles, pos);
- if (t->angle < 0.001)
- t->angle = 0;
+ if (pos) {
+ center_x /= pos;
+ center_y /= pos;
+ t->angle = clean_mean(angles, pos);
+ if (t->angle < 0.001)
+ t->angle = 0;
+ } else {
+ t->angle = 0;
+ }
// Find the most common motion vector in the frame and use it as the gmv
for (y = deshake->ry * 2; y >= 0; y--) {
More information about the ffmpeg-cvslog
mailing list