webosbrew / hyperion-webos

hyperion.ng video grabber for webOS
MIT License
153 stars 30 forks source link

use libyuv's functions for YUV/RGB stuff in libvtcapture #36

Closed chbartsch closed 2 years ago

chbartsch commented 2 years ago

Output of libvtcapture wasn't looking right: blacks too bright, whites too dark and colors a bit dull.

So I replaced the lib's internal functions for YUV/ RGB conversion and blending with functions implemented in libyuv (just like libdile_vt is doing).

NV21ToARGB() and NV21ToRGB24() are using the BT.601 color space by default but standard on TVs should be BT.709 (and BT.2020 for HDR on capable TVs). When calling NV21ToARGBMatrix() and NV21ToRGB24Matrix() instead we are able to set the color space we want to use for conversion. So these functions are in place now and the color space is fixed to BT.709. We can talk about making the color space variable and selectable through the piccap-GUI... ;)

Additional:

TBSniller commented 2 years ago

Hey, I couldn't commit into your PR. I have pushed my changes into this branch: https://github.com/webosbrew/hyperion-webos/tree/chbartsch-libvtcapture-with-libyuv I don't know whats the smoothest, allowing me to push into your Fork, or creating another PR from that branch, or maybe something else? You can also feel free to just copy&paste it over. Sorry, very newbee :D

I have also corrected some stride/width calls and tested any possible situation (hal, vt, vt not ready, ....). For example my video capture was warped - It seems to work, testing from you again would be nice.

Thank you again very much for contributing! :)

TBSniller commented 2 years ago

Here is also an example what it had looked like: image

chbartsch commented 2 years ago

Hey, you should be able to push to my branch now. Had it disabled because I thought "why would this be necessary?" but now I see why... I also have to figure out how this whole PR thing works on github. ;)

Have you fixed the warped capture or is it still there? I think this happens when you call the libyuv functions with wrong stride, height or width values which leads to pixels getting shifted into wrong lines.

Will test your changes tomorrow. ;)

chbartsch commented 2 years ago

After thinking about it: I think it would be best if your push your latest changes to my branch/fork. This would keep the history and allows us to keep talking about/commenting code changes right here.

TBSniller commented 2 years ago

Hey, you should be able to push to my branch now. Had it disabled because I thought "why would this be necessary?" but now I see why... I also have to figure out how this whole PR thing works on github. ;)

Have you fixed the warped capture or is it still there? I think this happens when you call the libyuv functions with wrong stride, height or width values which leads to pixels getting shifted into wrong lines.

Will test your changes tomorrow. ;)

Yeah, was working :) So, on my TV everything is fixed and working with my recent commit. Do you want to test it again?

@Informatic Would be nice if you could also look for some mistakes.

Thx guys!

chbartsch commented 2 years ago

Yeah, was working :) So, on my TV everything is fixed and working with my recent commit. Do you want to test it again?

I made some simple tests. Basically starting with GUI+Video, GUI only and Video only each. Looks good on my TV!