oneam / h264bsd

A simple h264 software decoding library
Other
194 stars 52 forks source link

The h264bsd fully doesn't render the original colors #20

Closed myjimmy closed 2 years ago

myjimmy commented 2 years ago

Hi everyone

When rendering H.264 frames with this project, it fully doesn't show the original colors. For example, when rendering the following image with this project, [Original Image] Grayscale-bar-sample

that image is rendered as follows. [Rendered Image] h264bsd-render

I hope you fix this issue. Thanks.

oneam commented 2 years ago

The anomaly you're seeing is due to studio color range versus full color range. The best explanation I could find is here: https://en.wikipedia.org/wiki/YUV#Numerical_approximations

They are generally a pain to deal with in encoding/decoding loops

If you're input coolers are limited to studio range [16,235], the renderer will reproduce your colors exactly.

If you want to use full range colors, you will need to adjust the YCbCr conversion matrix here

I'll see if I can add a flag for switching between full and studio range.

oneam commented 2 years ago

I've added an optional parameter to the H264bsdCanvas 'fullRangeColor' that will assume that the input is full range color.

That should remove the clipping you're seeing.