summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2013-03-11 13:59:15 +0100
committerJosep Torra <n770galaxy@gmail.com>2013-03-11 17:07:34 +0100
commit39972701baeb0f4284615f637978b6c265bed8b6 (patch)
treed7d4dd774424da4a029741b8469ba50831ded96a
parent5f3d1f06fa44d168b183dea0878c830d955b7c4f (diff)
downloadgst-omx-39972701baeb0f4284615f637978b6c265bed8b6.tar.gz
omx: Don't set profile/level in other encoders if downstream caps don't specify any
Conflicts: omx/gstomxh263enc.c omx/gstomxmpeg4videoenc.c
-rw-r--r--omx/gstomxaacenc.c25
-rw-r--r--omx/gstomxh263enc.c54
-rw-r--r--omx/gstomxmpeg4videoenc.c71
3 files changed, 77 insertions, 73 deletions
diff --git a/omx/gstomxaacenc.c b/omx/gstomxaacenc.c
index e8dbd18..12cc7e2 100644
--- a/omx/gstomxaacenc.c
+++ b/omx/gstomxaacenc.c
@@ -219,8 +219,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);
@@ -263,13 +261,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 (intersection);
@@ -281,19 +279,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);
@@ -305,9 +303,6 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
gst_caps_unref (intersection);
}
- 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 01ecf4f..9e589a4 100644
--- a/omx/gstomxh263enc.c
+++ b/omx/gstomxh263enc.c
@@ -87,8 +87,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;
@@ -102,6 +100,17 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
if (err != OMX_ErrorNone)
return FALSE;
+ GST_OMX_INIT_STRUCT (&param);
+ 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, &param);
+ if (err != OMX_ErrorNone) {
+ GST_WARNING_OBJECT (self,
+ "Getting profile/level not supported by component");
+ return TRUE;
+ }
+
peercaps = gst_pad_peer_get_caps (GST_VIDEO_ENCODER_SRC_PAD (enc));
if (peercaps) {
GstStructure *s;
@@ -120,31 +129,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;
@@ -153,25 +162,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;
@@ -180,11 +189,6 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
gst_caps_unref (peercaps);
}
- GST_OMX_INIT_STRUCT (&param);
- 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, &param);
@@ -193,8 +197,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 4a36770..de49dd2 100644
--- a/omx/gstomxmpeg4videoenc.c
+++ b/omx/gstomxmpeg4videoenc.c
@@ -92,8 +92,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;
@@ -107,6 +105,18 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
if (err != OMX_ErrorNone)
return FALSE;
+ GST_OMX_INIT_STRUCT (&param);
+ 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, &param);
+ if (err != OMX_ErrorNone) {
+ GST_WARNING_OBJECT (self,
+ "Getting profile/level not supported by component");
+ return FALSE;
+ }
+
peercaps = gst_pad_peer_get_caps (GST_VIDEO_ENCODER_SRC_PAD (enc));
if (peercaps) {
GstStructure *s;
@@ -126,37 +136,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;
}
@@ -164,21 +174,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;
}
@@ -187,11 +197,6 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
gst_caps_unref (intersection);
}
- GST_OMX_INIT_STRUCT (&param);
- 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, &param);
@@ -200,8 +205,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;
}