1 /* GStreamer
2 * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.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_VP9_PICTURE_H__
21 #define __GST_VP9_PICTURE_H__
22
23 #include <gst/codecs/codecs-prelude.h>
24 #include <gst/codecs/gstvp9statefulparser.h>
25
26 G_BEGIN_DECLS
27
28 #define GST_TYPE_VP9_PICTURE (gst_vp9_picture_get_type())
29 #define GST_IS_VP9_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_VP9_PICTURE))
30 #define GST_VP9_PICTURE(obj) ((GstVp9Picture *)obj)
31 #define GST_VP9_PICTURE_CAST(obj) (GST_VP9_PICTURE(obj))
32
33 typedef struct _GstVp9Picture GstVp9Picture;
34
35 struct _GstVp9Picture
36 {
37 /*< private >*/
38 GstMiniObject parent;
39
40 /* From GstVideoCodecFrame */
41 guint32 system_frame_number;
42
43 GstVp9FrameHeader frame_hdr;
44
45 /* raw data and size (does not have ownership) */
46 const guint8 * data;
47 gsize size;
48
49 gpointer user_data;
50 GDestroyNotify notify;
51 };
52
53 GST_CODECS_API
54 GType gst_vp9_picture_get_type (void);
55
56 GST_CODECS_API
57 GstVp9Picture * gst_vp9_picture_new (void);
58
59 static inline GstVp9Picture *
gst_vp9_picture_ref(GstVp9Picture * picture)60 gst_vp9_picture_ref (GstVp9Picture * picture)
61 {
62 return (GstVp9Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
63 }
64
65 static inline void
gst_vp9_picture_unref(GstVp9Picture * picture)66 gst_vp9_picture_unref (GstVp9Picture * picture)
67 {
68 gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
69 }
70
71 static inline gboolean
gst_vp9_picture_replace(GstVp9Picture ** old_picture,GstVp9Picture * new_picture)72 gst_vp9_picture_replace (GstVp9Picture ** old_picture,
73 GstVp9Picture * new_picture)
74 {
75 return gst_mini_object_replace ((GstMiniObject **) old_picture,
76 (GstMiniObject *) new_picture);
77 }
78
79 static inline void
gst_vp9_picture_clear(GstVp9Picture ** picture)80 gst_vp9_picture_clear (GstVp9Picture ** picture)
81 {
82 if (picture && *picture) {
83 gst_vp9_picture_unref (*picture);
84 *picture = NULL;
85 }
86 }
87
88 GST_CODECS_API
89 void gst_vp9_picture_set_user_data (GstVp9Picture * picture,
90 gpointer user_data,
91 GDestroyNotify notify);
92
93 GST_CODECS_API
94 gpointer gst_vp9_picture_get_user_data (GstVp9Picture * picture);
95
96 /*******************
97 * GstVp9Dpb *
98 *******************/
99 typedef struct _GstVp9Dpb GstVp9Dpb;
100
101 struct _GstVp9Dpb
102 {
103 GstVp9Picture *pic_list[GST_VP9_REF_FRAMES];
104 };
105
106 GST_CODECS_API
107 GstVp9Dpb * gst_vp9_dpb_new (void);
108
109 GST_CODECS_API
110 void gst_vp9_dpb_free (GstVp9Dpb * dpb);
111
112 GST_CODECS_API
113 void gst_vp9_dpb_clear (GstVp9Dpb * dpb);
114
115 GST_CODECS_API
116 void gst_vp9_dpb_add (GstVp9Dpb * dpb,
117 GstVp9Picture * picture);
118
119 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVp9Picture, gst_vp9_picture_unref)
120
121 G_END_DECLS
122
123 #endif /* __GST_VP9_PICTURE_H__ */
124