mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 04:52:28 +00:00
gst/videoscale/gstvideoscale.c: Prefer the given format if it contains something stricter than [1,MAX] for height or ...
Original commit message from CVS: * gst/videoscale/gstvideoscale.c: (gst_video_scale_transform_caps): Prefer the given format if it contains something stricter than [1,MAX] for height or width and only put a structure that requires rescaling as second. This makes it possible to use videoscale in pipelines where the source can actually produce the wanted height/width but usually selects a different one from the requested.
This commit is contained in:
parent
f934d1c233
commit
8b14d08115
2 changed files with 43 additions and 1 deletions
|
@ -1,3 +1,12 @@
|
|||
2008-06-04 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/videoscale/gstvideoscale.c: (gst_video_scale_transform_caps):
|
||||
Prefer the given format if it contains something stricter than [1,MAX]
|
||||
for height or width and only put a structure that requires rescaling
|
||||
as second. This makes it possible to use videoscale in pipelines where
|
||||
the source can actually produce the wanted height/width but usually
|
||||
selects a different one from the requested.
|
||||
|
||||
2008-06-03 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||
|
||||
Based on patch by: John Millikin <jmillikin gmail com>
|
||||
|
|
|
@ -139,6 +139,7 @@ static GType
|
|||
gst_video_scale_method_get_type (void)
|
||||
{
|
||||
static GType video_scale_method_type = 0;
|
||||
|
||||
static const GEnumValue video_scale_methods[] = {
|
||||
{GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
|
||||
{GST_VIDEO_SCALE_BILINEAR, "Bilinear", "bilinear"},
|
||||
|
@ -187,9 +188,13 @@ gst_video_scale_sink_template_factory (void)
|
|||
|
||||
|
||||
static void gst_video_scale_base_init (gpointer g_class);
|
||||
|
||||
static void gst_video_scale_class_init (GstVideoScaleClass * klass);
|
||||
|
||||
static void gst_video_scale_init (GstVideoScale * videoscale);
|
||||
|
||||
static void gst_video_scale_finalize (GstVideoScale * videoscale);
|
||||
|
||||
static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
|
||||
GstEvent * event);
|
||||
|
||||
|
@ -255,6 +260,7 @@ static void
|
|||
gst_video_scale_class_init (GstVideoScaleClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
|
||||
GstBaseTransformClass *trans_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
|
@ -341,9 +347,13 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
|||
GstPadDirection direction, GstCaps * caps)
|
||||
{
|
||||
GstVideoScale *videoscale;
|
||||
|
||||
GstCaps *ret;
|
||||
|
||||
GstStructure *structure;
|
||||
|
||||
const GValue *par;
|
||||
|
||||
gint method;
|
||||
|
||||
/* this function is always called with a simple caps */
|
||||
|
@ -371,15 +381,19 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
|||
}
|
||||
|
||||
ret = gst_caps_copy (caps);
|
||||
structure = gst_caps_get_structure (ret, 0);
|
||||
structure = gst_structure_copy (gst_caps_get_structure (ret, 0));
|
||||
|
||||
gst_structure_set (structure,
|
||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
|
||||
gst_caps_merge_structure (ret, structure);
|
||||
structure = gst_caps_get_structure (ret, 0);
|
||||
|
||||
/* if pixel aspect ratio, make a range of it */
|
||||
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
|
||||
GstCaps *copy;
|
||||
|
||||
GstStructure *cstruct;
|
||||
|
||||
/* copy input PAR first, this is the prefered PAR */
|
||||
|
@ -411,6 +425,7 @@ static int
|
|||
gst_video_scale_get_format (GstCaps * caps)
|
||||
{
|
||||
int i;
|
||||
|
||||
GstCaps *icaps, *scaps;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++) {
|
||||
|
@ -505,6 +520,7 @@ static gboolean
|
|||
parse_caps (GstCaps * caps, gint * format, gint * width, gint * height)
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
|
@ -521,6 +537,7 @@ static gboolean
|
|||
gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
||||
{
|
||||
GstVideoScale *videoscale;
|
||||
|
||||
gboolean ret;
|
||||
|
||||
videoscale = GST_VIDEO_SCALE (trans);
|
||||
|
@ -562,7 +579,9 @@ gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|||
guint * size)
|
||||
{
|
||||
GstVideoScale *videoscale;
|
||||
|
||||
gint format, width, height;
|
||||
|
||||
VSImage img;
|
||||
|
||||
g_assert (size);
|
||||
|
@ -584,6 +603,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
|
|||
GstCaps * caps, GstCaps * othercaps)
|
||||
{
|
||||
GstStructure *ins, *outs;
|
||||
|
||||
const GValue *from_par, *to_par;
|
||||
|
||||
g_return_if_fail (gst_caps_is_fixed (caps));
|
||||
|
@ -600,7 +620,9 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
|
|||
/* we have both PAR but they might not be fixated */
|
||||
if (from_par && to_par) {
|
||||
gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
|
||||
|
||||
gint count = 0, w = 0, h = 0;
|
||||
|
||||
guint num, den;
|
||||
|
||||
/* from_par should be fixed */
|
||||
|
@ -729,13 +751,21 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
|||
GstBuffer * out)
|
||||
{
|
||||
GstVideoScale *videoscale;
|
||||
|
||||
GstFlowReturn ret = GST_FLOW_OK;
|
||||
|
||||
VSImage *dest;
|
||||
|
||||
VSImage *src;
|
||||
|
||||
VSImage dest_u;
|
||||
|
||||
VSImage dest_v;
|
||||
|
||||
VSImage src_u;
|
||||
|
||||
VSImage src_v;
|
||||
|
||||
gint method;
|
||||
|
||||
videoscale = GST_VIDEO_SCALE (trans);
|
||||
|
@ -884,8 +914,11 @@ static gboolean
|
|||
gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||
{
|
||||
GstVideoScale *videoscale;
|
||||
|
||||
gboolean ret;
|
||||
|
||||
double a;
|
||||
|
||||
GstStructure *structure;
|
||||
|
||||
videoscale = GST_VIDEO_SCALE (trans);
|
||||
|
|
Loading…
Reference in a new issue