[FFmpeg-devel] [PATCH] Fix warnings in decode_significance_x86 and decode_significance_8x8_x86 (in h264_i386.h)

Måns Rullgård mans
Sun Jun 27 22:28:33 CEST 2010


Eli Friedman <eli.friedman at gmail.com> writes:

> Patch attached; adds extra casts so gcc doesn't warn about truncating
> pointers.

Do you mean "implicit conversion of pointer to integer of different size"?

> Someone else should double-check that this is the intent, though;
> truncating pointers is an unusual operation, although it looks like
> it's okay in this case.
>
> -Eli
>
> Index: libavcodec/x86/h264_i386.h
> ===================================================================
> --- libavcodec/x86/h264_i386.h	(revision 23832)
> +++ libavcodec/x86/h264_i386.h	(working copy)
> @@ -38,8 +38,8 @@
>                                     uint8_t *significant_coeff_ctx_base,
>                                     int *index){
>      void *end= significant_coeff_ctx_base + max_coeff - 1;
> -    int minusstart= -(int)significant_coeff_ctx_base;
> -    int minusindex= 4-(int)index;
> +    int minusstart= -(int)(x86_reg)significant_coeff_ctx_base;
> +    int minusindex= 4-(int)(x86_reg)index;
>      int coeff_count;
>      __asm__ volatile(
>          "movl "RANGE    "(%3), %%esi            \n\t"
> @@ -91,7 +91,7 @@
>  static int decode_significance_8x8_x86(CABACContext *c,
>                                         uint8_t *significant_coeff_ctx_base,
>                                         int *index, const uint8_t *sig_off){
> -    int minusindex= 4-(int)index;
> +    int minusindex= 4-(int)(x86_reg)index;
>      int coeff_count;
>      x86_reg last=0;
>      __asm__ volatile(

Double casts are almost always the wrong solution.  It seems to me
that casting to intptr_t is the correct solution here.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list