[FFmpeg-devel] [PATCH] Variable used uninitialized

Michael Niedermayer michaelni at gmx.at
Sat Jan 21 05:27:56 CET 2012


On Fri, Jan 20, 2012 at 06:19:46PM -0800, Ray Simard wrote:
> In this part of deshaking filter vf_deshake.c, dynamically-allocated
> array angles collects information when certain conditions are met while
> scanning an image for motion.
> 
>    pos = 0;
>    for (y = deshake->ry; y < height - deshake->ry - ...
>         for (x = deshake->rx; x < width - deshake->rx -  ...
>     ...
>                     if (x > deshake->rx && y > deshake->ry)
>                         angles[pos++] = block_angle(x, y, 0, 0, &mv);
> 
>                     center_x += mv.x;
>                     center_y += mv.y;
>                 }
>             }
>         }
>     }
> 
>     pos = FFMAX(1, pos);
> 
>     center_x /= pos;
>     center_y /= pos;
> 
>     t->angle = clean_mean(angles, pos);
>     if (t->angle < 0.001)
>         t->angle = 0;
> 
> When the scan is done, function clean_mean makes a few adjustments and
> returns the mean of the values in the array.
> 
> Sometimes the scan finds nothing that qualifies for addition to
> the array and pos is zero after the loops.  The code above 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.
> I haven't run it through FATE yet.
> 
> Ray Simard
> rhs.ffmpeg at sylvan-glade.com
> 

>  vf_deshake.c |   17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 4f70afcffa37ef00e36581fd88e4cbced1fbce1c  vf_deshake-variable-used-uninitialized.patch
> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c

applied

please use "git format-patch" for future patches as it makes applying
them easier and also contains a commit message

Thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120121/987b61b2/attachment.asc>


More information about the ffmpeg-devel mailing list