MCPcopy Create free account
hub / github.com/FastLED/FastLED / validateGif

Function validateGif

tests/fl/codec/decode_file.hpp:185–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185static void validateGif(const fl::vector<fl::u8>& data) {
186 fl::string error;
187 fl::GifInfo info = fl::Gif::parseGifInfo(data, &error);
188 FL_CHECK_MESSAGE(info.isValid, "GIF metadata parse failed: " << error);
189 if (info.isValid) {
190 FL_CHECK_GT(info.width, 0);
191 FL_CHECK_GT(info.height, 0);
192 FL_MESSAGE("GIF: " << info.width << "x" << info.height
193 << " frames=" << info.frameCount);
194 }
195
196 if (fl::Gif::isSupported()) {
197 fl::GifConfig config;
198 config.mode = fl::GifConfig::SingleFrame;
199 config.format = fl::PixelFormat::RGB888;
200 fl::string dec_error;
201 auto decoder = fl::Gif::createDecoder(config, &dec_error);
202 FL_REQUIRE_MESSAGE(decoder, "GIF decoder creation failed: " << dec_error);
203 auto stream = fl::make_shared<fl::memorybuf>(data.size());
204 stream->write(data);
205 FL_REQUIRE(decoder->begin(stream));
206 auto result = decoder->decode();
207 if (result == fl::DecodeResult::Success) {
208 fl::Frame frame = decoder->getCurrentFrame();
209 FL_CHECK(frame.isValid());
210 FL_CHECK_GT(frame.getWidth(), 0);
211 FL_CHECK_GT(frame.getHeight(), 0);
212 FL_MESSAGE("GIF first frame: " << frame.getWidth() << "x" << frame.getHeight());
213 }
214 decoder->end();
215 } else {
216 FL_MESSAGE("GIF decoder not supported on this platform");
217 }
218}
219
220static void validateJpeg(const fl::vector<fl::u8>& data) {
221 if (fl::Jpeg::isSupported()) {

Callers 1

FL_TEST_FILEFunction · 0.85

Calls 9

sizeMethod · 0.45
writeMethod · 0.45
beginMethod · 0.45
decodeMethod · 0.45
getCurrentFrameMethod · 0.45
isValidMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected