mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 06:58:56 +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>
|
2008-06-03 Tim-Philipp Müller <tim.muller at collabora co uk>
|
||||||
|
|
||||||
Based on patch by: John Millikin <jmillikin gmail com>
|
Based on patch by: John Millikin <jmillikin gmail com>
|
||||||
|
|
|
@ -139,6 +139,7 @@ static GType
|
||||||
gst_video_scale_method_get_type (void)
|
gst_video_scale_method_get_type (void)
|
||||||
{
|
{
|
||||||
static GType video_scale_method_type = 0;
|
static GType video_scale_method_type = 0;
|
||||||
|
|
||||||
static const GEnumValue video_scale_methods[] = {
|
static const GEnumValue video_scale_methods[] = {
|
||||||
{GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
|
{GST_VIDEO_SCALE_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
|
||||||
{GST_VIDEO_SCALE_BILINEAR, "Bilinear", "bilinear"},
|
{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_base_init (gpointer g_class);
|
||||||
|
|
||||||
static void gst_video_scale_class_init (GstVideoScaleClass * klass);
|
static void gst_video_scale_class_init (GstVideoScaleClass * klass);
|
||||||
|
|
||||||
static void gst_video_scale_init (GstVideoScale * videoscale);
|
static void gst_video_scale_init (GstVideoScale * videoscale);
|
||||||
|
|
||||||
static void gst_video_scale_finalize (GstVideoScale * videoscale);
|
static void gst_video_scale_finalize (GstVideoScale * videoscale);
|
||||||
|
|
||||||
static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
|
static gboolean gst_video_scale_src_event (GstBaseTransform * trans,
|
||||||
GstEvent * event);
|
GstEvent * event);
|
||||||
|
|
||||||
|
@ -255,6 +260,7 @@ static void
|
||||||
gst_video_scale_class_init (GstVideoScaleClass * klass)
|
gst_video_scale_class_init (GstVideoScaleClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
|
|
||||||
GstBaseTransformClass *trans_class;
|
GstBaseTransformClass *trans_class;
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
gobject_class = (GObjectClass *) klass;
|
||||||
|
@ -341,9 +347,13 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
||||||
GstPadDirection direction, GstCaps * caps)
|
GstPadDirection direction, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstVideoScale *videoscale;
|
GstVideoScale *videoscale;
|
||||||
|
|
||||||
GstCaps *ret;
|
GstCaps *ret;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
const GValue *par;
|
const GValue *par;
|
||||||
|
|
||||||
gint method;
|
gint method;
|
||||||
|
|
||||||
/* this function is always called with a simple caps */
|
/* 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);
|
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,
|
gst_structure_set (structure,
|
||||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||||
"height", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
"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 pixel aspect ratio, make a range of it */
|
||||||
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
|
if ((par = gst_structure_get_value (structure, "pixel-aspect-ratio"))) {
|
||||||
GstCaps *copy;
|
GstCaps *copy;
|
||||||
|
|
||||||
GstStructure *cstruct;
|
GstStructure *cstruct;
|
||||||
|
|
||||||
/* copy input PAR first, this is the prefered PAR */
|
/* copy input PAR first, this is the prefered PAR */
|
||||||
|
@ -411,6 +425,7 @@ static int
|
||||||
gst_video_scale_get_format (GstCaps * caps)
|
gst_video_scale_get_format (GstCaps * caps)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
GstCaps *icaps, *scaps;
|
GstCaps *icaps, *scaps;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (gst_video_scale_format_caps); i++) {
|
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)
|
parse_caps (GstCaps * caps, gint * format, gint * width, gint * height)
|
||||||
{
|
{
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
|
@ -521,6 +537,7 @@ static gboolean
|
||||||
gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
gst_video_scale_set_caps (GstBaseTransform * trans, GstCaps * in, GstCaps * out)
|
||||||
{
|
{
|
||||||
GstVideoScale *videoscale;
|
GstVideoScale *videoscale;
|
||||||
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
videoscale = GST_VIDEO_SCALE (trans);
|
videoscale = GST_VIDEO_SCALE (trans);
|
||||||
|
@ -562,7 +579,9 @@ gst_video_scale_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
||||||
guint * size)
|
guint * size)
|
||||||
{
|
{
|
||||||
GstVideoScale *videoscale;
|
GstVideoScale *videoscale;
|
||||||
|
|
||||||
gint format, width, height;
|
gint format, width, height;
|
||||||
|
|
||||||
VSImage img;
|
VSImage img;
|
||||||
|
|
||||||
g_assert (size);
|
g_assert (size);
|
||||||
|
@ -584,6 +603,7 @@ gst_video_scale_fixate_caps (GstBaseTransform * base, GstPadDirection direction,
|
||||||
GstCaps * caps, GstCaps * othercaps)
|
GstCaps * caps, GstCaps * othercaps)
|
||||||
{
|
{
|
||||||
GstStructure *ins, *outs;
|
GstStructure *ins, *outs;
|
||||||
|
|
||||||
const GValue *from_par, *to_par;
|
const GValue *from_par, *to_par;
|
||||||
|
|
||||||
g_return_if_fail (gst_caps_is_fixed (caps));
|
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 */
|
/* we have both PAR but they might not be fixated */
|
||||||
if (from_par && to_par) {
|
if (from_par && to_par) {
|
||||||
gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
|
gint from_w, from_h, from_par_n, from_par_d, to_par_n, to_par_d;
|
||||||
|
|
||||||
gint count = 0, w = 0, h = 0;
|
gint count = 0, w = 0, h = 0;
|
||||||
|
|
||||||
guint num, den;
|
guint num, den;
|
||||||
|
|
||||||
/* from_par should be fixed */
|
/* from_par should be fixed */
|
||||||
|
@ -729,13 +751,21 @@ gst_video_scale_transform (GstBaseTransform * trans, GstBuffer * in,
|
||||||
GstBuffer * out)
|
GstBuffer * out)
|
||||||
{
|
{
|
||||||
GstVideoScale *videoscale;
|
GstVideoScale *videoscale;
|
||||||
|
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
|
|
||||||
VSImage *dest;
|
VSImage *dest;
|
||||||
|
|
||||||
VSImage *src;
|
VSImage *src;
|
||||||
|
|
||||||
VSImage dest_u;
|
VSImage dest_u;
|
||||||
|
|
||||||
VSImage dest_v;
|
VSImage dest_v;
|
||||||
|
|
||||||
VSImage src_u;
|
VSImage src_u;
|
||||||
|
|
||||||
VSImage src_v;
|
VSImage src_v;
|
||||||
|
|
||||||
gint method;
|
gint method;
|
||||||
|
|
||||||
videoscale = GST_VIDEO_SCALE (trans);
|
videoscale = GST_VIDEO_SCALE (trans);
|
||||||
|
@ -884,8 +914,11 @@ static gboolean
|
||||||
gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
|
gst_video_scale_src_event (GstBaseTransform * trans, GstEvent * event)
|
||||||
{
|
{
|
||||||
GstVideoScale *videoscale;
|
GstVideoScale *videoscale;
|
||||||
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
double a;
|
double a;
|
||||||
|
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
|
||||||
videoscale = GST_VIDEO_SCALE (trans);
|
videoscale = GST_VIDEO_SCALE (trans);
|
||||||
|
|
Loading…
Reference in a new issue