Gitweb links:

...log 
http://git.netsurf-browser.org/libnsgif.git/shortlog/49a2c4374ab846b4d4cce982ea61946ee664628a
...commit 
http://git.netsurf-browser.org/libnsgif.git/commit/49a2c4374ab846b4d4cce982ea61946ee664628a
...tree 
http://git.netsurf-browser.org/libnsgif.git/tree/49a2c4374ab846b4d4cce982ea61946ee664628a

The branch, master has been updated
       via  49a2c4374ab846b4d4cce982ea61946ee664628a (commit)
       via  cd27d786ddb1a1491ce28788504f4e99870ef955 (commit)
       via  f8f094ab59f9ae71767a2a01c35224da9a04d583 (commit)
      from  cc18507ae1ffe1753eb7dc66e26f9d8a9231cba6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libnsgif.git/commit/?id=49a2c4374ab846b4d4cce982ea61946ee664628a
commit 49a2c4374ab846b4d4cce982ea61946ee664628a
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    API: Add function to control handling of small frame delays.
    
    By default we match the mainstream behaviour, and this new
    call allows that to be overriden by the client.
    
    Note this only affects animations that are managed by LibNSGIF
    via nsgif_frame_prepare().

diff --git a/include/nsgif.h b/include/nsgif.h
index 03f9b16..a02597c 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -408,4 +408,35 @@ const nsgif_frame_info_t *nsgif_get_frame_info(
                const nsgif_t *gif,
                uint32_t frame);
 
+/**
+ * Configure handling of small frame delays.
+ *
+ * Historically people created GIFs with a tiny frame delay, however the slow
+ * hardware of the time meant they actually played much slower. As computers
+ * sped up, to prevent animations playing faster than intended, decoders came
+ * to ignore overly small frame delays.
+ *
+ * By default a \ref nsgif_frame_prepare() managed animation will override
+ * frame delays of less than 2 centiseconds with a default frame delay of
+ * 10 centiseconds. This matches the behaviour of web browsers and other
+ * renderers.
+ *
+ * Both the minimum and the default values can be overridden for a given GIF
+ * by the client. To get frame delays exactly as specified by the GIF file, set
+ * \ref delay_min to zero.
+ *
+ * Note that this does not affect the frame delay in the frame info
+ * (\ref nsgif_frame_info_t) structure, which will always contain values
+ * specified by the GIF.
+ *
+ * \param[in]  gif            The \ref nsgif_t object to configure.
+ * \param[in]  delay_min      The minimum frame delay in centiseconds.
+ * \param[in]  delay_default  The delay to use if a frame delay is less than
+ *                            \ref delay_min.
+ */
+void nsgif_set_frame_delay_behaviour(
+               nsgif_t *gif,
+               uint16_t delay_min,
+               uint16_t delay_default);
+
 #endif
diff --git a/src/gif.c b/src/gif.c
index 181e4e6..509883e 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -1450,6 +1450,16 @@ nsgif_error nsgif_create(
        return NSGIF_OK;
 }
 
+/* exported function documented in nsgif.h */
+void nsgif_set_frame_delay_behaviour(
+               nsgif_t *gif,
+               uint16_t delay_min,
+               uint16_t delay_default)
+{
+       gif->delay_min = delay_min;
+       gif->delay_default = delay_default;
+}
+
 /**
  * Read GIF header.
  *


commitdiff 
http://git.netsurf-browser.org/libnsgif.git/commit/?id=cd27d786ddb1a1491ce28788504f4e99870ef955
commit cd27d786ddb1a1491ce28788504f4e99870ef955
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    GIF: Clarify minimum frame delay handling.

diff --git a/src/gif.c b/src/gif.c
index 91999d3..181e4e6 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -20,6 +20,16 @@
 /** Maximum colour table size */
 #define NSGIF_MAX_COLOURS 256
 
