-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
feat(libjpeg_turbo): add JPEG image EXIF data parsing #5263
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not store the rotation EXIF data in LVGL image object, instead the decoder should decode the image in the correct angle.
I agree. |
Interesting. |
Well, I think we should not use LVGL to rotate an image (if it's stored for example in portrait mode / 90 degree rotation), instead the image should be decoded in the correct angle/rotation based on the rotation info in source image meta/EXIF data. |
e44bad4
to
d14fbff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test the code changes, could you please add a small test JPEG file (and the reference PNG file to compare)?
The JPEG file should have that specific EXIF data for which you have created this PR.
f8fac45
to
9fa845a
Compare
@@ -369,8 +393,10 @@ static lv_draw_buf_t * decode_jpeg_file(const char * filename) | |||
jpeg_read_scanlines(&cinfo, buffer, 1); | |||
|
|||
/* Assume put_scanline_someplace wants a pointer and sample count. */ | |||
lv_memcpy(cur_pos, buffer[0], stride); | |||
cur_pos += decoded->header.stride; | |||
dispose_buffer(cur_pos, buffer[0], line_index, cinfo.output_width, cinfo.output_height, decoded->header.stride, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rename function to rotate_buffer()?
Dispose means to me releasing a resource, cleaning up, for example in .NET we use for that purpose.
But there is also a dispose pattern for releasing resources, so dispose is not the best name for rotating image parts.
@@ -37,16 +38,27 @@ static lv_result_t decoder_open(lv_image_decoder_t * decoder, lv_image_decoder_d | |||
const lv_image_decoder_args_t * args); | |||
static void decoder_close(lv_image_decoder_t * decoder, lv_image_decoder_dsc_t * dsc); | |||
static lv_draw_buf_t * decode_jpeg_file(const char * filename); | |||
static bool get_jpeg_size(const char * filename, uint32_t * width, uint32_t * height); | |||
static uint8_t * alloc_file(const char * filename, uint32_t * size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you are already editing this file, could you please rename alloc_file()
to read_file()
?
This name describes better what the function does: reads the file content into memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the feedback, I'll update them later.
1173a4a
to
2b86afd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 2 CI builds fail on this libjpeg changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix CI build errors -> libjpeg test fails.
It seems there is a memory leak somehow.
looks like need more memory actually. |
I've checked the test image, found 2 non rotated images, and thought something is not working. And them saw this comment. I think showing the 180° rotated image as normal is less intuitive. |
If I understand correctly, this PR introduces capability to rotate JPEG image as instructed. |
I assume the intention was to show a rotated image correct: In this PR maybe a label could be added below the 2 images (that show correct, without upside-down):
PS: |
Ah,it seems I'm really misunderstanding something. Let's say I take a portrait picture with my camera. I guess the EXIF rotation will be 90°. But if we ignore the EXIF data, what image will be shown? A portrait or a landscape? |
All clear, thank you! If by processing the EXIF data we get exactly the same output as with a normal image, I suggest using this the original reference image for all 4 EXIF options. |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
@liujp-arch @kisvegabor My personal suggestion is to build a set of basic function APIs for image processing in future, such as rotation and scaling, similar to the draw API. This will unify their usage in image decoding and other parts, and also make it easier to accelerate them using SIMD in the future. |
The actual code is OK (for me), there was only 1 suggestion: But I think we can do it also later, after merging this PR. |
@kisvegabor you mean all the 4 EXIF options images should be decoded to the left image in the last line ? |
Yes, we can have only a single reference image like this: and all 4 variants can be compared to that. |
We need some feedback on this pull request. Now we mark this as "stale" because there was no activity here for 14 days. Remove the "stale" label or comment else this will be closed in 7 days. |
I think it's a useful feature and only a little is missing. Did not give up now! 🙂 |
I need to do more testing on the rotation of the image. I will update once it's finished. |
a432b88
to
4066b78
Compare
Parse the rotation information of a JPEG image
4066b78
to
24aa0fb
Compare
Parse the rotation information of a JPEG image
Help us review this PR! Anyone can approve it or request changes.
Description of the feature or fix
A clear and concise description of what the bug or new feature is.
Checkpoints
lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig.scripts/code-format.py
(astyle needs to be installed) and follow the Code Conventions