Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- gst-omx_old/omx/gstomxh264enc.c 2014-01-03 21:07:09.000000000 +0000
- +++ gst-omx/omx/gstomxh264enc.c 2014-01-08 23:18:07.637708920 +0000
- @@ -26,6 +26,10 @@
- #include "gstomxh264enc.h"
- +#ifdef USE_OMX_TARGET_RPI
- +#include <OMX_Broadcom.h>
- +#endif
- +
- GST_DEBUG_CATEGORY_STATIC (gst_omx_h264_enc_debug_category);
- #define GST_CAT_DEFAULT gst_omx_h264_enc_debug_category
- @@ -36,12 +40,32 @@
- GstOMXPort * port, GstVideoCodecState * state);
- static GstFlowReturn gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc *
- self, GstOMXPort * port, GstOMXBuffer * buf, GstVideoCodecFrame * frame);
- +static void gst_omx_h264_enc_set_property (GObject * object, guint prop_id,
- + const GValue * value, GParamSpec * pspec);
- +static void gst_omx_h264_enc_get_property (GObject * object, guint prop_id,
- + GValue * value, GParamSpec * pspec);
- enum
- {
- - PROP_0
- + PROP_0,
- +#ifdef USE_OMX_TARGET_RPI
- + PROP_INLINESPSPPSHEADERS,
- +#endif
- + PROP_PERIODICITYOFIDRFRAMES,
- + PROP_INTERVALOFCODINGINTRAFRAMES
- };
- +#ifdef USE_OMX_TARGET_RPI
- +/**< reference: OMX_CONFIG_PORTBOOLEANTYPE*/
- +#define OMX_IndexParamBrcmVideoAVCInlineHeaderEnable 0x7f0000df
- +#define OMX_IndexParamBrcmPixelAspectRatio 0x7f00004d
- +
- +#define GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT TRUE
- +#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)
- +
- +
- /* class initialization */
- #define DEBUG_INIT \
- @@ -54,12 +78,39 @@
- static void
- gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass)
- {
- + GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
- GstOMXVideoEncClass *videoenc_class = GST_OMX_VIDEO_ENC_CLASS (klass);
- videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_set_format);
- videoenc_class->get_caps = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_get_caps);
- + gobject_class->set_property = gst_omx_h264_enc_set_property;
- + gobject_class->get_property = gst_omx_h264_enc_get_property;
- +
- +#ifdef USE_OMX_TARGET_RPI
- + g_object_class_install_property (gobject_class, PROP_INLINESPSPPSHEADERS,
- + g_param_spec_boolean ("inline-header", "Inline SPS/PPS headers before IDR",
- + "Inline SPS/PPS header before IDR", GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT,
- + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
- + GST_PARAM_MUTABLE_READY));
- +#endif
- +
- + g_object_class_install_property (gobject_class, PROP_PERIODICITYOFIDRFRAMES,
- + g_param_spec_uint ("periodicty-idr", "Target Bitrate",
- + "Periodicity of IDR frames (0xffffffff=component default)",
- + 0, G_MAXUINT, GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT,
- + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
- + GST_PARAM_MUTABLE_READY));
- +
- + g_object_class_install_property (gobject_class, PROP_INTERVALOFCODINGINTRAFRAMES,
- + g_param_spec_uint ("interval-intraframes", "Interval of coding Intra frames",
- + "Interval of coding Intra frames (0xffffffff=component default)",
- + 0, G_MAXUINT, GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT,
- + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
- + GST_PARAM_MUTABLE_READY));
- +
- +
- videoenc_class->cdata.default_src_template_caps = "video/x-h264, "
- "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]";
- videoenc_class->handle_output_frame =
- @@ -75,8 +126,61 @@
- }
- static void
- +gst_omx_h264_enc_set_property (GObject * object, guint prop_id,
- + const GValue * value, GParamSpec * pspec)
- +{
- + GstOMXH264Enc *self = GST_OMX_H264_ENC (object);
- +
- + switch (prop_id) {
- +#ifdef USE_OMX_TARGET_RPI
- + case PROP_INLINESPSPPSHEADERS:
- + self->inline_sps_pps_headers = g_value_get_boolean(value);
- + break;
- +#endif
- + case PROP_PERIODICITYOFIDRFRAMES:
- + self->periodicty_idr = g_value_get_uint (value);
- + break;
- + case PROP_INTERVALOFCODINGINTRAFRAMES:
- + self->interval_intraframes = g_value_get_uint (value);
- + break;
- + default:
- + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- + break;
- + }
- +}
- +
- +static void
- +gst_omx_h264_enc_get_property (GObject * object, guint prop_id, GValue * value,
- + GParamSpec * pspec)
- +{
- + GstOMXH264Enc *self = GST_OMX_H264_ENC (object);
- +
- + switch (prop_id) {
- +#ifdef USE_OMX_TARGET_RPI
- + case PROP_INLINESPSPPSHEADERS:
- + g_value_set_boolean(value, self->inline_sps_pps_headers);
- + break;
- +#endif
- + case PROP_PERIODICITYOFIDRFRAMES:
- + g_value_set_uint (value, self->periodicty_idr);
- + break;
- + case PROP_INTERVALOFCODINGINTRAFRAMES:
- + g_value_set_uint (value, self->interval_intraframes);
- + break;
- + default:
- + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- + break;
- + }
- +}
- +
- +static void
- gst_omx_h264_enc_init (GstOMXH264Enc * self)
- {
- +#ifdef USE_OMX_TARGET_RPI
- + self->inline_sps_pps_headers = GST_OMX_H264_VIDEO_ENC_INLINE_SPS_PPS_HEADERS_DEFAULT;
- +#endif
- + 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;
- }
- static gboolean
- @@ -86,10 +190,71 @@
- GstOMXH264Enc *self = GST_OMX_H264_ENC (enc);
- GstCaps *peercaps;
- OMX_PARAM_PORTDEFINITIONTYPE port_def;
- - OMX_VIDEO_PARAM_PROFILELEVELTYPE param;
- + OMX_VIDEO_PARAM_PROFILELEVELTYPE h264_profile_level_param;
- + OMX_VIDEO_CONFIG_AVCINTRAPERIOD video_avc_intra_period_param;
- +#ifdef USE_OMX_TARGET_RPI
- + OMX_CONFIG_PORTBOOLEANTYPE h264_enc_inline_header_param;
- +#endif
- OMX_ERRORTYPE err;
- const gchar *profile_string, *level_string;
- +#ifdef USE_OMX_TARGET_RPI
- + GST_OMX_INIT_STRUCT (&h264_enc_inline_header_param);
- + h264_enc_inline_header_param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index;
- + err = gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexParamBrcmVideoAVCInlineHeaderEnable,
- + &h264_enc_inline_header_param);
- + 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) {
- + h264_enc_inline_header_param.bEnabled = OMX_TRUE;
- + }
- + else {
- + h264_enc_inline_header_param.bEnabled = OMX_FALSE;
- + }
- +
- + err = gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexParamBrcmVideoAVCInlineHeaderEnable,
- + &h264_enc_inline_header_param);
- + 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 (&video_avc_intra_period_param);
- + video_avc_intra_period_param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index;
- + err = gst_omx_component_get_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexConfigVideoAVCIntraPeriod, &video_avc_intra_period_param);
- + if (err != OMX_ErrorNone) {
- + GST_ERROR_OBJECT (self, "can't get OMX_IndexConfigVideoAVCIntraPeriod %s (0x%08x)", gst_omx_error_to_string (err), err);
- + return FALSE;
- + }
- +
- + GST_DEBUG_OBJECT(self, "default nPFrames:%u, nIDRPeriod:%u", video_avc_intra_period_param.nPFrames, video_avc_intra_period_param.nIDRPeriod);
- +
- + if(self->periodicty_idr != GST_OMX_H264_VIDEO_ENC_PERIODICITY_OF_IDR_FRAMES_DEFAULT) {
- + video_avc_intra_period_param.nIDRPeriod = self->periodicty_idr;
- + }
- +
- + if(self->interval_intraframes != GST_OMX_H264_VIDEO_ENC_INTERVAL_OF_CODING_INTRA_FRAMES_DEFAULT) {
- + video_avc_intra_period_param.nPFrames = self->interval_intraframes;
- + }
- +
- + err = gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc, OMX_IndexConfigVideoAVCIntraPeriod,
- + &video_avc_intra_period_param);
- + if (err != OMX_ErrorNone) {
- + GST_ERROR_OBJECT (self, "can't set OMX_IndexConfigVideoAVCIntraPeriod %s (0x%08x)", gst_omx_error_to_string (err), err);
- + return FALSE;
- + }
- + }
- +
- +
- +
- gst_omx_port_get_port_definition (GST_OMX_VIDEO_ENC (self)->enc_out_port,
- &port_def);
- port_def.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
- @@ -99,12 +264,12 @@
- if (err != OMX_ErrorNone)
- return FALSE;
- - GST_OMX_INIT_STRUCT (¶m);
- - param.nPortIndex = GST_OMX_VIDEO_ENC (self)->enc_out_port->index;
- + GST_OMX_INIT_STRUCT (&h264_profile_level_param);
- + h264_profile_level_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);
- + OMX_IndexParamVideoProfileLevelCurrent, &h264_profile_level_param);
- if (err != OMX_ErrorNone) {
- GST_WARNING_OBJECT (self,
- "Setting profile/level not supported by component");
- @@ -126,19 +291,19 @@
- profile_string = gst_structure_get_string (s, "profile");
- if (profile_string) {
- if (g_str_equal (profile_string, "baseline")) {
- - param.eProfile = OMX_VIDEO_AVCProfileBaseline;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileBaseline;
- } else if (g_str_equal (profile_string, "main")) {
- - param.eProfile = OMX_VIDEO_AVCProfileMain;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileMain;
- } else if (g_str_equal (profile_string, "extended")) {
- - param.eProfile = OMX_VIDEO_AVCProfileExtended;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileExtended;
- } else if (g_str_equal (profile_string, "high")) {
- - param.eProfile = OMX_VIDEO_AVCProfileHigh;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileHigh;
- } else if (g_str_equal (profile_string, "high-10")) {
- - param.eProfile = OMX_VIDEO_AVCProfileHigh10;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileHigh10;
- } else if (g_str_equal (profile_string, "high-4:2:2")) {
- - param.eProfile = OMX_VIDEO_AVCProfileHigh422;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileHigh422;
- } else if (g_str_equal (profile_string, "high-4:4:4")) {
- - param.eProfile = OMX_VIDEO_AVCProfileHigh444;
- + h264_profile_level_param.eProfile = OMX_VIDEO_AVCProfileHigh444;
- } else {
- goto unsupported_profile;
- }
- @@ -146,37 +311,37 @@
- level_string = gst_structure_get_string (s, "level");
- if (level_string) {
- if (g_str_equal (level_string, "1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel1;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel1;
- } else if (g_str_equal (level_string, "1b")) {
- - param.eLevel = OMX_VIDEO_AVCLevel1b;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel1b;
- } else if (g_str_equal (level_string, "1.1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel11;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel11;
- } else if (g_str_equal (level_string, "1.2")) {
- - param.eLevel = OMX_VIDEO_AVCLevel12;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel12;
- } else if (g_str_equal (level_string, "1.3")) {
- - param.eLevel = OMX_VIDEO_AVCLevel13;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel13;
- } else if (g_str_equal (level_string, "2")) {
- - param.eLevel = OMX_VIDEO_AVCLevel2;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel2;
- } else if (g_str_equal (level_string, "2.1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel21;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel21;
- } else if (g_str_equal (level_string, "2.2")) {
- - param.eLevel = OMX_VIDEO_AVCLevel22;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel22;
- } else if (g_str_equal (level_string, "3")) {
- - param.eLevel = OMX_VIDEO_AVCLevel3;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel3;
- } else if (g_str_equal (level_string, "3.1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel31;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel31;
- } else if (g_str_equal (level_string, "3.2")) {
- - param.eLevel = OMX_VIDEO_AVCLevel32;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel32;
- } else if (g_str_equal (level_string, "4")) {
- - param.eLevel = OMX_VIDEO_AVCLevel4;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel4;
- } else if (g_str_equal (level_string, "4.1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel41;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel41;
- } else if (g_str_equal (level_string, "4.2")) {
- - param.eLevel = OMX_VIDEO_AVCLevel42;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel42;
- } else if (g_str_equal (level_string, "5")) {
- - param.eLevel = OMX_VIDEO_AVCLevel5;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel5;
- } else if (g_str_equal (level_string, "5.1")) {
- - param.eLevel = OMX_VIDEO_AVCLevel51;
- + h264_profile_level_param.eLevel = OMX_VIDEO_AVCLevel51;
- } else {
- goto unsupported_level;
- }
- @@ -186,14 +351,14 @@
- err =
- gst_omx_component_set_parameter (GST_OMX_VIDEO_ENC (self)->enc,
- - OMX_IndexParamVideoProfileLevelCurrent, ¶m);
- + OMX_IndexParamVideoProfileLevelCurrent, &h264_profile_level_param);
- if (err == OMX_ErrorUnsupportedIndex) {
- GST_WARNING_OBJECT (self,
- "Setting profile/level not supported by component");
- } else if (err != OMX_ErrorNone) {
- GST_ERROR_OBJECT (self,
- "Error setting profile %u and level %u: %s (0x%08x)",
- - (guint) param.eProfile, (guint) param.eLevel,
- + (guint) h264_profile_level_param.eProfile, (guint) h264_profile_level_param.eLevel,
- gst_omx_error_to_string (err), err);
- return FALSE;
- }
- --- gst-omx_old/omx/gstomxh264enc.h 2014-01-03 21:07:09.000000000 +0000
- +++ gst-omx/omx/gstomxh264enc.h 2014-01-08 23:07:52.050031499 +0000
- @@ -45,6 +45,10 @@
- struct _GstOMXH264Enc
- {
- GstOMXVideoEnc parent;
- +
- + gboolean inline_sps_pps_headers;
- + guint32 periodicty_idr;
- + guint32 interval_intraframes;
- };
- struct _GstOMXH264EncClass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement