mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
gst/videomixer/videomixer.c: Fix caps negotiation. (#323896)
Original commit message from CVS: 2005-12-12 Julien MOUTTE <julien@moutte.net> * gst/videomixer/videomixer.c: (gst_videomixer_pad_sink_setcaps), (gst_videomixer_getcaps), (gst_videomixer_fill_queues), (gst_videomixer_update_queues), (gst_videomixer_collected): Fix caps negotiation. (#323896)
This commit is contained in:
parent
fe8b19e160
commit
5fa259d071
2 changed files with 37 additions and 22 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2005-12-12 Julien MOUTTE <julien@moutte.net>
|
||||||
|
|
||||||
|
* gst/videomixer/videomixer.c: (gst_videomixer_pad_sink_setcaps),
|
||||||
|
(gst_videomixer_getcaps), (gst_videomixer_fill_queues),
|
||||||
|
(gst_videomixer_update_queues), (gst_videomixer_collected):
|
||||||
|
Fix caps negotiation. (#323896)
|
||||||
|
|
||||||
2005-12-12 Arwed v. Merkatz <v.merkatz@gmx.net>
|
2005-12-12 Arwed v. Merkatz <v.merkatz@gmx.net>
|
||||||
|
|
||||||
* gst/matroska/matroska-demux.c:
|
* gst/matroska/matroska-demux.c:
|
||||||
|
|
|
@ -99,8 +99,8 @@ struct _GstVideoMixerPad
|
||||||
guint64 queued;
|
guint64 queued;
|
||||||
|
|
||||||
guint in_width, in_height;
|
guint in_width, in_height;
|
||||||
gint in_framerate_numerator;
|
gint fps_n;
|
||||||
gint in_framerate_denominator;
|
gint fps_d;
|
||||||
|
|
||||||
gint xpos, ypos;
|
gint xpos, ypos;
|
||||||
guint zorder;
|
guint zorder;
|
||||||
|
@ -227,6 +227,9 @@ gst_videomixer_pad_set_property (GObject * object, guint prop_id,
|
||||||
gst_object_unref (mix);
|
gst_object_unref (mix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstVideoMixerBackground:
|
||||||
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
VIDEO_MIXER_BACKGROUND_CHECKER,
|
VIDEO_MIXER_BACKGROUND_CHECKER,
|
||||||
|
@ -257,8 +260,8 @@ struct _GstVideoMixer
|
||||||
|
|
||||||
GstVideoMixerBackground background;
|
GstVideoMixerBackground background;
|
||||||
|
|
||||||
gint in_framerate_numerator;
|
gint fps_n;
|
||||||
gint in_framerate_denominator;
|
gint fps_d;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVideoMixerClass
|
struct _GstVideoMixerClass
|
||||||
|
@ -279,18 +282,21 @@ gst_videomixer_pad_sink_setcaps (GstPad * pad, GstCaps * vscaps)
|
||||||
mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad));
|
mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad));
|
||||||
mixpad = GST_VIDEO_MIXER_PAD (pad);
|
mixpad = GST_VIDEO_MIXER_PAD (pad);
|
||||||
|
|
||||||
GST_DEBUG ("videomixer: setcaps triggered on %s", gst_pad_get_name (pad));
|
if (!mixpad) {
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (mixpad, "setcaps triggered");
|
||||||
|
|
||||||
structure = gst_caps_get_structure (vscaps, 0);
|
structure = gst_caps_get_structure (vscaps, 0);
|
||||||
|
|
||||||
if (!gst_structure_get_int (structure, "width", &in_width)
|
if (!gst_structure_get_int (structure, "width", &in_width)
|
||||||
|| !gst_structure_get_int (structure, "height", &in_height)
|
|| !gst_structure_get_int (structure, "height", &in_height)
|
||||||
|| (framerate = gst_structure_get_value (structure, "framerate")) != NULL)
|
|| (framerate = gst_structure_get_value (structure, "framerate")) == NULL)
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
mixpad->in_framerate_numerator = gst_value_get_fraction_numerator (framerate);
|
mixpad->fps_n = gst_value_get_fraction_numerator (framerate);
|
||||||
mixpad->in_framerate_denominator =
|
mixpad->fps_d = gst_value_get_fraction_denominator (framerate);
|
||||||
gst_value_get_fraction_denominator (framerate);
|
|
||||||
|
|
||||||
mixpad->in_width = in_width;
|
mixpad->in_width = in_width;
|
||||||
mixpad->in_height = in_height;
|
mixpad->in_height = in_height;
|
||||||
|
@ -298,14 +304,19 @@ gst_videomixer_pad_sink_setcaps (GstPad * pad, GstCaps * vscaps)
|
||||||
mixpad->xpos = 0;
|
mixpad->xpos = 0;
|
||||||
mixpad->ypos = 0;
|
mixpad->ypos = 0;
|
||||||
|
|
||||||
|
/* Biggest input geometry will be our output geometry */
|
||||||
mix->in_width = MAX (mix->in_width, mixpad->in_width);
|
mix->in_width = MAX (mix->in_width, mixpad->in_width);
|
||||||
mix->in_height = MAX (mix->in_height, mixpad->in_height);
|
mix->in_height = MAX (mix->in_height, mixpad->in_height);
|
||||||
|
|
||||||
/* If mix framerate < mixpad framerate, using fractions */
|
/* If mix framerate < mixpad framerate, using fractions */
|
||||||
if ((gint64) mix->in_framerate_numerator * mixpad->in_framerate_denominator <
|
GST_DEBUG_OBJECT (mix, "comparing mix framerate %d/%d to mixpad's %d/%d",
|
||||||
(gint64) mixpad->in_framerate_numerator * mix->in_framerate_denominator) {
|
mix->fps_n, mix->fps_d, mixpad->fps_n, mixpad->fps_d);
|
||||||
mix->in_framerate_numerator = mixpad->in_framerate_numerator;
|
if ((!mix->fps_n && !mix->fps_d) ||
|
||||||
mix->in_framerate_denominator = mixpad->in_framerate_denominator;
|
((gint64) mix->fps_n * mixpad->fps_d <
|
||||||
|
(gint64) mixpad->fps_n * mix->fps_d)) {
|
||||||
|
mix->fps_n = mixpad->fps_n;
|
||||||
|
mix->fps_d = mixpad->fps_d;
|
||||||
|
GST_DEBUG_OBJECT (mixpad, "becomes the master pad");
|
||||||
mix->master = mixpad;
|
mix->master = mixpad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,10 +540,9 @@ gst_videomixer_getcaps (GstPad * pad)
|
||||||
if (mix->out_height != 0) {
|
if (mix->out_height != 0) {
|
||||||
gst_structure_set (structure, "height", G_TYPE_INT, mix->out_height, NULL);
|
gst_structure_set (structure, "height", G_TYPE_INT, mix->out_height, NULL);
|
||||||
}
|
}
|
||||||
if (mix->in_framerate_denominator != 0) {
|
if (mix->fps_d != 0) {
|
||||||
gst_structure_set (structure,
|
gst_structure_set (structure,
|
||||||
"framerate", GST_TYPE_FRACTION, mix->in_framerate_numerator,
|
"framerate", GST_TYPE_FRACTION, mix->fps_n, mix->fps_d, NULL);
|
||||||
mix->in_framerate_denominator, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_object_unref (mix);
|
gst_object_unref (mix);
|
||||||
|
@ -907,11 +917,10 @@ gst_videomixer_fill_queues (GstVideoMixer * mix)
|
||||||
duration = GST_BUFFER_DURATION (mixcol->buffer);
|
duration = GST_BUFFER_DURATION (mixcol->buffer);
|
||||||
/* no duration on the buffer, use the framerate */
|
/* no duration on the buffer, use the framerate */
|
||||||
if (!GST_CLOCK_TIME_IS_VALID (duration)) {
|
if (!GST_CLOCK_TIME_IS_VALID (duration)) {
|
||||||
if (mixpad->in_framerate_numerator == 0) {
|
if (mixpad->fps_n == 0) {
|
||||||
duration = GST_CLOCK_TIME_NONE;
|
duration = GST_CLOCK_TIME_NONE;
|
||||||
} else {
|
} else {
|
||||||
duration = GST_SECOND * mixpad->in_framerate_denominator /
|
duration = GST_SECOND * mixpad->fps_d / mixpad->fps_n;
|
||||||
mixpad->in_framerate_numerator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GST_CLOCK_TIME_IS_VALID (duration))
|
if (GST_CLOCK_TIME_IS_VALID (duration))
|
||||||
|
@ -970,11 +979,10 @@ gst_videomixer_update_queues (GstVideoMixer * mix)
|
||||||
|
|
||||||
interval = mix->master->queued;
|
interval = mix->master->queued;
|
||||||
if (interval <= 0) {
|
if (interval <= 0) {
|
||||||
if (mix->in_framerate_numerator == 0) {
|
if (mix->fps_n == 0) {
|
||||||
interval = G_MAXINT64;
|
interval = G_MAXINT64;
|
||||||
} else {
|
} else {
|
||||||
interval = GST_SECOND * mix->in_framerate_denominator /
|
interval = GST_SECOND * mix->fps_d / mix->fps_n;
|
||||||
mix->in_framerate_numerator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue