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