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

[Android] Implement 'HDR display enable' for ffmpeg decoded streams #16557

Merged
merged 1 commit into from Sep 6, 2019

Conversation

peak3d
Copy link
Contributor

@peak3d peak3d commented Sep 1, 2019

Description

This PR implements switching HDR capable displays into HDR mode when playing HDR streams using LinuxRendererGLES GPU rendering.
When using this path, our internal HDR implementation is overriden and HDR calulation is done on GPU / display, its compareable to audio passthrough.

Motivation and Context

VP9 profile 2 HDR streams are currently not supported on NVIDIA Shield TV, using this PR its from theory possible to play them. 1080p streams don't play smooth yet, but there are still ptions to optimize the render chain (e.g. YUV scanout instead our own YUV2RGB shader)

How Has This Been Tested?

  • NVIDIA Shield TV + youtube addon
    enable vp9 dash in youtube addon settings
    search for 'vp9 hdr' and play one stream.

  • AFTV 4K (no GPU HDR extension)
    HDR setting is not visible and internal HDR pipeline is used

  • WETEK HUB (SDK version does not support HDR)
    HDR setting is not visible and internal HDR pipeline is used

For discussion

Solved: Should there be an settings option to disable this feature and use our shader HDR calulation instead?
There is now a setting which is only visible if display supports HDR and let users switch between display HDR and internal GL(ES) shader HDR

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

pVideoPicture->color_range = 0;
pVideoPicture->color_range = m_hints.colorRange == AVCOL_RANGE_JPEG ? 1 : 0;

CLog::Log(LOGWARNING, "XXX PRI: %d TRC: %d SPC: %d RNG: %d", pVideoPicture->color_primaries, pVideoPicture->color_transfer, pVideoPicture->color_space, (int)pVideoPicture->color_range);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want this to be LOGWARNING?
Looks more like a candidate for LOGDEBUG to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use C++ style cast

@@ -116,6 +116,7 @@ bool CLinuxRendererGLES::ValidateRenderTarget()

bool CLinuxRendererGLES::Configure(const VideoPicture &picture, float fps, unsigned int orientation)
{
CLog::Log(LOGDEBUG, "LinuxRendererGLES: Configire with HDR metadad: %s", (picture.hasDisplayMetadata && picture.hasLightMetadata) ? "true" : "false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LinuxRendererGLES: Configure with HDR metadata

@@ -7,12 +7,14 @@
*/

#include "WinSystemAndroidGLESContext.h"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "VideoSyncAndroid.h"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "VideoSyncAndroid.h"

#include "cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodec.h"
#include "platform/android/activity/XBMCApp.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pVideoPicture->color_range = 0;
pVideoPicture->color_range = m_hints.colorRange == AVCOL_RANGE_JPEG ? 1 : 0;

CLog::Log(LOGWARNING, "XXX PRI: %d TRC: %d SPC: %d RNG: %d", pVideoPicture->color_primaries, pVideoPicture->color_transfer, pVideoPicture->color_space, (int)pVideoPicture->color_range);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use C++ style cast

xbmc/windowing/android/WinSystemAndroidGLESContext.cpp Outdated Show resolved Hide resolved
@peak3d
Copy link
Contributor Author

peak3d commented Sep 4, 2019

Jenkins build this please

2 similar comments
@peak3d
Copy link
Contributor Author

peak3d commented Sep 4, 2019

Jenkins build this please

@peak3d
Copy link
Contributor Author

peak3d commented Sep 4, 2019

Jenkins build this please

@ksooo
Copy link
Member

ksooo commented Sep 4, 2019

jenkins build this please

<condition on="property" name="ishdrdisplay" />
</dependency>
</dependencies>
<!--requirement>ishdrdisplay</requirement-->
Copy link
Member

@ksooo ksooo Sep 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is now a setting which is only visible if display supports HDR and let users switch between display HDR and internal GL(ES) shader HDR

Really? With this commented out the setting will always be visible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm, sorry for the noise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, I'll remove the comment - leftover from testing

xbmc/utils/EGLUtils.h Outdated Show resolved Hide resolved
xbmc/windowing/android/AndroidUtils.h Outdated Show resolved Hide resolved
xbmc/windowing/android/AndroidUtils.h Outdated Show resolved Hide resolved
xbmc/windowing/android/AndroidUtils.h Outdated Show resolved Hide resolved
@peak3d
Copy link
Contributor Author

peak3d commented Sep 5, 2019

Jenkins build this please

1 similar comment
@peak3d
Copy link
Contributor Author

peak3d commented Sep 5, 2019

Jenkins build this please

@peak3d peak3d merged commit f4ead59 into xbmc:master Sep 6, 2019
@peak3d peak3d deleted the vp9hdr branch September 6, 2019 11:52
@CiNcH83
Copy link

CiNcH83 commented Sep 6, 2019

I am not seeing this setting on BRAVIA. Suppose it does not support the Android/EGL HDR APIs.

@ksooo
Copy link
Member

ksooo commented Sep 7, 2019

Working fine on Shield.

@CiNcH83
Copy link

CiNcH83 commented Sep 7, 2019

On BRAVIA:
2019-09-07 11:41:16.187 T:2487245168 DEBUG: CWinSystemAndroidGLESContext::InitWindowSystem: HDRConfig: 0, HDRExtensions: 0

@peak3d
Copy link
Contributor Author

peak3d commented Sep 7, 2019

@CiNcH83 yes, there has to be a EGL extension. Not sure if we will arrive this extension on devices other than Nvidia Shield, because the Shield is the only one which focusses on Game development, too.

Could be that we have a chance for other devices if we use the Vulkan API, but - your HDR videos should look ok if you use our HDR implementation. The display switch to HDR could save some GPU resources, but results should match.

@CiNcH83
Copy link

CiNcH83 commented Sep 7, 2019

your HDR videos should look ok if you use our HDR implementation.

On my BRAVIA, SW decoding in Kodi isn't feasible anyway. HDR video playback via MediaCodec Surface is fine (and has been fine before).

The only problem is the Kodi menu/OSD. When the TV detects an HDR video and switches into the respective HDR mode, there is always a distinct color and luminance shift in OSDs. Artwork is way too dark for example. Haven't checked yet whether this is still the case.

@MilhouseVH
Copy link
Contributor

This PR has broken the RPi4 with Kodi 19 (latest master), which is using mesa.

kod.bin now exits with the following error (it does not crash):

ERROR: Unable to create GUI. Exiting

In the kodi debug log:

2019-09-07 19:31:31.417 T:3006934624  NOTICE: EGL_VERSION = 1.4
2019-09-07 19:31:31.417 T:3006934624  NOTICE: EGL_VENDOR = Mesa Project
2019-09-07 19:31:31.418 T:3006934624  NOTICE: EGL_EXTENSIONS = EGL_EXT_buffer_age EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context EGL_KHR_create_context_no_error EGL_KHR_fence_sync EGL_KHR_get_all_proc_addresses EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image EGL_KHR_gl_texture_cubemap_image EGL_KHR_image EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_no_config_context EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_EXT_pixel_format_float EGL_KHR_wait_sync EGL_MESA_configless_context EGL_MESA_drm_image EGL_MESA_image_dma_buf_export
2019-09-07 19:31:31.418 T:3006934624  NOTICE: EGL_CLIENT_EXTENSIONS = EGL_EXT_client_extensions EGL_EXT_device_base EGL_EXT_device_enumeration EGL_EXT_device_query EGL_EXT_platform_base EGL_KHR_client_get_all_proc_addresses EGL_KHR_debug EGL_MESA_platform_gbm
2019-09-07 19:31:31.418 T:3006934624   DEBUG: failed to find EGL config with EGL_NATIVE_VISUAL_ID=875713089
2019-09-07 19:31:31.418 T:3006934624   DEBUG: failed to find EGL config with EGL_NATIVE_VISUAL_ID=875713112
2019-09-07 19:31:31.418 T:3006934624   DEBUG: failed to find EGL config with EGL_NATIVE_VISUAL_ID=875713089
2019-09-07 19:31:31.418 T:3006934624   DEBUG: failed to find EGL config with EGL_NATIVE_VISUAL_ID=875713112
2019-09-07 19:31:31.418 T:3006934624   FATAL: CApplication::Create: Unable to init windowing system

Reverting this PR (and also #16579) restores working Kodi with RPi4.

@MilhouseVH
Copy link
Contributor

From @Kwiboo on LibreELEC Slack:

cool, I suspect the EGL_PBUFFER_BIT change to be the most likely culprit, the driver probably do not supports creating pixel buffer surfaces

and

that is just my best guess, could also be the EGL_ALPHA_SIZE change, the rest of the changes do mostly look to be isolated to when hdr = true

#. Description of setting with label #13436 "Use display HDR capabilities"
#: system/settings/settings.xml
msgctxt "#36299"
msgid "Switch display into HDR mode if media with HDR information is played.\nIf disabled, HDR information are applied using kodi's internal HDR path"
Copy link
Member

@ksooo ksooo Sep 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peak3d typo: kodi's => Kodi's (capital K, please) and a period is missing to end the second sentence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants