RenderHeads / UnityPlugin-AVProVideo

AVPro Video is a multi-platform Unity plugin for advanced video playback
https://www.renderheads.com/products/avpro-video/
238 stars 28 forks source link

Add 10bit support to the Resolve To Render Texture component #1921

Closed acgourley closed 2 months ago

acgourley commented 4 months ago

When decoding 10bit HEVC videos on OSX Editor, PlatformMediaPlayer.cs queries _playerTexture.planes[i].textureFormat and sets textureFormat based on what it finds there. That switch statement finds a BGR10A2 texture but does not know how to handle it, so it falls back to using the 8-bit texture format.

Screenshot by Dropbox Capture

I modified the code myself to have a new switch statement and it seems to work

case Native.AVPPlayerTextureFormat.BGR10A2:
  textureFormat = TextureFormat.RGBAFloat;
  break;

I'm not sure if RGBAFloat, or Half, or perhaps one of the 16bits per color textures would be optimal, but any would be better than 8 bit.

Setup

Videos Here's a clip you can use https://www.dropbox.com/scl/fi/jjfai0x4a534suuwo7eix/H12_10b_Log_WBAuto.MP4?rlkey=3f8sn9lwi1nwwh4ycbmqmsnbg&st=oysst8af&dl=0

MorrisRH commented 4 months ago

The texture passed up to Unity is 10bit. Because there is no script level texture format that matches we use one with the same bytes per pixel. We've not seen any issues with this in our testing.

acgourley commented 3 months ago

Mm, could you look one more time @MorrisRH? While the texture passed up from the native part of your plugin to your C# part is 10-bit, the AVPro plugin blits it into a BGRA32 texture, which is 8-bit. This is because the texture format selected in line 371 in that screenshot is never overwritten by a leg of the switch statement.

MorrisRH commented 3 months ago

I'm not sure what you mean. The platform media player doesn't perform any blits when updating the texture. Unity's texture simply wraps the native texture handle. No processing or conversion is performed. Are you using the ResolveToRenderTexture component? (which would perform a blit)

acgourley commented 3 months ago

Yes I am using resolve to render texture. Is there any other way to get access to the 10 bit data before that blit?

On Tue, Jul 23, 2024, 1:39 AM Morris Butler @.***> wrote:

I'm not sure what you mean. The platform media player doesn't perform any blits when updating the texture. Unity's texture simply wraps the native texture handle. No processing or conversion is performed. Are you using the ResolveToRenderTexture component? (which would perform a blit)

— Reply to this email directly, view it on GitHub https://github.com/RenderHeads/UnityPlugin-AVProVideo/issues/1921#issuecomment-2244601681, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAB4AGLKMVUURJUD6T5MS3ZNYJFXAVCNFSM6AAAAABKGBK7UKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENBUGYYDCNRYGE . You are receiving this because you authored the thread.Message ID: @.***>

MorrisRH commented 3 months ago

ResolveToRenderTexture internally creates an ARGB32 render target. We'll look at getting that fixed so that it will create a render target capable of keeping the increased colour precision (probably RenderTextureFormat.ARGB2101010).

MorrisRH commented 3 months ago

Support for resolving to higher bit-depth render targets will make it into the next release (version 3.0.9)

Ste-RH commented 2 months ago

AVPro Video v3.0.9 has just been released. Do let us know if the issue has been fixed for you.