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

Function processMpeg1

examples/Codec/codec_processor.cpp:148–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void processMpeg1() {
149 Serial.println("\n=== Processing MPEG1 ===");
150
151 if (!fl::Mpeg1::isSupported()) {
152 Serial.println("MPEG1 decoding not supported on this platform");
153 return;
154 }
155
156 // Copy data from PROGMEM to RAM
157 fl::vector<fl::u8> mpegData(CodecData::sampleMpeg1DataLength);
158 fl::memcopy(mpegData.data(), CodecData::sampleMpeg1Data, CodecData::sampleMpeg1DataLength);
159
160 // Configure MPEG1 decoder
161 fl::Mpeg1Config config;
162 config.mode = fl::Mpeg1Config::SingleFrame;
163 config.targetFps = TARGET_FPS;
164 config.looping = false;
165 config.skipAudio = true;
166
167 // Create decoder
168 fl::string error_msg;
169 fl::shared_ptr<fl::IDecoder> decoder = fl::Mpeg1::createDecoder(config, &error_msg);
170
171 if (!decoder) {
172 Serial.print("Failed to create MPEG1 decoder: ");
173 Serial.println(error_msg.c_str());
174 return;
175 }
176
177 // Create byte stream from data
178 auto stream = fl::make_shared<fl::memorybuf>(mpegData.size());
179 stream->write(mpegData);
180
181 // Begin decoding
182 if (!decoder->begin(stream)) {
183 fl::string error;
184 decoder->hasError(&error);
185 Serial.print("Failed to begin MPEG1 decoding: ");
186 Serial.println(error.c_str());
187 return;
188 }
189
190 // Decode first frame
191 fl::DecodeResult result = decoder->decode();
192
193 if (result == fl::DecodeResult::Success) {
194 fl::Frame frame = decoder->getCurrentFrame();
195 if (frame.isValid()) {
196 displayFrameOnLEDs(frame);
197 showDecodedMessage("MPEG1 decoded successfully!");
198 } else {
199 Serial.println("Invalid MPEG1 frame received");
200 }
201 } else {
202 fl::string error;
203 decoder->hasError(&error);
204 Serial.print("MPEG1 frame decode error: ");
205 Serial.println(error.c_str());

Callers

nothing calls this directly

Calls 15

memcopyFunction · 0.85
displayFrameOnLEDsFunction · 0.85
showDecodedMessageFunction · 0.85
printlnMethod · 0.45
dataMethod · 0.45
printMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
beginMethod · 0.45
hasErrorMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected