FastLED 3.9.15
Loading...
Searching...
No Matches

◆ nsgif__parse_extension_application()

static nsgif_error fl::third_party::nsgif__parse_extension_application ( struct nsgif * gif,
const fl::u8 * data,
fl::size len )
static

Parse the application extension.

Parameters
[in]gifThe gif object we're decoding.
[in]dataThe data to decode.
[in]lenByte length of data.
Returns
NSGIF_ERR_END_OF_DATA if more data is needed, NSGIF_OK for success.

Definition at line 846 of file gif.cpp.hpp.

850{
851 /* 14-byte+ Application Extension is:
852 *
853 * +0 CHAR Application Extension Label
854 * +1 CHAR Block Size
855 * +2 8CHARS Application Identifier
856 * +10 3CHARS Appl. Authentication Code
857 * +13 1-256 Application Data (Data sub-blocks)
858 */
859 if (len < 17) {
861 }
862
863 if (nsgif__app_ext_is_loop_count(data, len)) {
864 enum {
865 EXT_LOOP_COUNT_SUB_BLOCK_SIZE = 0x03,
866 EXT_LOOP_COUNT_SUB_BLOCK_ID = 0x01,
867 };
868 if ((data[13] == EXT_LOOP_COUNT_SUB_BLOCK_SIZE) &&
869 (data[14] == EXT_LOOP_COUNT_SUB_BLOCK_ID)) {
870 gif->info.loop_max = data[15] | (data[16] << 8);
871
872 /* The value in the source data means repeat N times
873 * after the first implied play. A value of zero has
874 * the special meaning of loop forever. (The only way
875 * to play the animation once is not to have this
876 * extension at all. */
877 if (gif->info.loop_max > 0) {
878 gif->info.loop_max++;
879 }
880 }
881 }
882
883 return NSGIF_OK;
884}
@ NSGIF_ERR_END_OF_DATA
Unexpected end of GIF source data.
Definition nsgif.hpp:87
@ NSGIF_OK
Success.
Definition nsgif.hpp:62
static bool nsgif__app_ext_is_loop_count(const fl::u8 *data, fl::size len) FL_NOEXCEPT
Check an app ext identifier and authentication code for loop count extension.
Definition gif.cpp.hpp:816
int loop_max
number of times to play animation (zero means loop forever)
Definition nsgif.hpp:390
struct nsgif_info info
Definition gif.cpp.hpp:72

References FL_NOEXCEPT, nsgif__app_ext_is_loop_count(), NSGIF_ERR_END_OF_DATA, and NSGIF_OK.

Referenced by nsgif__parse_frame_extensions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: