omx: Don't set profile/level in other encoders if downstream caps don't specify any

This commit is contained in:
Sebastian Dröge 2013-03-11 13:59:15 +01:00
parent 77f95de529
commit 3544fa5ae3
3 changed files with 77 additions and 73 deletions

View file

@ -216,8 +216,6 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
GstOMXAACEnc *self = GST_OMX_AAC_ENC (enc); GstOMXAACEnc *self = GST_OMX_AAC_ENC (enc);
OMX_AUDIO_PARAM_AACPROFILETYPE aac_profile; OMX_AUDIO_PARAM_AACPROFILETYPE aac_profile;
GstCaps *peercaps; GstCaps *peercaps;
OMX_AUDIO_AACSTREAMFORMATTYPE stream_format = OMX_AUDIO_AACStreamFormatRAW;
OMX_AUDIO_AACPROFILETYPE profile = OMX_AUDIO_AACObjectLC;
OMX_ERRORTYPE err; OMX_ERRORTYPE err;
GST_OMX_INIT_STRUCT (&aac_profile); GST_OMX_INIT_STRUCT (&aac_profile);
@ -255,13 +253,13 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
if (profile_string) { if (profile_string) {
if (g_str_equal (profile_string, "main")) { 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")) { } 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")) { } 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")) { } else if (g_str_equal (profile_string, "ltp")) {
profile = OMX_AUDIO_AACObjectLTP; aac_profile.eAACProfile = OMX_AUDIO_AACObjectLTP;
} else { } else {
GST_ERROR_OBJECT (self, "Unsupported profile '%s'", profile_string); GST_ERROR_OBJECT (self, "Unsupported profile '%s'", profile_string);
gst_caps_unref (peercaps); 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"); stream_format_string = gst_structure_get_string (s, "stream-format");
if (stream_format_string) { if (stream_format_string) {
if (g_str_equal (stream_format_string, "raw")) { 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")) { } else if (g_str_equal (stream_format_string, "adts")) {
if (mpegversion == 2) { if (mpegversion == 2) {
stream_format = OMX_AUDIO_AACStreamFormatMP2ADTS; aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP2ADTS;
} else { } else {
stream_format = OMX_AUDIO_AACStreamFormatMP4ADTS; aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatMP4ADTS;
} }
} else if (g_str_equal (stream_format_string, "loas")) { } 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")) { } 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")) { } else if (g_str_equal (stream_format_string, "adif")) {
stream_format = OMX_AUDIO_AACStreamFormatADIF; aac_profile.eAACStreamFormat = OMX_AUDIO_AACStreamFormatADIF;
} else { } else {
GST_ERROR_OBJECT (self, "Unsupported stream-format '%s'", GST_ERROR_OBJECT (self, "Unsupported stream-format '%s'",
stream_format_string); stream_format_string);
@ -297,9 +295,6 @@ gst_omx_aac_enc_set_format (GstOMXAudioEnc * enc, GstOMXPort * port,
gst_caps_unref (peercaps); gst_caps_unref (peercaps);
} }
aac_profile.eAACProfile = profile;
aac_profile.eAACStreamFormat = stream_format;
aac_profile.nAACtools = self->aac_tools; aac_profile.nAACtools = self->aac_tools;
aac_profile.nAACERtools = self->aac_er_tools; aac_profile.nAACERtools = self->aac_er_tools;

View file

@ -82,8 +82,6 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
GstOMXH263Enc *self = GST_OMX_H263_ENC (enc); GstOMXH263Enc *self = GST_OMX_H263_ENC (enc);
GstCaps *peercaps; GstCaps *peercaps;
OMX_PARAM_PORTDEFINITIONTYPE port_def; 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_VIDEO_PARAM_PROFILELEVELTYPE param;
OMX_ERRORTYPE err; OMX_ERRORTYPE err;
guint profile_id, level_id; guint profile_id, level_id;
@ -97,6 +95,17 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
if (err != OMX_ErrorNone) if (err != OMX_ErrorNone)
return FALSE; 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_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc), peercaps = gst_pad_peer_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc),
gst_pad_get_pad_template_caps (GST_VIDEO_ENCODER_SRC_PAD (enc))); gst_pad_get_pad_template_caps (GST_VIDEO_ENCODER_SRC_PAD (enc)));
if (peercaps) { 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)) { if (gst_structure_get_uint (s, "profile", &profile_id)) {
switch (profile_id) { switch (profile_id) {
case 0: case 0:
profile = OMX_VIDEO_H263ProfileBaseline; param.eProfile = OMX_VIDEO_H263ProfileBaseline;
break; break;
case 1: case 1:
profile = OMX_VIDEO_H263ProfileH320Coding; param.eProfile = OMX_VIDEO_H263ProfileH320Coding;
break; break;
case 2: case 2:
profile = OMX_VIDEO_H263ProfileBackwardCompatible; param.eProfile = OMX_VIDEO_H263ProfileBackwardCompatible;
break; break;
case 3: case 3:
profile = OMX_VIDEO_H263ProfileISWV2; param.eProfile = OMX_VIDEO_H263ProfileISWV2;
break; break;
case 4: case 4:
profile = OMX_VIDEO_H263ProfileISWV3; param.eProfile = OMX_VIDEO_H263ProfileISWV3;
break; break;
case 5: case 5:
profile = OMX_VIDEO_H263ProfileHighCompression; param.eProfile = OMX_VIDEO_H263ProfileHighCompression;
break; break;
case 6: case 6:
profile = OMX_VIDEO_H263ProfileInternet; param.eProfile = OMX_VIDEO_H263ProfileInternet;
break; break;
case 7: case 7:
profile = OMX_VIDEO_H263ProfileInterlace; param.eProfile = OMX_VIDEO_H263ProfileInterlace;
break; break;
case 8: case 8:
profile = OMX_VIDEO_H263ProfileHighLatency; param.eProfile = OMX_VIDEO_H263ProfileHighLatency;
break; break;
default: default:
goto unsupported_profile; 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)) { if (gst_structure_get_uint (s, "level", &level_id)) {
switch (level_id) { switch (level_id) {
case 10: case 10:
level = OMX_VIDEO_H263Level10; param.eLevel = OMX_VIDEO_H263Level10;
break; break;
case 20: case 20:
level = OMX_VIDEO_H263Level20; param.eLevel = OMX_VIDEO_H263Level20;
break; break;
case 30: case 30:
level = OMX_VIDEO_H263Level30; param.eLevel = OMX_VIDEO_H263Level30;
break; break;
case 40: case 40:
level = OMX_VIDEO_H263Level40; param.eLevel = OMX_VIDEO_H263Level40;
break; break;
case 50: case 50:
level = OMX_VIDEO_H263Level50; param.eLevel = OMX_VIDEO_H263Level50;
break; break;
case 60: case 60:
level = OMX_VIDEO_H263Level60; param.eLevel = OMX_VIDEO_H263Level60;
break; break;
case 70: case 70:
level = OMX_VIDEO_H263Level70; param.eLevel = OMX_VIDEO_H263Level70;
break; break;
default: default:
goto unsupported_level; goto unsupported_level;
@ -172,11 +181,6 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
gst_caps_unref (peercaps); 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 = err =
gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamVideoProfileLevelCurrent, &param); OMX_IndexParamVideoProfileLevelCurrent, &param);
@ -185,8 +189,8 @@ gst_omx_h263_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
"Setting profile/level not supported by component"); "Setting profile/level not supported by component");
} else if (err != OMX_ErrorNone) { } else if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self, GST_ERROR_OBJECT (self,
"Error setting profile %d and level %d: %s (0x%08x)", profile, level, "Error setting profile %d and level %d: %s (0x%08x)", param.eProfile,
gst_omx_error_to_string (err), err); param.eLevel, gst_omx_error_to_string (err), err);
return FALSE; return FALSE;
} }

