diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2009-08-20 00:16:02 +0200 |
---|---|---|
committer | Jan Schmidt <thaytan@noraisin.net> | 2009-09-16 10:25:47 +0100 |
commit | f85c84af1fb9228c27ea5b13d045ad43cdf916c2 (patch) | |
tree | 84b27d58bf72fa7a74a0ce5ab069cd544a86ddb6 /sys | |
parent | 0b979b48fccedfa193a97d173ad711410c0e5f4f (diff) |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vdpau/gstvdputils.c | 13 | ||||
-rw-r--r-- | 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 ecb635240..7602225f5 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 7b965e9d3..9673bd3bb 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)) |