mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-19 06:46:38 +00:00
Merge branch 'master' into 0.11
Conflicts: ext/theora/gsttheoraenc.c
This commit is contained in:
commit
b1aec14767
2 changed files with 62 additions and 14 deletions
|
@ -247,6 +247,8 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstTheoraEnc, gst_theora_enc,
|
G_DEFINE_TYPE_WITH_CODE (GstTheoraEnc, gst_theora_enc,
|
||||||
GST_TYPE_ELEMENT, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
|
GST_TYPE_ELEMENT, G_IMPLEMENT_INTERFACE (GST_TYPE_PRESET, NULL));
|
||||||
|
|
||||||
|
static GstCaps *theora_enc_src_caps;
|
||||||
|
|
||||||
static gboolean theora_enc_sink_event (GstPad * pad, GstEvent * event);
|
static gboolean theora_enc_sink_event (GstPad * pad, GstEvent * event);
|
||||||
static gboolean theora_enc_src_event (GstPad * pad, GstEvent * event);
|
static gboolean theora_enc_src_event (GstPad * pad, GstEvent * event);
|
||||||
static GstFlowReturn theora_enc_chain (GstPad * pad, GstBuffer * buffer);
|
static GstFlowReturn theora_enc_chain (GstPad * pad, GstBuffer * buffer);
|
||||||
|
@ -263,11 +265,14 @@ static void theora_enc_finalize (GObject * object);
|
||||||
static gboolean theora_enc_write_multipass_cache (GstTheoraEnc * enc,
|
static gboolean theora_enc_write_multipass_cache (GstTheoraEnc * enc,
|
||||||
gboolean begin, gboolean eos);
|
gboolean begin, gboolean eos);
|
||||||
|
|
||||||
|
static char *theora_enc_get_supported_formats (void);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_theora_enc_class_init (GstTheoraEncClass * klass)
|
gst_theora_enc_class_init (GstTheoraEncClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||||
|
char *caps_string;
|
||||||
|
|
||||||
/* query runtime encoder properties */
|
/* query runtime encoder properties */
|
||||||
th_enc_ctx *th_ctx;
|
th_enc_ctx *th_ctx;
|
||||||
|
@ -396,6 +401,14 @@ gst_theora_enc_class_init (GstTheoraEncClass * klass)
|
||||||
"encode raw YUV video to a theora stream",
|
"encode raw YUV video to a theora stream",
|
||||||
"Wim Taymans <wim@fluendo.com>");
|
"Wim Taymans <wim@fluendo.com>");
|
||||||
|
|
||||||
|
caps_string = g_strdup_printf ("video/x-raw-yuv, "
|
||||||
|
"format = (fourcc) { %s }, "
|
||||||
|
"framerate = (fraction) [1/MAX, MAX], "
|
||||||
|
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]",
|
||||||
|
theora_enc_get_supported_formats ());
|
||||||
|
theora_enc_src_caps = gst_caps_from_string (caps_string);
|
||||||
|
g_free (caps_string);
|
||||||
|
|
||||||
gstelement_class->change_state = theora_enc_change_state;
|
gstelement_class->change_state = theora_enc_change_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,6 +426,7 @@ gst_theora_enc_init (GstTheoraEnc * enc)
|
||||||
enc->srcpad =
|
enc->srcpad =
|
||||||
gst_pad_new_from_static_template (&theora_enc_src_factory, "src");
|
gst_pad_new_from_static_template (&theora_enc_src_factory, "src");
|
||||||
gst_pad_set_event_function (enc->srcpad, theora_enc_src_event);
|
gst_pad_set_event_function (enc->srcpad, theora_enc_src_event);
|
||||||
|
gst_pad_use_fixed_caps (enc->srcpad);
|
||||||
gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
|
gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
|
||||||
|
|
||||||
gst_segment_init (&enc->segment, GST_FORMAT_UNDEFINED);
|
gst_segment_init (&enc->segment, GST_FORMAT_UNDEFINED);
|
||||||
|
@ -580,24 +594,49 @@ theora_enc_get_supported_formats (void)
|
||||||
static GstCaps *
|
static GstCaps *
|
||||||
theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter)
|
theora_enc_sink_getcaps (GstPad * pad, GstCaps * filter)
|
||||||
{
|
{
|
||||||
|
GstTheoraEnc *encoder;
|
||||||
|
GstPad *peer;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
char *supported_formats, *caps_string;
|
|
||||||
|
|
||||||
supported_formats = theora_enc_get_supported_formats ();
|
/* If we already have caps return them */
|
||||||
if (!supported_formats) {
|
if (GST_PAD_CAPS (pad))
|
||||||
GST_WARNING ("no supported formats found. Encoder disabled?");
|
return gst_caps_ref (GST_PAD_CAPS (pad));
|
||||||
|
|
||||||
|
encoder = GST_THEORA_ENC (gst_pad_get_parent (pad));
|
||||||
|
if (!encoder)
|
||||||
return gst_caps_new_empty ();
|
return gst_caps_new_empty ();
|
||||||
|
|
||||||
|
peer = gst_pad_get_peer (encoder->srcpad);
|
||||||
|
if (peer) {
|
||||||
|
const GstCaps *templ_caps;
|
||||||
|
GstCaps *peer_caps;
|
||||||
|
GstStructure *s;
|
||||||
|
guint i, n;
|
||||||
|
|
||||||
|
peer_caps = gst_pad_get_caps (peer);
|
||||||
|
|
||||||
|
/* Translate peercaps to YUV */
|
||||||
|
peer_caps = gst_caps_make_writable (peer_caps);
|
||||||
|
n = gst_caps_get_size (peer_caps);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
s = gst_caps_get_structure (peer_caps, i);
|
||||||
|
|
||||||
|
gst_structure_set_name (s, "video/x-raw-yuv");
|
||||||
|
gst_structure_remove_field (s, "streamheader");
|
||||||
}
|
}
|
||||||
|
|
||||||
caps_string = g_strdup_printf ("video/x-raw-yuv, "
|
templ_caps = gst_pad_get_pad_template_caps (pad);
|
||||||
"format = (fourcc) { %s }, "
|
|
||||||
"framerate = (fraction) [1/MAX, MAX], "
|
caps = gst_caps_intersect (peer_caps, templ_caps);
|
||||||
"width = (int) [ 1, MAX ], " "height = (int) [ 1, MAX ]",
|
caps = gst_caps_intersect (caps, theora_enc_src_caps);
|
||||||
supported_formats);
|
gst_caps_unref (peer_caps);
|
||||||
caps = gst_caps_from_string (caps_string);
|
gst_object_unref (peer);
|
||||||
g_free (caps_string);
|
peer = NULL;
|
||||||
g_free (supported_formats);
|
} else {
|
||||||
GST_DEBUG ("Supported caps: %" GST_PTR_FORMAT, caps);
|
caps = gst_caps_ref (theora_enc_src_caps);
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_object_unref (encoder);
|
||||||
|
|
||||||
if (filter) {
|
if (filter) {
|
||||||
GstCaps *intersection;
|
GstCaps *intersection;
|
||||||
|
@ -652,12 +691,16 @@ theora_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
enc->info.fps_denominator = enc->fps_d = fps_d;
|
enc->info.fps_denominator = enc->fps_d = fps_d;
|
||||||
if (par) {
|
if (par) {
|
||||||
enc->info.aspect_numerator = gst_value_get_fraction_numerator (par);
|
enc->info.aspect_numerator = gst_value_get_fraction_numerator (par);
|
||||||
|
enc->par_n = gst_value_get_fraction_numerator (par);
|
||||||
enc->info.aspect_denominator = gst_value_get_fraction_denominator (par);
|
enc->info.aspect_denominator = gst_value_get_fraction_denominator (par);
|
||||||
|
enc->par_d = gst_value_get_fraction_denominator (par);
|
||||||
} else {
|
} else {
|
||||||
/* setting them to 0 indicates that the decoder can chose a good aspect
|
/* setting them to 0 indicates that the decoder can chose a good aspect
|
||||||
* ratio, defaulting to 1/1 */
|
* ratio, defaulting to 1/1 */
|
||||||
enc->info.aspect_numerator = 0;
|
enc->info.aspect_numerator = 0;
|
||||||
|
enc->par_n = 1;
|
||||||
enc->info.aspect_denominator = 0;
|
enc->info.aspect_denominator = 0;
|
||||||
|
enc->par_d = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
enc->info.colorspace = TH_CS_UNSPECIFIED;
|
enc->info.colorspace = TH_CS_UNSPECIFIED;
|
||||||
|
@ -1204,7 +1247,11 @@ theora_enc_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
buffers = g_slist_reverse (buffers);
|
buffers = g_slist_reverse (buffers);
|
||||||
|
|
||||||
/* mark buffers and put on caps */
|
/* mark buffers and put on caps */
|
||||||
caps = gst_pad_get_caps (enc->srcpad, NULL);
|
caps = gst_caps_new_simple ("video/x-theora",
|
||||||
|
"width", G_TYPE_INT, enc->width,
|
||||||
|
"height", G_TYPE_INT, enc->height,
|
||||||
|
"framerate", GST_TYPE_FRACTION, enc->fps_n, enc->fps_d,
|
||||||
|
"pixel-aspect-ratio", GST_TYPE_FRACTION, enc->par_n, enc->par_d, NULL);
|
||||||
caps = theora_set_header_on_caps (caps, buffers);
|
caps = theora_set_header_on_caps (caps, buffers);
|
||||||
GST_DEBUG ("here are the caps: %" GST_PTR_FORMAT, caps);
|
GST_DEBUG ("here are the caps: %" GST_PTR_FORMAT, caps);
|
||||||
gst_pad_set_caps (enc->srcpad, caps);
|
gst_pad_set_caps (enc->srcpad, caps);
|
||||||
|
|
|
@ -102,6 +102,7 @@ struct _GstTheoraEnc
|
||||||
gint info_width, info_height;
|
gint info_width, info_height;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint fps_n, fps_d;
|
gint fps_n, fps_d;
|
||||||
|
gint par_n, par_d;
|
||||||
GstClockTime next_ts;
|
GstClockTime next_ts;
|
||||||
|
|
||||||
GstClockTime expected_ts;
|
GstClockTime expected_ts;
|
||||||
|
|
Loading…
Reference in a new issue