2 * Copyright (C) <2017> Sean DuBois <sean@siobud.com>
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.
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.
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.
21 #ifndef __GST_AV1_ENC_H__
22 #define __GST_AV1_ENC_H__
26 #include <gst/video/video.h>
27 #include <gst/video/gstvideoencoder.h>
29 #include <aom/aom_codec.h>
30 #include <aom/aom_encoder.h>
31 #include <aom/aomcx.h>
34 #define GST_TYPE_AV1_ENC \
35 (gst_av1_enc_get_type())
36 #define GST_AV1_ENC(obj) \
37 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AV1_ENC,GstAV1Enc))
38 #define GST_AV1_ENC_CLASS(klass) \
39 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AV1_ENC,GstAV1EncClass))
40 #define GST_IS_AV1_ENC(obj) \
41 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AV1_ENC))
42 #define GST_IS_AV1_ENC_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AV1_ENC))
44 #define GST_AV1_ENC_GET_CLASS(obj) \
45 (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_AV1_ENC, GstAV1EncClass))
46 #define GST_AV1_ENC_CAST(obj) \
49 typedef struct _GstAV1Enc GstAV1Enc;
50 typedef struct _GstAV1EncClass GstAV1EncClass;
53 * GstAV1EncResizeMode:
54 * @GST_AV1_ENC_RESIZE_NONE: No frame resizing allowed
55 * @GST_AV1_ENC_RESIZE_FIXED: All frames are coded at the specified scale
56 * @GST_AV1_ENC_RESIZE_RANDOM: All frames are coded at a random scale
62 GST_AV1_ENC_RESIZE_NONE = 0,
63 GST_AV1_ENC_RESIZE_FIXED = 1,
64 GST_AV1_ENC_RESIZE_RANDOM = 2,
65 GST_AV1_ENC_RESIZE_MODES
66 } GstAV1EncResizeMode;
69 * GstAV1EncSuperresMode
70 * @GST_AV1_ENC_SUPERRES_NONE: No frame superres allowed
71 * @GST_AV1_ENC_SUPERRES_FIXED: All frames are coded at the specified scale and
73 * @GST_AV1_ENC_SUPERRES_QTHRESH: Superres scale for a frame is determined based
76 * Frame super-resolution mode
80 GST_AV1_ENC_SUPERRES_NONE = 0,
81 GST_AV1_ENC_SUPERRES_FIXED = 1,
82 GST_AV1_ENC_SUPERRES_RANDOM = 2,
83 GST_AV1_ENC_SUPERRES_QTHRESH = 3,
84 GST_AV1_ENC_SUPERRES_MODES
85 } GstAV1EncSuperresMode;
88 * GstAV1EncEndUsageMode
89 * @GST_AV1_ENC_END_USAGE_VBR: Variable Bit Rate Mode
90 * @GST_AV1_ENC_END_USAGE_CBR: Constant Bit Rate Mode
91 * @GST_AV1_ENC_END_USAGE_CQ: Constrained Quality Mode
92 * @GST_AV1_ENC_END_USAGE_Q: Constant Quality Mode
94 * Rate control algorithm to use
99 GST_AV1_ENC_END_USAGE_VBR = 0,
100 GST_AV1_ENC_END_USAGE_CBR = 1,
101 GST_AV1_ENC_END_USAGE_CQ = 2,
102 GST_AV1_ENC_END_USAGE_Q = 3,
103 GST_AV1_ENC_END_USAGE_MODES
104 } GstAV1EncEndUsageMode;
108 GstVideoEncoder base_video_encoder;
119 gboolean encoder_inited;
120 GstVideoCodecState *input_state;
121 aom_codec_enc_cfg_t aom_cfg;
122 aom_codec_ctx_t encoder;
123 aom_img_fmt_t format;
126 /* next pts, in running time */
127 GstClockTime next_pts;
129 gboolean target_bitrate_set;
132 struct _GstAV1EncClass
134 GstVideoEncoderClass parent_class;
135 /*supported aom algo*/
136 aom_codec_iface_t *codec_algo;
139 GType gst_av1_enc_get_type (void);
141 GST_ELEMENT_REGISTER_DECLARE (av1enc);
144 #endif /* __GST_AV1_ENC_H__ */