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

◆ processChunk()

bool fl::third_party::TJpgInstanceDecoder::processChunk ( )

Definition at line 140 of file driver.cpp.hpp.

140 {
142 return false;
143 }
144
147 }
148
149 startTick();
150
151 if (use_progressive_) {
152 // Progressive decoding with time budget
153 fl::u8 more_data_needed = 0;
154 fl::u8 processing_complete = 0;
155
159 embedded_tjpg_.jpg_scale,
160 progressive_config_.max_mcus_per_tick,
161 &more_data_needed,
162 &processing_complete
163 );
164
165 if (processing_complete) {
167 progress_ = 1.0f;
168 return false;
169 }
170
171 if (res == (JRESULT)JDR_SUSPEND) {
172 // Time budget exceeded, more work remains
173 // Update progress
174 if (progressive_state_.total_mcus > 0) {
175 progress_ = (float)progressive_state_.mcus_processed /
176 (float)progressive_state_.total_mcus;
177 }
178 return true; // More work to do
179 }
180
181 if (res != JDR_OK) {
182 char err_str[32];
183 fl::snprintf(err_str, sizeof(err_str), "Progressive decode error: %d", (int)res);
184 setError(err_str);
185 return false;
186 }
187
188 return true; // Continue processing
189 } else {
190 // Non-progressive decoding (all at once)
191 JDEC* jdec = reinterpret_cast<JDEC*>(embedded_tjpg_.workspace);
192
193 JRESULT res = jd_decomp(jdec, outputCallback, embedded_tjpg_.jpg_scale);
194
195 if (res == JDR_OK) {
196 // Check if any pixels were actually set by sampling the first pixel
197 CRGB* pixels = current_frame_->rgb().data();
198 fl::u8 first_pixel_sum = 0;
199 if (pixels) {
200 first_pixel_sum = pixels[0].r + pixels[0].g + pixels[0].b;
201 }
202
203 char debug_str[64];
204 fl::snprintf(debug_str, sizeof(debug_str), "JPEG decode OK, first_pixel_sum=%d", first_pixel_sum);
205
206 // If no pixels were set, this indicates the output callback wasn't called
207 if (first_pixel_sum == 0) {
208 setError("JPEG decode succeeded but output callback was not called");
209 return false;
210 }
211
213 progress_ = 1.0f;
214 return false; // Complete
215 } else {
216 char err_str[32];
217 fl::snprintf(err_str, sizeof(err_str), "Decode error: %d", (int)res);
218 setError(err_str);
219 return false;
220 }
221 }
222}
struct fl::third_party::TJpgInstanceDecoder::EmbeddedTJpgState embedded_tjpg_
JDEC_Progressive progressive_state_
Definition driver.h:67
fl::shared_ptr< Frame > current_frame_
Definition driver.h:75
TJpgProgressiveConfig progressive_config_
Definition driver.h:71
void setError(const fl::string &msg) FL_NOEXCEPT
static int outputCallback(JDEC *jd, void *bitmap, JRECT *rect) FL_NOEXCEPT
unsigned char u8
Definition coder.h:132
JRESULT jd_decomp(JDEC *jd, int(*outfunc)(JDEC *, void *, JRECT *), uint8_t scale) FL_NOEXCEPT
JRESULT jd_decomp_progressive(JDEC_Progressive *jpd, int(*outfunc)(JDEC *, void *, JRECT *), uint8_t scale, uint16_t max_mcus_per_call, uint8_t *more_data_needed, uint8_t *processing_complete) FL_NOEXCEPT
struct JDEC JDEC
Definition tjpgd.h:49
fl::CRGB CRGB
Definition video.h:15
int snprintf(char *buffer, fl::size size, const char *format, const Args &... args) FL_NOEXCEPT
Snprintf-like formatting function that writes to a buffer.
Definition stdio.h:666

References Complete, current_frame_, Decoding, embedded_tjpg_, Error, FL_NOEXCEPT, HeaderParsed, fl::third_party::jd_decomp(), fl::third_party::jd_decomp_progressive(), fl::third_party::JDR_OK, fl::third_party::JDR_SUSPEND, outputCallback(), progress_, progressive_config_, progressive_state_, setError(), fl::snprintf(), startTick(), state_, and use_progressive_.

+ Here is the call graph for this function: