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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
/* GStreamer
* Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.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.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstvp9picture.h"
GST_DEBUG_CATEGORY_EXTERN (gst_vp9_decoder_debug);
#define GST_CAT_DEFAULT gst_vp9_decoder_debug
GST_DEFINE_MINI_OBJECT_TYPE (GstVp9Picture, gst_vp9_picture);
static void
_gst_vp9_picture_free (GstVp9Picture * picture)
{
GST_TRACE ("Free picture %p", picture);
if (picture->notify)
picture->notify (picture->user_data);
g_free (picture);
}
/**
* gst_vp9_picture_new:
*
* Create new #GstVp9Picture
*
* Returns: a new #GstVp9Picture
*/
GstVp9Picture *
gst_vp9_picture_new (void)
{
GstVp9Picture *pic;
pic = g_new0 (GstVp9Picture, 1);
gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
GST_TYPE_VP9_PICTURE, NULL, NULL,
(GstMiniObjectFreeFunction) _gst_vp9_picture_free);
GST_TRACE ("New picture %p", pic);
return pic;
}
/**
* gst_vp9_picture_set_user_data:
* @picture: a #GstVp9Picture
* @user_data: private data
* @notify: (closure user_data): a #GDestroyNotify
*
* Sets @user_data on the picture and the #GDestroyNotify that will be called when
* the picture is freed.
*
* If a @user_data was previously set, then the previous set @notify will be called
* before the @user_data is replaced.
*/
void
gst_vp9_picture_set_user_data (GstVp9Picture * picture, gpointer user_data,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_VP9_PICTURE (picture));
if (picture->notify)
picture->notify (picture->user_data);
picture->user_data = user_data;
picture->notify = notify;
}
/**
* gst_vp9_picture_get_user_data:
* @picture: a #GstVp9Picture
*
* Gets private data set on the picture via
* gst_vp9_picture_set_user_data() previously.
*
* Returns: (transfer none): The previously set user_data
*/
gpointer
gst_vp9_picture_get_user_data (GstVp9Picture * picture)
{
return picture->user_data;
}
/**
* gst_vp9_dpb_new: (skip)
*
* Create new #GstVp9Dpb
*
* Returns: a new #GstVp9Dpb
*/
GstVp9Dpb *
gst_vp9_dpb_new (void)
{
GstVp9Dpb *dpb;
dpb = g_new0 (GstVp9Dpb, 1);
return dpb;
}
/**
* gst_vp9_dpb_free:
* @dpb: a #GstVp9Dpb to free
*
* Free the @dpb
*/
void
gst_vp9_dpb_free (GstVp9Dpb * dpb)
{
g_return_if_fail (dpb != NULL);
gst_vp9_dpb_clear (dpb);
g_free (dpb);
}
/**
* gst_vp9_dpb_clear:
* @dpb: a #GstVp9Dpb
*
* Clear all stored #GstVp9Picture
*/
void
gst_vp9_dpb_clear (GstVp9Dpb * dpb)
{
gint i;
g_return_if_fail (dpb != NULL);
for (i = 0; i < GST_VP9_REF_FRAMES; i++)
gst_vp9_picture_clear (&dpb->pic_list[i]);
}
/**
* gst_vp9_dpb_add:
* @dpb: a #GstVp9Dpb
* @picture: (transfer full): a #GstVp9Picture
*
* Store the @picture
*/
void
gst_vp9_dpb_add (GstVp9Dpb * dpb, GstVp9Picture * picture)
{
guint8 refresh_frame_flags;
gint i;
g_return_if_fail (dpb != NULL);
g_return_if_fail (GST_IS_VP9_PICTURE (picture));
if (picture->frame_hdr.frame_type == GST_VP9_KEY_FRAME) {
refresh_frame_flags = (1 << GST_VP9_REF_FRAMES) - 1;
GST_TRACE ("keyframe, fill to all pictures");
} else {
refresh_frame_flags = picture->frame_hdr.refresh_frame_flags;
GST_TRACE ("non-keyframe, refresh frame flags 0x%x", refresh_frame_flags);
}
for (i = 0; i < GST_VP9_REF_FRAMES; i++) {
if (refresh_frame_flags & 0x1) {
gst_vp9_picture_replace (&dpb->pic_list[i], picture);
}
refresh_frame_flags >>= 1;
}
gst_vp9_picture_unref (picture);
}
|