// Copyright 2020 BitBank Software, Inc. All Rights Reserved. // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //=========================================================================== #ifndef __ANIMATEDGIF__ #define __ANIMATEDGIF__ #include "../../lv_conf_internal.h" #if LV_USE_GIF #include "../../misc/lv_fs.h" // // GIF Animator // Written by Larry Bank // Copyright (c) 2020 BitBank Software, Inc. // bitbank@pobox.com // // Designed to decode images up to 480x320 on MCUs // using less than 22K of RAM // ...and decode any sized image when more RAM is available // // ** NEW ** // Turbo mode added Feb 18, 2024. This option decodes images // up to 30x faster if there is enough RAM (48K + full framebuffer) // /* GIF Defines and variables */ #define MAX_CHUNK_SIZE 255 // // These 2 macros can be changed to limit the amount of RAM // required by the decoder. For example, decoding 1-bit images to // a 128x32 display will not need a max code size of 12 nor a palette // with 256 entries // #define TURBO_BUFFER_SIZE 0x6100 // If you intend to decode generic GIFs, you want this value to be 12. If you are using GIFs solely for animations in // your own project, and you control the GIFs you intend to play, then you can save additional RAM here: // the decoder must reserve a minimum of 4 byte * (1<10kB RAM, but you will not be able to decode arbitrary // images anymore. One application to craft such GIFs can be found here (use option -d) // https://create.stephan-brumme.com/flexigif-lossless-gif-lzw-optimization/ #define MAX_CODE_SIZE 12 #define MAX_COLORS 256 #define MAX_WIDTH 480 #define LZW_BUF_SIZE (6*MAX_CHUNK_SIZE) #define LZW_HIGHWATER (4*MAX_CHUNK_SIZE) // This buffer is used to store the pixel sequence in reverse order // it needs to be large enough to hold the longest possible // sequence (1<