+/** Default minimum allowable frame delay in cs. */
+#define NSGIF_FRAME_DELAY_MIN 2
+
+/**
+ * Default frame delay to apply.
+ *
+ * Used when a frame delay lower than the minimum is requested.
+ */
+#define NSGIF_FRAME_DELAY_DEFAULT 10
+
 /** GIF frame data */
 typedef struct nsgif_frame {
        struct nsgif_frame_info info;
@@ -65,7 +75,10 @@ struct nsgif {
        /** currently decoded image; stored as bitmap from bitmap_create 
callback */
        nsgif_bitmap_t *frame_image;
 
+       /** Minimum allowable frame delay. */
        uint16_t delay_min;
+
+       /** Frame delay to apply when delay is less than \ref delay_min. */
        uint16_t delay_default;
 
        /** number of animation loops so far */
@@ -1428,8 +1441,8 @@ nsgif_error nsgif_create(
        gif->decoded_frame = NSGIF_FRAME_INVALID;
        gif->prev_index = NSGIF_FRAME_INVALID;
 
-       gif->delay_min = 2;
-       gif->delay_default = 10;
+       gif->delay_min = NSGIF_FRAME_DELAY_MIN;
+       gif->delay_default = NSGIF_FRAME_DELAY_DEFAULT;
 
        gif->colour_layout = nsgif__bitmap_fmt_to_colour_layout(bitmap_fmt);
 


commitdiff 
http://git.netsurf-browser.org/libnsgif.git/commit/?id=f8f094ab59f9ae71767a2a01c35224da9a04d583
commit f8f094ab59f9ae71767a2a01c35224da9a04d583
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    API: Don't expose loop_count.
    
    It is internal state for a libnsgif managed animation, not
    information about the GIF.

diff --git a/include/nsgif.h b/include/nsgif.h
index 0ee00e8..03f9b16 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -343,8 +343,6 @@ typedef struct nsgif_info {
        uint32_t frame_count;
        /** number of times to play animation (zero means loop forever) */
        int loop_max;
-       /** number of animation loops so far */
-       int loop_count;
        /** background colour in same pixel format as \ref nsgif_bitmap_t. */
        uint32_t background;
 } nsgif_info_t;
diff --git a/src/gif.c b/src/gif.c
index 84df50e..91999d3 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -68,6 +68,9 @@ struct nsgif {
        uint16_t delay_min;
        uint16_t delay_default;
 
+       /** number of animation loops so far */
+       int loop_count;
+
        /** number of frames partially decoded */
        uint32_t frame_count_partial;
 
@@ -1737,7 +1740,7 @@ static inline bool nsgif__animation_complete(int count, 
int max)
 nsgif_error nsgif_reset(
                nsgif_t *gif)
 {
-       gif->info.loop_count = 0;
+       gif->loop_count = 0;
        gif->frame = NSGIF_FRAME_INVALID;
 
        return NSGIF_OK;
@@ -1765,7 +1768,7 @@ nsgif_error nsgif_frame_prepare(
        }
 
        if (nsgif__animation_complete(
-                       gif->info.loop_count,
+                       gif->loop_count,
                        gif->info.loop_max)) {
                return NSGIF_ERR_ANIMATION_END;
        }
@@ -1776,7 +1779,7 @@ nsgif_error nsgif_frame_prepare(
        }
 
        if (gif->frame != NSGIF_FRAME_INVALID && frame < gif->frame) {
-               gif->info.loop_count++;
+               gif->loop_count++;
        }
 
        if (gif->info.frame_count == 1) {
@@ -1791,7 +1794,7 @@ nsgif_error nsgif_frame_prepare(
 
                if (frame_next < frame) {
                        if (nsgif__animation_complete(
-                                       gif->info.loop_count + 1,
+                                       gif->loop_count + 1,
                                        gif->info.loop_max)) {
                                delay = NSGIF_INFINITE;
                        }


-----------------------------------------------------------------------

Summary of changes:
 include/nsgif.h |   33 +++++++++++++++++++++++++++++++--
 src/gif.c       |   38 ++++++++++++++++++++++++++++++++------
 2 files changed, 63 insertions(+), 8 deletions(-)

diff --git a/include/nsgif.h b/include/nsgif.h
index 0ee00e8..a02597c 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -343,8 +343,6 @@ typedef struct nsgif_info {
        uint32_t frame_count;
        /** number of times to play animation (zero means loop forever) */
        int loop_max;
-       /** number of animation loops so far */
-       int loop_count;
        /** background colour in same pixel format as \ref nsgif_bitmap_t. */
        uint32_t background;
 } nsgif_info_t;
@@ -410,4 +408,35 @@ const nsgif_frame_info_t *nsgif_get_frame_info(
                const nsgif_t *gif,
                uint32_t frame);
 
+/**
+ * Configure handling of small frame delays.
+ *
+ * Historically people created GIFs with a tiny frame delay, however the slow
+ * hardware of the time meant they actually played much slower. As computers
+ * sped up, to prevent animations playing faster than intended, decoders came
+ * to ignore overly small frame delays.
+ *
+ * By default a \ref nsgif_frame_prepare() managed animation will override
+ * frame delays of less than 2 centiseconds with a default frame delay of
+ * 10 centiseconds. This matches the behaviour of web browsers and other
+ * renderers.
+ *
+ * Both the minimum and the default values can be overridden for a given GIF
+ * by the client. To get frame delays exactly as specified by the GIF file, set
+ * \ref delay_min to zero.
+ *
+ * Note that this does not affect the frame delay in the frame info
+ * (\ref nsgif_frame_info_t) structure, which will always contain values
+ * specified by the GIF.
+ *
+ * \param[in]  gif            The \ref nsgif_t object to configure.
+ * \param[in]  delay_min      The minimum frame delay in centiseconds.
+ * \param[in]  delay_default  The delay to use if a frame delay is less than
+ *                            \ref delay_min.
+ */
+void nsgif_set_frame_delay_behaviour(
+               nsgif_t *gif,
+               uint16_t delay_min,
+               uint16_t delay_default);
+
 #endif
diff --git a/src/gif.c b/src/gif.c
index 84df50e..509883e 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -20,6 +20,16 @@
 /** Maximum colour table size */
 #define NSGIF_MAX_COLOURS 256
 
+/** Default minimum allowable frame delay in cs. */
+#define NSGIF_FRAME_DELAY_MIN 2
+
+/**
+ * Default frame delay to apply.
+ *
+ * Used when a frame delay lower than the minimum is requested.
+ */
+#define NSGIF_FRAME_DELAY_DEFAULT 10
+
 /** GIF frame data */
 typedef struct nsgif_frame {
        struct nsgif_frame_info info;
@@ -65,9 +75,15 @@ struct nsgif {
        /** currently decoded image; stored as bitmap from bitmap_create 
callback */
        nsgif_bitmap_t *frame_image;
 
+       /** Minimum allowable frame delay. */
        uint16_t delay_min;
+
+       /** Frame delay to apply when delay is less than \ref delay_min. */
        uint16_t delay_default;
 
+       /** number of animation loops so far */
+       int loop_count;
+
        /** number of frames partially decoded */
        uint32_t frame_count_partial;
 
@@ -1425,8 +1441,8 @@ nsgif_error nsgif_create(
        gif->decoded_frame = NSGIF_FRAME_INVALID;
        gif->prev_index = NSGIF_FRAME_INVALID;
 
-       gif->delay_min = 2;
-       gif->delay_default = 10;
+       gif->delay_min = NSGIF_FRAME_DELAY_MIN;
+       gif->delay_default = NSGIF_FRAME_DELAY_DEFAULT;
 
        gif->colour_layout = nsgif__bitmap_fmt_to_colour_layout(bitmap_fmt);
 
@@ -1434,6 +1450,16 @@ nsgif_error nsgif_create(
        return NSGIF_OK;
 }
 
+/* exported function documented in nsgif.h */
+void nsgif_set_frame_delay_behaviour(
+               nsgif_t *gif,
+               uint16_t delay_min,
+               uint16_t delay_default)
+{
+       gif->delay_min = delay_min;
+       gif->delay_default = delay_default;
+}
+
 /**
  * Read GIF header.
  *
@@ -1737,7 +1763,7 @@ static inline bool nsgif__animation_complete(int count, 
int max)
 nsgif_error nsgif_reset(
                nsgif_t *gif)
 {
-       gif->info.loop_count = 0;
+       gif->loop_count = 0;
        gif->frame = NSGIF_FRAME_INVALID;
 
        return NSGIF_OK;
@@ -1765,7 +1791,7 @@ nsgif_error nsgif_frame_prepare(
        }
 
        if (nsgif__animation_complete(
-                       gif->info.loop_count,
+                       gif->loop_count,
                        gif->info.loop_max)) {
                return NSGIF_ERR_ANIMATION_END;
        }
@@ -1776,7 +1802,7 @@ nsgif_error nsgif_frame_prepare(
        }
 
        if (gif->frame != NSGIF_FRAME_INVALID && frame < gif->frame) {
-               gif->info.loop_count++;
+               gif->loop_count++;
        }
 
        if (gif->info.frame_count == 1) {
@@ -1791,7 +1817,7 @@ nsgif_error nsgif_frame_prepare(
 
                if (frame_next < frame) {
                        if (nsgif__animation_complete(
-                                       gif->info.loop_count + 1,
+                                       gif->loop_count + 1,
                                        gif->info.loop_max)) {
                                delay = NSGIF_INFINITE;
                        }


-- 
NetSurf GIF Decoder
_______________________________________________
netsurf-commits mailing list -- netsurf-commits@netsurf-browser.org
To unsubscribe send an email to netsurf-commits-le...@netsurf-browser.org

Reply via email to