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

◆ initializeDecoder()

bool fl::third_party::TJpgInstanceDecoder::initializeDecoder ( )
private

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

85 {
86 // Create JDEC instance in our workspace
87 JDEC* jdec = reinterpret_cast<JDEC*>(embedded_tjpg_.workspace);
88
89 // Calculate working memory pool (after JDEC struct)
90 fl::size jdec_size = sizeof(JDEC);
91 fl::u8* pool = embedded_tjpg_.workspace + jdec_size;
92 fl::size pool_size = sizeof(embedded_tjpg_.workspace) - jdec_size;
93
94 // Prepare decoder with our input callback
95 JRESULT res = jd_prepare(jdec, inputCallback, pool, pool_size, &embedded_tjpg_);
96
97 if (res != JDR_OK) {
98 char err_str[32];
99 fl::snprintf(err_str, sizeof(err_str), "jd_prepare failed: %d", (int)res);
100 setError(err_str);
101 return false;
102 }
103
104 // Get image dimensions
105 fl::u16 width = jdec->width;
106 fl::u16 height = jdec->height;
107
108
109 // Apply scaling based on jpg_scale setting
110 if (embedded_tjpg_.jpg_scale > 1) {
111 width /= embedded_tjpg_.jpg_scale;
112 height /= embedded_tjpg_.jpg_scale;
113 }
114
115
116 // Allocate frame buffer
118
119 // Create frame object
121
122 if (!current_frame_->isValid()) {
123 setError("Failed to create frame");
124 return false;
125 }
126
127 // Initialize progressive state if needed
128 if (use_progressive_) {
129 fl::memcpy(&progressive_state_.base, jdec, sizeof(JDEC));
130 progressive_state_.current_mcu_x = 0;
131 progressive_state_.current_mcu_y = 0;
132 progressive_state_.mcus_processed = 0;
133 progressive_state_.total_mcus = (jdec->width / jdec->msx / 8) *
134 (jdec->height / jdec->msy / 8);
135 }
136
137 return true;
138}
static fl::size inputCallback(JDEC *jd, fl::u8 *buff, fl::size nbyte) FL_NOEXCEPT
struct fl::third_party::TJpgInstanceDecoder::EmbeddedTJpgState embedded_tjpg_
JDEC_Progressive progressive_state_
Definition driver.h:67
fl::unique_ptr< fl::u8[]> frame_buffer_
Definition driver.h:76
fl::shared_ptr< Frame > current_frame_
Definition driver.h:75
void allocateFrameBuffer(fl::u16 width, fl::u16 height) FL_NOEXCEPT
void setError(const fl::string &msg) FL_NOEXCEPT
unsigned char u8
Definition coder.h:132
JRESULT jd_prepare(JDEC *jd, size_t(*infunc)(JDEC *, uint8_t *, size_t), void *pool, size_t sz_pool, void *dev) FL_NOEXCEPT
struct JDEC JDEC
Definition tjpgd.h:49
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT
u8 u8 height
Definition blur.h:186
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
u8 width
Definition blur.h:186
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414

References allocateFrameBuffer(), current_frame_, embedded_tjpg_, FL_NOEXCEPT, frame_buffer_, fl::height, fl::third_party::JDEC::height, inputCallback(), fl::third_party::jd_prepare(), fl::third_party::JDR_OK, fl::make_shared(), fl::memcpy(), fl::third_party::JDEC::msx, fl::third_party::JDEC::msy, pixel_format_, progressive_state_, setError(), fl::snprintf(), use_progressive_, fl::third_party::JDEC::width, and fl::width.

Referenced by beginDecodingStream().

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