Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jpegdecoder #8696

Merged
merged 13 commits into from
Dec 8, 2023
Merged

Jpegdecoder #8696

merged 13 commits into from
Dec 8, 2023

Conversation

jepler
Copy link
Member

@jepler jepler commented Dec 5, 2023

Something's wrong with the doc build; I'll get that sorted soon.

Testing file:
test

Testing code:

import jpegio
import displayio
import adafruit_pycamera
import numpy
cam = adafruit_pycamera.PyCamera()
j = jpegio.JpegDecoder()
with open("test.jpg", "rb") as f: b = f.read()
w, h = j.decode(b, None)
print(w, h)
bm = displayio.Bitmap(w, h, 65535)
j.decode(b, bm)
arr = ulab.numpy.frombuffer(bm, dtype=ulab.numpy.int16)
arr[:] = arr.byteswap()
cam.blit(bm)
while True:
    pass

@jepler
Copy link
Member Author

jepler commented Dec 5, 2023

This ends up NOT using the ROM jpeg decooder, becaues it's an older version, is not header-compatible, and uses RGB888 instead of RGB565 as desired.

it would be nice to eliminate the need to byte-swap the image before merging this, as that'd be an incompatible change.

@jepler jepler marked this pull request as ready for review December 6, 2023 17:55
@jepler
Copy link
Member Author

jepler commented Dec 6, 2023

PXL_20231205_180816311(1)

@tannewt tannewt self-requested a review December 7, 2023 20:40
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat! We may want to enable it on more boards in the future so we can display jpegs right off the web.

shared-bindings/jpegio/JpegDecoder.c Show resolved Hide resolved
shared-module/jpegio/JpegDecoder.c Show resolved Hide resolved
@jepler jepler marked this pull request as draft December 8, 2023 03:17
@jepler
Copy link
Member Author

jepler commented Dec 8, 2023

If we're planning to try incorporating the esp32 jpeg decoder, we may want to hold off on this specific API; the esp32 simd decoder may not support the /2 /4 /8 downsampling; I'm not sure yet.

/8 downsampling is very useful (for thumbnailing photos taken on a camera, it makes the highest resolution downsample to 320x240 or something)! (and downsampling after decoding isn't viable, as the simd decoder only decodes full images, so it would need 10MB+ RAM for the full image).

Setting back to draft, since it shouldn't go in a beta if we don't think the API's settled.

@jepler
Copy link
Member Author

jepler commented Dec 8, 2023

and it needs bitmaps to be 16-aligned which MAY be guaranteed (aren't gc blocks 16-aligned?)

@tannewt
Copy link
Member

tannewt commented Dec 8, 2023

and it needs bitmaps to be 16-aligned which MAY be guaranteed (aren't gc blocks 16-aligned?)

Ya, python heap is 16 byte aligned on everything but imx. On imx it is 32 byte aligned to match the cache structure.

@tannewt
Copy link
Member

tannewt commented Dec 8, 2023

/8 downsampling is very useful

I'd leave it since it is useful. You can always raise an error on other implementations if you really need to. Or fall back to the shared implementation.

tannewt
tannewt previously approved these changes Dec 8, 2023
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Won't merge since still a draft.

@jepler
Copy link
Member Author

jepler commented Dec 8, 2023

It looks like there are some boards to disable it on for size reasons. After that I think this'll be ready to go.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Thanks for turning it on everywhere we can!

@tannewt tannewt merged commit ca1b680 into adafruit:main Dec 8, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants