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

◆ decodeStream()

bool fl::Jpeg::decodeStream ( const JpegConfig & config,
fl::filebuf_ptr input_stream,
Frame * frame,
fl::u32 max_time_per_chunk_ms = 4,
fl::function< bool(float)> progress_callback = {} )
static

Definition at line 443 of file jpeg.cpp.hpp.

448 {
449
450 if (!frame || !input_stream) {
451 return false;
452 }
453
454 auto decoder = createDecoder(config);
455
456 ProgressiveConfig prog_config;
457 prog_config.max_time_per_tick_ms = max_time_per_chunk_ms;
458 decoder->setProgressiveConfig(prog_config);
459
460 if (!decoder->begin(input_stream)) {
461 return false;
462 }
463
464 // Use callback-based decode with progress notifications
465 fl::optional<fl::function<bool()>> yield_func;
466 if (mProgresscallback) {
467 yield_func = fl::function<bool()>([&]() {
468 float progress = decoder->getProgress();
469 return !mProgresscallback(progress); // Yield if callback returns false
470 });
471 }
472 DecodeResult result = decoder->decode(yield_func);
473
475 Frame decoded = decoder->getCurrentFrame();
476
477 if (frame->getWidth() != decoded.getWidth() || frame->getHeight() != decoded.getHeight()) {
478 return false;
479 }
480
481 frame->copy(decoded);
482 return true;
483 }
484
485 return false;
486}
static JpegDecoderPtr createDecoder(const JpegConfig &config)
Definition jpeg.cpp.hpp:372
Optional< T > optional
Definition optional.h:16
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
DecodeResult
Definition idecoder.h:18

References fl::Frame::copy(), createDecoder(), fl::Frame::getHeight(), fl::Frame::getWidth(), fl::ProgressiveConfig::max_time_per_tick_ms, and fl::Success.

+ Here is the call graph for this function: