xref: /OK3568_Linux_fs/external/gstreamer-rockchip/gst/rockchipmpp/gstmppenc.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2017 Rockchip Electronics Co., Ltd
3  *     Author: Randy Li <randy.li@rock-chips.com>
4  *
5  * Copyright 2021 Rockchip Electronics Co., Ltd
6  *     Author: Jeffy Chen <jeffy.chen@rock-chips.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 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  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  *
23  */
24 
25 #ifndef  __GST_MPP_ENC_H__
26 #define  __GST_MPP_ENC_H__
27 
28 #include <gst/video/gstvideoencoder.h>
29 
30 #include "gstmpp.h"
31 
32 G_BEGIN_DECLS;
33 
34 #define GST_TYPE_MPP_ENC (gst_mpp_enc_get_type())
35 G_DECLARE_FINAL_TYPE (GstMppEnc, gst_mpp_enc, GST, MPP_ENC, GstVideoEncoder);
36 
37 #define GST_MPP_ENC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
38     GST_TYPE_MPP_ENC, GstMppEnc))
39 
40 struct _GstMppEnc
41 {
42   GstVideoEncoder parent;
43 
44   GMutex mutex;
45   GstAllocator *allocator;
46   GstVideoCodecState *input_state;
47 
48   /* final input video info */
49   GstVideoInfo info;
50 
51   /* stop handling new frame when flushing */
52   gboolean flushing;
53 
54   /* drop frames when flushing but not draining */
55   gboolean draining;
56 
57   guint pending_frames;
58   GMutex event_mutex;
59   GCond event_cond;
60 
61   /* flow return from pad task */
62   GstFlowReturn task_ret;
63 
64   MppEncHeaderMode header_mode;
65   MppEncRcMode rc_mode;
66   MppEncSeiMode sei_mode;
67 
68   gint rotation;
69   gint width;
70   gint height;
71 
72   gint gop;
73   guint max_reenc;
74 
75   guint bps;
76   guint bps_min;
77   guint bps_max;
78 
79   gboolean zero_copy_pkt;
80 
81   gboolean arm_afbc;
82 
83   gboolean prop_dirty;
84 
85   MppEncCfg mpp_cfg;
86   MppFrame mpp_frame;
87 
88   MppCodingType mpp_type;
89   MppCtx mpp_ctx;
90   MppApi *mpi;
91 };
92 
93 #define MPP_ENC_IN_FORMATS \
94     "NV12, I420, YUY2, UYVY, " \
95     "BGR16, RGB16, " \
96     "ABGR, ARGB, BGRA, RGBA, xBGR, xRGB, BGRx, RGBx"
97 
98 #ifdef HAVE_RGA
99 #define MPP_ENC_FORMATS MPP_ENC_IN_FORMATS "," GST_RGA_FORMATS
100 #else
101 #define MPP_ENC_FORMATS MPP_ENC_IN_FORMATS
102 #endif
103 
104 gboolean gst_mpp_enc_apply_properties (GstVideoEncoder * encoder);
105 gboolean gst_mpp_enc_set_src_caps (GstVideoEncoder * encoder, GstCaps * caps);
106 
107 gboolean gst_mpp_enc_supported (MppCodingType mpp_type);
108 
109 G_END_DECLS;
110 
111 #endif /* __GST_MPP_ENC_H__ */
112