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
This commit is contained in:
Carl-Anton Ingmarsson 2009-08-20 00:16:02 +02:00 committed by Jan Schmidt
parent 0b979b48fc
commit f85c84af1f
2 changed files with 26 additions and 4 deletions

View file

@ -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;

View file

@ -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))