Skip to content

Commit 03bb9db

Browse files
align naming convention
1 parent fc12088 commit 03bb9db

File tree

4 files changed

+71
-60
lines changed

4 files changed

+71
-60
lines changed

src/Arduino_DataBus.cpp

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,31 +181,36 @@ void Arduino_DataBus::writeIndexedPixelsDouble(uint8_t *data, uint16_t *idx, uin
181181

182182
void Arduino_DataBus::writeYCbCrPixels(uint8_t *yData, uint8_t *cbData, uint8_t *crData, uint16_t w, uint16_t h)
183183
{
184-
w >>= 1;
185-
for (int i = 0; i < h;)
184+
int cols = w >> 1;
185+
186+
uint8_t pxCb, pxCr;
187+
int16_t pxR, pxG, pxB, pxY;
188+
189+
for (int row = 0; row < h;)
186190
{
187-
for (int j = 0; j < w; ++j)
191+
for (int col = 0; col < cols; ++col)
188192
{
189-
uint8_t cb = *cbData++;
190-
uint8_t cr = *crData++;
191-
int16_t r = CR2R16[cr];
192-
int16_t g = -CB2G16[cb] - CR2G16[cr];
193-
int16_t b = CB2B16[cb];
194-
int16_t y = Y2I16[*yData++];
195-
_data16.value = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
193+
pxCb = *cbData++;
194+
pxCr = *crData++;
195+
pxR = CR2R16[pxCr];
196+
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
197+
pxB = CB2B16[pxCb];
198+
199+
pxY = Y2I16[*yData++];
200+
_data16.value = CLIPRBE[pxY + pxCr] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
196201
write(_data16.lsb);
197202
write(_data16.msb);
198-
y = Y2I16[*yData++];
199-
_data16.value = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
203+
pxY = Y2I16[*yData++];
204+
_data16.value = CLIPRBE[pxY + pxCr] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
200205
write(_data16.lsb);
201206
write(_data16.msb);
202207
}
203208

204-
if (++i & 1)
209+
if (++row & 1)
205210
{
206211
// rollback CbCr data
207-
cbData -= w;
208-
crData -= w;
212+
cbData -= cols;
213+
crData -= cols;
209214
}
210215
}
211216
}

src/databus/Arduino_ESP32LCD16.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,28 +483,30 @@ void Arduino_ESP32LCD16::writeYCbCrPixels(uint8_t *yData, uint8_t *cbData, uint8
483483
uint16_t *dest = _buffer16;
484484
uint16_t *dest2 = dest + w;
485485

486+
uint8_t pxCb, pxCr;
487+
int16_t pxR, pxG, pxB, pxY;
488+
486489
uint16_t l = (w * 4) - 4;
487490
uint32_t out_dmadesc = ((l + 3) & (~3)) | l << 12 | 0xC0000000;
488491
bool poll_started = false;
489492
for (int row = 0; row < rows; ++row)
490493
{
491494
for (int col = 0; col < cols; ++col)
492495
{
493-
uint8_t cb = *cbData++;
494-
uint8_t cr = *crData++;
495-
int16_t r = CR2R16[cr];
496-
int16_t g = -CB2G16[cb] - CR2G16[cr];
497-
int16_t b = CB2B16[cb];
498-
int16_t y;
499-
500-
y = Y2I16[*yData++];
501-
*dest++ = CLIPR[y + r] | CLIPG[y + g] | CLIPB[y + b];
502-
y = Y2I16[*yData++];
503-
*dest++ = CLIPR[y + r] | CLIPG[y + g] | CLIPB[y + b];
504-
y = Y2I16[*yData2++];
505-
*dest2++ = CLIPR[y + r] | CLIPG[y + g] | CLIPB[y + b];
506-
y = Y2I16[*yData2++];
507-
*dest2++ = CLIPR[y + r] | CLIPG[y + g] | CLIPB[y + b];
496+
pxCb = *cbData++;
497+
pxCr = *crData++;
498+
pxR = CR2R16[pxCr];
499+
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
500+
pxB = CB2B16[pxCb];
501+
502+
pxY = Y2I16[*yData++];
503+
*dest++ = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
504+
pxY = Y2I16[*yData++];
505+
*dest++ = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
506+
pxY = Y2I16[*yData2++];
507+
*dest2++ = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
508+
pxY = Y2I16[*yData2++];
509+
*dest2++ = CLIPR[pxY + pxR] | CLIPG[pxY + pxG] | CLIPB[pxY + pxB];
508510
}
509511
yData += w;
510512
yData2 += w;

src/databus/Arduino_ESP32QSPI.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -718,26 +718,28 @@ void Arduino_ESP32QSPI::writeYCbCrPixels(uint8_t *yData, uint8_t *cbData, uint8_
718718

719719
uint16_t out_bits = w << 5;
720720

721+
uint8_t pxCb, pxCr;
722+
int16_t pxR, pxG, pxB, pxY;
723+
721724
CS_LOW();
722725
for (int row = 0; row < rows; ++row)
723726
{
724727
for (int col = 0; col < cols; ++col)
725728
{
726-
uint8_t cb = *cbData++;
727-
uint8_t cr = *crData++;
728-
int16_t r = CR2R16[cr];
729-
int16_t g = -CB2G16[cb] - CR2G16[cr];
730-
int16_t b = CB2B16[cb];
731-
int16_t y;
732-
733-
y = Y2I16[*yData++];
734-
*dest++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
735-
y = Y2I16[*yData++];
736-
*dest++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
737-
y = Y2I16[*yData2++];
738-
*dest2++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
739-
y = Y2I16[*yData2++];
740-
*dest2++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
729+
pxCb = *cbData++;
730+
pxCr = *crData++;
731+
pxR = CR2R16[pxCr];
732+
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
733+
pxB = CB2B16[pxCb];
734+
735+
pxY = Y2I16[*yData++];
736+
*dest++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
737+
pxY = Y2I16[*yData++];
738+
*dest++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
739+
pxY = Y2I16[*yData2++];
740+
*dest2++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
741+
pxY = Y2I16[*yData2++];
742+
*dest2++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
741743
}
742744
yData += w;
743745
yData2 += w;

src/databus/Arduino_ESP32SPIDMA.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -824,27 +824,29 @@ void Arduino_ESP32SPIDMA::writeYCbCrPixels(uint8_t *yData, uint8_t *cbData, uint
824824
uint16_t *dest = _buffer16;
825825
uint16_t *dest2 = dest + w;
826826

827+
uint8_t pxCb, pxCr;
828+
int16_t pxR, pxG, pxB, pxY;
829+
827830
uint16_t out_bits = w << 5;
828831
bool poll_started = false;
829832
for (int row = 0; row < rows; ++row)
830833
{
831834
for (int col = 0; col < cols; ++col)
832835
{
833-
uint8_t cb = *cbData++;
834-
uint8_t cr = *crData++;
835-
int16_t r = CR2R16[cr];
836-
int16_t g = -CB2G16[cb] - CR2G16[cr];
837-
int16_t b = CB2B16[cb];
838-
int16_t y;
839-
840-
y = Y2I16[*yData++];
841-
*dest++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
842-
y = Y2I16[*yData++];
843-
*dest++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
844-
y = Y2I16[*yData2++];
845-
*dest2++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
846-
y = Y2I16[*yData2++];
847-
*dest2++ = CLIPRBE[y + r] | CLIPGBE[y + g] | CLIPBBE[y + b];
836+
pxCb = *cbData++;
837+
pxCr = *crData++;
838+
pxR = CR2R16[pxCr];
839+
pxG = -CB2G16[pxCb] - CR2G16[pxCr];
840+
pxB = CB2B16[pxCb];
841+
842+
pxY = Y2I16[*yData++];
843+
*dest++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
844+
pxY = Y2I16[*yData++];
845+
*dest++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
846+
pxY = Y2I16[*yData2++];
847+
*dest2++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
848+
pxY = Y2I16[*yData2++];
849+
*dest2++ = CLIPRBE[pxY + pxR] | CLIPGBE[pxY + pxG] | CLIPBBE[pxY + pxB];
848850
}
849851
yData += w;
850852
yData2 += w;

0 commit comments

Comments
 (0)