mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
x264enc: put all theoretically possible formats in template caps
and decide at runtime which subset of these (8-bit or 10-bit video formats) is supported. libx264 will be compiled for one of these two options, and it is possible to switch by pointing the dynamic linker to a different libx264 build at runtime. If we want our template caps to be correct, they should contain all then, with the actually supported ones determined at runtime. https://bugzilla.gnome.org/show_bug.cgi?id=691935
This commit is contained in:
parent
e765deb01b
commit
201e3f74be
1 changed files with 32 additions and 7 deletions
|
@ -389,6 +389,21 @@ gst_x264_enc_build_tunings_string (GstX264Enc * x264enc)
|
||||||
x264enc->tunings->str);
|
x264enc->tunings->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
|
#define FORMATS "I420, YV12, Y42B, Y444, NV12, I420_10LE, I422_10LE, Y444_10LE"
|
||||||
|
#else
|
||||||
|
#define FORMATS "I420, YV12, Y42B, Y444, NV12, I420_10BE, I422_10BE, Y444_10BE"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
|
GST_PAD_SINK,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS ("video/x-raw, "
|
||||||
|
"format = (string) { " FORMATS " }, "
|
||||||
|
"framerate = (fraction) [0, MAX], "
|
||||||
|
"width = (int) [ 16, MAX ], " "height = (int) [ 16, MAX ]")
|
||||||
|
);
|
||||||
|
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
|
@ -544,6 +559,20 @@ gst_x264_enc_get_supported_input_caps (void)
|
||||||
"width", GST_TYPE_INT_RANGE, 16, G_MAXINT,
|
"width", GST_TYPE_INT_RANGE, 16, G_MAXINT,
|
||||||
"height", GST_TYPE_INT_RANGE, 16, G_MAXINT, NULL);
|
"height", GST_TYPE_INT_RANGE, 16, G_MAXINT, NULL);
|
||||||
|
|
||||||
|
GST_DEBUG ("returning %" GST_PTR_FORMAT, caps);
|
||||||
|
return caps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allowed input caps depending on whether libx264 was built for 8 or 10 bits */
|
||||||
|
static GstCaps *
|
||||||
|
gst_x264_enc_sink_getcaps (GstVideoEncoder * enc, GstCaps * filter)
|
||||||
|
{
|
||||||
|
GstCaps *supported_incaps, *caps;
|
||||||
|
|
||||||
|
supported_incaps = gst_x264_enc_get_supported_input_caps ();
|
||||||
|
caps = gst_video_encoder_proxy_getcaps (enc, supported_incaps, filter);
|
||||||
|
gst_caps_unref (supported_incaps);
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,9 +582,7 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
GObjectClass *gobject_class;
|
GObjectClass *gobject_class;
|
||||||
GstElementClass *element_class;
|
GstElementClass *element_class;
|
||||||
GstVideoEncoderClass *gstencoder_class;
|
GstVideoEncoderClass *gstencoder_class;
|
||||||
GstPadTemplate *tmpl;
|
|
||||||
const gchar *partitions = NULL;
|
const gchar *partitions = NULL;
|
||||||
GstCaps *caps;
|
|
||||||
|
|
||||||
x264enc_defaults = g_string_new ("");
|
x264enc_defaults = g_string_new ("");
|
||||||
|
|
||||||
|
@ -573,6 +600,7 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
GST_DEBUG_FUNCPTR (gst_x264_enc_handle_frame);
|
GST_DEBUG_FUNCPTR (gst_x264_enc_handle_frame);
|
||||||
gstencoder_class->reset = GST_DEBUG_FUNCPTR (gst_x264_enc_reset);
|
gstencoder_class->reset = GST_DEBUG_FUNCPTR (gst_x264_enc_reset);
|
||||||
gstencoder_class->finish = GST_DEBUG_FUNCPTR (gst_x264_enc_finish);
|
gstencoder_class->finish = GST_DEBUG_FUNCPTR (gst_x264_enc_finish);
|
||||||
|
gstencoder_class->getcaps = GST_DEBUG_FUNCPTR (gst_x264_enc_sink_getcaps);
|
||||||
gstencoder_class->propose_allocation =
|
gstencoder_class->propose_allocation =
|
||||||
GST_DEBUG_FUNCPTR (gst_x264_enc_propose_allocation);
|
GST_DEBUG_FUNCPTR (gst_x264_enc_propose_allocation);
|
||||||
|
|
||||||
|
@ -807,13 +835,10 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
|
||||||
"Josef Zlomek <josef.zlomek@itonis.tv>, "
|
"Josef Zlomek <josef.zlomek@itonis.tv>, "
|
||||||
"Mark Nauwelaerts <mnauw@users.sf.net>");
|
"Mark Nauwelaerts <mnauw@users.sf.net>");
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (element_class,
|
||||||
|
gst_static_pad_template_get (&sink_factory));
|
||||||
gst_element_class_add_pad_template (element_class,
|
gst_element_class_add_pad_template (element_class,
|
||||||
gst_static_pad_template_get (&src_factory));
|
gst_static_pad_template_get (&src_factory));
|
||||||
|
|
||||||
caps = gst_x264_enc_get_supported_input_caps ();
|
|
||||||
tmpl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
|
||||||
gst_element_class_add_pad_template (element_class, tmpl);
|
|
||||||
gst_caps_unref (caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue