[FFmpeg-devel] [PATCH] vhook/{fish, ppm}.c: Fix compilation warnings

Patrik Kullman patrik
Sun Feb 22 10:18:14 CET 2009


On Sat, 2009-02-21 at 22:11 +0100, Diego Biurrun wrote:
> On Mon, Feb 16, 2009 at 10:32:59AM +0100, Patrik Kullman wrote:
> > 
> > Moving the last part of the function to within the same if-statement to
> > prevent uninitialization of the out_* ints.
> > 
> > --- vhook/ppm.c	(revision 17319)
> > +++ vhook/ppm.c	(working copy)
> > @@ -318,33 +323,38 @@
> >                  ptr += picture2.linesize[ 0 ];
> >              }
> >          }
> > -    }
> >  
> > -    /* Convert the returned PPM back to the input format */
> > -    if ( !err )
> > -    {
> > -        /* The out_width/out_height returned from the PPM
> > -         * filter won't necessarily be the same as width and height
> > -         * but it will be scaled anyway to width/height.
> > -         */
> > -        av_log(NULL, AV_LOG_DEBUG,
> > +        /* Convert the returned PPM back to the input format */
> > +
> > +        if ( !err )
> > +        {
> > +            /* The out_width/out_height returned from the PPM
> > +             * filter won't necessarily be the same as width and height
> > +             * but it will be scaled anyway to width/height.
> > +             */
> > +            av_log(NULL, AV_LOG_DEBUG,
> >                    "PPM vhook: Input dimensions: %d x %d Output dimensions: %d x %d\n",
> >                    width, height, out_width, out_height);
> > -        ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
> > +            ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
> >                                          out_width, out_height, PIX_FMT_RGB24,
> >                                          width,     height,     pix_fmt,
> >                                          sws_flags, NULL, NULL, NULL);
> > -        if (ci->fromRGB_convert_ctx == NULL) {
> > -            av_log(NULL, AV_LOG_ERROR,
> > +            if (ci->fromRGB_convert_ctx == NULL) {
> > +                av_log(NULL, AV_LOG_ERROR,
> >                     "Cannot initialize the fromRGB conversion context\n");
> > -            return;
> > -        }
> > +                return;
> > +            }
> >  
> >  // img_convert parameters are          2 first destination, then 4 source
> >  // sws_scale   parameters are context, 4 first source,      then 2 destination
> > -        sws_scale(ci->fromRGB_convert_ctx,
> > +            sws_scale(ci->fromRGB_convert_ctx,
> >                   picture2.data, picture2.linesize, 0, out_height,
> >                   picture->data, picture->linesize);
> > +        }
> > +    } else {
> > +        av_log(NULL, AV_LOG_ERROR,
> > +               "Read PPM header failed\n");
> > +        return;
> 
> This is at least 90% cosmetics.
> 
> Some parts of this patch are now applied, resend whatever is missing and
> you want to see applied.

Well, I moved the last if-statement to within the previous if-statement,
which coding style wise made me indent most of the code.

This is to make sure that the PPM could be read before trying to convert
it, thus making sure that out_height / out_width is set in any part of
the function that tries to use it.

Attaching new patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ffmpeg-vhook-ppm.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090222/eb393cce/attachment.bin>



More information about the ffmpeg-devel mailing list