From 575e806cc8997e8f23db577dab1e6992b5867e86 Mon Sep 17 00:00:00 2001 From: Mike Bell Date: Sat, 3 Jun 2023 17:01:42 +0100 Subject: [PATCH] Remove unnecessary data from JPEG range tables --- libraries/jpegdec/jpeg.inl | 436 +++++++++++++------------------------ 1 file changed, 152 insertions(+), 284 deletions(-) diff --git a/libraries/jpegdec/jpeg.inl b/libraries/jpegdec/jpeg.inl index be792a25..d6bfb543 100644 --- a/libraries/jpegdec/jpeg.inl +++ b/libraries/jpegdec/jpeg.inl @@ -182,138 +182,82 @@ static const uint16_t usGrayTo565[] = {0x0000,0x0000,0x0000,0x0000,0x0020,0x0020 // // Clip and convert red value into 5-bits for RGB565 // -static const uint16_t usRangeTableR[] = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // 0 - 0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800,0x0800, - 0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000,0x1000, - 0x1800,0x1800,0x1800,0x1800,0x1800,0x1800,0x1800,0x1800, - 0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000,0x2000, - 0x2800,0x2800,0x2800,0x2800,0x2800,0x2800,0x2800,0x2800, - 0x3000,0x3000,0x3000,0x3000,0x3000,0x3000,0x3000,0x3000, - 0x3800,0x3800,0x3800,0x3800,0x3800,0x3800,0x3800,0x3800, - 0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000,0x4000, - 0x4800,0x4800,0x4800,0x4800,0x4800,0x4800,0x4800,0x4800, - 0x5000,0x5000,0x5000,0x5000,0x5000,0x5000,0x5000,0x5000, - 0x5800,0x5800,0x5800,0x5800,0x5800,0x5800,0x5800,0x5800, - 0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000,0x6000, - 0x6800,0x6800,0x6800,0x6800,0x6800,0x6800,0x6800,0x6800, - 0x7000,0x7000,0x7000,0x7000,0x7000,0x7000,0x7000,0x7000, - 0x7800,0x7800,0x7800,0x7800,0x7800,0x7800,0x7800,0x7800, - 0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000,0x8000, - 0x8800,0x8800,0x8800,0x8800,0x8800,0x8800,0x8800,0x8800, - 0x9000,0x9000,0x9000,0x9000,0x9000,0x9000,0x9000,0x9000, - 0x9800,0x9800,0x9800,0x9800,0x9800,0x9800,0x9800,0x9800, - 0xa000,0xa000,0xa000,0xa000,0xa000,0xa000,0xa000,0xa000, - 0xa800,0xa800,0xa800,0xa800,0xa800,0xa800,0xa800,0xa800, - 0xb000,0xb000,0xb000,0xb000,0xb000,0xb000,0xb000,0xb000, - 0xb800,0xb800,0xb800,0xb800,0xb800,0xb800,0xb800,0xb800, - 0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000,0xc000, - 0xc800,0xc800,0xc800,0xc800,0xc800,0xc800,0xc800,0xc800, - 0xd000,0xd000,0xd000,0xd000,0xd000,0xd000,0xd000,0xd000, - 0xd800,0xd800,0xd800,0xd800,0xd800,0xd800,0xd800,0xd800, - 0xe000,0xe000,0xe000,0xe000,0xe000,0xe000,0xe000,0xe000, - 0xe800,0xe800,0xe800,0xe800,0xe800,0xe800,0xe800,0xe800, - 0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, // 256 +static const uint16_t usRangeTableR[] = {0x0000, // 0 + 0x0800, + 0x1000, + 0x1800, + 0x2000, + 0x2800, + 0x3000, + 0x3800, + 0x4000, + 0x4800, + 0x5000, + 0x5800, + 0x6000, + 0x6800, + 0x7000, + 0x7800, + 0x8000, + 0x8800, + 0x9000, + 0x9800, + 0xa000, + 0xa800, + 0xb000, + 0xb800, + 0xc000, + 0xc800, + 0xd000, + 0xd800, + 0xe000, + 0xe800, + 0xf000, + 0xf800, + 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, // 32 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800,0xf800, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 512 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 768 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 64 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 96 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // -// Clip and convert green value into 5-bits for RGB565 +// Clip and convert green value into 6-bits for RGB565 // -static const uint16_t usRangeTableG[] = {0x0000,0x0000,0x0000,0x0000,0x0020,0x0020,0x0020,0x0020, // 0 - 0x0040,0x0040,0x0040,0x0040,0x0060,0x0060,0x0060,0x0060, - 0x0080,0x0080,0x0080,0x0080,0x00a0,0x00a0,0x00a0,0x00a0, - 0x00c0,0x00c0,0x00c0,0x00c0,0x00e0,0x00e0,0x00e0,0x00e0, - 0x0100,0x0100,0x0100,0x0100,0x0120,0x0120,0x0120,0x0120, - 0x0140,0x0140,0x0140,0x0140,0x0160,0x0160,0x0160,0x0160, - 0x0180,0x0180,0x0180,0x0180,0x01a0,0x01a0,0x01a0,0x01a0, - 0x01c0,0x01c0,0x01c0,0x01c0,0x01e0,0x01e0,0x01e0,0x01e0, - 0x0200,0x0200,0x0200,0x0200,0x0220,0x0220,0x0220,0x0220, - 0x0240,0x0240,0x0240,0x0240,0x0260,0x0260,0x0260,0x0260, - 0x0280,0x0280,0x0280,0x0280,0x02a0,0x02a0,0x02a0,0x02a0, - 0x02c0,0x02c0,0x02c0,0x02c0,0x02e0,0x02e0,0x02e0,0x02e0, - 0x0300,0x0300,0x0300,0x0300,0x0320,0x0320,0x0320,0x0320, - 0x0340,0x0340,0x0340,0x0340,0x0360,0x0360,0x0360,0x0360, - 0x0380,0x0380,0x0380,0x0380,0x03a0,0x03a0,0x03a0,0x03a0, - 0x03c0,0x03c0,0x03c0,0x03c0,0x03e0,0x03e0,0x03e0,0x03e0, - 0x0400,0x0400,0x0400,0x0400,0x0420,0x0420,0x0420,0x0420, - 0x0440,0x0440,0x0440,0x0440,0x0460,0x0460,0x0460,0x0460, - 0x0480,0x0480,0x0480,0x0480,0x04a0,0x04a0,0x04a0,0x04a0, - 0x04c0,0x04c0,0x04c0,0x04c0,0x04e0,0x04e0,0x04e0,0x04e0, - 0x0500,0x0500,0x0500,0x0500,0x0520,0x0520,0x0520,0x0520, - 0x0540,0x0540,0x0540,0x0540,0x0560,0x0560,0x0560,0x0560, - 0x0580,0x0580,0x0580,0x0580,0x05a0,0x05a0,0x05a0,0x05a0, - 0x05c0,0x05c0,0x05c0,0x05c0,0x05e0,0x05e0,0x05e0,0x05e0, - 0x0600,0x0600,0x0600,0x0600,0x0620,0x0620,0x0620,0x0620, - 0x0640,0x0640,0x0640,0x0640,0x0660,0x0660,0x0660,0x0660, - 0x0680,0x0680,0x0680,0x0680,0x06a0,0x06a0,0x06a0,0x06a0, - 0x06c0,0x06c0,0x06c0,0x06c0,0x06e0,0x06e0,0x06e0,0x06e0, - 0x0700,0x0700,0x0700,0x0700,0x0720,0x0720,0x0720,0x0720, - 0x0740,0x0740,0x0740,0x0740,0x0760,0x0760,0x0760,0x0760, - 0x0780,0x0780,0x0780,0x0780,0x07a0,0x07a0,0x07a0,0x07a0, - 0x07c0,0x07c0,0x07c0,0x07c0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, // 256 +static const uint16_t usRangeTableG[] = {0x0000,0x0020, // 0 + 0x0040,0x0060, + 0x0080,0x00a0, + 0x00c0,0x00e0, + 0x0100,0x0120, + 0x0140,0x0160, + 0x0180,0x01a0, + 0x01c0,0x01e0, + 0x0200,0x0220, + 0x0240,0x0260, + 0x0280,0x02a0, + 0x02c0,0x02e0, + 0x0300,0x0320, + 0x0340,0x0360, + 0x0380,0x03a0, + 0x03c0,0x03e0, + 0x0400,0x0420, + 0x0440,0x0460, + 0x0480,0x04a0, + 0x04c0,0x04e0, + 0x0500,0x0520, + 0x0540,0x0560, + 0x0580,0x05a0, + 0x05c0,0x05e0, + 0x0600,0x0620, + 0x0640,0x0660, + 0x0680,0x06a0, + 0x06c0,0x06e0, + 0x0700,0x0720, + 0x0740,0x0760, + 0x0780,0x07a0, + 0x07c0,0x07e0, + 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, // 64 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, @@ -321,160 +265,56 @@ static const uint16_t usRangeTableG[] = {0x0000,0x0000,0x0000,0x0000,0x0020,0x00 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0,0x07e0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 512 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // // Clip and convert blue value into 5-bits for RGB565 // -static const uint16_t usRangeTableB[] = {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, // 0 - 0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001,0x0001, - 0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002,0x0002, - 0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003,0x0003, - 0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004,0x0004, - 0x0005,0x0005,0x0005,0x0005,0x0005,0x0005,0x0005,0x0005, - 0x0006,0x0006,0x0006,0x0006,0x0006,0x0006,0x0006,0x0006, - 0x0007,0x0007,0x0007,0x0007,0x0007,0x0007,0x0007,0x0007, - 0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008,0x0008, - 0x0009,0x0009,0x0009,0x0009,0x0009,0x0009,0x0009,0x0009, - 0x000a,0x000a,0x000a,0x000a,0x000a,0x000a,0x000a,0x000a, - 0x000b,0x000b,0x000b,0x000b,0x000b,0x000b,0x000b,0x000b, - 0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c,0x000c, - 0x000d,0x000d,0x000d,0x000d,0x000d,0x000d,0x000d,0x000d, - 0x000e,0x000e,0x000e,0x000e,0x000e,0x000e,0x000e,0x000e, - 0x000f,0x000f,0x000f,0x000f,0x000f,0x000f,0x000f,0x000f, - 0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010,0x0010, - 0x0011,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011,0x0011, - 0x0012,0x0012,0x0012,0x0012,0x0012,0x0012,0x0012,0x0012, - 0x0013,0x0013,0x0013,0x0013,0x0013,0x0013,0x0013,0x0013, - 0x0014,0x0014,0x0014,0x0014,0x0014,0x0014,0x0014,0x0014, - 0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015, - 0x0016,0x0016,0x0016,0x0016,0x0016,0x0016,0x0016,0x0016, - 0x0017,0x0017,0x0017,0x0017,0x0017,0x0017,0x0017,0x0017, - 0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018, - 0x0019,0x0019,0x0019,0x0019,0x0019,0x0019,0x0019,0x0019, - 0x001a,0x001a,0x001a,0x001a,0x001a,0x001a,0x001a,0x001a, - 0x001b,0x001b,0x001b,0x001b,0x001b,0x001b,0x001b,0x001b, - 0x001c,0x001c,0x001c,0x001c,0x001c,0x001c,0x001c,0x001c, - 0x001d,0x001d,0x001d,0x001d,0x001d,0x001d,0x001d,0x001d, - 0x001e,0x001e,0x001e,0x001e,0x001e,0x001e,0x001e,0x001e, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, // 256 +static const uint16_t usRangeTableB[] = {0x0000, // 0 + 0x0001, + 0x0002, + 0x0003, + 0x0004, + 0x0005, + 0x0006, + 0x0007, + 0x0008, + 0x0009, + 0x000a, + 0x000b, + 0x000c, + 0x000d, + 0x000e, + 0x000f, + 0x0010, + 0x0011, + 0x0012, + 0x0013, + 0x0014, + 0x0015, + 0x0016, + 0x0017, + 0x0018, + 0x0019, + 0x001a, + 0x001b, + 0x001c, + 0x001d, + 0x001e, + 0x001f, + 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, // 32 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f, - 0x001f,0x001f,0x001f,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 64 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 96 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; #if defined (__MACH__) || defined( __LINUX__ ) || defined( __MCUXPRESSO ) // @@ -2288,9 +2128,9 @@ static void JPEGPixelLE(uint16_t *pDest, int iY, int iCb, int iCr) iCBG = -1409 * (iCb-0x80); iCRG = -2925 * (iCr-0x80); iCRR = 5742 * (iCr-0x80); - usPixel = usRangeTableB[((iCBB + iY) >> 12) & 0x3ff]; // blue pixel - usPixel |= usRangeTableG[((iCBG + iCRG + iY) >> 12) & 0x3ff]; // green pixel - usPixel |= usRangeTableR[((iCRR + iY) >> 12) & 0x3ff]; // red pixel + usPixel = usRangeTableB[((iCBB + iY) >> 15) & 0x7f]; // blue pixel + usPixel |= usRangeTableG[((iCBG + iCRG + iY) >> 14) & 0xff]; // green pixel + usPixel |= usRangeTableR[((iCRR + iY) >> 15) & 0x7f]; // red pixel pDest[0] = usPixel; #endif } /* JPEGPixelLE() */ @@ -2304,9 +2144,9 @@ static void JPEGPixelBE(uint16_t *pDest, int iY, int iCb, int iCr) iCBG = -1409 * (iCb-0x80); iCRG = -2925 * (iCr-0x80); iCRR = 5742 * (iCr-0x80); - usPixel = usRangeTableB[((iCBB + iY) >> 12) & 0x3ff]; // blue pixel - usPixel |= usRangeTableG[((iCBG + iCRG + iY) >> 12) & 0x3ff]; // green pixel - usPixel |= usRangeTableR[((iCRR + iY) >> 12) & 0x3ff]; // red pixel + usPixel = usRangeTableB[((iCBB + iY) >> 15) & 0x7f]; // blue pixel + usPixel |= usRangeTableG[((iCBG + iCRG + iY) >> 14) & 0xff]; // green pixel + usPixel |= usRangeTableR[((iCRR + iY) >> 15) & 0x7f]; // red pixel pDest[0] = __builtin_bswap16(usPixel); } /* JPEGPixelBE() */ @@ -2340,13 +2180,13 @@ static void JPEGPixel2LE(uint16_t *pDest, int iY1, int iY2, int iCb, int iCr) iCBG = -1409 * (iCb-0x80); iCRG = -2925 * (iCr-0x80); iCRR = 5742 * (iCr-0x80); - ulPixel1 = usRangeTableB[((iCBB + iY1) >> 12) & 0x3ff]; // blue pixel - ulPixel1 |= usRangeTableG[((iCBG + iCRG + iY1) >> 12) & 0x3ff]; // green pixel - ulPixel1 |= usRangeTableR[((iCRR + iY1) >> 12) & 0x3ff]; // red pixel + ulPixel1 = usRangeTableB[((iCBB + iY1) >> 15) & 0x7f]; // blue pixel + ulPixel1 |= usRangeTableG[((iCBG + iCRG + iY1) >> 14) & 0xff]; // green pixel + ulPixel1 |= usRangeTableR[((iCRR + iY1) >> 15) & 0x7f]; // red pixel - ulPixel2 = usRangeTableB[((iCBB + iY2) >> 12) & 0x3ff]; // blue pixel - ulPixel2 |= usRangeTableG[((iCBG + iCRG + iY2) >> 12) & 0x3ff]; // green pixel - ulPixel2 |= usRangeTableR[((iCRR + iY2) >> 12) & 0x3ff]; // red pixel + ulPixel2 = usRangeTableB[((iCBB + iY2) >> 15) & 0x7f]; // blue pixel + ulPixel2 |= usRangeTableG[((iCBG + iCRG + iY2) >> 14) & 0xff]; // green pixel + ulPixel2 |= usRangeTableR[((iCRR + iY2) >> 15) & 0x7f]; // red pixel *(uint32_t *)&pDest[0] = (ulPixel1 | (ulPixel2<<16)); #endif } /* JPEGPixel2LE() */ @@ -2360,16 +2200,44 @@ static void JPEGPixel2BE(uint16_t *pDest, int32_t iY1, int32_t iY2, int32_t iCb, iCBG = -1409L * (iCb-0x80); iCRG = -2925L * (iCr-0x80); iCRR = 5742L * (iCr-0x80); - ulPixel1 = usRangeTableB[((iCBB + iY1) >> 12) & 0x3ff]; // blue pixel - ulPixel1 |= usRangeTableG[((iCBG + iCRG + iY1) >> 12) & 0x3ff]; // green pixel - ulPixel1 |= usRangeTableR[((iCRR + iY1) >> 12) & 0x3ff]; // red pixel + ulPixel1 = usRangeTableB[((iCBB + iY1) >> 15) & 0x7f]; // blue pixel + ulPixel1 |= usRangeTableG[((iCBG + iCRG + iY1) >> 14) & 0xff]; // green pixel + ulPixel1 |= usRangeTableR[((iCRR + iY1) >> 15) & 0x7f]; // red pixel - ulPixel2 = usRangeTableB[((iCBB + iY2) >> 12) & 0x3ff]; // blue pixel - ulPixel2 |= usRangeTableG[((iCBG + iCRG + iY2) >> 12) & 0x3ff]; // green pixel - ulPixel2 |= usRangeTableR[((iCRR + iY2) >> 12) & 0x3ff]; // red pixel + ulPixel2 = usRangeTableB[((iCBB + iY2) >> 15) & 0x7f]; // blue pixel + ulPixel2 |= usRangeTableG[((iCBG + iCRG + iY2) >> 14) & 0xff]; // green pixel + ulPixel2 |= usRangeTableR[((iCRR + iY2) >> 15) & 0x7f]; // red pixel *(uint32_t *)&pDest[0] = __builtin_bswap16(ulPixel1) | ((uint32_t)__builtin_bswap16(ulPixel2)<<16); } /* JPEGPixel2BE() */ +#if 0 +static void JPEGPixelLE888(uint8_t *pDest, int iY, int iCb, int iCr) +{ + int32_t iCBB, iCBG, iCRG, iCRR; + uint32_t uVal; + + iCBB = 7258 * (iCb-0x80); + iCBG = -1409 * (iCb-0x80); + iCRG = -2925 * (iCr-0x80); + iCRR = 5742 * (iCr-0x80); + + // Red + uVal = ((iCRR + iY) >> 13) & 0x1FF; + if (uVal & 0x100) uVal = 0; + *pDest++ = uVal; + + // Green + uVal = ((iCBG + iCRG + iY) >> 13) & 0x1FF; + if (uVal & 0x100) uVal = 0; + *pDest++ = uVal; + + // Blue + uVal = ((iCBB + iY) >> 13) & 0x1FF; + if (uVal & 0x100) uVal = 0; + *pDest++ = uVal; +} +#endif + static void JPEGPutMCU11(JPEGIMAGE *pJPEG, int x, int iPitch) { int iCr, iCb;