Debian Codegraph @

gst-libs/gst/codecs/gsth266picture.h

raw symbols SCIP
1 /* GStreamer
2 * Copyright (C) 2023 He Junyan <[email protected]>
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 #pragma once
21
22 #ifndef GST_USE_UNSTABLE_API
23 #warning "The CODECs library is unstable API and may change in future."
24 #warning "You can define GST_USE_UNSTABLE_API to avoid this warning."
25 #endif
26
27 #include <gst/gst.h>
28 #include <gst/codecs/codecs-prelude.h>
29 #include <gst/codecs/gstcodecpicture.h>
30 #include <gst/codecparsers/gsth266parser.h>
31 #include <gst/video/video.h>
32
33 G_BEGIN_DECLS
34
35 #define GST_TYPE_H266_PICTURE (gst_h266_picture_get_type())
36 #define GST_IS_H266_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_H266_PICTURE))
37 #define GST_H266_PICTURE(obj) ((GstH266Picture *)obj)
38
39 typedef struct _GstH266Slice GstH266Slice;
40 typedef struct _GstH266Picture GstH266Picture;
41 typedef struct _GstH266Dpb GstH266Dpb;
42
43 /**
44 * GstH266Slice:
45 *
46 * The #GstH266Slice represents a slice for decoding.
47 *
48 * Since: 1.26
49 */
50 struct _GstH266Slice
51 {
52 GstH266SliceHdr header;
53
54 /* parsed nal unit (doesn't take ownership of raw data) */
55 GstH266NalUnit nalu;
56
57 /*< private > */
58 gboolean no_output_before_recovery_flag;
59 gboolean no_output_of_prior_pics_flag;
60 /* The first slice of the picture. */
61 gboolean first_slice;
62 gboolean clear_dpb;
63 };
64
65 /**
66 * GstH266Picture:
67 *
68 * The #GstH266Picture represents a picture for decoding.
69 *
70 * Since: 1.26
71 */
72 struct _GstH266Picture
73 {
74 /*< private > */
75 GstCodecPicture parent;
76
77 GstH266SliceType type;
78
79 gint pic_order_cnt;
80 gint pic_order_cnt_msb;
81 gint pic_order_cnt_lsb;
82
83 guint pic_latency_cnt;
84
85 gboolean output_flag;
86 gboolean NoOutputOfPriorPicsFlag;
87 gboolean NoOutputBeforeRecoveryFlag;
88
89 /* PPS resolution may be smaller than SPS resolution. */
90 gint pps_width, pps_height;
91 gboolean pps_conformance_window_flag;
92 gint pps_crop_rect_width, pps_crop_rect_height;
93 gint pps_crop_rect_x, pps_crop_rect_y;
94
95 /* Never be a ref in RPL, except the first time adding to DPB. */
96 gboolean non_ref;
97 gboolean ref;
98 gboolean long_term;
99 gboolean inter_layer_ref;
100 gboolean needed_for_output;
101
102 GstH266FrameFieldInfo ff_info;
103
104 GstVideoBufferFlags buffer_flags;
105 };
106
107 GST_CODECS_API
108 GType gst_h266_picture_get_type (void);
109
110 GST_CODECS_API
111 GstH266Picture *gst_h266_picture_new (void) G_GNUC_WARN_UNUSED_RESULT;
112
113 static inline GstH266Picture *
114 gst_h266_picture_ref (GstH266Picture * picture)
115 {
116 return (GstH266Picture *)
117 gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
118 }
119
120 static inline void
121 gst_h266_picture_unref (GstH266Picture * picture)
122 {
123 gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
124 }
125
126 static inline gboolean
127 gst_h266_picture_replace (GstH266Picture ** old_picture,
128 GstH266Picture * new_picture)
129 {
130 return gst_mini_object_replace ((GstMiniObject **) old_picture,
131 (GstMiniObject *) new_picture);
132 }
133
134 static inline void
135 gst_clear_h266_picture (GstH266Picture ** picture)
136 {
137 if (picture && *picture) {
138 gst_h266_picture_unref (*picture);
139 *picture = NULL;
140 }
141 }
142
143 static inline void
144 gst_h266_picture_set_user_data (GstH266Picture * picture, gpointer user_data,
145 GDestroyNotify notify)
146 {
147 gst_codec_picture_set_user_data (GST_CODEC_PICTURE (picture),
148 user_data, notify);
149 }
150
151 static inline gpointer
152 gst_h266_picture_get_user_data (GstH266Picture * picture)
153 {
154 return gst_codec_picture_get_user_data (GST_CODEC_PICTURE (picture));
155 }
156
157 static inline void
158 gst_h266_picture_set_discont_state (GstH266Picture * picture,
159 GstVideoCodecState * discont_state)
160 {
161 gst_codec_picture_set_discont_state (GST_CODEC_PICTURE (picture),
162 discont_state);
163 }
164
165 GST_CODECS_API
166 GstH266Dpb *gst_h266_dpb_new (void);
167
168 GST_CODECS_API
169 void gst_h266_dpb_free (GstH266Dpb * dpb);
170
171 GST_CODECS_API
172 void gst_h266_dpb_clear (GstH266Dpb * dpb);
173
174 GST_CODECS_API
175 void gst_h266_dpb_set_max_num_pics (GstH266Dpb * dpb,
176 gint max_num_pics);
177
178 GST_CODECS_API
179 gint gst_h266_dpb_get_max_num_pics (GstH266Dpb * dpb);
180
181 GST_CODECS_API
182 void gst_h266_dpb_add (GstH266Dpb * dpb, GstH266Picture * picture);
183
184 GST_CODECS_API
185 void gst_h266_dpb_delete_unused (GstH266Dpb * dpb);
186
187 GST_CODECS_API
188 gint gst_h266_dpb_num_ref_pictures (GstH266Dpb * dpb);
189
190 GST_CODECS_API
191 gint gst_h266_dpb_get_size (GstH266Dpb * dpb);
192
193 GST_CODECS_API
194 gboolean gst_h266_dpb_needs_bump (GstH266Dpb * dpb, guint max_num_reorder_pics,
195 guint max_latency_increase, guint max_dec_pic_buffering);
196
197 GST_CODECS_API
198 GstH266Picture *gst_h266_dpb_bump (GstH266Dpb * dpb, gboolean drain) G_GNUC_WARN_UNUSED_RESULT;
199
200 GST_CODECS_API
201 void gst_h266_dpb_mark_all_non_ref (GstH266Dpb * dpb);
202
203 GST_CODECS_API
204 void gst_h266_dpb_mark_all_non_output (GstH266Dpb * dpb);
205
206 GST_CODECS_API
207 GstH266Picture *gst_h266_dpb_get_picture_by_poc_lsb (GstH266Dpb * dpb,
208 gint poc_lsb) G_GNUC_WARN_UNUSED_RESULT;
209
210 GST_CODECS_API
211 GstH266Picture *gst_h266_dpb_get_picture_by_poc (GstH266Dpb * dpb, gint poc) G_GNUC_WARN_UNUSED_RESULT;
212
213 GST_CODECS_API
214 GArray *gst_h266_dpb_get_pictures_all (GstH266Dpb * dpb) G_GNUC_WARN_UNUSED_RESULT;
215
216 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GstH266Picture, gst_h266_picture_unref)
217
218 G_END_DECLS