Gitweb links:

...log 
http://git.netsurf-browser.org/libnsgif.git/shortlog/61934ff70402ffff91fbea9238cb1833ffa6cec6
...commit 
http://git.netsurf-browser.org/libnsgif.git/commit/61934ff70402ffff91fbea9238cb1833ffa6cec6
...tree 
http://git.netsurf-browser.org/libnsgif.git/tree/61934ff70402ffff91fbea9238cb1833ffa6cec6

The branch, master has been updated
       via  61934ff70402ffff91fbea9238cb1833ffa6cec6 (commit)
       via  c77c518aa14ed14ca1424cfa635ca8bf95cb0814 (commit)
       via  1091ca3fe72971d86b7be486e8f410f7c859ab98 (commit)
      from  716e0fae9a007e7c3c5d52cfb7354b139f851b6d (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=61934ff70402ffff91fbea9238cb1833ffa6cec6
commit 61934ff70402ffff91fbea9238cb1833ffa6cec6
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    GIF: Support AnimExts Looping Application Extension.
    
    The the NETSCAPE2.0 and ANIMEXTS1.0 extensions are identical.

diff --git a/src/gif.c b/src/gif.c
index d49cfe0..287b632 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -771,6 +771,34 @@ static nsgif_error nsgif__parse_extension_graphic_control(
 }
 
 /**
+ * Check an app ext identifier and authentication code for loop count 
extension.
+ *
+ * \param[in] data  The data to decode.
+ * \param[in] len   Byte length of data.
+ * \return true if extension is a loop count extension.
+ */
+static bool nsgif__app_ext_is_loop_count(
+               const uint8_t *data,
+               size_t len)
+{
+       enum {
+               EXT_LOOP_COUNT_BLOCK_SIZE = 0x0b,
+       };
+
+       assert(len > 13);
+       (void)(len);
+
+       if (data[1] == EXT_LOOP_COUNT_BLOCK_SIZE) {
+               if (strncmp((const char *)data + 2, "NETSCAPE2.0", 11) == 0 ||
+                   strncmp((const char *)data + 2, "ANIMEXTS1.0", 11) == 0) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+/**
  * Parse the application extension
  *
  * \param[in] gif   The gif object we're decoding.
@@ -796,12 +824,23 @@ static nsgif_error nsgif__parse_extension_application(
                return NSGIF_ERR_END_OF_DATA;
        }
 
-       if ((data[1] == 0x0b) &&
-           (strncmp((const char *)data + 2, "NETSCAPE2.0", 11) == 0) &&
-           (data[13] == 0x03) && (data[14] == 0x01)) {
-               gif->info.loop_max = data[15] | (data[16] << 8);
-               if (gif->info.loop_max > 0) {
-                       gif->info.loop_max++;
+       if (nsgif__app_ext_is_loop_count(data, len)) {
+               enum {
+                       EXT_LOOP_COUNT_SUB_BLOCK_SIZE = 0x03,
+                       EXT_LOOP_COUNT_SUB_BLOCK_ID   = 0x01,
+               };
+               if ((data[13] == EXT_LOOP_COUNT_SUB_BLOCK_SIZE) &&
+                   (data[14] == EXT_LOOP_COUNT_SUB_BLOCK_ID)) {
+                       gif->info.loop_max = data[15] | (data[16] << 8);
+
+                       /* The value in the source data means repeat N times
+                        * after the first implied play. A value of zero has
+                        * the special meaning of loop forever. (The only way
+                        * to play the animation once is  not to have this
+                        * extension at all. */
+                       if (gif->info.loop_max > 0) {
+                               gif->info.loop_max++;
+                       }
                }
        }
 


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

    GIF: Fix handling of loop count value in application extension.

diff --git a/src/gif.c b/src/gif.c
index 4fdaaac..d49cfe0 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -800,6 +800,9 @@ static nsgif_error nsgif__parse_extension_application(
            (strncmp((const char *)data + 2, "NETSCAPE2.0", 11) == 0) &&
            (data[13] == 0x03) && (data[14] == 0x01)) {
                gif->info.loop_max = data[15] | (data[16] << 8);
+               if (gif->info.loop_max > 0) {
+                       gif->info.loop_max++;
+               }
        }
 
        return NSGIF_OK;


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

    API: Docs: Document meaning of zero for loop_max gif info member.

diff --git a/include/nsgif.h b/include/nsgif.h
index c2a98c1..54dcd71 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -284,7 +284,7 @@ typedef struct nsgif_info {
        uint32_t height;
        /** number of frames decoded */
        uint32_t frame_count;
-       /** number of times to loop animation */
+       /** number of times to play animation (zero means loop forever) */
        int loop_max;
        /** number of animation loops so far */
        int loop_count;


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

Summary of changes:
 include/nsgif.h |    2 +-
 src/gif.c       |   50 ++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/include/nsgif.h b/include/nsgif.h
index c2a98c1..54dcd71 100644
--- a/include/nsgif.h
+++ b/include/nsgif.h
@@ -284,7 +284,7 @@ typedef struct nsgif_info {
        uint32_t height;
        /** number of frames decoded */
        uint32_t frame_count;
-       /** number of times to loop animation */
+       /** number of times to play animation (zero means loop forever) */
        int loop_max;
        /** number of animation loops so far */
        int loop_count;
diff --git a/src/gif.c b/src/gif.c
index 4fdaaac..287b632 100644
--- a/src/gif.c
+++ b/src/gif.c
@@ -771,6 +771,34 @@ static nsgif_error nsgif__parse_extension_graphic_control(
 }
 
 /**
+ * Check an app ext identifier and authentication code for loop count 
extension.
+ *
+ * \param[in] data  The data to decode.
+ * \param[in] len   Byte length of data.
+ * \return true if extension is a loop count extension.
+ */
+static bool nsgif__app_ext_is_loop_count(
+               const uint8_t *data,
+               size_t len)
+{
+       enum {
+               EXT_LOOP_COUNT_BLOCK_SIZE = 0x0b,
+       };
+
+       assert(len > 13);
+       (void)(len);
+
+       if (data[1] == EXT_LOOP_COUNT_BLOCK_SIZE) {
+               if (strncmp((const char *)data + 2, "NETSCAPE2.0", 11) == 0 ||
+                   strncmp((const char *)data + 2, "ANIMEXTS1.0", 11) == 0) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+/**
  * Parse the application extension
  *
  * \param[in] gif   The gif object we're decoding.
@@ -796,10 +824,24 @@ static nsgif_error nsgif__parse_extension_application(
                return NSGIF_ERR_END_OF_DATA;
        }
 
-       if ((data[1] == 0x0b) &&
-           (strncmp((const char *)data + 2, "NETSCAPE2.0", 11) == 0) &&
-           (data[13] == 0x03) && (data[14] == 0x01)) {
-               gif->info.loop_max = data[15] | (data[16] << 8);
+       if (nsgif__app_ext_is_loop_count(data, len)) {
+               enum {
+                       EXT_LOOP_COUNT_SUB_BLOCK_SIZE = 0x03,
+                       EXT_LOOP_COUNT_SUB_BLOCK_ID   = 0x01,
+               };
+               if ((data[13] == EXT_LOOP_COUNT_SUB_BLOCK_SIZE) &&
+                   (data[14] == EXT_LOOP_COUNT_SUB_BLOCK_ID)) {
+                       gif->info.loop_max = data[15] | (data[16] << 8);
+
+                       /* The value in the source data means repeat N times
+                        * after the first implied play. A value of zero has
+                        * the special meaning of loop forever. (The only way
+                        * to play the animation once is  not to have this
+                        * extension at all. */
+                       if (gif->info.loop_max > 0) {
+                               gif->info.loop_max++;
+                       }
+               }
        }
 
        return NSGIF_OK;


-- 
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