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

Pixel copy to flip texture is too slow, WebPDecoderOptions.flip should be used, but how? #21

Open
shunia opened this issue Mar 26, 2020 · 5 comments

Comments

@shunia
Copy link
Contributor

shunia commented Mar 26, 2020

Pixel copy is blocking the main thread and consumes too much time, which is not acceptable.

I tried with one of our webp animation file, and the overall performance is something like:

libwebp decode: 230ms
flip upside down by pixel copy: 735ms

And because these all happened in the main thread, it freeze the app for almost 1 secend.

And then I found this in project libwebp inside the 1.0.0 tag, which is the exact version used by unity.webp:

// Decoding options
struct WebPDecoderOptions {
  ...
  int flip;                           // flip output vertically
  ...
};

This flip option has been implemented to solve the upside down problem, but how could I use this option? Please help.

@netpyoung
Copy link
Owner

netpyoung commented Mar 26, 2020 via email

@netpyoung
Copy link
Owner

I used function WebPAnimDecoderNewInternal

But I failed to find insert WebPDecoderOptions option to there. So It seems need to write manually like this https://stackoverflow.com/a/28472740 .

During weekends I will trying that again

@shunia
Copy link
Contributor Author

shunia commented Jul 14, 2020

Possible solution here: #24

@netpyoung
Copy link
Owner

netpyoung commented Jul 14, 2020

after merge, I fixed compile error then I realized flip parameter comes from WebPAnimDecoderOptions not in WebPDecoderOptions .

@shunia
Copy link
Contributor Author

shunia commented Jul 14, 2020

Oh, I forgot to organize WebPDecoderWrapper.cs.

The flip option won't work, though i forgot the details: https://github.com/webmproject/libwebp/blob/be738c6d396fa5a272c1b209be4379a7532debfe/src/dec/buffer_dec.c#L153

And Texture2DExt.LoadRGBAFromWebP works just great and implemented well so I just used it.

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

No branches or pull requests

2 participants