From 3544fa5ae32e38dfd9ee08a02288bc3699c85f71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 11 Mar 2013 13:59:15 +0100 Subject: [PATCH] omx: Don't set profile/level in other encoders if downstream caps don't specify any --- omx/gstomxaacenc.c | 25 +++++++---------- omx/gstomxh263enc.c | 54 ++++++++++++++++++----------------- omx/gstomxmpeg4videoenc.c | 71 +++++++++++++++++++++++++---------------------- 3 files changed, 77 insertions(+), 73 deletions(-) diff --git a/omx/gstomxaacenc.c b/omx/gstomxaacenc.c index 15ec0df..1ef8ff9 100644 --- a/omx/gstomxaacenc.c +++ b/omx/gstomxaacenc.c @@ -216,8 +216,6 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port, GstOMXAACEnc *self = GST_OMX_AAC_ENC (enc); OMX_AUDIO_PARAM_AACPROFILETYPE aac_profile; GstCaps *peercaps; - OMX_AUDIO_AACSTREAMFORMATTYPE stream_format = OMX_AUDIO_AACStreamFormatRAW; - OMX_AUDIO_AACPROFILETYPE profile = OMX_AUDIO_AACObjectLC; OMX_ERRORTYPE err; GST_OMX_INIT_STRUCT (&aac_profile); @@ -255,13 +253,13 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port, if (profile_string) { if (g_str_equal (profile_string, "main")) { - profile = OMX_AUDIO_AACObjectMain; + aac_profile.eAACProfile = OMX_AUDIO_AACObjectMain; } else if (g_str_equal (profile_string, "lc")) { - profile = OMX_AUDIO_AACObjectLC; + aac_profile.eAACProfile = OMX_AUDIO_AACObjectLC; } else if (g_str_equal (profile_string, "ssr")) { - profile = OMX_AUDIO_AACObjectSSR; + aac_profile.eAACProfile = OMX_AUDIO_AACObjectSSR; } else if (g_str_equal (profile_string, "ltp")) { - profile = OMX_AUDIO_AACObjectLTP; + aac_profile.eAACProfile = OMX_AUDIO_AACObjectLTP; } else { GST_ERROR_OBJECT (self, "Unsupported profile '%s'", profile_string); gst_caps_unref (peercaps); @@ -273,19 +271,19 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port, stream_format_string = gst_structure_get_string (s, "stream-format"); if (stream_format_string) { if (g_str_equal (stream_format_string, "raw")) { - stream_format = OMX_AUDIO_AACStreamFormatRAW; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatRAW; } else if (g_str_equal (stream_format_string, "adts")) { if (mpegversion == 2) { - stream_format = OMX_AUDIO_AACStreamFormatMP2ADTS; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS; } else { - stream_format = OMX_AUDIO_AACStreamFormatMP4ADTS; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS; } } else if (g_str_equal (stream_format_string, "loas")) { - stream_format = OMX_AUDIO_AACStreamFormatMP4LOAS; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4LOAS; } else if (g_str_equal (stream_format_string, "latm")) { - stream_format = OMX_AUDIO_AACStreamFormatMP4LATM; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4LATM; } else if (g_str_equal (stream_format_string, "adif")) { - stream_format = OMX_AUDIO_AACStreamFormatADIF; + aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF; } else { GST_ERROR_OBJECT (self, "Unsupported stream-format '%s'", stream_format_string); @@ -297,9 +295,6 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port, gst_caps_unref (peercaps); } - aac_profile.eAACProfile = profile; - aac_profile.eAACStreamFormat = stream_format; - aac_profile.nAACtools = self->aac_tools; aac_profile.nAACERtools = self->aac_er_tools; diff --git a/omx/gstomxh263enc.c b/omx/gstomxh263enc.c index 35d3358..2fea91e 100644 --- a/omx/gstomxh263enc.c +++ b/omx/gstomxh263enc.c @@ -82,8 +82,6 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, GstOMXH263Enc *self = GST_OMX_H263_ENC (enc); GstCaps *peercaps; OMX_PARAM_PORTDEFINITIONTYPE port_def; - OMX_VIDEO_H263PROFILETYPE profile = OMX_VIDEO_H263ProfileBaseline; - OMX_VIDEO_H263LEVELTYPE level = OMX_VIDEO_H263Level10; OMX_VIDEO_PARAM_PROFILELEVELTYPE param; OMX_ERRORTYPE err; guint profile_id, level_id; @@ -97,6 +95,17 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, if (err != OMX_ErrorNone) return FALSE; + GST_OMX_INIT_STRUCT (¶m); + param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index; + err = + gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc, + OMX_IndexParamVideoProfileLevelCurrent, ¶m); + if (err != OMX_ErrorNone) { + GST_WARNING_OBJECT (self, + "Getting profile/level not supported by component"); + return TRUE; + } + peercaps = gst_pad_peer_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc), gst_pad_get_pad_template_caps (GST_VIDEO_ENCODER_SRC_PAD (enc))); if (peercaps) { @@ -112,31 +121,31 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, if (gst_structure_get_uint (s, "profile", &profile_id)) { switch (profile_id) { case 0: - profile = OMX_VIDEO_H263ProfileBaseline; + param.eProfile = OMX_VIDEO_H263ProfileBaseline; break; case 1: - profile = OMX_VIDEO_H263ProfileH320Coding; + param.eProfile = OMX_VIDEO_H263ProfileH320Coding; break; case 2: - profile = OMX_VIDEO_H263ProfileBackwardCompatible; + param.eProfile = OMX_VIDEO_H263ProfileBackwardCompatible; break; case 3: - profile = OMX_VIDEO_H263ProfileISWV2; + param.eProfile = OMX_VIDEO_H263ProfileISWV2; break; case 4: - profile = OMX_VIDEO_H263ProfileISWV3; + param.eProfile = OMX_VIDEO_H263ProfileISWV3; break; case 5: - profile = OMX_VIDEO_H263ProfileHighCompression; + param.eProfile = OMX_VIDEO_H263ProfileHighCompression; break; case 6: - profile = OMX_VIDEO_H263ProfileInternet; + param.eProfile = OMX_VIDEO_H263ProfileInternet; break; case 7: - profile = OMX_VIDEO_H263ProfileInterlace; + param.eProfile = OMX_VIDEO_H263ProfileInterlace; break; case 8: - profile = OMX_VIDEO_H263ProfileHighLatency; + param.eProfile = OMX_VIDEO_H263ProfileHighLatency; break; default: goto unsupported_profile; @@ -145,25 +154,25 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, if (gst_structure_get_uint (s, "level", &level_id)) { switch (level_id) { case 10: - level = OMX_VIDEO_H263Level10; + param.eLevel = OMX_VIDEO_H263Level10; break; case 20: - level = OMX_VIDEO_H263Level20; + param.eLevel = OMX_VIDEO_H263Level20; break; case 30: - level = OMX_VIDEO_H263Level30; + param.eLevel = OMX_VIDEO_H263Level30; break; case 40: - level = OMX_VIDEO_H263Level40; + param.eLevel = OMX_VIDEO_H263Level40; break; case 50: - level = OMX_VIDEO_H263Level50; + param.eLevel = OMX_VIDEO_H263Level50; break; case 60: - level = OMX_VIDEO_H263Level60; + param.eLevel = OMX_VIDEO_H263Level60; break; case 70: - level = OMX_VIDEO_H263Level70; + param.eLevel = OMX_VIDEO_H263Level70; break; default: goto unsupported_level; @@ -172,11 +181,6 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, gst_caps_unref (peercaps); } - GST_OMX_INIT_STRUCT (¶m); - param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index; - param.eProfile = profile; - param.eLevel = level; - err = gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexParamVideoProfileLevelCurrent, ¶m); @@ -185,8 +189,8 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, "Setting profile/level not supported by component"); } else if (err != OMX_ErrorNone) { GST_ERROR_OBJECT (self, - "Error setting profile %d and level %d: %s (0x%08x)", profile, level, - gst_omx_error_to_string (err), err); + "Error setting profile %d and level %d: %s (0x%08x)", param.eProfile, + param.eLevel, gst_omx_error_to_string (err), err); return FALSE; } diff --git a/omx/gstomxmpeg4videoenc.c b/omx/gstomxmpeg4videoenc.c index a217018..14dfc34 100644 --- a/omx/gstomxmpeg4videoenc.c +++ b/omx/gstomxmpeg4videoenc.c @@ -86,8 +86,6 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, GstOMXMPEG4VideoEnc *self = GST_OMX_MPEG4_VIDEO_ENC (enc); GstCaps *peercaps, *intersection; OMX_PARAM_PORTDEFINITIONTYPE port_def; - OMX_VIDEO_MPEG4PROFILETYPE profile = OMX_VIDEO_MPEG4ProfileSimple; - OMX_VIDEO_MPEG4LEVELTYPE level = OMX_VIDEO_MPEG4Level1; OMX_VIDEO_PARAM_PROFILELEVELTYPE param; OMX_ERRORTYPE err; const gchar *profile_string, *level_string; @@ -101,6 +99,18 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, if (err != OMX_ErrorNone) return FALSE; + GST_OMX_INIT_STRUCT (¶m); + param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index; + + err = + gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc, + OMX_IndexParamVideoProfileLevelCurrent, ¶m); + if (err != OMX_ErrorNone) { + GST_WARNING_OBJECT (self, + "Getting profile/level not supported by component"); + return FALSE; + } + peercaps = gst_pad_peer_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc), NULL); if (peercaps) { GstStructure *s; @@ -120,37 +130,37 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, profile_string = gst_structure_get_string (s, "profile"); if (profile_string) { if (g_str_equal (profile_string, "simple")) { - profile = OMX_VIDEO_MPEG4ProfileSimple; + param.eProfile = OMX_VIDEO_MPEG4ProfileSimple; } else if (g_str_equal (profile_string, "simple-scalable")) { - profile = OMX_VIDEO_MPEG4ProfileSimpleScalable; + param.eProfile = OMX_VIDEO_MPEG4ProfileSimpleScalable; } else if (g_str_equal (profile_string, "core")) { - profile = OMX_VIDEO_MPEG4ProfileCore; + param.eProfile = OMX_VIDEO_MPEG4ProfileCore; } else if (g_str_equal (profile_string, "main")) { - profile = OMX_VIDEO_MPEG4ProfileMain; + param.eProfile = OMX_VIDEO_MPEG4ProfileMain; } else if (g_str_equal (profile_string, "n-bit")) { - profile = OMX_VIDEO_MPEG4ProfileNbit; + param.eProfile = OMX_VIDEO_MPEG4ProfileNbit; } else if (g_str_equal (profile_string, "scalable")) { - profile = OMX_VIDEO_MPEG4ProfileScalableTexture; + param.eProfile = OMX_VIDEO_MPEG4ProfileScalableTexture; } else if (g_str_equal (profile_string, "simple-face")) { - profile = OMX_VIDEO_MPEG4ProfileSimpleFace; + param.eProfile = OMX_VIDEO_MPEG4ProfileSimpleFace; } else if (g_str_equal (profile_string, "simple-fba")) { - profile = OMX_VIDEO_MPEG4ProfileSimpleFBA; + param.eProfile = OMX_VIDEO_MPEG4ProfileSimpleFBA; } else if (g_str_equal (profile_string, "basic-animated-texture")) { - profile = OMX_VIDEO_MPEG4ProfileBasicAnimated; + param.eProfile = OMX_VIDEO_MPEG4ProfileBasicAnimated; } else if (g_str_equal (profile_string, "hybrid")) { - profile = OMX_VIDEO_MPEG4ProfileHybrid; + param.eProfile = OMX_VIDEO_MPEG4ProfileHybrid; } else if (g_str_equal (profile_string, "advanced-real-time-simple")) { - profile = OMX_VIDEO_MPEG4ProfileAdvancedRealTime; + param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedRealTime; } else if (g_str_equal (profile_string, "core-scalable")) { - profile = OMX_VIDEO_MPEG4ProfileCoreScalable; + param.eProfile = OMX_VIDEO_MPEG4ProfileCoreScalable; } else if (g_str_equal (profile_string, "advanced-coding-efficiency")) { - profile = OMX_VIDEO_MPEG4ProfileAdvancedCoding; + param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedCoding; } else if (g_str_equal (profile_string, "advanced-core")) { - profile = OMX_VIDEO_MPEG4ProfileAdvancedCore; + param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedCore; } else if (g_str_equal (profile_string, "advanced-scalable-texture")) { - profile = OMX_VIDEO_MPEG4ProfileAdvancedScalable; + param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedScalable; } else if (g_str_equal (profile_string, "advanced-simple")) { - profile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; + param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; } else { goto unsupported_profile; } @@ -158,21 +168,21 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, level_string = gst_structure_get_string (s, "level"); if (level_string) { if (g_str_equal (level_string, "0")) { - level = OMX_VIDEO_MPEG4Level0; + param.eLevel = OMX_VIDEO_MPEG4Level0; } else if (g_str_equal (level_string, "0b")) { - level = OMX_VIDEO_MPEG4Level0b; + param.eLevel = OMX_VIDEO_MPEG4Level0b; } else if (g_str_equal (level_string, "1")) { - level = OMX_VIDEO_MPEG4Level1; + param.eLevel = OMX_VIDEO_MPEG4Level1; } else if (g_str_equal (level_string, "2")) { - level = OMX_VIDEO_MPEG4Level2; + param.eLevel = OMX_VIDEO_MPEG4Level2; } else if (g_str_equal (level_string, "3")) { - level = OMX_VIDEO_MPEG4Level3; + param.eLevel = OMX_VIDEO_MPEG4Level3; } else if (g_str_equal (level_string, "4")) { - level = OMX_VIDEO_MPEG4Level4; + param.eLevel = OMX_VIDEO_MPEG4Level4; } else if (g_str_equal (level_string, "4a")) { - level = OMX_VIDEO_MPEG4Level4a; + param.eLevel = OMX_VIDEO_MPEG4Level4a; } else if (g_str_equal (level_string, "5")) { - level = OMX_VIDEO_MPEG4Level5; + param.eLevel = OMX_VIDEO_MPEG4Level5; } else { goto unsupported_level; } @@ -181,11 +191,6 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, gst_caps_unref (intersection); } - GST_OMX_INIT_STRUCT (¶m); - param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index; - param.eProfile = profile; - param.eLevel = level; - err = gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexParamVideoProfileLevelCurrent, ¶m); @@ -194,8 +199,8 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, "Setting profile/level not supported by component"); } else if (err != OMX_ErrorNone) { GST_ERROR_OBJECT (self, - "Error setting profile %d and level %d: %s (0x%08x)", profile, level, - gst_omx_error_to_string (err), err); + "Error setting profile %d and level %d: %s (0x%08x)", param.eProfile, + param.eLevel, gst_omx_error_to_string (err), err); return FALSE; } -- 2.7.4