diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index 15dd190f1949c1769ac04ac757b62fa71d86858a..2be3dd3b9ca7d5646b3b5f23968763be9ebd81cf 100644 (file)
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
#define ARG_PSY_TUNE_DEFAULT 0 /* no psy tuning */
#define ARG_TUNE_DEFAULT 0 /* no tuning */
+enum
+{
+ GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY,
+ GST_X264_ENC_STREAM_FORMAT_AVC,
+ GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM
+};
+
enum
{
GST_X264_ENC_PASS_CBR = 0,
{
int i = 1;
- if (x264enc->tunings && x264enc->tunings->len)
+ if (x264enc->tunings)
g_string_free (x264enc->tunings, TRUE);
if (x264enc->psy_tune) {
"Josef Zlomek <josef.zlomek@itonis.tv>, "
"Mark Nauwelaerts <mnauw@users.sf.net>");
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&src_factory));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&sink_factory));
+ gst_element_class_add_static_pad_template (element_class, &src_factory);
+ gst_element_class_add_static_pad_template (element_class, &sink_factory);
}
/* don't forget to free the string after use */
encoder->x264enc = NULL;
encoder->width = 0;
encoder->height = 0;
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
GST_OBJECT_LOCK (encoder);
encoder->i_type = X264_TYPE_AUTO;
if (encoder->peer_level->frame_only) {
encoder->x264param.b_interlaced = FALSE;
+#if X264_BUILD >= 95
encoder->x264param.b_fake_interlaced = FALSE;
+#endif
}
}
@@ -1445,7 +1453,14 @@ gst_x264_enc_set_src_caps (GstX264Enc * encoder, GstPad * pad, GstCaps * caps)
structure = gst_caps_get_structure (outcaps, 0);
- if (!encoder->byte_stream) {
+ if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY) {
+ if (encoder->byte_stream) {
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM;
+ } else {
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC;
+ }
+ }
+ if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_AVC) {
buf = gst_x264_enc_header_buf (encoder);
if (buf != NULL) {
gst_caps_set_simple (outcaps, "codec_data", GST_TYPE_BUFFER, buf, NULL);
peer_caps = gst_pad_peer_get_caps_reffed (encoder->srcpad);
if (peer_caps) {
gint i;
- gboolean has_profile_or_level = FALSE;
+ gboolean has_profile_or_level_or_format = FALSE;
for (i = 0; i < gst_caps_get_size (peer_caps); i++) {
GstStructure *s = gst_caps_get_structure (peer_caps, i);
if (gst_structure_has_name (s, "video/x-h264") &&
(gst_structure_has_field (s, "profile") ||
- gst_structure_has_field (s, "level"))) {
- has_profile_or_level = TRUE;
+ gst_structure_has_field (s, "level") ||
+ gst_structure_has_field (s, "stream-format"))) {
+ has_profile_or_level_or_format = TRUE;
break;
}
}
- if (has_profile_or_level) {
+ if (has_profile_or_level_or_format) {
template_caps = gst_pad_get_pad_template_caps (encoder->srcpad);
allowed_caps = gst_caps_intersect (peer_caps, template_caps);
GstStructure *s;
const gchar *profile;
const gchar *level;
+ const gchar *stream_format;
if (gst_caps_is_empty (allowed_caps)) {
gst_caps_unref (allowed_caps);
}
}
+ stream_format = gst_structure_get_string (s, "stream-format");
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
+ if (stream_format) {
+ if (!strcmp (stream_format, "avc")) {
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_AVC;
+ g_string_append_printf (encoder->option_string, ":annexb=0");
+ } else if (!strcmp (stream_format, "byte-stream")) {
+ encoder->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM;
+ g_string_append_printf (encoder->option_string, ":annexb=1");
+ } else {
+ /* means we have both in caps and _FROM_PROPERTY should be the option */
+ }
+ }
+
gst_caps_unref (allowed_caps);
}
GstPad *peer;
GstCaps *caps;
- /* If we already have caps return them */
- if (GST_PAD_CAPS (pad))
- return gst_caps_ref (GST_PAD_CAPS (pad));
-
encoder = GST_X264_ENC (gst_pad_get_parent (pad));
if (!encoder)
return gst_caps_new_empty ();
caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
}
+ /* If we already have caps return them */
+ if (GST_PAD_CAPS (pad) && gst_caps_can_intersect (GST_PAD_CAPS (pad), caps)) {
+ GstCaps *tmpcaps = gst_caps_copy (GST_PAD_CAPS (pad));
+
+ gst_caps_merge (tmpcaps, caps);
+ caps = tmpcaps;
+ }
+
gst_object_unref (encoder);
return caps;
nal_size =
x264_nal_encode (encoder->buffer + i_size + 4, &i_data, 0, &nal[i]);
- if (encoder->byte_stream)
+ g_assert (encoder->current_byte_stream !=
+ GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY);
+ if (encoder->current_byte_stream == GST_X264_ENC_STREAM_FORMAT_BYTE_STREAM)
GST_WRITE_UINT32_BE (encoder->buffer + i_size, 1);
else
GST_WRITE_UINT32_BE (encoder->buffer + i_size, nal_size);