[FFmpeg-devel] [PATCH]Simplify some palette calculations

Michael Niedermayer michaelni at gmx.at
Sun Nov 13 20:48:58 CET 2011


On Sun, Nov 13, 2011 at 08:11:57PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> As suggested by Reimar.
> 
> Please comment, Carl Eugen
[...]
> diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
> index 9111d17..b9bc22b 100644
> --- a/libavcodec/flicvideo.c
> +++ b/libavcodec/flicvideo.c
> @@ -150,7 +150,6 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
>      int color_packets;
>      int color_changes;
>      int color_shift;
> -    unsigned char r, g, b;
>  
>      int lines;
>      int compressed_lines;
> @@ -235,10 +234,8 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
>                      if ((unsigned)palette_ptr >= 256)
>                          palette_ptr = 0;
>  
> -                    r = buf[stream_ptr++] << color_shift;
> -                    g = buf[stream_ptr++] << color_shift;
> -                    b = buf[stream_ptr++] << color_shift;
> -                    entry = 0xFF << 24 | r << 16 | g << 8 | b;
> +                    entry = 0xFF << 24 | AV_RB24(&buf[stream_ptr]) << color_shift;

r/g/b are 8bit thus the << and assign to them truncated the bits
the new code does not.
I dont know if the change is ok or not


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- 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/20111113/3329ce87/attachment.asc>


More information about the ffmpeg-devel mailing list