[gst-cvs] gst-plugins-bad: vdpauvideopostprocess: handle pixel-aspect-ratio better
Jan Schmidt
thaytan at kemper.freedesktop.org
Wed Sep 16 17:39:12 PDT 2009
Module: gst-plugins-bad
Branch: master
Commit: f85c84af1fb9228c27ea5b13d045ad43cdf916c2
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=f85c84af1fb9228c27ea5b13d045ad43cdf916c2
Author: Carl-Anton Ingmarsson <ca.ingmarsson at gmail.com>
Date: Thu Aug 20 00:16:02 2009 +0200
vdpauvideopostprocess: handle pixel-aspect-ratio better
the implementation is not entirely correct since we assume that the sink
element's pixel-aspect-ratio is 1/1
---
sys/vdpau/gstvdputils.c | 13 +++++++++++--
sys/vdpau/gstvdpvideopostprocess.c | 17 +++++++++++++++--
2 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/sys/vdpau/gstvdputils.c b/sys/vdpau/gstvdputils.c
index ecb6352..7602225 100644
--- a/sys/vdpau/gstvdputils.c
+++ b/sys/vdpau/gstvdputils.c
@@ -131,12 +131,21 @@ gst_vdp_video_to_output_caps (GstCaps * caps)
result = gst_caps_copy (caps);
for (i = 0; i < gst_caps_get_size (result); i++) {
GstStructure *structure = gst_caps_get_structure (result, i);
+ gint par_n, par_d;
gst_structure_set_name (structure, "video/x-vdpau-output");
gst_structure_remove_field (structure, "chroma-type");
- /* FIXME: don't know what to do with pixel-aspect-ratio */
- gst_structure_remove_field (structure, "pixel-aspect-ratio");
+ if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
+ &par_d)) {
+ gint width;
+
+ gst_structure_get_int (structure, "width", &width);
+ width = gst_util_uint64_scale_int (width, par_n, par_d);
+ gst_structure_set (structure, "width", G_TYPE_INT, width, NULL);
+
+ gst_structure_remove_field (structure, "pixel-aspect-ratio");
+ }
}
return result;
diff --git a/sys/vdpau/gstvdpvideopostprocess.c b/sys/vdpau/gstvdpvideopostprocess.c
index 7b965e9..9673bd3 100644
--- a/sys/vdpau/gstvdpvideopostprocess.c
+++ b/sys/vdpau/gstvdpvideopostprocess.c
@@ -509,8 +509,9 @@ gst_vdp_vpp_sink_setcaps (GstPad * pad, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0);
gst_structure_get_boolean (structure, "interlaced", &vpp->interlaced);
- output_caps = gst_vdp_video_to_output_caps (caps);
allowed_caps = gst_pad_get_allowed_caps (vpp->srcpad);
+ structure = gst_caps_get_structure (allowed_caps, 0);
+ output_caps = gst_vdp_video_to_output_caps (caps);
src_caps = gst_caps_intersect (output_caps, allowed_caps);
gst_caps_truncate (src_caps);
@@ -629,7 +630,10 @@ gst_vdp_vpp_chain (GstPad * pad, GstBuffer * buffer)
GstVdpOutputBuffer *outbuf;
GstStructure *structure;
- GstVideoRectangle src_r, dest_r;
+ GstVideoRectangle src_r = { 0, }
+ , dest_r = {
+ 0,};
+ gint par_n, par_d;
VdpRect rect;
GstVdpDevice *device;
@@ -646,6 +650,15 @@ gst_vdp_vpp_chain (GstPad * pad, GstBuffer * buffer)
!gst_structure_get_int (structure, "height", &src_r.h))
goto invalid_caps;
+ if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
+ &par_d)) {
+ gint new_width;
+
+ new_width = gst_util_uint64_scale_int (src_r.w, par_n, par_d);
+ src_r.x += (src_r.w - new_width) / 2;
+ src_r.w = new_width;
+ }
+
structure = gst_caps_get_structure (GST_BUFFER_CAPS (outbuf), 0);
if (!gst_structure_get_int (structure, "width", &dest_r.w) ||
!gst_structure_get_int (structure, "height", &dest_r.h))
More information about the Gstreamer-commits
mailing list