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

Function validateMpeg

tests/fl/codec/decode_file.hpp:151–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151static void validateMpeg(const fl::vector<fl::u8>& data) {
152 fl::string error;
153 fl::Mpeg1Info info = fl::Mpeg1::parseMpeg1Info(data, &error);
154 FL_CHECK_MESSAGE(info.isValid, "MPEG1 metadata parse failed: " << error);
155 if (info.isValid) {
156 FL_CHECK_GT(info.width, 0);
157 FL_CHECK_GT(info.height, 0);
158 FL_MESSAGE("MPEG1: " << info.width << "x" << info.height
159 << " fps=" << info.frameRate);
160 }
161
162 if (fl::Mpeg1::isSupported()) {
163 fl::Mpeg1Config config;
164 config.mode = fl::Mpeg1Config::SingleFrame;
165 fl::string dec_error;
166 auto decoder = fl::Mpeg1::createDecoder(config, &dec_error);
167 FL_REQUIRE_MESSAGE(decoder, "MPEG1 decoder creation failed: " << dec_error);
168 auto stream = fl::make_shared<fl::memorybuf>(data.size());
169 stream->write(data);
170 FL_CHECK(decoder->begin(stream));
171 auto result = decoder->decode();
172 if (result == fl::DecodeResult::Success) {
173 fl::Frame frame = decoder->getCurrentFrame();
174 FL_CHECK(frame.isValid());
175 FL_CHECK_GT(frame.getWidth(), 0);
176 FL_CHECK_GT(frame.getHeight(), 0);
177 FL_MESSAGE("MPEG1 first frame: " << frame.getWidth() << "x" << frame.getHeight());
178 }
179 decoder->end();
180 } else {
181 FL_MESSAGE("MPEG1 decoder not supported on this platform");
182 }
183}
184
185static void validateGif(const fl::vector<fl::u8>& data) {
186 fl::string error;

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