-
Notifications
You must be signed in to change notification settings - Fork 153
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
[Bug]: Issues with 8-bit to 10 bit conversion and reverse. (Forcing bit depth also enforces color primary conversion). #527
Comments
At this point AMF color converter doesn't support YUV-8 (NV12) to YUV-10 (P010) or opposite. We are working on this. |
At AMF there is no enforcement or such. I did a simple experiment: set these parameters in SimpleEncoder sample app and checked results in stream analyzer. All parameters are successfully set to whatever value application requested. |
Well, i knew they existed. And i even used them before, to transfer HDR. I just thought that they are mostly used in case of HDR or specific conversion case and not expected to be explicitly passed each time. If anything i think it should be expected to see them being copied from source by default. Well, i presume it is probably hard to have dynamic defaults based on source in API, rather than interface, because AMF does not parse through source and only executes call with set parameters... So BT.709 for 8-bit with BT.2020 for 10-bit are just fallback options instead? In case no option had been specified manually? Correct me if i was wrong in conclusion. Anyways, thanks, i guess... I will refer to this for VCEEncC creator to adjust transfer of these characteristics by default. |
These parameters are for encoder only. Yes, if not set, there are default values based on bit-ness: BT.709 for 8-bit with BT.2020 for 10-bit. |
Thanks for confirming. Then major part of the issue has been answered. Now, third part, i guess... That addendum in original post, with HDR video having it's first second broken on TranscodeHW transcode for some reason. All codecs had been affects, but each in it's own way. Well, after check on several sources i have, i can make an assumption that all affected files had been cropped out from larger source with ffmpeg. So i guess there is some wonkyness in interaction with cropped via ffmpeg sources... Even if they had been cropped by IDR frame. Still weird, though. |
Describe the bug
For some reason if you enforce bit depth and it does not align with source (aka 8bit --> 10bit and 10bit-->8bit respectively), resulting video will have distorted colors due to setting wrong color primaries (and doing conversion based on them).
For HEVC 8bit encodes BT.709+BT.709 is enforced, while for 10bit BT.2020+PQ. Mastering data is lost on encode (unless specified).
For AV1 encodes color primary data is stripped, but mastering for HDR is transferred without specification.
Weirdly TranscodeHW and VCEEncC (after update which dropped most it's defaults to AMF defaults) break colors in different ways.
TranscodeHW makes 8->10bit outputs look as low contrast,10->8bit look similar way.
While VCEEncC 8->10bit looks oversaturated, while 10->8bit looks bleak.
UPD: Oh no it's even worse than i thought... I had HEVC10 source with BT.709 color primaries lying around. Well, if i enforce 8-bit encode via TranscodeHW, it gets completely ruined.
At least VCEEncC could do HEVC 10bit BT.709 -> HEVC 8bit without completely ruining picture.
For VCEEncC:
BT.709 -> BT.709 conversion is always correct.
BT.709 -> BT.2020 causes oversaturated result.
BT.2020->BT.709 causes bleak result. Can be fixed by transferring HDR parameters.
For TranscodeHW:
BT.709->BT.709 conversion completely breaks with 8bit->10bit encode.
BT.709->BT.2020 causes image with less contrast, but colors are preserved.
BT.2020->BT.709 causes image with less contrast, but colors are preserved.
I assume that stems from source detection and what color primaries encoder is made to think source in? VCEEncC always presumes that source is BT.709
TranscodeHW always presumes that 8-bit source is BT.709, while 10-bit source is BT.2020. But why does it darken outputs?
To Reproduce
Used software:
TranscodeHW - from latest AMF repo. Just cloned and built it before testing.
VCEEncC 8.27 (also latest on moment of writing)
Used commands:
VCEEncC command list.
Setup (please complete the following information):
Screenshots
No debug logs, encode proceeds properly. But outputs are messed up. Here are screenshots. Names of files are visible and show respective encode parameters.
TranscodeHW. 8bit BT.709. Two right samples (-> 10bit enforced) look as low contrast.
TranscodeHW. 10bit BT.2020. Two left samples (-> 8bit enforced) look as low contrast.
TranscodeHW. 10bit BT.709. Two left samples (-> 8bit enforced) are broken. And two right samples (-> 10bit enforced) are oversaturated.
VCEEncC 8.27. 8bit BT.709. Two right samples (-> 10bit enforced) are oversaturated.
VCEEncC 8.27. 10bit BT.2020. Two left samples (-> 8bit enforced) are bleak
(well, this one actually is more or less expected outcome. Source is HDR and i didn't transfer it's parameters)
VCEEncC 8.27. 10bit BT.709. Two right samples (-> 10bit enforced) are oversaturated.
Expected behavior
Output color primaries should not solely depend on forced bit depth.
Breaking 10-bit BT.709 sample to this extent when reencoding it to 8-bit BT.709 definitely should not be a thing.
Additional context
Additional issue:
When i use TranscodeHW on 10-bit BT.2020 HDR source fragment (cropped via ffmpeg) beginning of outputs is ALWAYS corrupted.
First frames (like 3 or 4, perhaps? At least movement is visible) is fine, then there is corrupted several frame gap up to a exactly 1 second mark.
->AV1 8-bit enforced = several frames are either stuck or skipped. Looks like pause and snap afterwards.
->AV1 10-bit enforced = several frames are either stuck or skipped AND green tinted.
->HEVC 8-bit enforced = several frames are corrupted with distorted image.
-> HEVC 10-bit enforced = several frames are corrupted with distorted image and white-grey tint.
-> AVC (8-bit only) = several frames are either stuck/skipped or rapidly switching between two static frames until threshold is passed.
Here is how it looks. Sadly it is impossible to show stuck frames there.
Frankly speaking this also should not be a thing. (VCEEncC does not have this issue), so this one may be either decoder or reader issue. FFMPEG, perhaps?
The text was updated successfully, but these errors were encountered: