static void gst_vaapiencode_class_init (GstVaapiEncodeClass * klass) { GObjectClass *const object_class = G_OBJECT_CLASS (klass); GstElementClass *const element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *const venc_class = GST_VIDEO_ENCODER_CLASS (klass); GST_DEBUG_CATEGORY_INIT (gst_vaapiencode_debug, GST_PLUGIN_NAME, 0, GST_PLUGIN_DESC); gst_vaapi_plugin_base_class_init (GST_VAAPI_PLUGIN_BASE_CLASS (klass)); object_class->finalize = gst_vaapiencode_finalize; element_class->change_state = GST_DEBUG_FUNCPTR (gst_vaapiencode_change_state); venc_class->open = GST_DEBUG_FUNCPTR (gst_vaapiencode_open); venc_class->close = GST_DEBUG_FUNCPTR (gst_vaapiencode_close); venc_class->set_format = GST_DEBUG_FUNCPTR (gst_vaapiencode_set_format); venc_class->handle_frame = GST_DEBUG_FUNCPTR (gst_vaapiencode_handle_frame); venc_class->finish = GST_DEBUG_FUNCPTR (gst_vaapiencode_finish); venc_class->getcaps = GST_DEBUG_FUNCPTR (gst_vaapiencode_get_caps); venc_class->propose_allocation = GST_DEBUG_FUNCPTR (gst_vaapiencode_propose_allocation); klass->get_property = gst_vaapiencode_default_get_property; klass->set_property = gst_vaapiencode_default_set_property; klass->alloc_buffer = gst_vaapiencode_default_alloc_buffer; /* Registering debug symbols for function pointers */ GST_DEBUG_REGISTER_FUNCPTR (gst_vaapiencode_query); }
static gboolean gst_x265_enc_sink_query (GstVideoEncoder * enc, GstQuery * query) { gboolean res; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_ACCEPT_CAPS:{ GstCaps *acceptable, *caps; acceptable = gst_x265_enc_get_supported_input_caps (); gst_query_parse_accept_caps (query, &caps); gst_query_set_accept_caps_result (query, gst_caps_is_subset (caps, acceptable)); gst_caps_unref (acceptable); res = TRUE; } break; default: res = GST_VIDEO_ENCODER_CLASS (parent_class)->sink_query (enc, query); break; } return res; }
static void gst_video_encoder_tester_class_init (GstVideoEncoderTesterClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *videoencoder_class = GST_VIDEO_ENCODER_CLASS (klass); static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS ("video/x-raw")); static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("video/x-test-custom")); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_templ)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_templ)); gst_element_class_set_metadata (element_class, "VideoEncoderTester", "Encoder/Video", "yep", "me"); videoencoder_class->start = gst_video_encoder_tester_start; videoencoder_class->stop = gst_video_encoder_tester_stop; videoencoder_class->handle_frame = gst_video_encoder_tester_handle_frame; videoencoder_class->set_format = gst_video_encoder_tester_set_format; }
static void gst_v4l2_h264_enc_class_init (GstV4l2H264EncClass * klass) { GstElementClass *element_class; GObjectClass *gobject_class; GstVideoEncoderClass *baseclass; parent_class = g_type_class_peek_parent (klass); element_class = (GstElementClass *) klass; gobject_class = (GObjectClass *) klass; baseclass = GST_VIDEO_ENCODER_CLASS (klass); GST_DEBUG_CATEGORY_INIT (gst_v4l2_h264_enc_debug, "v4l2h264enc", 0, "V4L2 H.264 Encoder"); gst_element_class_set_static_metadata (element_class, "V4L2 H.264 Encoder", "Codec/Encoder/Video", "Encode H.264 video streams via V4L2 API", "ayaka <*****@*****.**>"); gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_v4l2_h264_enc_set_property); gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_v4l2_h264_enc_get_property); baseclass->negotiate = GST_DEBUG_FUNCPTR (gst_v4l2_h264_enc_negotiate); }
static gboolean gst_x265_enc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query) { gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL); return GST_VIDEO_ENCODER_CLASS (parent_class)->propose_allocation (encoder, query); }
static void gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *basevideoenc_class = GST_VIDEO_ENCODER_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)); basevideoenc_class->flush = gst_omx_h264_enc_flush; basevideoenc_class->stop = gst_omx_h264_enc_stop; videoenc_class->cdata.default_src_template_caps = "video/x-h264, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; videoenc_class->handle_output_frame = GST_DEBUG_FUNCPTR (gst_omx_h264_enc_handle_output_frame); gst_element_class_set_static_metadata (element_class, "OpenMAX H.264 Video Encoder", "Codec/Encoder/Video", "Encode H.264 video streams", "Sebastian Dröge <*****@*****.**>"); gst_omx_set_default_role (&videoenc_class->cdata, "video_encoder.avc"); }
static gboolean gst_omx_h264_enc_stop (GstVideoEncoder * enc) { GstOMXH264Enc *self = GST_OMX_H264_ENC (enc); g_list_free_full (self->headers, (GDestroyNotify) gst_buffer_unref); self->headers = NULL; return GST_VIDEO_ENCODER_CLASS (parent_class)->stop (enc); }
static gboolean gst_imx_vpu_encoder_base_sink_event(GstVideoEncoder *encoder, GstEvent *event) { GstImxVpuEncoderBaseClass *klass; GstImxVpuEncoderBase *vpu_encoder_base; gboolean ret; vpu_encoder_base = GST_IMX_VPU_ENCODER_BASE(encoder); klass = GST_IMX_VPU_ENCODER_BASE_CLASS(G_OBJECT_GET_CLASS(vpu_encoder_base)); ret = TRUE; if (klass->sink_event != NULL) ret = klass->sink_event(encoder, event); return ret && GST_VIDEO_ENCODER_CLASS(gst_imx_vpu_encoder_base_parent_class)->sink_event(encoder, event); }
static gboolean gst_vaapiencode_src_query (GstVideoEncoder * encoder, GstQuery * query) { gboolean ret = TRUE; GstElement *const element = GST_ELEMENT (encoder); switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CONTEXT: ret = gst_vaapi_handle_context_query (element, query); break; default: ret = GST_VIDEO_ENCODER_CLASS (gst_vaapiencode_parent_class)->src_query (encoder, query); break; } return ret; }
static void gst_y4m_encode_class_init (GstY4mEncodeClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *venc_class = GST_VIDEO_ENCODER_CLASS (klass); element_class->change_state = GST_DEBUG_FUNCPTR (gst_y4m_encode_change_state); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&y4mencode_src_factory)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&y4mencode_sink_factory)); gst_element_class_set_static_metadata (element_class, "YUV4MPEG video encoder", "Codec/Encoder/Video", "Encodes a YUV frame into the yuv4mpeg format (mjpegtools)", "Wim Taymans <*****@*****.**>"); venc_class->set_format = gst_y4m_encode_set_format; venc_class->handle_frame = gst_y4m_encode_handle_frame; }
static void gst_vp8_enc_class_init (GstVP8EncClass * klass) { GstElementClass *element_class; GstVideoEncoderClass *video_encoder_class; GstVPXEncClass *vpx_encoder_class; element_class = GST_ELEMENT_CLASS (klass); video_encoder_class = GST_VIDEO_ENCODER_CLASS (klass); vpx_encoder_class = GST_VPX_ENC_CLASS (klass); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_vp8_enc_src_template)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_vp8_enc_sink_template)); gst_element_class_set_static_metadata (element_class, "On2 VP8 Encoder", "Codec/Encoder/Video", "Encode VP8 video streams", "David Schleef <*****@*****.**>, " "Sebastian Dröge <*****@*****.**>"); video_encoder_class->pre_push = gst_vp8_enc_pre_push; vpx_encoder_class->get_algo = gst_vp8_enc_get_algo; vpx_encoder_class->enable_scaling = gst_vp8_enc_enable_scaling; vpx_encoder_class->set_image_format = gst_vp8_enc_set_image_format; vpx_encoder_class->get_new_vpx_caps = gst_vp8_enc_get_new_simple_caps; vpx_encoder_class->set_stream_info = gst_vp8_enc_set_stream_info; vpx_encoder_class->process_frame_user_data = gst_vp8_enc_process_frame_user_data; vpx_encoder_class->handle_invisible_frame_buffer = gst_vp8_enc_handle_invisible_frame_buffer; vpx_encoder_class->set_frame_user_data = gst_vp8_enc_set_frame_user_data; GST_DEBUG_CATEGORY_INIT (gst_vp8enc_debug, "vp8enc", 0, "VP8 Encoder"); }
static void gst_amc_video_enc_class_init (GstAmcVideoEncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *element_class = GST_ELEMENT_CLASS (klass); GstVideoEncoderClass *videoenc_class = GST_VIDEO_ENCODER_CLASS (klass); parent_class = g_type_class_peek_parent (klass); gobject_class->set_property = gst_amc_video_enc_set_property; gobject_class->get_property = gst_amc_video_enc_get_property; gobject_class->finalize = gst_amc_video_enc_finalize; element_class->change_state = GST_DEBUG_FUNCPTR (gst_amc_video_enc_change_state); videoenc_class->start = GST_DEBUG_FUNCPTR (gst_amc_video_enc_start); videoenc_class->stop = GST_DEBUG_FUNCPTR (gst_amc_video_enc_stop); videoenc_class->open = GST_DEBUG_FUNCPTR (gst_amc_video_enc_open); videoenc_class->close = GST_DEBUG_FUNCPTR (gst_amc_video_enc_close); videoenc_class->flush = GST_DEBUG_FUNCPTR (gst_amc_video_enc_flush); videoenc_class->set_format = GST_DEBUG_FUNCPTR (gst_amc_video_enc_set_format); videoenc_class->handle_frame = GST_DEBUG_FUNCPTR (gst_amc_video_enc_handle_frame); videoenc_class->finish = GST_DEBUG_FUNCPTR (gst_amc_video_enc_finish); g_object_class_install_property (gobject_class, PROP_BIT_RATE, g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in bit/sec", 1, G_MAXINT, BIT_RATE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_I_FRAME_INTERVAL, g_param_spec_uint ("i-frame-interval", "I-frame interval", "The frequency of I frames expressed in seconds between I frames (0 for automatic)", 0, G_MAXINT, I_FRAME_INTERVAL_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); }
static void gst_theora_enc_class_init (GstTheoraEncClass * klass) { GObjectClass *gobject_class = (GObjectClass *) klass; GstElementClass *element_class = (GstElementClass *) klass; GstVideoEncoderClass *gstvideo_encoder_class = GST_VIDEO_ENCODER_CLASS (klass); gobject_class->set_property = theora_enc_set_property; gobject_class->get_property = theora_enc_get_property; gobject_class->finalize = theora_enc_finalize; gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&theora_enc_src_factory)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&theora_enc_sink_factory)); gst_element_class_set_static_metadata (element_class, "Theora video encoder", "Codec/Encoder/Video", "encode raw YUV video to a theora stream", "Wim Taymans <*****@*****.**>"); gstvideo_encoder_class->start = GST_DEBUG_FUNCPTR (theora_enc_start); gstvideo_encoder_class->stop = GST_DEBUG_FUNCPTR (theora_enc_stop); gstvideo_encoder_class->set_format = GST_DEBUG_FUNCPTR (theora_enc_set_format); gstvideo_encoder_class->handle_frame = GST_DEBUG_FUNCPTR (theora_enc_handle_frame); gstvideo_encoder_class->pre_push = GST_DEBUG_FUNCPTR (theora_enc_pre_push); gstvideo_encoder_class->finish = GST_DEBUG_FUNCPTR (theora_enc_finish); gstvideo_encoder_class->getcaps = GST_DEBUG_FUNCPTR (theora_enc_getcaps); gstvideo_encoder_class->propose_allocation = GST_DEBUG_FUNCPTR (theora_enc_propose_allocation); /* general encoding stream options */ g_object_class_install_property (gobject_class, PROP_BITRATE, g_param_spec_int ("bitrate", "Bitrate", "Compressed video bitrate (kbps)", 0, (1 << 24) - 1, THEORA_DEF_BITRATE, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING)); g_object_class_install_property (gobject_class, PROP_QUALITY, g_param_spec_int ("quality", "Quality", "Video quality", 0, 63, THEORA_DEF_QUALITY, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING)); g_object_class_install_property (gobject_class, PROP_KEYFRAME_AUTO, g_param_spec_boolean ("keyframe-auto", "Keyframe Auto", "Automatic keyframe detection", THEORA_DEF_KEYFRAME_AUTO, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_KEYFRAME_FREQ, g_param_spec_int ("keyframe-freq", "Keyframe frequency", "Keyframe frequency", 1, 32768, THEORA_DEF_KEYFRAME_FREQ, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_KEYFRAME_FREQ_FORCE, g_param_spec_int ("keyframe-force", "Keyframe force", "Force keyframe every N frames", 1, 32768, THEORA_DEF_KEYFRAME_FREQ_FORCE, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_SPEEDLEVEL, g_param_spec_int ("speed-level", "Speed level", "Controls the amount of motion vector searching done while encoding", 0, 3, THEORA_DEF_SPEEDLEVEL, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_VP3_COMPATIBLE, g_param_spec_boolean ("vp3-compatible", "VP3 compatible", "Disables non-VP3 compatible features", THEORA_DEF_VP3_COMPATIBLE, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_DROP_FRAMES, g_param_spec_boolean ("drop-frames", "Drop frames", "Allow or disallow frame dropping", THEORA_DEF_DROP_FRAMES, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_CAP_OVERFLOW, g_param_spec_boolean ("cap-overflow", "Cap overflow", "Enable capping of bit reservoir overflows", THEORA_DEF_CAP_OVERFLOW, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_CAP_UNDERFLOW, g_param_spec_boolean ("cap-underflow", "Cap underflow", "Enable capping of bit reservoir underflows", THEORA_DEF_CAP_UNDERFLOW, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_RATE_BUFFER, g_param_spec_int ("rate-buffer", "Rate Control Buffer", "Sets the size of the rate control buffer, in units of frames. " "The default value of 0 instructs the encoder to automatically " "select an appropriate value", 0, 1000, THEORA_DEF_RATE_BUFFER, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_MULTIPASS_CACHE_FILE, g_param_spec_string ("multipass-cache-file", "Multipass Cache File", "Multipass cache file", THEORA_DEF_MULTIPASS_CACHE_FILE, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_MULTIPASS_MODE, g_param_spec_enum ("multipass-mode", "Multipass mode", "Single pass or first/second pass", GST_TYPE_MULTIPASS_MODE, THEORA_DEF_MULTIPASS_MODE, (GParamFlags) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); GST_DEBUG_CATEGORY_INIT (theoraenc_debug, "theoraenc", 0, "Theora encoder"); }
static gboolean gst_v4l2_h264_enc_negotiate (GstVideoEncoder * encoder) { GstV4l2H264Enc *self = GST_V4L2_H264_ENC (encoder); GstV4l2VideoEnc *venc = GST_V4L2_VIDEO_ENC (encoder); GstV4l2Object *v4l2object = venc->v4l2output; GstCaps *allowed_caps; struct ProfileLevelCtx ctx = { self, NULL, NULL }; GstVideoCodecState *state; GstStructure *s; GST_DEBUG_OBJECT (self, "Negotiating H264 profile and level."); allowed_caps = gst_pad_get_allowed_caps (GST_VIDEO_ENCODER_SRC_PAD (encoder)); if (allowed_caps) { if (gst_caps_is_empty (allowed_caps)) goto not_negotiated; allowed_caps = gst_caps_make_writable (allowed_caps); /* negotiate_profile_and_level() will return TRUE on failure to keep * iterating, if gst_caps_foreach() returns TRUE it means there was no * compatible profile and level in any of the structure */ if (gst_caps_foreach (allowed_caps, negotiate_profile_and_level, &ctx)) { goto no_profile_level; } } if (!ctx.profile) { struct v4l2_control control = { 0, }; control.id = V4L2_CID_MPEG_VIDEO_H264_PROFILE; if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_CTRL, &control) < 0) goto g_ctrl_failed; ctx.profile = v4l2_profile_to_string (control.value); } if (!ctx.level) { struct v4l2_control control = { 0, }; control.id = V4L2_CID_MPEG_VIDEO_H264_LEVEL; if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_G_CTRL, &control) < 0) goto g_ctrl_failed; ctx.level = v4l2_level_to_string (control.value); } GST_DEBUG_OBJECT (self, "Selected H264 profile %s at level %s", ctx.profile, ctx.level); state = gst_video_encoder_get_output_state (encoder); s = gst_caps_get_structure (state->caps, 0); gst_structure_set (s, "profile", G_TYPE_STRING, ctx.profile, "level", G_TYPE_STRING, ctx.level, NULL); return GST_VIDEO_ENCODER_CLASS (parent_class)->negotiate (encoder); g_ctrl_failed: GST_WARNING_OBJECT (self, "Failed to get H264 profile and level: '%s'", g_strerror (errno)); goto not_negotiated; no_profile_level: GST_WARNING_OBJECT (self, "No compatible level and profiled in caps: %" GST_PTR_FORMAT, allowed_caps); goto not_negotiated; not_negotiated: if (allowed_caps) gst_caps_unref (allowed_caps); return FALSE; }
void gst_imx_vpu_base_enc_class_init(GstImxVpuBaseEncClass *klass) { GObjectClass *object_class; GstVideoEncoderClass *base_class; GST_DEBUG_CATEGORY_INIT(imx_vpu_base_enc_debug, "imxvpubaseenc", 0, "Freescale i.MX VPU video encoder base class"); object_class = G_OBJECT_CLASS(klass); base_class = GST_VIDEO_ENCODER_CLASS(klass); object_class->set_property = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_set_property); object_class->get_property = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_get_property); base_class->start = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_start); base_class->stop = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_stop); base_class->set_format = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_set_format); base_class->handle_frame = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_handle_frame); /* TODO: Memory-mapped writes into physically contiguous memory blocks are quite slow. This is * probably caused by the mapping type: if for example it is not mapped with write combining * enabled, random access to the memory will cause lots of wasteful cycles, explaining the * slowdown. Until this can be verified, the buffer pool is disabled; upstream does not get a * proposal for its allocation, and buffer contents end up copied over to a local physical * memory block by using memcpy(). Currently, doing that is ~3 times faster than letting * upstream write directly into physical memory blocks allocated by the proposed buffer pool. * (This also affects the IPU elements.) */ /*base_class->propose_allocation = GST_DEBUG_FUNCPTR(gst_imx_vpu_base_enc_propose_allocation);*/ klass->set_open_params = NULL; klass->get_output_caps = NULL; klass->set_frame_enc_params = NULL; klass->fill_output_buffer = NULL; g_object_class_install_property( object_class, PROP_GOP_SIZE, g_param_spec_uint( "gop-size", "Group-of-picture size", "How many frames a group-of-picture shall contain", 0, 32767, DEFAULT_GOP_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_BITRATE, g_param_spec_uint( "bitrate", "Bitrate", "Bitrate to use, in kbps (0 = no bitrate control; constant quality mode is used)", 0, G_MAXUINT, DEFAULT_BITRATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_SLICE_SIZE, g_param_spec_int( "slice-size", "Slice size", "Maximum slice size (0 = unlimited, <0 in MB, >0 in bits)", G_MININT, G_MAXINT, DEFAULT_SLICE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_INTRA_REFRESH, g_param_spec_uint( "intra-refresh", "Intra Refresh", "Minimum number of MBs to encode as intra MB", 0, G_MAXUINT, DEFAULT_INTRA_REFRESH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); }
static void gst_x265_enc_class_init (GstX265EncClass * klass) { GObjectClass *gobject_class; GstElementClass *element_class; GstVideoEncoderClass *gstencoder_class; x265enc_defaults = g_string_new (""); gobject_class = G_OBJECT_CLASS (klass); element_class = GST_ELEMENT_CLASS (klass); gstencoder_class = GST_VIDEO_ENCODER_CLASS (klass); gobject_class->set_property = gst_x265_enc_set_property; gobject_class->get_property = gst_x265_enc_get_property; gobject_class->finalize = gst_x265_enc_finalize; gstencoder_class->set_format = GST_DEBUG_FUNCPTR (gst_x265_enc_set_format); gstencoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_x265_enc_handle_frame); gstencoder_class->start = GST_DEBUG_FUNCPTR (gst_x265_enc_start); gstencoder_class->stop = GST_DEBUG_FUNCPTR (gst_x265_enc_stop); gstencoder_class->flush = GST_DEBUG_FUNCPTR (gst_x265_enc_flush); gstencoder_class->finish = GST_DEBUG_FUNCPTR (gst_x265_enc_finish); gstencoder_class->getcaps = GST_DEBUG_FUNCPTR (gst_x265_enc_sink_getcaps); gstencoder_class->propose_allocation = GST_DEBUG_FUNCPTR (gst_x265_enc_propose_allocation); g_object_class_install_property (gobject_class, PROP_BITRATE, g_param_spec_uint ("bitrate", "Bitrate", "Bitrate in kbit/sec", 1, 100 * 1024, PROP_BITRATE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_PLAYING)); g_object_class_install_property (gobject_class, PROP_QP, g_param_spec_int ("qp", "Quantization parameter", "QP for P slices in (implied) CQP mode (-1 = disabled)", -1, 51, PROP_QP_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_OPTION_STRING, g_param_spec_string ("option-string", "Option string", "String of x264 options (overridden by element properties)", PROP_OPTION_STRING_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_X265_LOG_LEVEL, g_param_spec_enum ("log-level", "(internal) x265 log level", "x265 log level", GST_X265_ENC_LOG_LEVEL_TYPE, PROP_LOG_LEVEL_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_SPEED_PRESET, g_param_spec_enum ("speed-preset", "Speed preset", "Preset name for speed/quality tradeoff options", GST_X265_ENC_SPEED_PRESET_TYPE, PROP_SPEED_PRESET_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_TUNE, g_param_spec_enum ("tune", "Tune options", "Preset name for tuning options", GST_X265_ENC_TUNE_TYPE, PROP_TUNE_DEFAULT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gst_element_class_set_static_metadata (element_class, "x265enc", "Codec/Encoder/Video", "H265 Encoder", "Thijs Vermeir <*****@*****.**>"); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_factory)); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&src_factory)); }
static gboolean gst_vaapiencode_sink_event (GstVideoEncoder * venc, GstEvent * event) { GstVaapiEncode *const encode = GST_VAAPIENCODE_CAST (venc); GstPad *const srcpad = GST_VAAPI_PLUGIN_BASE_SRC_PAD (encode); gboolean ret; switch (GST_EVENT_TYPE (event)) { case GST_EVENT_CUSTOM_DOWNSTREAM:{ const GstStructure *s = gst_event_get_structure (event); if (gst_structure_has_name (s, "GstVaapiEncoderRegionOfInterest")) { GstVaapiROI roi; if (!encode->encoder) return TRUE; if (!gst_structure_get_uint (s, "roi-x", &roi.rect.x) || !gst_structure_get_uint (s, "roi-y", &roi.rect.y) || !gst_structure_get_uint (s, "roi-width", &roi.rect.width) || !gst_structure_get_uint (s, "roi-height", &roi.rect.height) || !gst_structure_get_int (s, "roi-value", &roi.roi_value)) { return TRUE; } if (roi.roi_value == 0) { ret = gst_vaapi_encoder_del_roi (encode->encoder, &roi); if (ret) { GST_INFO_OBJECT (venc, "ROI: region with %d/%d/%d/%d is removed", roi.rect.x, roi.rect.y, roi.rect.width, roi.rect.height); } } else { ret = gst_vaapi_encoder_add_roi (encode->encoder, &roi); if (ret) { GST_INFO_OBJECT (venc, "ROI: region with %d/%d/%d/%d is added", roi.rect.x, roi.rect.y, roi.rect.width, roi.rect.height); } } gst_event_unref (event); return ret; } break; } default: break; } ret = GST_VIDEO_ENCODER_CLASS (gst_vaapiencode_parent_class)->sink_event (venc, event); if (!ret) return FALSE; switch (GST_EVENT_TYPE (event)) { case GST_EVENT_FLUSH_START: gst_pad_pause_task (srcpad); break; case GST_EVENT_FLUSH_STOP: ret = gst_pad_start_task (srcpad, (GstTaskFunction) gst_vaapiencode_buffer_loop, encode, NULL); break; default: break; } return ret; }
static void gst_openh264enc_class_init (GstOpenh264EncClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstVideoEncoderClass *video_encoder_class = GST_VIDEO_ENCODER_CLASS (klass); /* Setting up pads and setting metadata should be moved to base_class_init if you intend to subclass this class. */ gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass), &gst_openh264enc_src_template); gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass), &gst_openh264enc_sink_template); gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass), "OpenH264 video encoder", "Encoder/Video", "OpenH264 video encoder", "Ericsson AB, http://www.ericsson.com"); gobject_class->set_property = gst_openh264enc_set_property; gobject_class->get_property = gst_openh264enc_get_property; gobject_class->finalize = gst_openh264enc_finalize; video_encoder_class->start = GST_DEBUG_FUNCPTR (gst_openh264enc_start); video_encoder_class->stop = GST_DEBUG_FUNCPTR (gst_openh264enc_stop); video_encoder_class->set_format = GST_DEBUG_FUNCPTR (gst_openh264enc_set_format); video_encoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_openh264enc_handle_frame); video_encoder_class->propose_allocation = GST_DEBUG_FUNCPTR (gst_openh264enc_propose_allocation); video_encoder_class->finish = GST_DEBUG_FUNCPTR (gst_openh264enc_finish); /* define properties */ g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_USAGE_TYPE, g_param_spec_enum ("usage-type", "Usage type", "Type of video content", GST_TYPE_USAGE_TYPE, CAMERA_VIDEO_REAL_TIME, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_RATE_CONTROL, g_param_spec_enum ("rate-control", "Rate control", "Rate control mode", GST_TYPE_RC_MODES, RC_QUALITY_MODE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_MULTI_THREAD, g_param_spec_uint ("multi-thread", "Number of threads", "The number of threads.", 0, G_MAXUINT, DEFAULT_MULTI_THREAD, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_ENABLE_DENOISE, g_param_spec_boolean ("enable-denoise", "Denoise Control", "Denoise control", FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_ENABLE_FRAME_SKIP, g_param_spec_boolean ("enable-frame-skip", "Skip Frames", "Skip frames to reach target bitrate", FALSE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_BITRATE, g_param_spec_uint ("bitrate", "Bitrate", "Bitrate (in bits per second)", 0, G_MAXUINT, DEFAULT_BITRATE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_MAX_BITRATE, g_param_spec_uint ("max-bitrate", "Max Bitrate", "Maximum Bitrate (in bits per second)", 0, G_MAXUINT, DEFAULT_MAX_BITRATE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_GOP_SIZE, g_param_spec_uint ("gop-size", "GOP size", "Number of frames between intra frames", 0, G_MAXUINT, DEFAULT_GOP_SIZE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_MAX_SLICE_SIZE, g_param_spec_uint ("max-slice-size", "Max slice size", "The maximum size of one slice (in bytes).", 0, G_MAXUINT, DEFAULT_MAX_SLICE_SIZE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_DEBLOCKING_MODE, g_param_spec_enum ("deblocking", "Deblocking mode", "Deblocking mode", GST_TYPE_OPENH264ENC_DEBLOCKING_MODE, DEFAULT_DEBLOCKING_MODE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_BACKGROUND_DETECTION, g_param_spec_boolean ("background-detection", "Background detection", "Background detection", DEFAULT_BACKGROUND_DETECTION, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_ADAPTIVE_QUANTIZATION, g_param_spec_boolean ("adaptive-quantization", "Adaptive quantization", "Adaptive quantization", DEFAULT_ADAPTIVE_QUANTIZATION, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_SCENE_CHANGE_DETECTION, g_param_spec_boolean ("scene-change-detection", "Scene change detection", "Scene change detection", DEFAULT_SCENE_CHANGE_DETECTION, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SLICE_MODE, g_param_spec_enum ("slice-mode", "Slice mode", "Slice mode", GST_TYPE_OPENH264ENC_SLICE_MODE, DEFAULT_SLICE_MODE, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_NUM_SLICES, g_param_spec_uint ("num-slices", "Number of slices", "The number of slices (needs slice-mode=n-slices)", 0, G_MAXUINT, DEFAULT_NUM_SLICES, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_COMPLEXITY, g_param_spec_enum ("complexity", "Complexity / quality / speed tradeoff", "Complexity", GST_TYPE_OPENH264ENC_COMPLEXITY, DEFAULT_COMPLEXITY, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); }
void gst_fsl_vpu_base_enc_class_init(GstFslVpuBaseEncClass *klass) { GObjectClass *object_class; GstVideoEncoderClass *base_class; GST_DEBUG_CATEGORY_INIT(vpu_base_enc_debug, "vpubaseenc", 0, "Freescale VPU video encoder base class"); object_class = G_OBJECT_CLASS(klass); base_class = GST_VIDEO_ENCODER_CLASS(klass); object_class->set_property = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_set_property); object_class->get_property = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_get_property); base_class->start = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_start); base_class->stop = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_stop); base_class->set_format = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_set_format); base_class->handle_frame = GST_DEBUG_FUNCPTR(gst_fsl_vpu_base_enc_handle_frame); klass->inst_counter = 0; g_object_class_install_property( object_class, PROP_GOP_SIZE, g_param_spec_uint( "gop-size", "Group-of-picture size", "How many frames a group-of-picture shall contain", 0, 32767, DEFAULT_GOP_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_QP_SMOOTHING, g_param_spec_double( "qp-smoothing", "Quantization parameter smoothing", "How fast the quantization parameter shall change; higher value means faster change (unused if qp is fixed)", 0.0, 1.0, DEFAULT_QP_SMOOTHING, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_INTRA_16X16_ONLY, g_param_spec_boolean( "intra-16x16-only", "Intra 16x16 only mode", "Whether or not to use the 16x16 intra only mode", DEFAULT_INTRA_16X16_ONLY, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_BITRATE, g_param_spec_uint( "bitrate", "Bitrate", "Bitrate to use, in kbps (0 = no bitrate control; constant quality mode is used)", 0, G_MAXUINT, DEFAULT_BITRATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); }
static void gst_imx_vpu_encoder_base_class_init(GstImxVpuEncoderBaseClass *klass) { GObjectClass *object_class; GstVideoEncoderClass *video_encoder_class; GST_DEBUG_CATEGORY_INIT(imx_vpu_encoder_base_debug, "imxvpuencoderbase", 0, "Freescale i.MX VPU video encoder base class"); imx_vpu_setup_logging(); object_class = G_OBJECT_CLASS(klass); video_encoder_class = GST_VIDEO_ENCODER_CLASS(klass); object_class->dispose = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_dispose); object_class->set_property = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_set_property); object_class->get_property = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_get_property); video_encoder_class->start = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_start); video_encoder_class->stop = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_stop); video_encoder_class->set_format = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_set_format); video_encoder_class->sink_event = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_sink_event); video_encoder_class->handle_frame = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_handle_frame); #ifdef ENABLE_PROPOSE_ALLOCATION video_encoder_class->propose_allocation = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_base_propose_allocation); #endif video_encoder_class->flush = GST_DEBUG_FUNCPTR(gst_imx_vpu_encoder_flush); klass->get_output_caps = NULL; klass->set_open_params = NULL; klass->set_frame_enc_params = NULL; klass->process_output_buffer = NULL; klass->sink_event = NULL; g_object_class_install_property( object_class, PROP_DROP, g_param_spec_boolean( "drop", "Drop", "Drop frames", DEFAULT_DROP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_GOP_SIZE, g_param_spec_uint( "gop-size", "Group-of-picture size", "How many frames a group-of-picture shall contain", 0, 32767, DEFAULT_GOP_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_BITRATE, g_param_spec_uint( "bitrate", "Bitrate", "Bitrate to use, in kbps (0 = no bitrate control; constant quality mode is used)", 0, G_MAXUINT, DEFAULT_BITRATE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_SLICE_SIZE, g_param_spec_int( "slice-size", "Slice size", "Maximum slice size (0 = unlimited, <0 in MB, >0 in bits)", G_MININT, G_MAXINT, DEFAULT_SLICE_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_INTRA_REFRESH, g_param_spec_uint( "intra-refresh", "Intra Refresh", "Minimum number of MBs to encode as intra MB", 0, G_MAXUINT, DEFAULT_INTRA_REFRESH, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); g_object_class_install_property( object_class, PROP_ME_SEARCH_RANGE, g_param_spec_enum( "me-search-range", "Motion estimation search range", "Search range for motion estimation", gst_imx_vpu_encoder_me_search_range_get_type(), DEFAULT_ME_SEARCH_RANGE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS ) ); }