diff options
author | Seungha Yang <seungha@centricular.com> | 2020-06-05 22:39:54 +0900 |
---|---|---|
committer | Seungha Yang <seungha@centricular.com> | 2020-06-05 13:47:49 +0000 |
commit | a38ac7a865f651bd0ebc3749635d2388f7e63f40 (patch) | |
tree | 1023f89287508cb1e330f658adf398022b5963e6 | |
parent | 2408fbe92d3c5afeb51563af6f0868a54e046fed (diff) | |
download | gstreamer-plugins-bad-a38ac7a865f651bd0ebc3749635d2388f7e63f40.tar.gz |
d3d11overlaycompositor: Fix wrong Y position calculation
The Y coordinate of vertex and screen/image are opposite
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1319>
-rw-r--r-- | sys/d3d11/gstd3d11overlaycompositor.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/sys/d3d11/gstd3d11overlaycompositor.c b/sys/d3d11/gstd3d11overlaycompositor.c index a90e319c2..b8c257a3f 100644 --- a/sys/d3d11/gstd3d11overlaycompositor.c +++ b/sys/d3d11/gstd3d11overlaycompositor.c @@ -131,6 +131,7 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self, GstD3D11Device *device = self->device; const guint index_count = 2 * 3; FLOAT x1, y1, x2, y2; + gdouble val; g_return_val_if_fail (overlay_rect != NULL, NULL); @@ -221,32 +222,45 @@ gst_d3d11_composition_overlay_new (GstD3D11OverlayCompositor * self, } vertex_data = (VertexData *) map.pData; - x1 = (x / (gfloat) GST_VIDEO_INFO_WIDTH (&self->out_info)) * 2.0f - 1.0f; - y1 = (y / (gfloat) GST_VIDEO_INFO_HEIGHT (&self->out_info)) * 2.0f - 1.0f; + /* bottom left */ + gst_util_fraction_to_double (x, GST_VIDEO_INFO_WIDTH (&self->out_info), &val); + x1 = (val * 2.0f) - 1.0f; - x2 = ((x + width) / - (gfloat) GST_VIDEO_INFO_WIDTH (&self->out_info)) * 2.0f - 1.0f; - y2 = ((y + height) / - (gfloat) GST_VIDEO_INFO_HEIGHT (&self->out_info)) * 2.0f - 1.0f; + gst_util_fraction_to_double (y + height, + GST_VIDEO_INFO_HEIGHT (&self->out_info), &val); + y1 = (val * -2.0f) + 1.0f; + /* top right */ + gst_util_fraction_to_double (x + width, + GST_VIDEO_INFO_WIDTH (&self->out_info), &val); + x2 = (val * 2.0f) - 1.0f; + + gst_util_fraction_to_double (y, + GST_VIDEO_INFO_HEIGHT (&self->out_info), &val); + y2 = (val * -2.0f) + 1.0f; + + /* bottom left */ vertex_data[0].position.x = x1; vertex_data[0].position.y = y1; vertex_data[0].position.z = 0.0f; vertex_data[0].texture.x = 0.0f; vertex_data[0].texture.y = 1.0f; + /* top left */ vertex_data[1].position.x = x1; vertex_data[1].position.y = y2; vertex_data[1].position.z = 0.0f; vertex_data[1].texture.x = 0.0f; vertex_data[1].texture.y = 0.0f; + /* top right */ vertex_data[2].position.x = x2; vertex_data[2].position.y = y2; vertex_data[2].position.z = 0.0f; vertex_data[2].texture.x = 1.0f; vertex_data[2].texture.y = 0.0f; + /* bottom right */ vertex_data[3].position.x = x2; vertex_data[3].position.y = y1; vertex_data[3].position.z = 0.0f; |