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

test barcode won't work with get_area_cb #4838

Closed
4 tasks
XuNeo opened this issue Nov 21, 2023 · 8 comments · Fixed by #4948
Closed
4 tasks

test barcode won't work with get_area_cb #4838

XuNeo opened this issue Nov 21, 2023 · 8 comments · Fixed by #4948
Labels

Comments

@XuNeo
Copy link
Collaborator

XuNeo commented Nov 21, 2023

While debugging CI issue when LV_BIN_DECODER_RAM_LOAD is set to 0.

The issue is when using get_area_cb, decoder_dsc->img_data becomes not NULL after img_decode_and_draw, the next time it's called from img_draw_tiled, It now thinks whole image is available(line 256) because decoder_dsc->img_data is not NULL.

if(decoder_dsc->img_data) {
img_draw_core(draw_unit, draw_dsc, decoder_dsc, &sup, img_area, clipped_img_area);
}
/*Draw in smaller pieces*/
else {
lv_area_t relative_full_area_to_decode = *clipped_img_area;
lv_area_move(&relative_full_area_to_decode, -img_area->x1, -img_area->y1);
lv_area_t relative_decoded_area;
relative_decoded_area.x1 = LV_COORD_MIN;
relative_decoded_area.y1 = LV_COORD_MIN;
relative_decoded_area.x2 = LV_COORD_MIN;
relative_decoded_area.y2 = LV_COORD_MIN;
lv_result_t res = LV_RESULT_OK;
while(res == LV_RESULT_OK) {
res = lv_image_decoder_get_area(decoder_dsc, &relative_full_area_to_decode, &relative_decoded_area);
lv_area_t absolute_decoded_area = relative_decoded_area;
lv_area_move(&absolute_decoded_area, img_area->x1, img_area->y1);
if(res == LV_RESULT_OK) {
/*Limit draw area to the current decoded area and draw the image*/
lv_area_t clipped_img_area_sub;
if(_lv_area_intersect(&clipped_img_area_sub, clipped_img_area, &absolute_decoded_area)) {
img_draw_core(draw_unit, draw_dsc, decoder_dsc, &sup,
&absolute_decoded_area, &clipped_img_area_sub);
}
}
}
}

I currently hacked the code to mark img_data as NULL, so to continue debug CI test fail issues.

Perform all steps below and tick them with [x]

  • Read the FAQ
  • Check the related part of the Documentation
  • Update lvgl to the latest version
  • Reproduce the issue in a Simulator

Describe the bug

To Reproduce

Expected behavior

Screenshots or video

@XuNeo
Copy link
Collaborator Author

XuNeo commented Nov 26, 2023

In order to solve this, the decoded image should not be a simple pointer of img_data but a complete draw_buf with decoded area.

#4833

img_decode_and_draw should check if the area to be draw has already been decoded or not.

/**Describe an image decoding session. Stores data about the decoding*/
typedef struct _lv_image_decoder_dsc_t {
    /**The decoder which was able to open the image source*/
    lv_image_decoder_t * decoder;

    /*A copy of parameters of how this image is decoded*/
    lv_image_decoder_args_t * args;

    /**The image source. A file path like "S:my_img.png" or pointer to an `lv_image_dsc_t` variable*/
    const void * src;

    /** Pointer to a buffer where the image's data (pixels) are stored in a decoded, plain format.
     *  MUST be set in `open` function*/
    const uint8_t * img_data;
   
    ...
} lv_image_decoder_dsc_t;

@XuNeo
Copy link
Collaborator Author

XuNeo commented Nov 26, 2023

A similar issue is for indexed image, it could decode to ARGB8888 image, which makes it inconsistent with header->cf. Adding lv_draw_buf_t decoded could also solve it. Decoded format could differ to original format.

@kisvegabor
Copy link
Member

I currently hacked the code to mark img_data as NULL, so to continue debug CI test fail issues.

I don't think it's hacky, but rather a good clean up.

A similar issue is for indexed image, it could decode to ARGB8888 image, which makes it inconsistent with header->cf. Adding lv_draw_buf_t decoded could also solve it. Decoded format could differ to original format.

The header here should store data for the decoded image.

/**Info about the opened image: color format, size, etc. MUST be set in `open` function*/
lv_image_header_t header;

However considering it a lv_draw_buf_t decoded_image is definitely more elegant. Let's go for it!

@XuNeo
Copy link
Collaborator Author

XuNeo commented Nov 27, 2023

The header here should store data for the decoded image.

If so, then get_area_cb will get lost because it should deal with indexed image for example, not ARGB8888.

@kisvegabor
Copy link
Member

It could use const void * src; to read the original color format. However I do agree to add lv_draw_buf_t decoded_image it's much less hacky.

XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 6, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 6, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 6, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 6, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 11, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
@lvgl-bot
Copy link

We need some feedback on this issue.

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.

@lvgl-bot lvgl-bot added the stale label Dec 12, 2023
XuNeo added a commit to XuNeo/lvgl that referenced this issue Dec 12, 2023
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
@lvgl-bot
Copy link

As there was no activity here for a while we close this issue. But don't worry, the conversation is still here and you can get back to it at any time.

So feel free to comment if you have remarks or ideas on this topic.

@lvgl-bot lvgl-bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2023
@XuNeo
Copy link
Collaborator Author

XuNeo commented Dec 20, 2023

Will be fixed in #4948, close it for now.

XuNeo added a commit to XuNeo/lvgl that referenced this issue Jan 18, 2024
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
XuNeo added a commit to XuNeo/lvgl that referenced this issue Jan 18, 2024
Fix lvgl#4838

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants