diff mbox

[FFmpeg-devel,2/5] avcodec/anm: fix palette alpha

Message ID 20180424190501.23908-2-cus@passwd.hu
State Accepted
Commit e894d958fce6f47cbe1e4a5e3f2c74af47057125
Headers show

Commit Message

Marton Balint April 24, 2018, 7:04 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/anm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marton Balint April 26, 2018, 7:21 p.m. UTC | #1
On Tue, 24 Apr 2018, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavcodec/anm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/anm.c b/libavcodec/anm.c
> index 72684189bb..ab6a3994e9 100644
> --- a/libavcodec/anm.c
> +++ b/libavcodec/anm.c
> @@ -54,7 +54,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>
>     bytestream2_skipu(&s->gb, 16 * 8);
>     for (i = 0; i < 256; i++)
> -        s->palette[i] = bytestream2_get_le32u(&s->gb);
> +        s->palette[i] = (0xFFU << 24) | bytestream2_get_le32u(&s->gb);
>
>     return 0;
> }

Meanwhile I found some "documentation" about the file format:

http://ftp.textmod.es/mirror/ftp.shroo.ms/textfiles.com/programming/FORMATS/animfile.txt

It says:

Following the anim file header is the color palette:

ULONG palette[256] Color palette arranged as 3 bytes each of Red Green
                    & Blue and one unused byte.

So the extra byte indeed seems unused and it is not related to 
transparency.

Regards,
Marton
Carl Eugen Hoyos April 26, 2018, 10:40 p.m. UTC | #2
2018-04-24 21:04 GMT+02:00, Marton Balint <cus@passwd.hu>:
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
>  libavcodec/anm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/anm.c b/libavcodec/anm.c
> index 72684189bb..ab6a3994e9 100644
> --- a/libavcodec/anm.c
> +++ b/libavcodec/anm.c
> @@ -54,7 +54,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
>
>      bytestream2_skipu(&s->gb, 16 * 8);
>      for (i = 0; i < 256; i++)
> -        s->palette[i] = bytestream2_get_le32u(&s->gb);
> +        s->palette[i] = (0xFFU << 24) | bytestream2_get_le32u(&s->gb);

This is also ok just by looking at our samples.

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavcodec/anm.c b/libavcodec/anm.c
index 72684189bb..ab6a3994e9 100644
--- a/libavcodec/anm.c
+++ b/libavcodec/anm.c
@@ -54,7 +54,7 @@  static av_cold int decode_init(AVCodecContext *avctx)
 
     bytestream2_skipu(&s->gb, 16 * 8);
     for (i = 0; i < 256; i++)
-        s->palette[i] = bytestream2_get_le32u(&s->gb);
+        s->palette[i] = (0xFFU << 24) | bytestream2_get_le32u(&s->gb);
 
     return 0;
 }