1 /* 2 * gstvaapiencoder.h - VA encoder abstraction 3 * 4 * Copyright (C) 2013-2014 Intel Corporation 5 * Author: Wind Yuan <feng.yuan@intel.com> 6 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public License 10 * as published by the Free Software Foundation; either version 2.1 11 * of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free 20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 * Boston, MA 02110-1301 USA 22 */ 23 24 #ifndef GST_VAAPI_ENCODER_H 25 #define GST_VAAPI_ENCODER_H 26 27 #include <gst/video/gstvideoutils.h> 28 #include <gst/vaapi/gstvaapicodedbufferproxy.h> 29 30 G_BEGIN_DECLS 31 32 #define GST_VAAPI_ENCODER(encoder) \ 33 ((GstVaapiEncoder *) (encoder)) 34 35 typedef struct _GstVaapiEncoder GstVaapiEncoder; 36 37 /** 38 * GstVaapiEncoderStatus: 39 * @GST_VAAPI_ENCODER_STATUS_SUCCESS: Success. 40 * @GST_VAAPI_ENCODER_STATUS_NO_SURFACE: No surface left to encode. 41 * @GST_VAAPI_ENCODER_STATUS_NO_BUFFER: No coded buffer left to hold 42 * the encoded picture. 43 * @GST_VAAPI_ENCODER_STATUS_ERROR_UNKNOWN: Unknown error. 44 * @GST_VAAPI_ENCODER_STATUS_ERROR_ALLOCATION_FAILED: No memory left. 45 * @GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED: The requested 46 * operation failed to execute properly. e.g. invalid point in time to 47 * execute the operation. 48 * @GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_RATE_CONTROL: 49 * Unsupported rate control value. 50 * @GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE: Unsupported profile. 51 * @GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER: Invalid parameter. 52 * @GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_BUFFER: Invalid buffer. 53 * @GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_SURFACE: Invalid surface. 54 * @GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_HEADER: Invalid header. 55 * 56 * Set of #GstVaapiEncoder status codes. 57 */ 58 typedef enum 59 { 60 GST_VAAPI_ENCODER_STATUS_SUCCESS = 0, 61 GST_VAAPI_ENCODER_STATUS_NO_SURFACE = 1, 62 GST_VAAPI_ENCODER_STATUS_NO_BUFFER = 2, 63 64 GST_VAAPI_ENCODER_STATUS_ERROR_UNKNOWN = -1, 65 GST_VAAPI_ENCODER_STATUS_ERROR_ALLOCATION_FAILED = -2, 66 GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED = -3, 67 GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_RATE_CONTROL = -4, 68 GST_VAAPI_ENCODER_STATUS_ERROR_UNSUPPORTED_PROFILE = -5, 69 GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_PARAMETER = -100, 70 GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_BUFFER = -101, 71 GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_SURFACE = -102, 72 GST_VAAPI_ENCODER_STATUS_ERROR_INVALID_HEADER = -103, 73 } GstVaapiEncoderStatus; 74 75 /** 76 * GstVaapiEncoderTune: 77 * @GST_VAAPI_ENCODER_TUNE_NONE: No tuning option set. 78 * @GST_VAAPI_ENCODER_TUNE_HIGH_COMPRESSION: Tune for higher compression 79 * ratios, at the expense of lower compatibility at decoding time. 80 * @GST_VAAPI_ENCODER_TUNE_LOW_LATENCY: Tune for low latency decoding. 81 * @GST_VAAPI_ENCODER_TUNE_LOW_POWER: Tune encoder for low power / 82 * resources conditions. This can affect compression ratio or visual 83 * quality to match low power conditions. 84 * 85 * The set of tuning options for a #GstVaapiEncoder. By default, 86 * maximum compatibility for decoding is preferred, so the lowest 87 * coding tools are enabled. 88 */ 89 typedef enum { 90 GST_VAAPI_ENCODER_TUNE_NONE = 0, 91 GST_VAAPI_ENCODER_TUNE_HIGH_COMPRESSION, 92 GST_VAAPI_ENCODER_TUNE_LOW_LATENCY, 93 GST_VAAPI_ENCODER_TUNE_LOW_POWER, 94 } GstVaapiEncoderTune; 95 96 /** 97 * GstVaapiEncoderMbbrc: 98 * @GST_VAAPI_ENCODER_MBBRC_AUTO: bitrate control auto 99 * @GST_VAAPI_ENCODER_MBBRC_ON: bitrate control on 100 * @GST_VAAPI_ENCODER_MBBRC_OFF: bitrate control off 101 * 102 * Values for the macroblock level bitrate control. 103 * 104 * This property values are only available for H264 and H265 (HEVC) 105 * encoders, when rate control is not Constant QP. 106 **/ 107 typedef enum { 108 GST_VAAPI_ENCODER_MBBRC_AUTO = 0, 109 GST_VAAPI_ENCODER_MBBRC_ON = 1, 110 GST_VAAPI_ENCODER_MBBRC_OFF = 2, 111 } GstVaapiEncoderMbbrc; 112 113 /** 114 * GstVaapiEncoderProp: 115 * @GST_VAAPI_ENCODER_PROP_RATECONTROL: Rate control (#GstVaapiRateControl). 116 * @GST_VAAPI_ENCODER_PROP_BITRATE: Bitrate expressed in kbps (uint). 117 * @GST_VAAPI_ENCODER_PROP_KEYFRAME_PERIOD: The maximal distance 118 * between two keyframes (uint). 119 * @GST_VAAPI_ENCODER_PROP_TUNE: The tuning options (#GstVaapiEncoderTune). 120 * 121 * The set of configurable properties for the encoder. 122 */ 123 typedef enum { 124 GST_VAAPI_ENCODER_PROP_RATECONTROL = 1, 125 GST_VAAPI_ENCODER_PROP_BITRATE, 126 GST_VAAPI_ENCODER_PROP_KEYFRAME_PERIOD, 127 GST_VAAPI_ENCODER_PROP_TUNE, 128 GST_VAAPI_ENCODER_PROP_QUALITY_LEVEL, 129 GST_VAAPI_ENCODER_PROP_DEFAULT_ROI_VALUE 130 } GstVaapiEncoderProp; 131 132 /** 133 * GstVaapiEncoderPropInfo: 134 * @prop: the #GstVaapiEncoderProp 135 * @pspec: the #GParamSpec describing the associated configurable value 136 * 137 * A #GstVaapiEncoderProp descriptor. 138 */ 139 typedef struct { 140 const gint prop; 141 GParamSpec *const pspec; 142 } GstVaapiEncoderPropInfo; 143 144 GType 145 gst_vaapi_encoder_tune_get_type (void) G_GNUC_CONST; 146 147 GType 148 gst_vaapi_encoder_mbbrc_get_type (void) G_GNUC_CONST; 149 150 GstVaapiEncoder * 151 gst_vaapi_encoder_ref (GstVaapiEncoder * encoder); 152 153 void 154 gst_vaapi_encoder_unref (GstVaapiEncoder * encoder); 155 156 void 157 gst_vaapi_encoder_replace (GstVaapiEncoder ** old_encoder_ptr, 158 GstVaapiEncoder * new_encoder); 159 160 GstVaapiEncoderStatus 161 gst_vaapi_encoder_get_codec_data (GstVaapiEncoder * encoder, 162 GstBuffer ** out_codec_data_ptr); 163 164 GstVaapiEncoderStatus 165 gst_vaapi_encoder_set_codec_state (GstVaapiEncoder * encoder, 166 GstVideoCodecState * state); 167 168 GstVaapiEncoderStatus 169 gst_vaapi_encoder_set_property (GstVaapiEncoder * encoder, gint prop_id, 170 const GValue * value); 171 172 GstVaapiEncoderStatus 173 gst_vaapi_encoder_set_rate_control (GstVaapiEncoder * encoder, 174 GstVaapiRateControl rate_control); 175 176 GstVaapiEncoderStatus 177 gst_vaapi_encoder_set_bitrate (GstVaapiEncoder * encoder, guint bitrate); 178 179 GstVaapiEncoderStatus 180 gst_vaapi_encoder_put_frame (GstVaapiEncoder * encoder, 181 GstVideoCodecFrame * frame); 182 183 GstVaapiEncoderStatus 184 gst_vaapi_encoder_set_keyframe_period (GstVaapiEncoder * encoder, 185 guint keyframe_period); 186 187 GstVaapiEncoderStatus 188 gst_vaapi_encoder_set_tuning (GstVaapiEncoder * encoder, 189 GstVaapiEncoderTune tuning); 190 191 GstVaapiEncoderStatus 192 gst_vaapi_encoder_set_quality_level (GstVaapiEncoder * encoder, 193 guint quality_level); 194 195 GstVaapiEncoderStatus 196 gst_vaapi_encoder_get_buffer_with_timeout (GstVaapiEncoder * encoder, 197 GstVaapiCodedBufferProxy ** out_codedbuf_proxy_ptr, guint64 timeout); 198 199 GstVaapiEncoderStatus 200 gst_vaapi_encoder_flush (GstVaapiEncoder * encoder); 201 202 GArray * 203 gst_vaapi_encoder_get_surface_formats (GstVaapiEncoder * encoder, 204 GstVaapiProfile profile); 205 G_END_DECLS 206 207 #endif /* GST_VAAPI_ENCODER_H */ 208