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

◆ jd_decomp_progressive()

JRESULT fl::third_party::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 )

Definition at line 1186 of file tjpgd.cpp.hpp.

1194{
1195 JDEC* jd = &jpd->base;
1196 unsigned int mx, my;
1197 uint16_t rst, rsc;
1198 JRESULT rc;
1199 uint16_t mcus_processed_this_call = 0;
1200
1201 // Initialize output flags
1202 if (more_data_needed) *more_data_needed = 0;
1203 if (processing_complete) *processing_complete = 0;
1204
1205 if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR;
1206 jd->scale = scale;
1207
1208 mx = jd->msx * 8; my = jd->msy * 8; /* Size of the MCU (pixel) */
1209
1210 // Initialize progressive state if first call
1211 if (!jpd->workspace_initialized) {
1212 jpd->current_mcu_x = 0;
1213 jpd->current_mcu_y = 0;
1214 jpd->mcus_processed = 0;
1215 jpd->total_mcus = ((jd->width + mx - 1) / mx) * ((jd->height + my - 1) / my);
1216 jpd->is_suspended = 0;
1217 jpd->workspace_initialized = 1;
1218
1219 // Initialize DC values and restart state
1220 jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0;
1221 rst = rsc = 0;
1222 }
1223
1224 rc = JDR_OK;
1225
1226 // Resume from where we left off
1227 unsigned int x = jpd->current_mcu_x * mx;
1228 unsigned int y = jpd->current_mcu_y * my;
1229 rst = jpd->mcus_processed % (jd->nrst ? jd->nrst : 1);
1230 rsc = jpd->mcus_processed / (jd->nrst ? jd->nrst : 1);
1231
1232 // Process MCUs with yield support
1233 while (y < jd->height) {
1234 while (x < jd->width) {
1235 // Process restart interval if enabled
1236 if (jd->nrst && rst++ == jd->nrst) {
1237 rc = restart(jd, rsc++);
1238 if (rc != JDR_OK) return rc;
1239 rst = 1;
1240 }
1241
1242 // Load and output single MCU
1243 rc = mcu_load(jd);
1244 if (rc != JDR_OK) return rc;
1245
1246 rc = mcu_output(jd, outfunc, x, y);
1247 if (rc != JDR_OK) return rc;
1248
1249 // Update progressive state
1250 jpd->mcus_processed++;
1251 mcus_processed_this_call++;
1252 x += mx;
1253 jpd->current_mcu_x++;
1254
1255 // Check if we should yield
1256 if (mcus_processed_this_call >= max_mcus_per_call) {
1257 jpd->is_suspended = 1;
1258 jpd->suspend_reason = 1; // Time/MCU limit reached
1259
1260 // Save current position
1261 if (x >= jd->width) {
1262 jpd->current_mcu_x = 0;
1263 jpd->current_mcu_y++;
1264 } else {
1265 jpd->current_mcu_x = x / mx;
1266 }
1267
1268 return (JRESULT)JDR_SUSPEND;
1269 }
1270 }
1271
1272 // Move to next row
1273 x = 0;
1274 y += my;
1275 jpd->current_mcu_x = 0;
1276 jpd->current_mcu_y++;
1277 }
1278
1279 // Processing complete
1280 if (processing_complete) *processing_complete = 1;
1281 return rc;
1282}
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::UISlider scale("Scale", 4,.1, 4,.1)
fl::u16 uint16_t
Definition coder.h:214
static JRESULT restart(JDEC *jd, uint16_t rstn) FL_NOEXCEPT
static JRESULT mcu_load(JDEC *jd) FL_NOEXCEPT
static JRESULT mcu_output(JDEC *jd, int(*outfunc)(JDEC *, void *, JRECT *), unsigned int x, unsigned int y) FL_NOEXCEPT
int16_t dcv[3]
Definition tjpgd.h:59
uint16_t height
Definition tjpgd.h:61
u8 u8 height
Definition blur.h:186
u8 width
Definition blur.h:186
#define JD_USE_SCALE
Definition tjpgdcnf.h:15

References fl::third_party::JDEC_Progressive::base, fl::third_party::JDEC_Progressive::current_mcu_x, fl::third_party::JDEC_Progressive::current_mcu_y, fl::third_party::JDEC::dcv, FL_NOEXCEPT, fl::height, fl::third_party::JDEC::height, fl::third_party::JDEC_Progressive::is_suspended, JD_USE_SCALE, JDR_OK, JDR_PAR, JDR_SUSPEND, mcu_load(), mcu_output(), fl::third_party::JDEC_Progressive::mcus_processed, fl::third_party::JDEC::msx, fl::third_party::JDEC::msy, fl::third_party::JDEC::nrst, restart(), fl::third_party::JDEC::scale, scale, fl::third_party::JDEC_Progressive::suspend_reason, fl::third_party::JDEC_Progressive::total_mcus, fl::third_party::JDEC::width, fl::width, fl::third_party::JDEC_Progressive::workspace_initialized, fl::x, and fl::y.

Referenced by fl::third_party::TJpgInstanceDecoder::processChunk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: