mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-18 02:38:27 +00:00
Generalize SDR white level handling into a color scale
This gives applications better control over how and when light levels are adjusted when working with HDR content and display.
This commit is contained in:
parent
82d89ff4fb
commit
d4caef5b89
34 changed files with 3279 additions and 3234 deletions
|
@ -646,6 +646,10 @@ static SDL_bool GetTextureForD3D11Frame(AVFrame *frame, SDL_Texture **texture)
|
|||
SDL_QueryTexture(*texture, NULL, NULL, &texture_width, &texture_height);
|
||||
}
|
||||
if (!*texture || (UINT)texture_width != desc.Width || (UINT)texture_height != desc.Height) {
|
||||
SDL_bool HDR_display = SDL_TRUE;
|
||||
SDL_bool HDR_video = SDL_FALSE;
|
||||
float display_white_level, video_white_level;
|
||||
|
||||
if (*texture) {
|
||||
SDL_DestroyTexture(*texture);
|
||||
}
|
||||
|
@ -658,9 +662,11 @@ static SDL_bool GetTextureForD3D11Frame(AVFrame *frame, SDL_Texture **texture)
|
|||
break;
|
||||
case DXGI_FORMAT_P010:
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_P010);
|
||||
HDR_video = SDL_TRUE;
|
||||
break;
|
||||
case DXGI_FORMAT_P016:
|
||||
SDL_SetNumberProperty(props, SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER, SDL_PIXELFORMAT_P016);
|
||||
HDR_video = SDL_TRUE;
|
||||
break;
|
||||
default:
|
||||
/* This should be checked above */
|
||||
|
@ -675,6 +681,20 @@ static SDL_bool GetTextureForD3D11Frame(AVFrame *frame, SDL_Texture **texture)
|
|||
if (!*texture) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
if (HDR_video != HDR_display) {
|
||||
/* Use some reasonable assumptions for white levels */
|
||||
if (HDR_display) {
|
||||
display_white_level = 200.0f; /* SDR white level */
|
||||
video_white_level = 80.0f;
|
||||
} else {
|
||||
display_white_level = 80.0f;
|
||||
video_white_level = 400.0f;
|
||||
}
|
||||
SDL_SetRenderColorScale(renderer, display_white_level / video_white_level);
|
||||
} else {
|
||||
SDL_SetRenderColorScale(renderer, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ID3D11Resource *dx11_resource = SDL_GetProperty(SDL_GetTextureProperties(*texture), SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue