diff options
-rw-r--r-- | sys/mediafoundation/gstmfh264enc.cpp | 32 | ||||
-rw-r--r-- | sys/mediafoundation/gstmfh265enc.cpp | 7 | ||||
-rw-r--r-- | sys/mediafoundation/gstmfvideoenc.cpp | 7 |
3 files changed, 43 insertions, 3 deletions
diff --git a/sys/mediafoundation/gstmfh264enc.cpp b/sys/mediafoundation/gstmfh264enc.cpp index a9ea77dd7..a1c4b5f7e 100644 --- a/sys/mediafoundation/gstmfh264enc.cpp +++ b/sys/mediafoundation/gstmfh264enc.cpp @@ -216,6 +216,7 @@ typedef struct _GstMFH264Enc guint qp_p; guint qp_b; guint max_num_ref; + gchar *profile_str; } GstMFH264Enc; typedef struct _GstMFH264EncClass @@ -225,6 +226,7 @@ typedef struct _GstMFH264EncClass static GstElementClass *parent_class = NULL; +static void gst_mf_h264_enc_finalize (GObject * object); static void gst_mf_h264_enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void gst_mf_h264_enc_set_property (GObject * object, guint prop_id, @@ -247,6 +249,7 @@ gst_mf_h264_enc_class_init (GstMFH264EncClass * klass, gpointer data) parent_class = (GstElementClass *) g_type_class_peek_parent (klass); + gobject_class->finalize = gst_mf_h264_enc_finalize; gobject_class->get_property = gst_mf_h264_enc_get_property; gobject_class->set_property = gst_mf_h264_enc_set_property; @@ -538,6 +541,16 @@ gst_mf_h264_enc_init (GstMFH264Enc * self) } static void +gst_mf_h264_enc_finalize (GObject * object) +{ + GstMFH264Enc *self = (GstMFH264Enc *) (object); + + g_free (self->profile_str); + + G_OBJECT_CLASS (parent_class)->finalize (object); +} + +static void gst_mf_h264_enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { @@ -761,10 +774,13 @@ gst_mf_h264_enc_set_option (GstMFVideoEnc * mfenc, GstVideoCodecState * state, GstMFVideoEncDeviceCaps *device_caps = &klass->device_caps; HRESULT hr; GstCaps *allowed_caps, *template_caps; - guint selected_profile = eAVEncH264VProfile_Main; + eAVEncH264VProfile selected_profile = eAVEncH264VProfile_Main; gint level_idc = -1; GstMFTransform *transform = mfenc->transform; + g_free (self->profile_str); + self->profile_str = g_strdup ("main"); + template_caps = gst_pad_get_pad_template_caps (GST_VIDEO_ENCODER_SRC_PAD (self)); allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (self)); @@ -788,12 +804,21 @@ gst_mf_h264_enc_set_option (GstMFVideoEnc * mfenc, GstVideoCodecState * state, profile = gst_structure_get_string (s, "profile"); if (profile) { - if (!strcmp (profile, "baseline")) { + /* Although we are setting eAVEncH264VProfile_Base, actual profile + * chosen by MFT seems to be constrained-baseline */ + if (strcmp (profile, "baseline") == 0 || + strcmp (profile, "constrained-baseline") == 0) { selected_profile = eAVEncH264VProfile_Base; + g_free (self->profile_str); + self->profile_str = g_strdup (profile); } else if (g_str_has_prefix (profile, "high")) { selected_profile = eAVEncH264VProfile_High; + g_free (self->profile_str); + self->profile_str = g_strdup (profile); } else if (g_str_has_prefix (profile, "main")) { selected_profile = eAVEncH264VProfile_Main; + g_free (self->profile_str); + self->profile_str = g_strdup (profile); } } @@ -992,7 +1017,8 @@ gst_mf_h264_enc_set_src_caps (GstMFVideoEnc * mfenc, s = gst_caps_get_structure (out_caps, 0); gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream", - "alignment", G_TYPE_STRING, "au", NULL); + "alignment", G_TYPE_STRING, "au", "profile", + G_TYPE_STRING, self->profile_str, NULL); out_state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self), out_caps, state); diff --git a/sys/mediafoundation/gstmfh265enc.cpp b/sys/mediafoundation/gstmfh265enc.cpp index cb59d40b3..4972cbe16 100644 --- a/sys/mediafoundation/gstmfh265enc.cpp +++ b/sys/mediafoundation/gstmfh265enc.cpp @@ -757,6 +757,13 @@ gst_mf_h265_enc_set_src_caps (GstMFVideoEnc * mfenc, gst_structure_set (s, "stream-format", G_TYPE_STRING, "byte-stream", "alignment", G_TYPE_STRING, "au", NULL); + if (GST_VIDEO_INFO_FORMAT (&mfenc->input_state->info) == + GST_VIDEO_FORMAT_P010_10LE) { + gst_structure_set (s, "profile", G_TYPE_STRING, "main-10", NULL); + } else { + gst_structure_set (s, "profile", G_TYPE_STRING, "main", NULL); + } + out_state = gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (self), out_caps, state); diff --git a/sys/mediafoundation/gstmfvideoenc.cpp b/sys/mediafoundation/gstmfvideoenc.cpp index 768b7455d..5ff22e24c 100644 --- a/sys/mediafoundation/gstmfvideoenc.cpp +++ b/sys/mediafoundation/gstmfvideoenc.cpp @@ -1535,6 +1535,13 @@ gst_mf_video_enc_enum_internal (GstMFTransform * transform, GUID &subtype, g_value_init (profiles, GST_TYPE_LIST); } + /* Add "constrained-baseline" in addition to "baseline" */ + if (profile_str == "baseline") { + g_value_init (&profile_val, G_TYPE_STRING); + g_value_set_static_string (&profile_val, "constrained-baseline"); + gst_value_list_append_and_take_value (profiles, &profile_val); + } + g_value_init (&profile_val, G_TYPE_STRING); g_value_set_static_string (&profile_val, profile_str); gst_value_list_append_and_take_value (profiles, &profile_val); |