mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 08:41:07 +00:00
y4menc: Add interlaced support
Fixes #591713 Signed-off-by: David Schleef <ds@schleef.org>
This commit is contained in:
parent
55d2754098
commit
c6b2dff77e
2 changed files with 29 additions and 5 deletions
|
@ -159,7 +159,7 @@ gst_y4m_encode_setcaps (GstPad * pad, GstCaps * vscaps)
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
gboolean res;
|
gboolean res;
|
||||||
gint w, h;
|
gint w, h;
|
||||||
const GValue *fps, *par;
|
const GValue *fps, *par, *interlaced;
|
||||||
|
|
||||||
filter = GST_Y4M_ENCODE (GST_PAD_PARENT (pad));
|
filter = GST_Y4M_ENCODE (GST_PAD_PARENT (pad));
|
||||||
|
|
||||||
|
@ -172,6 +172,9 @@ gst_y4m_encode_setcaps (GstPad * pad, GstCaps * vscaps)
|
||||||
if (!res || w <= 0 || h <= 0 || !GST_VALUE_HOLDS_FRACTION (fps))
|
if (!res || w <= 0 || h <= 0 || !GST_VALUE_HOLDS_FRACTION (fps))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* optional interlaced info */
|
||||||
|
interlaced = gst_structure_get_value (structure, "interlaced");
|
||||||
|
|
||||||
/* optional par info */
|
/* optional par info */
|
||||||
par = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
par = gst_structure_get_value (structure, "pixel-aspect-ratio");
|
||||||
|
|
||||||
|
@ -186,7 +189,12 @@ gst_y4m_encode_setcaps (GstPad * pad, GstCaps * vscaps)
|
||||||
filter->par_num = 0;
|
filter->par_num = 0;
|
||||||
filter->par_den = 0;
|
filter->par_den = 0;
|
||||||
}
|
}
|
||||||
|
if ((interlaced != NULL) && G_VALUE_HOLDS (interlaced, G_TYPE_BOOLEAN)) {
|
||||||
|
filter->interlaced = g_value_get_boolean (interlaced);
|
||||||
|
} else {
|
||||||
|
/* assume progressive if no interlaced property in caps */
|
||||||
|
filter->interlaced = FALSE;
|
||||||
|
}
|
||||||
/* the template caps will do for the src pad, should always accept */
|
/* the template caps will do for the src pad, should always accept */
|
||||||
return gst_pad_set_caps (filter->srcpad,
|
return gst_pad_set_caps (filter->srcpad,
|
||||||
gst_static_pad_template_get_caps (&y4mencode_src_factory));
|
gst_static_pad_template_get_caps (&y4mencode_src_factory));
|
||||||
|
@ -197,9 +205,17 @@ gst_y4m_encode_get_stream_header (GstY4mEncode * filter)
|
||||||
{
|
{
|
||||||
gpointer header;
|
gpointer header;
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
|
gchar interlaced;
|
||||||
|
|
||||||
header = g_strdup_printf ("YUV4MPEG2 W%d H%d I? F%d:%d A%d:%d\n",
|
interlaced = 'p';
|
||||||
filter->width, filter->height,
|
|
||||||
|
if (filter->interlaced && filter->top_field_first)
|
||||||
|
interlaced = 't';
|
||||||
|
else if (filter->interlaced)
|
||||||
|
interlaced = 'b';
|
||||||
|
|
||||||
|
header = g_strdup_printf ("YUV4MPEG2 W%d H%d I%c F%d:%d A%d:%d\n",
|
||||||
|
filter->width, filter->height, interlaced,
|
||||||
filter->fps_num, filter->fps_den, filter->par_num, filter->par_den);
|
filter->fps_num, filter->fps_den, filter->par_num, filter->par_den);
|
||||||
|
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
@ -244,6 +260,13 @@ gst_y4m_encode_chain (GstPad * pad, GstBuffer * buf)
|
||||||
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
timestamp = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
if (G_UNLIKELY (!filter->header)) {
|
if (G_UNLIKELY (!filter->header)) {
|
||||||
|
if (filter->interlaced == TRUE) {
|
||||||
|
if (GST_BUFFER_FLAG_IS_SET (buf, GST_VIDEO_BUFFER_TFF)) {
|
||||||
|
filter->top_field_first = TRUE;
|
||||||
|
} else {
|
||||||
|
filter->top_field_first = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
outbuf = gst_y4m_encode_get_stream_header (filter);
|
outbuf = gst_y4m_encode_get_stream_header (filter);
|
||||||
filter->header = TRUE;
|
filter->header = TRUE;
|
||||||
outbuf = gst_buffer_join (outbuf, gst_y4m_encode_get_frame_header (filter));
|
outbuf = gst_buffer_join (outbuf, gst_y4m_encode_get_frame_header (filter));
|
||||||
|
|
|
@ -51,7 +51,8 @@ struct _GstY4mEncode {
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint fps_num, fps_den;
|
gint fps_num, fps_den;
|
||||||
gint par_num, par_den;
|
gint par_num, par_den;
|
||||||
|
gboolean interlaced;
|
||||||
|
gboolean top_field_first;
|
||||||
/* state information */
|
/* state information */
|
||||||
gboolean header;
|
gboolean header;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue