PROP_INLINESPSPPSHEADERS,
#endif
PROP_PERIODICITYOFIDRFRAMES,
- PROP_INTERVALOFCODINGINTRAFRAMES
+ PROP_INTERVALOFCODINGINTRAFRAMES,
+ PROP_B_FRAMES,
};
#ifdef USE_OMX_TARGET_RPI
#endif
#define GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT (0xffffffff)
#define GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT (0xffffffff)
+#define GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT (0xffffffff)
/* class initialization */
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
GST_PARAM_MUTABLE_READY));
+ g_object_class_install_property (gobject_class, PROP_B_FRAMES,
+ g_param_spec_uint ("b-frames", "Number of B-frames",
+ "Number of B-frames between two consecutive I-frames (0xffffffff=component default)",
+ 0, G_MAXUINT, GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
+ GST_PARAM_MUTABLE_READY));
+
basevideoenc_class->flush = gst_omx_h264_enc_flush;
basevideoenc_class->stop = gst_omx_h264_enc_stop;
case PROP_INTERVALOFCODINGINTRAFRAMES:
self->interval_intraframes = g_value_get_uint (value);
break;
+ case PROP_B_FRAMES:
+ self->b_frames = g_value_get_uint (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_INTERVALOFCODINGINTRAFRAMES:
g_value_set_uint (value, self->interval_intraframes);
break;
+ case PROP_B_FRAMES:
+ g_value_set_uint (value, self->b_frames);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT;
self->interval_intraframes =
GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT;
+ self->b_frames = GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT;
}
static gboolean
if (level != OMX_VIDEO_AVCLevelMax)
param.eLevel = level;
+ /* GOP pattern */
+ if (self->interval_intraframes !=
+ GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT) {
+ param.nPFrames = self->interval_intraframes;
+
+ /* If user specified a specific number of B-frames, reduce the number of
+ * P-frames by this amount. If not ensure there is no B-frame to have the
+ * requested GOP length. */
+ if (self->b_frames != GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT) {
+ if (self->b_frames > self->interval_intraframes) {
+ GST_ERROR_OBJECT (self,
+ "The interval_intraframes perdiod (%u) needs to be higher than the number of B-frames (%u)",
+ self->interval_intraframes, self->b_frames);
+ return FALSE;
+ }
+ param.nPFrames -= self->b_frames;
+ } else {
+ param.nBFrames = 0;
+ }
+ }
+
+ if (self->b_frames != GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT) {
+ if (profile == OMX_VIDEO_AVCProfileBaseline && self->b_frames > 0) {
+ GST_ERROR_OBJECT (self,
+ "Baseline profile doesn't support B-frames (%u requested)",
+ self->b_frames);
+ return FALSE;
+ }
+ param.nBFrames = self->b_frames;
+ }
+
err =
gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
OMX_IndexParamVideoAvc, ¶m);
if (self->interval_intraframes !=
GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT) {
- config_avcintraperiod.nPFrames = self->interval_intraframes;
+ /* This OMX API doesn't allow us to specify the number of B-frames.
+ * So if user requested one we have to rely on update_param_avc()
+ * to configure the intraframes interval so it can take the
+ * B-frames into account. */
+ if (self->b_frames == GST_OMX_H264_VIDEO_ENC_B_FRAMES_DEFAULT)
+ config_avcintraperiod.nPFrames = self->interval_intraframes;
}
err =
gst_caps_unref (peercaps);
if (profile != OMX_VIDEO_AVCProfileMax || level != OMX_VIDEO_AVCLevelMax) {
- /* OMX provides 2 API to set the profile and level so try using both */
+ /* OMX provides 2 API to set the profile and level. We try using the
+ * generic on here and the H264 specific when calling
+ * update_param_avc() */
if (!update_param_profile_level (self, profile, level))
return FALSE;
-
- if (!update_param_avc (self, profile, level))
- return FALSE;
}
}
+ if (!update_param_avc (self, profile, level))
+ return FALSE;
+
return TRUE;
unsupported_profile: