mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-08 04:27:12 +03:00
try to detect when JPEG decoding fails - release
This commit is contained in:
@@ -24,6 +24,7 @@ typedef struct {
|
|||||||
const unsigned char *InData; // Pointer to jpeg data
|
const unsigned char *InData; // Pointer to jpeg data
|
||||||
int InPos; // Current position in jpeg data
|
int InPos; // Current position in jpeg data
|
||||||
int Width, Height;
|
int Width, Height;
|
||||||
|
uint32_t Pixels;
|
||||||
uint8_t Mode;
|
uint8_t Mode;
|
||||||
union {
|
union {
|
||||||
void *OutData;
|
void *OutData;
|
||||||
@@ -143,6 +144,8 @@ static unsigned OutHandlerDirect(JDEC *Decoder, void *Bitmap, JRECT *Frame) {
|
|||||||
uint8_t *Pixels = (uint8_t*) Bitmap;
|
uint8_t *Pixels = (uint8_t*) Bitmap;
|
||||||
int Shift = 8 - Context->Depth;
|
int Shift = 8 - Context->Depth;
|
||||||
|
|
||||||
|
Context->Pixels += (Frame->bottom - Frame->top + 1) * (Frame->right - Frame->left + 1); \
|
||||||
|
|
||||||
// decoded image is RGB888, shift only make sense for grayscale
|
// decoded image is RGB888, shift only make sense for grayscale
|
||||||
if (Context->Mode == GDS_RGB888) {
|
if (Context->Mode == GDS_RGB888) {
|
||||||
OUTHANDLERDIRECT(Scaler888, 0);
|
OUTHANDLERDIRECT(Scaler888, 0);
|
||||||
@@ -418,10 +421,11 @@ bool GDS_DrawJPEG(struct GDS_Device* Device, uint8_t *Source, int x, int y, int
|
|||||||
Context.XMin = x - Context.XOfs;
|
Context.XMin = x - Context.XOfs;
|
||||||
Context.YMin = y - Context.YOfs;
|
Context.YMin = y - Context.YOfs;
|
||||||
Context.Mode = Device->Mode;
|
Context.Mode = Device->Mode;
|
||||||
|
Context.Pixels = 0;
|
||||||
|
|
||||||
// do decompress & draw
|
// do decompress & draw
|
||||||
Res = jd_decomp(&Decoder, OutHandlerDirect, N);
|
Res = jd_decomp(&Decoder, OutHandlerDirect, N);
|
||||||
if (Res == JDR_OK) {
|
if (Res == JDR_OK && Context.Pixels != (Context.Width + 1) * (Context.Height + 1)) {
|
||||||
Device->Dirty = true;
|
Device->Dirty = true;
|
||||||
Ret = true;
|
Ret = true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user