mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-08 23:42:28 +00:00
d3d11videosink: Clarify the meaning of various width and height variables
* Remove redundant variables for width/height and par from GstD3D11Window.
GstVideoInfo holds all the values.
* Don't need to pass par to gst_d3d11_window_prepare().
It will be parsed from caps again
* Remove duplicated math
Fixing regression of the commit 9dada90108
This commit is contained in:
parent
25e9ee10b0
commit
9b7c20bfca
4 changed files with 25 additions and 48 deletions
|
@ -389,8 +389,8 @@ gst_d3d11_video_sink_set_caps (GstBaseSink * sink, GstCaps * caps)
|
||||||
|
|
||||||
self->have_video_processor = FALSE;
|
self->have_video_processor = FALSE;
|
||||||
if (!gst_d3d11_window_prepare (self->window, GST_VIDEO_SINK_WIDTH (self),
|
if (!gst_d3d11_window_prepare (self->window, GST_VIDEO_SINK_WIDTH (self),
|
||||||
GST_VIDEO_SINK_HEIGHT (self), video_par_n, video_par_d,
|
GST_VIDEO_SINK_HEIGHT (self), caps, &self->have_video_processor,
|
||||||
caps, &self->have_video_processor, &error)) {
|
&error)) {
|
||||||
GstMessage *error_msg;
|
GstMessage *error_msg;
|
||||||
|
|
||||||
GST_ERROR_OBJECT (self, "cannot create swapchain");
|
GST_ERROR_OBJECT (self, "cannot create swapchain");
|
||||||
|
|
|
@ -176,9 +176,6 @@ gst_d3d11_window_init (GstD3D11Window * self)
|
||||||
self->enable_navigation_events = DEFAULT_ENABLE_NAVIGATION_EVENTS;
|
self->enable_navigation_events = DEFAULT_ENABLE_NAVIGATION_EVENTS;
|
||||||
self->fullscreen_toggle_mode = GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE;
|
self->fullscreen_toggle_mode = GST_D3D11_WINDOW_FULLSCREEN_TOGGLE_MODE_NONE;
|
||||||
self->fullscreen = DEFAULT_FULLSCREEN;
|
self->fullscreen = DEFAULT_FULLSCREEN;
|
||||||
|
|
||||||
self->aspect_ratio_n = 1;
|
|
||||||
self->aspect_ratio_d = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -335,23 +332,17 @@ gst_d3d11_window_on_resize_default (GstD3D11Window * window, guint width,
|
||||||
window->surface_width = desc.Width;
|
window->surface_width = desc.Width;
|
||||||
window->surface_height = desc.Height;
|
window->surface_height = desc.Height;
|
||||||
|
|
||||||
width = window->width;
|
|
||||||
height = window->height;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
src_rect.x = 0;
|
|
||||||
src_rect.y = 0;
|
|
||||||
src_rect.w = width * window->aspect_ratio_n;
|
|
||||||
src_rect.h = height * window->aspect_ratio_d;
|
|
||||||
|
|
||||||
dst_rect.x = 0;
|
dst_rect.x = 0;
|
||||||
dst_rect.y = 0;
|
dst_rect.y = 0;
|
||||||
dst_rect.w = window->surface_width;
|
dst_rect.w = window->surface_width;
|
||||||
dst_rect.h = window->surface_height;
|
dst_rect.h = window->surface_height;
|
||||||
|
|
||||||
if (window->force_aspect_ratio) {
|
if (window->force_aspect_ratio) {
|
||||||
src_rect.w = width * window->aspect_ratio_n;
|
src_rect.x = 0;
|
||||||
src_rect.h = height * window->aspect_ratio_d;
|
src_rect.y = 0;
|
||||||
|
src_rect.w = GST_VIDEO_INFO_WIDTH (&window->render_info);
|
||||||
|
src_rect.h = GST_VIDEO_INFO_HEIGHT (&window->render_info);
|
||||||
|
|
||||||
gst_video_sink_center_rect (src_rect, dst_rect, &rst_rect, TRUE);
|
gst_video_sink_center_rect (src_rect, dst_rect, &rst_rect, TRUE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -426,9 +417,9 @@ gst_d3d11_window_on_mouse_event (GstD3D11Window * window, const gchar * event,
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
gst_d3d11_window_prepare (GstD3D11Window * window, guint display_width,
|
||||||
guint aspect_ratio_n, guint aspect_ratio_d, GstCaps * caps,
|
guint display_height, GstCaps * caps, gboolean * video_processor_available,
|
||||||
gboolean * video_processor_available, GError ** error)
|
GError ** error)
|
||||||
{
|
{
|
||||||
GstD3D11WindowClass *klass;
|
GstD3D11WindowClass *klass;
|
||||||
GstCaps *render_caps;
|
GstCaps *render_caps;
|
||||||
|
@ -437,11 +428,9 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
||||||
gboolean need_processor_input_configure = FALSE;
|
gboolean need_processor_input_configure = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_D3D11_WINDOW (window), FALSE);
|
g_return_val_if_fail (GST_IS_D3D11_WINDOW (window), FALSE);
|
||||||
g_return_val_if_fail (aspect_ratio_n > 0, FALSE);
|
|
||||||
g_return_val_if_fail (aspect_ratio_d > 0, FALSE);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (window, "Prepare window with %dx%d caps %" GST_PTR_FORMAT,
|
GST_DEBUG_OBJECT (window, "Prepare window, display resolution %dx%d, caps %"
|
||||||
width, height, caps);
|
GST_PTR_FORMAT, display_width, display_height, caps);
|
||||||
|
|
||||||
gst_clear_buffer (&window->cached_buffer);
|
gst_clear_buffer (&window->cached_buffer);
|
||||||
|
|
||||||
|
@ -492,16 +481,18 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
||||||
window->compositor = NULL;
|
window->compositor = NULL;
|
||||||
|
|
||||||
/* preserve upstream colorimetry */
|
/* preserve upstream colorimetry */
|
||||||
window->render_info.width = width;
|
window->render_info.width = display_width;
|
||||||
window->render_info.height = height;
|
window->render_info.height = display_height;
|
||||||
|
|
||||||
window->render_info.colorimetry.primaries =
|
window->render_info.colorimetry.primaries =
|
||||||
window->info.colorimetry.primaries;
|
window->info.colorimetry.primaries;
|
||||||
window->render_info.colorimetry.transfer = window->info.colorimetry.transfer;
|
window->render_info.colorimetry.transfer = window->info.colorimetry.transfer;
|
||||||
|
|
||||||
window->processor =
|
window->processor =
|
||||||
gst_d3d11_video_processor_new (window->device, width, height, width,
|
gst_d3d11_video_processor_new (window->device,
|
||||||
height);
|
GST_VIDEO_INFO_WIDTH (&window->info),
|
||||||
|
GST_VIDEO_INFO_HEIGHT (&window->info),
|
||||||
|
display_width, display_height);
|
||||||
if (window->processor) {
|
if (window->processor) {
|
||||||
const GstD3D11Format *in_format;
|
const GstD3D11Format *in_format;
|
||||||
const GstD3D11Format *out_format;
|
const GstD3D11Format *out_format;
|
||||||
|
@ -581,26 +572,20 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
||||||
|
|
||||||
window->dxgi_format = window->render_format->dxgi_format;
|
window->dxgi_format = window->render_format->dxgi_format;
|
||||||
|
|
||||||
window->aspect_ratio_n = aspect_ratio_n;
|
|
||||||
window->aspect_ratio_d = aspect_ratio_d;
|
|
||||||
|
|
||||||
window->render_rect.left = 0;
|
window->render_rect.left = 0;
|
||||||
window->render_rect.top = 0;
|
window->render_rect.top = 0;
|
||||||
window->render_rect.right = width;
|
window->render_rect.right = display_width;
|
||||||
window->render_rect.bottom = height;
|
window->render_rect.bottom = display_height;
|
||||||
|
|
||||||
window->input_rect.left = 0;
|
window->input_rect.left = 0;
|
||||||
window->input_rect.top = 0;
|
window->input_rect.top = 0;
|
||||||
window->input_rect.right = GST_VIDEO_INFO_WIDTH (&window->info);
|
window->input_rect.right = GST_VIDEO_INFO_WIDTH (&window->info);
|
||||||
window->input_rect.bottom = GST_VIDEO_INFO_HEIGHT (&window->info);
|
window->input_rect.bottom = GST_VIDEO_INFO_HEIGHT (&window->info);
|
||||||
|
|
||||||
window->width = width;
|
|
||||||
window->height = height;
|
|
||||||
|
|
||||||
klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
klass = GST_D3D11_WINDOW_GET_CLASS (window);
|
||||||
if (!window->swap_chain &&
|
if (!window->swap_chain &&
|
||||||
!klass->create_swap_chain (window, window->dxgi_format,
|
!klass->create_swap_chain (window, window->dxgi_format,
|
||||||
width, height, swapchain_flags, &window->swap_chain)) {
|
display_width, display_height, swapchain_flags, &window->swap_chain)) {
|
||||||
GST_ERROR_OBJECT (window, "Cannot create swapchain");
|
GST_ERROR_OBJECT (window, "Cannot create swapchain");
|
||||||
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_FAILED,
|
||||||
"Cannot create swapchain");
|
"Cannot create swapchain");
|
||||||
|
@ -707,7 +692,7 @@ gst_d3d11_window_prepare (GstD3D11Window * window, guint width, guint height,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* call resize to allocated resources */
|
/* call resize to allocated resources */
|
||||||
klass->on_resize (window, width, height);
|
klass->on_resize (window, display_width, display_height);
|
||||||
|
|
||||||
if (window->requested_fullscreen != window->fullscreen) {
|
if (window->requested_fullscreen != window->fullscreen) {
|
||||||
klass->change_fullscreen_mode (window);
|
klass->change_fullscreen_mode (window);
|
||||||
|
|
|
@ -93,15 +93,9 @@ struct _GstD3D11Window
|
||||||
/* requested rect via gst_d3d11_window_render */
|
/* requested rect via gst_d3d11_window_render */
|
||||||
GstVideoRectangle rect;
|
GstVideoRectangle rect;
|
||||||
|
|
||||||
guint width;
|
|
||||||
guint height;
|
|
||||||
|
|
||||||
guint surface_width;
|
guint surface_width;
|
||||||
guint surface_height;
|
guint surface_height;
|
||||||
|
|
||||||
guint aspect_ratio_n;
|
|
||||||
guint aspect_ratio_d;
|
|
||||||
|
|
||||||
IDXGISwapChain *swap_chain;
|
IDXGISwapChain *swap_chain;
|
||||||
ID3D11RenderTargetView *rtv;
|
ID3D11RenderTargetView *rtv;
|
||||||
ID3D11VideoProcessorOutputView *pov;
|
ID3D11VideoProcessorOutputView *pov;
|
||||||
|
@ -150,10 +144,8 @@ void gst_d3d11_window_set_render_rectangle (GstD3D11Window * window,
|
||||||
gint width, gint height);
|
gint width, gint height);
|
||||||
|
|
||||||
gboolean gst_d3d11_window_prepare (GstD3D11Window * window,
|
gboolean gst_d3d11_window_prepare (GstD3D11Window * window,
|
||||||
guint width,
|
guint display_width,
|
||||||
guint height,
|
guint display_height,
|
||||||
guint aspect_ratio_n,
|
|
||||||
guint aspect_ratio_d,
|
|
||||||
GstCaps * caps,
|
GstCaps * caps,
|
||||||
gboolean * video_processor_available,
|
gboolean * video_processor_available,
|
||||||
GError ** error);
|
GError ** error);
|
||||||
|
|
|
@ -824,8 +824,8 @@ gst_d3d11_window_win32_show (GstD3D11Window * window)
|
||||||
GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (window);
|
GstD3D11WindowWin32 *self = GST_D3D11_WINDOW_WIN32 (window);
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
width = window->width;
|
width = GST_VIDEO_INFO_WIDTH (&window->render_info);
|
||||||
height = window->height;
|
height = GST_VIDEO_INFO_HEIGHT (&window->render_info);
|
||||||
|
|
||||||
if (!self->visible) {
|
if (!self->visible) {
|
||||||
/* if no parent the real size has to be set now because this has not been done
|
/* if no parent the real size has to be set now because this has not been done
|
||||||
|
|
Loading…
Reference in a new issue