1 /* GStreamer
2 * Copyright (C) 2020 He Junyan <junyan.he@intel.com>
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 #ifndef __GST_AV1_PICTURE_H__
21 #define __GST_AV1_PICTURE_H__
22
23 #include <gst/codecs/codecs-prelude.h>
24 #include <gst/codecparsers/gstav1parser.h>
25
26 G_BEGIN_DECLS
27
28 /**
29 * GST_TYPE_AV1_PICTURE:
30 *
31 * Since: 1.20
32 */
33 #define GST_TYPE_AV1_PICTURE (gst_av1_picture_get_type())
34 /**
35 * GST_IS_AV1_PICTURE:
36 *
37 * Since: 1.20
38 */
39 #define GST_IS_AV1_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_AV1_PICTURE))
40 /**
41 * GST_AV1_PICTURE:
42 *
43 * Since: 1.20
44 */
45 #define GST_AV1_PICTURE(obj) ((GstAV1Picture *)obj)
46
47 typedef struct _GstAV1Picture GstAV1Picture;
48 typedef struct _GstAV1Tile GstAV1Tile;
49
50 /**
51 * GstAV1Tile:
52 *
53 * Since: 1.20
54 */
55 struct _GstAV1Tile
56 {
57 GstAV1TileGroupOBU tile_group;
58 /* raw data and size of tile group (does not have ownership) */
59 GstAV1OBU obu;
60 };
61
62 /**
63 * GstAV1Picture:
64 *
65 * Since: 1.20
66 */
67 struct _GstAV1Picture
68 {
69 GstMiniObject parent;
70
71 /* From GstVideoCodecFrame */
72 guint32 system_frame_number;
73
74 GstAV1FrameHeaderOBU frame_hdr;
75
76 /* copied from parser */
77 guint32 display_frame_id;
78 gboolean show_frame;
79 gboolean showable_frame;
80 gboolean apply_grain;
81
82 gpointer user_data;
83 GDestroyNotify notify;
84 };
85
86 GST_CODECS_API
87 GType gst_av1_picture_get_type (void);
88
89 GST_CODECS_API
90 GstAV1Picture * gst_av1_picture_new (void);
91
92 static inline GstAV1Picture *
gst_av1_picture_ref(GstAV1Picture * picture)93 gst_av1_picture_ref (GstAV1Picture * picture)
94 {
95 return (GstAV1Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
96 }
97
98 static inline void
gst_av1_picture_unref(GstAV1Picture * picture)99 gst_av1_picture_unref (GstAV1Picture * picture)
100 {
101 gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
102 }
103
104 static inline gboolean
gst_av1_picture_replace(GstAV1Picture ** old_picture,GstAV1Picture * new_picture)105 gst_av1_picture_replace (GstAV1Picture ** old_picture,
106 GstAV1Picture * new_picture)
107 {
108 return gst_mini_object_replace ((GstMiniObject **) old_picture,
109 (GstMiniObject *) new_picture);
110 }
111
112 static inline void
gst_av1_picture_clear(GstAV1Picture ** picture)113 gst_av1_picture_clear (GstAV1Picture ** picture)
114 {
115 if (picture && *picture) {
116 gst_av1_picture_unref (*picture);
117 *picture = NULL;
118 }
119 }
120
121 GST_CODECS_API
122 void gst_av1_picture_set_user_data (GstAV1Picture * picture,
123 gpointer user_data,
124 GDestroyNotify notify);
125
126 GST_CODECS_API
127 gpointer gst_av1_picture_get_user_data (GstAV1Picture * picture);
128
129 /*******************
130 * GstAV1Dpb *
131 *******************/
132 typedef struct _GstAV1Dpb GstAV1Dpb;
133
134 /**
135 * GstAV1Dpb:
136 *
137 * Since: 1.20
138 */
139 struct _GstAV1Dpb
140 {
141 GstAV1Picture *pic_list[GST_AV1_NUM_REF_FRAMES];
142 };
143
144 GST_CODECS_API
145 GstAV1Dpb * gst_av1_dpb_new (void);
146
147 GST_CODECS_API
148 void gst_av1_dpb_free (GstAV1Dpb * dpb);
149
150 GST_CODECS_API
151 void gst_av1_dpb_clear (GstAV1Dpb * dpb);
152
153 GST_CODECS_API
154 void gst_av1_dpb_add (GstAV1Dpb * dpb,
155 GstAV1Picture * picture);
156
157 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstAV1Picture, gst_av1_picture_unref)
158
159 G_END_DECLS
160
161 #endif /* __GST_AV1_PICTURE_H__ */
162