View file

@ -86,8 +86,6 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
GstOMXMPEG4VideoEnc *self = GST_OMX_MPEG4_VIDEO_ENC (enc); GstOMXMPEG4VideoEnc *self = GST_OMX_MPEG4_VIDEO_ENC (enc);
GstCaps *peercaps, *intersection; GstCaps *peercaps, *intersection;
OMX_PARAM_PORTDEFINITIONTYPE port_def; 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_VIDEO_PARAM_PROFILELEVELTYPE param;
OMX_ERRORTYPE err; OMX_ERRORTYPE err;
const gchar *profile_string, *level_string; 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) if (err != OMX_ErrorNone)
return FALSE; 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_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc), NULL); peercaps = gst_pad_peer_query_caps (GST_VIDEO_ENCODER_SRC_PAD (enc), NULL);
if (peercaps) { if (peercaps) {
GstStructure *s; 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"); profile_string = gst_structure_get_string (s, "profile");
if (profile_string) { if (profile_string) {
if (g_str_equal (profile_string, "simple")) { 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } else if (g_str_equal (profile_string, "advanced-simple")) {
profile = OMX_VIDEO_MPEG4ProfileAdvancedSimple; param.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple;
} else { } else {
goto unsupported_profile; 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"); level_string = gst_structure_get_string (s, "level");
if (level_string) { if (level_string) {
if (g_str_equal (level_string, "0")) { if (g_str_equal (level_string, "0")) {
level = OMX_VIDEO_MPEG4Level0; param.eLevel = OMX_VIDEO_MPEG4Level0;
} else if (g_str_equal (level_string, "0b")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } 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")) { } else if (g_str_equal (level_string, "5")) {
level = OMX_VIDEO_MPEG4Level5; param.eLevel = OMX_VIDEO_MPEG4Level5;
} else { } else {
goto unsupported_level; goto unsupported_level;
} }
@ -181,11 +191,6 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
gst_caps_unref (intersection); 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 = err =
gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamVideoProfileLevelCurrent, &param); OMX_IndexParamVideoProfileLevelCurrent, &param);
@ -194,8 +199,8 @@ gst_omx_mpeg4_video_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
"Setting profile/level not supported by component"); "Setting profile/level not supported by component");
} else if (err != OMX_ErrorNone) { } else if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self, GST_ERROR_OBJECT (self,
"Error setting profile %d and level %d: %s (0x%08x)", profile, level, "Error setting profile %d and level %d: %s (0x%08x)", param.eProfile,
gst_omx_error_to_string (err), err); param.eLevel, gst_omx_error_to_string (err), err);
return FALSE; return FALSE;
} }