1 /* GStreamer H265 encoder plugin 2 * Copyright (C) 2019 Yeongjin Jeong <yeongjin.jeong@navercorp.com> 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more details. 13 * 14 * You should have received a copy of the GNU Library General Public 15 * License along with this library; if not, write to the 16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 17 * Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __GST_SVTHEVC_ENC_H__ 21 #define __GST_SVTHEVC_ENC_H__ 22 23 #include <gst/gst.h> 24 #include <gst/video/video.h> 25 #include <gst/video/gstvideoencoder.h> 26 27 #include <EbApi.h> 28 29 G_BEGIN_DECLS 30 #define GST_TYPE_SVTHEVC_ENC \ 31 (gst_svthevc_enc_get_type()) 32 G_DECLARE_FINAL_TYPE (GstSvtHevcEnc, gst_svthevc_enc, GST, SVTHEVC_ENC, GstVideoEncoder) 33 #define GST_SVTHEVC_ENC_CLASS(klass) \ 34 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SVTHEVC_ENC,GstSvtHevcEncClass)) 35 #define GST_IS_SVTHEVC_ENC_CLASS(klass) \ 36 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SVTHEVC_ENC)) 37 38 typedef enum svt_eos_status 39 { 40 EOS_NOT_REACHED = 0, 41 EOS_REACHED, 42 EOS_TOTRIGGER 43 } SVT_EOS_STATUS; 44 45 typedef enum 46 { 47 GST_SVTHEVC_ENC_B_PYRAMID_FLAT, 48 GST_SVTHEVC_ENC_B_PYRAMID_2LEVEL_HIERARCHY, 49 GST_SVTHEVC_ENC_B_PYRAMID_3LEVEL_HIERARCHY, 50 GST_SVTHEVC_ENC_B_PYRAMID_4LEVEL_HIERARCHY, 51 } GstSvtHevcEncBPyramid; 52 53 typedef enum 54 { 55 GST_SVTHEVC_ENC_BASE_LAYER_MODE_BFRAME, 56 GST_SVTHEVC_ENC_BASE_LAYER_MODE_PFRAME, 57 } GstSvtHevcEncBaseLayerMode; 58 59 typedef enum 60 { 61 GST_SVTHEVC_ENC_RC_CQP, 62 GST_SVTHEVC_ENC_RC_VBR, 63 } GstSvtHevcEncRC; 64 65 typedef enum 66 { 67 GST_SVTHEVC_ENC_TUNE_SQ, 68 GST_SVTHEVC_ENC_TUNE_OQ, 69 GST_SVTHEVC_ENC_TUNE_VMAF, 70 } GstSvtHevcEncTune; 71 72 typedef enum 73 { 74 GST_SVTHEVC_ENC_PRED_STRUCT_LOW_DELAY_P, 75 GST_SVTHEVC_ENC_PRED_STRUCT_LOW_DELAY_B, 76 GST_SVTHEVC_ENC_PRED_STRUCT_RANDOM_ACCESS, 77 } GstSvtHevcEncPredStruct; 78 79 struct _GstSvtHevcEnc 80 { 81 GstVideoEncoder element; 82 83 /*< private > */ 84 const gchar *svthevc_version; 85 EB_H265_ENC_CONFIGURATION enc_params; 86 EB_COMPONENTTYPE *svt_handle; 87 88 EB_BUFFERHEADERTYPE *in_buf; 89 90 SVT_EOS_STATUS svt_eos_flag; 91 92 GstClockTime dts_offset; 93 GstVideoCodecFrame *first_frame; 94 gboolean push_header; 95 gboolean first_buffer; 96 gboolean update_latency; 97 98 /* Internally used for convert stride to multiple of pstride */ 99 GstBufferPool *internal_pool; 100 GstVideoInfo *aligned_info; 101 102 /* properties */ 103 gboolean insert_vui; 104 gboolean aud; 105 GstSvtHevcEncBPyramid hierarchical_level; 106 guint la_depth; 107 guint enc_mode; 108 GstSvtHevcEncRC rc_mode; 109 guint qp_i; 110 guint qp_max; 111 guint qp_min; 112 gboolean scene_change_detection; 113 GstSvtHevcEncTune tune; 114 GstSvtHevcEncBaseLayerMode base_layer_switch_mode; 115 guint bitrate; 116 gint keyintmax; 117 gboolean enable_open_gop; 118 guint config_interval; 119 guint cores; 120 gint socket; 121 guint tile_row; 122 guint tile_col; 123 GstSvtHevcEncPredStruct pred_structure; 124 guint vbv_maxrate; 125 guint vbv_bufsize; 126 127 guint profile; 128 guint tier; 129 guint level; 130 131 /* input description */ 132 GstVideoCodecState *input_state; 133 134 /* configuration changed while playing */ 135 gboolean reconfig; 136 }; 137 138 G_END_DECLS 139 #endif /* __GST_SVTHEVC_ENC_H__ */ 140