omxh264enc: factor out set_avc_intra_perdiod()

https://bugzilla.gnome.org/show_bug.cgi?id=783829
This commit is contained in:
Guillaume Desmottes 2017-06-28 15:03:52 +02:00 committed by Nicolas Dufresne
parent f79b21f12c
commit 895086e2e2

View file

@ -218,56 +218,10 @@ gst_omx_h264_enc_stop (GstVideoEncoder * enc)
}
static gboolean
gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
GstVideoCodecState * state)
set_avc_intra_perdiod (GstOMXH264Enc * self)
{
GstOMXH264Enc *self = GST_OMX_H264_ENC (enc);
GstCaps *peercaps;
OMX_PARAM_PORTDEFINITIONTYPE port_def;
OMX_VIDEO_PARAM_PROFILELEVELTYPE param;
OMX_VIDEO_CONFIG_AVCINTRAPERIOD config_avcintraperiod;
#ifdef USE_OMX_TARGET_RPI
OMX_CONFIG_PORTBOOLEANTYPE config_inline_header;
#endif
OMX_ERRORTYPE err;
const gchar *profile_string, *level_string;
#ifdef USE_OMX_TARGET_RPI
GST_OMX_INIT_STRUCT (&config_inline_header);
config_inline_header.nPortIndex =
GST_OMX_VIDEO_ENC (self)->enc_out_port->index;
err =
gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, &config_inline_header);
if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self,
"can't get OMX_IndexParamBrcmVideoAVCInlineHeaderEnable %s (0x%08x)",
gst_omx_error_to_string (err), err);
return FALSE;
}
if (self->inline_sps_pps_headers) {
config_inline_header.bEnabled = OMX_TRUE;
} else {
config_inline_header.bEnabled = OMX_FALSE;
}
err =
gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, &config_inline_header);
if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self,
"can't set OMX_IndexParamBrcmVideoAVCInlineHeaderEnable %s (0x%08x)",
gst_omx_error_to_string (err), err);
return FALSE;
}
#endif
if (self->periodicty_idr !=
GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT
|| self->interval_intraframes !=
GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT) {
GST_OMX_INIT_STRUCT (&config_avcintraperiod);
config_avcintraperiod.nPortIndex =
@ -305,6 +259,61 @@ gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
gst_omx_error_to_string (err), err);
return FALSE;
}
return TRUE;
}
static gboolean
gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port,
GstVideoCodecState * state)
{
GstOMXH264Enc *self = GST_OMX_H264_ENC (enc);
GstCaps *peercaps;
OMX_PARAM_PORTDEFINITIONTYPE port_def;
OMX_VIDEO_PARAM_PROFILELEVELTYPE param;
#ifdef USE_OMX_TARGET_RPI
OMX_CONFIG_PORTBOOLEANTYPE config_inline_header;
#endif
OMX_ERRORTYPE err;
const gchar *profile_string, *level_string;
#ifdef USE_OMX_TARGET_RPI
GST_OMX_INIT_STRUCT (&config_inline_header);
config_inline_header.nPortIndex =
GST_OMX_VIDEO_ENC (self)->enc_out_port->index;
err =
gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, &config_inline_header);
if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self,
"can't get OMX_IndexParamBrcmVideoAVCInlineHeaderEnable %s (0x%08x)",
gst_omx_error_to_string (err), err);
return FALSE;
}
if (self->inline_sps_pps_headers) {
config_inline_header.bEnabled = OMX_TRUE;
} else {
config_inline_header.bEnabled = OMX_FALSE;
}
err =
gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamBrcmVideoAVCInlineHeaderEnable, &config_inline_header);
if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self,
"can't set OMX_IndexParamBrcmVideoAVCInlineHeaderEnable %s (0x%08x)",
gst_omx_error_to_string (err), err);
return FALSE;
}
#endif
/* Configure GOP pattern */
if (self->periodicty_idr !=
GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT
|| self->interval_intraframes !=
GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT) {
set_avc_intra_perdiod (self);
}
gst_omx_port_get_port_definition (GST_OMX_VIDEO_ENC (self)->enc_out_port,