From c8862f4680144e551f0fb0823419375b3be288d4 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Sun, 11 Aug 2024 16:32:09 -0500 Subject: [PATCH] feat(jpeg): Update JPEGDEC to latest supporting SIMD decode on S3 (#85) --- components/jpeg/include/jpeg.hpp | 21 +++++++++------------ components/jpegdec | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/components/jpeg/include/jpeg.hpp b/components/jpeg/include/jpeg.hpp index bedbb762..bca30cc3 100644 --- a/components/jpeg/include/jpeg.hpp +++ b/components/jpeg/include/jpeg.hpp @@ -99,25 +99,22 @@ class Jpeg { } static int on_data_decode(JPEGDRAW *pDraw) { - // NOTE: for some reason our images are 100px wide, but we keep getting - // larger for iWidth. Therefore when we do our destination calculation we - // need to use width, but when we do our source calculation we need to use - // iWidth. - int width = std::min(image_width_, pDraw->iWidth); - int height = pDraw->iHeight; + auto width = pDraw->iWidth; + auto height = pDraw->iHeight; auto xs = pDraw->x; auto ys = pDraw->y; - auto ye = pDraw->y + height - 1; uint16_t *dst_buffer = (uint16_t*)decoded_data_; const uint16_t *src_buffer = (const uint16_t*)pDraw->pPixels; // two bytes per pixel for RGB565 - auto num_bytes_per_row = width * 2; - for (int y=ys; y<=ye; y++) { - int dst_offset = y * width + xs; - int src_offset = (y-ys) * pDraw->iWidth + xs; + uint16_t num_bytes_per_row = width * 2; + for (uint16_t i = 0; i < height; i++) { + uint16_t y = ys + i; + uint16_t dst_offset = y * image_width_ + xs; + uint16_t src_offset = i * width + xs; memcpy(&dst_buffer[dst_offset], &src_buffer[src_offset], num_bytes_per_row); } - return 1; // continue decode + // continue decode + return 1; } static uint8_t *encoded_data_; diff --git a/components/jpegdec b/components/jpegdec index 99c8a61a..e8e99cdf 160000 --- a/components/jpegdec +++ b/components/jpegdec @@ -1 +1 @@ -Subproject commit 99c8a61abc40f81665f2ff78460d84f32e4f2ca1 +Subproject commit e8e99cdfa71acc4419ccd6659efbdb09ab750db9