[FFmpeg-devel] [PATCH] Odd, random-appearing crashes

Stefano Sabatini stefasab at gmail.com
Thu Jan 12 10:07:36 CET 2012


On date Wednesday 2012-01-11 21:10:26 -0800, Ray Simard encoded:
[...]
> >From 9e05afcf43dd1d561f19b66b44f700b9ffff6086 Mon Sep 17 00:00:00 2001
> From: Ray Simard <rhs.ffmpeg at sylvan-glade.com>
> Date: Wed, 11 Jan 2012 16:52:17 -0800
> Subject: [PATCH] 1. Variable used uninitialized causing crashes. 2. Unused
>  variable removed. Signed-off-by: Ray Simard
>  <rhs.ffmpeg at sylvan-glade.com>

Please split the patch in two, one for each logical change.

Something like this should work:

git reset --soft HEAD^ # undo previous commit, keep changes in the stage
git add -p             # 1. add interactively changes to the next commit index
git commit
                       # goto 1. for another commit

> ---
>  libavfilter/vf_deshake.c |   15 ++++-----------
>  1 files changed, 4 insertions(+), 11 deletions(-)
> 
> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
> index 7013f6c..8089698 100644
> --- a/libavfilter/vf_deshake.c
> +++ b/libavfilter/vf_deshake.c
> @@ -254,8 +254,6 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
>  
>      int pos;
>      double *angles = av_malloc(sizeof(*angles) * width * height / (16 * deshake->blocksize));
> -    double totalangles = 0;
> -
>      int center_x = 0, center_y = 0;
>      double p_x, p_y;
>  
> @@ -294,13 +292,6 @@ static void find_motion(DeshakeContext *deshake, uint8_t *src1, uint8_t *src2,
>      center_x /= pos;
>      center_y /= pos;
>  
> -    for (x = 0; x < pos; x++) {
> -        totalangles += angles[x];
> -    }
> -
> -    //av_log(NULL, AV_LOG_ERROR, "Angle: %lf\n", totalangles / (pos - 1));
> -    t->angle = totalangles / (pos - 1);
> -
>      t->angle = clean_mean(angles, pos);
>      if (t->angle < 0.001)
>          t->angle = 0;
> @@ -428,11 +419,13 @@ static void end_frame(AVFilterLink *link)
>      DeshakeContext *deshake = link->dst->priv;
>      AVFilterBufferRef *in  = link->cur_buf;
>      AVFilterBufferRef *out = link->dst->outputs[0]->out_buf;
> -    Transform t;
> +    Transform t, orig;
>      float matrix[9];
>      float alpha = 2.0 / deshake->refcount;
>      char tmp[256];
> -    Transform orig;
> +
> +    memset(&t,0,sizeof(t));
> +    memset(&orig,0,sizeof(orig));

Transform t = {0}, orig = {0};

should do it as well (and is more compact).

>  
>      if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) {
>          // Find the most likely global motion for the current frame

Looks good to me otherwise, thanks.
-- 
FFmpeg = Free and Fundamental Mean Plastic Ecletic Gangster


More information about the ffmpeg-devel mailing list