[vlc-devel] [PATCH 09/10] avcodec: video: fix comparing signed/unsigned resolutions

Rémi Denis-Courmont remi at remlab.net
Sun Sep 4 16:38:22 CEST 2016


Le dimanche 4 septembre 2016, 15:30:13 ileoo at videolan.org a écrit :
> From: Ilkka Ollakka <ileoo at videolan.org>
> 
> Cleared up the comparision as it was actually just comparing if
> visible_width is different to width, with few extra steps taken previously.
> ---
>  modules/codec/avcodec/video.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
> index 5e70ce0..a9435c1 100644
> --- a/modules/codec/avcodec/video.c
> +++ b/modules/codec/avcodec/video.c
> @@ -339,16 +339,14 @@ static int OpenVideoCodec( decoder_t *p_dec )
>          }
>      }
> 
> -    p_sys->p_context->width  = p_dec->fmt_in.video.i_visible_width;
> -    p_sys->p_context->height = p_dec->fmt_in.video.i_visible_height;
> -    if (p_sys->p_context->width  == 0)
> -        p_sys->p_context->width  = p_dec->fmt_in.video.i_width;
> -    else if (p_sys->p_context->width != p_dec->fmt_in.video.i_width)
> +    p_sys->p_context->coded_width  = p_sys->p_context->width  =
> p_dec->fmt_in.video.i_visible_width; +    p_sys->p_context->coded_height =
> p_sys->p_context->height = p_dec->fmt_in.video.i_visible_height; +
> +    if (p_dec->fmt_in.video.i_visible_width != p_dec->fmt_in.video.i_width)
> p_sys->p_context->coded_width = p_dec->fmt_in.video.i_width; -    if
> (p_sys->p_context->height == 0)
> -        p_sys->p_context->height = p_dec->fmt_in.video.i_height;
> -    else if (p_sys->p_context->height != p_dec->fmt_in.video.i_height)
> +    if (p_dec->fmt_in.video.i_visible_height !=
> p_dec->fmt_in.video.i_height) p_sys->p_context->coded_height =
> p_dec->fmt_in.video.i_height; +
>      p_sys->p_context->bits_per_coded_sample =
> p_dec->fmt_in.video.i_bits_per_pixel; p_sys->pix_fmt = AV_PIX_FMT_NONE;
>      p_sys->profile = -1;

This is:

a = b;
if (b != c)
    a = c;

which can be simplified to:

a = c;

(and optimizing compilers might even do that).

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list