[vlc-commits] direct3d11: merge QueryDisplayFormat into UpdateDisplayFormat
Steve Lhomme
git at videolan.org
Tue Sep 1 09:30:26 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Sep 1 09:30:17 2020 +0200| [7cb87557f8e4bb8ae9152df21bdb54a7db1c7f17] | committer: Steve Lhomme
direct3d11: merge QueryDisplayFormat into UpdateDisplayFormat
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7cb87557f8e4bb8ae9152df21bdb54a7db1c7f17
---
modules/video_output/win32/direct3d11.c | 121 +++++++++++++++-----------------
1 file changed, 57 insertions(+), 64 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index eb7c926006..9d1c43a3e2 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -146,16 +146,62 @@ static void SetQuadVSProjection(vout_display_sys_t *);
static int Control(vout_display_t *, int, va_list);
-static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *out,
- const video_format_t *input_fmt)
+static int UpdateDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
{
vout_display_sys_t *sys = vd->sys;
+ libvlc_video_render_cfg_t cfg;
+
+ cfg.width = sys->area.vdcfg.display.width;
+ cfg.height = sys->area.vdcfg.display.height;
+
+ switch (fmt->i_chroma)
+ {
+ case VLC_CODEC_D3D11_OPAQUE:
+ cfg.bitdepth = 8;
+ break;
+ case VLC_CODEC_D3D11_OPAQUE_RGBA:
+ case VLC_CODEC_D3D11_OPAQUE_BGRA:
+ cfg.bitdepth = 8;
+ break;
+ case VLC_CODEC_D3D11_OPAQUE_10B:
+ cfg.bitdepth = 10;
+ break;
+ default:
+ {
+ const vlc_chroma_description_t *p_format = vlc_fourcc_GetChromaDescription(fmt->i_chroma);
+ if (p_format == NULL)
+ {
+ cfg.bitdepth = 8;
+ }
+ else
+ {
+ cfg.bitdepth = p_format->pixel_bits == 0 ? 8 : p_format->pixel_bits /
+ (p_format->plane_count==1 ? p_format->pixel_size : 1);
+ }
+ }
+ break;
+ }
+ cfg.full_range = fmt->color_range == COLOR_RANGE_FULL ||
+ /* the YUV->RGB conversion already output full range */
+ is_d3d11_opaque(fmt->i_chroma) ||
+ vlc_fourcc_IsYUV(fmt->i_chroma);
+ cfg.primaries = (libvlc_video_color_primaries_t) fmt->primaries;
+ cfg.colorspace = (libvlc_video_color_space_t) fmt->space;
+ cfg.transfer = (libvlc_video_transfer_func_t) fmt->transfer;
+
+ libvlc_video_output_cfg_t out;
+ if (!sys->updateOutputCb( sys->outside_opaque, &cfg, &out ))
+ {
+ msg_Err(vd, "Failed to set format %dx%d %d bits on output", cfg.width, cfg.height, cfg.bitdepth);
+ return VLC_EGENERIC;
+ }
+
display_info_t new_display = { 0 };
for (const d3d_format_t *output_format = GetRenderFormatList();
output_format->name != NULL; ++output_format)
{
- if (output_format->formatTexture == (DXGI_FORMAT)out->dxgi_format &&
+ if (output_format->formatTexture == (DXGI_FORMAT)out.dxgi_format &&
!is_d3d11_opaque(output_format->fourcc))
{
new_display.pixelFormat = output_format;
@@ -168,13 +214,13 @@ static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *ou
return VLC_EGENERIC;
}
- new_display.color = (video_color_space_t) out->colorspace;
- new_display.transfer = (video_transfer_func_t) out->transfer;
- new_display.primaries = (video_color_primaries_t) out->primaries;
- new_display.b_full_range = out->full_range;
+ new_display.color = (video_color_space_t) out.colorspace;
+ new_display.transfer = (video_transfer_func_t) out.transfer;
+ new_display.primaries = (video_color_primaries_t) out.primaries;
+ new_display.b_full_range = out.full_range;
/* guestimate the display peak luminance */
- switch (out->transfer)
+ switch (out.transfer)
{
case TRANSFER_FUNC_LINEAR:
case TRANSFER_FUNC_SRGB:
@@ -198,7 +244,7 @@ static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *ou
{
sys->display = new_display;
/* TODO release the pixel shaders if the format changed */
- if (Direct3D11CreateFormatResources(vd, input_fmt)) {
+ if (Direct3D11CreateFormatResources(vd, fmt)) {
msg_Err(vd, "Failed to allocate format resources");
return VLC_EGENERIC;
}
@@ -207,66 +253,13 @@ static int UpdateDisplayFormat(vout_display_t *vd, libvlc_video_output_cfg_t *ou
return VLC_SUCCESS;
}
-static int QueryDisplayFormat(vout_display_t *vd, const video_format_t *fmt)
-{
- vout_display_sys_t *sys = vd->sys;
- libvlc_video_render_cfg_t cfg;
-
- cfg.width = sys->area.vdcfg.display.width;
- cfg.height = sys->area.vdcfg.display.height;
-
- switch (fmt->i_chroma)
- {
- case VLC_CODEC_D3D11_OPAQUE:
- cfg.bitdepth = 8;
- break;
- case VLC_CODEC_D3D11_OPAQUE_RGBA:
- case VLC_CODEC_D3D11_OPAQUE_BGRA:
- cfg.bitdepth = 8;
- break;
- case VLC_CODEC_D3D11_OPAQUE_10B:
- cfg.bitdepth = 10;
- break;
- default:
- {
- const vlc_chroma_description_t *p_format = vlc_fourcc_GetChromaDescription(fmt->i_chroma);
- if (p_format == NULL)
- {
- cfg.bitdepth = 8;
- }
- else
- {
- cfg.bitdepth = p_format->pixel_bits == 0 ? 8 : p_format->pixel_bits /
- (p_format->plane_count==1 ? p_format->pixel_size : 1);
- }
- }
- break;
- }
- cfg.full_range = fmt->color_range == COLOR_RANGE_FULL ||
- /* the YUV->RGB conversion already output full range */
- is_d3d11_opaque(fmt->i_chroma) ||
- vlc_fourcc_IsYUV(fmt->i_chroma);
- cfg.primaries = (libvlc_video_color_primaries_t) fmt->primaries;
- cfg.colorspace = (libvlc_video_color_space_t) fmt->space;
- cfg.transfer = (libvlc_video_transfer_func_t) fmt->transfer;
-
- libvlc_video_output_cfg_t out;
- if (!sys->updateOutputCb( sys->outside_opaque, &cfg, &out ))
- {
- msg_Err(vd, "Failed to set format %dx%d %d bits on output", cfg.width, cfg.height, cfg.bitdepth);
- return VLC_EGENERIC;
- }
-
- return UpdateDisplayFormat(vd, &out, fmt);
-}
-
static void UpdateSize(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
msg_Dbg(vd, "Detected size change %dx%d", sys->area.place.width,
sys->area.place.height);
- QueryDisplayFormat(vd, &vd->fmt);
+ UpdateDisplayFormat(vd, &vd->fmt);
RECT rect_dst = {
.left = sys->area.place.x,
@@ -830,7 +823,7 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmtp, vlc_video_co
CommonPlacePicture(vd, &sys->area, &sys->sys);
- err = QueryDisplayFormat(vd, &fmt);
+ err = UpdateDisplayFormat(vd, &fmt);
if (err != VLC_SUCCESS) {
msg_Err(vd, "Could not update the backbuffer");
return err;
More information about the vlc-commits
mailing list