diff mbox series

[FFmpeg-devel,2/4] mm: decode partial palette

Message ID e721b4d0a464400b233205e15163d33148e1824a.1717837373.git.pross@xvid.org
State New
Headers show
Series [FFmpeg-devel,1/4] mm: set audio pts proportionally to audio offset | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Peter Ross June 8, 2024, 9:05 a.m. UTC
---
palette decoding now conforms to description at https://wiki.multimedia.cx/index.php/IBM_PhotoMotion

 libavcodec/mmvideo.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Andreas Rheinhardt June 8, 2024, 1:47 p.m. UTC | #1
Peter Ross:
> ---
> palette decoding now conforms to description at https://wiki.multimedia.cx/index.php/IBM_PhotoMotion
> 
>  libavcodec/mmvideo.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c
> index 3038d9ea92..b5b6ffd25b 100644
> --- a/libavcodec/mmvideo.c
> +++ b/libavcodec/mmvideo.c
> @@ -79,12 +79,10 @@ static av_cold int mm_decode_init(AVCodecContext *avctx)
>  static void mm_decode_pal(MmContext *s)
>  {
>      int i;
> -
> -    bytestream2_skip(&s->gb, 4);
> -    for (i = 0; i < 128; i++) {
> -        s->palette[i] = 0xFFU << 24 | bytestream2_get_be24(&s->gb);
> -        s->palette[i+128] = s->palette[i]<<2;
> -    }
> +    int start = bytestream2_get_le16(&s->gb);
> +    int count = bytestream2_get_le16(&s->gb);
> +    for (i = 0; i < count; i++)

You can use loop-scope for the iterator here and save a line.

> +        s->palette[start+i] = 0xFFU << 24 | (bytestream2_get_be24(&s->gb) << 2);
>  }
>  
>  /**
diff mbox series

Patch

diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c
index 3038d9ea92..b5b6ffd25b 100644
--- a/libavcodec/mmvideo.c
+++ b/libavcodec/mmvideo.c
@@ -79,12 +79,10 @@  static av_cold int mm_decode_init(AVCodecContext *avctx)
 static void mm_decode_pal(MmContext *s)
 {
     int i;
-
-    bytestream2_skip(&s->gb, 4);
-    for (i = 0; i < 128; i++) {
-        s->palette[i] = 0xFFU << 24 | bytestream2_get_be24(&s->gb);
-        s->palette[i+128] = s->palette[i]<<2;
-    }
+    int start = bytestream2_get_le16(&s->gb);
+    int count = bytestream2_get_le16(&s->gb);
+    for (i = 0; i < count; i++)
+        s->palette[start+i] = 0xFFU << 24 | (bytestream2_get_be24(&s->gb) << 2);
 }
 
 /**