2 * Copyright (C) 2020 He Junyan <junyan.he@intel.com>
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.
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.
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.
24 #include "gstav1picture.h"
26 GST_DEBUG_CATEGORY_EXTERN (gst_av1_decoder_debug);
27 #define GST_CAT_DEFAULT gst_av1_decoder_debug
29 GST_DEFINE_MINI_OBJECT_TYPE (GstAV1Picture, gst_av1_picture);
32 _gst_av1_picture_free (GstAV1Picture * picture)
34 GST_TRACE ("Free picture %p", picture);
37 picture->notify (picture->user_data);
39 if (picture->discont_state)
40 gst_video_codec_state_unref (picture->discont_state);
46 * gst_av1_picture_new:
48 * Create new #GstAV1Picture
50 * Returns: a new #GstAV1Picture
55 gst_av1_picture_new (void)
59 pic = g_new0 (GstAV1Picture, 1);
61 gst_mini_object_init (GST_MINI_OBJECT_CAST (pic), 0,
62 GST_TYPE_AV1_PICTURE, NULL, NULL,
63 (GstMiniObjectFreeFunction) _gst_av1_picture_free);
65 GST_TRACE ("New picture %p", pic);
71 * gst_av1_picture_set_user_data:
72 * @picture: a #GstAV1Picture
73 * @user_data: private data
74 * @notify: (closure user_data): a #GDestroyNotify
76 * Sets @user_data on the picture and the #GDestroyNotify that will be called when
77 * the picture is freed.
79 * If a @user_data was previously set, then the previous set @notify will be called
80 * before the @user_data is replaced.
85 gst_av1_picture_set_user_data (GstAV1Picture * picture, gpointer user_data,
86 GDestroyNotify notify)
88 g_return_if_fail (GST_IS_AV1_PICTURE (picture));
91 picture->notify (picture->user_data);
93 picture->user_data = user_data;
94 picture->notify = notify;
98 * gst_av1_picture_get_user_data:
99 * @picture: a #GstAV1Picture
101 * Gets private data set on the picture via
102 * gst_av1_picture_set_user_data() previously.
104 * Returns: (transfer none): The previously set user_data
109 gst_av1_picture_get_user_data (GstAV1Picture * picture)
111 return picture->user_data;
115 * gst_av1_dpb_new: (skip)
117 * Create new #GstAV1Dpb
119 * Returns: a new #GstAV1Dpb
124 gst_av1_dpb_new (void)
128 dpb = g_new0 (GstAV1Dpb, 1);
135 * @dpb: a #GstAV1Dpb to free
142 gst_av1_dpb_free (GstAV1Dpb * dpb)
144 g_return_if_fail (dpb != NULL);
146 gst_av1_dpb_clear (dpb);
154 * Clear all stored #GstAV1Picture
159 gst_av1_dpb_clear (GstAV1Dpb * dpb)
163 g_return_if_fail (dpb != NULL);
165 for (i = 0; i < GST_AV1_NUM_REF_FRAMES; i++)
166 gst_clear_av1_picture (&dpb->pic_list[i]);
172 * @picture: (transfer full): a #GstAV1Picture
179 gst_av1_dpb_add (GstAV1Dpb * dpb, GstAV1Picture * picture)
181 GstAV1FrameHeaderOBU *fh;
184 g_return_if_fail (dpb != NULL);
185 g_return_if_fail (GST_IS_AV1_PICTURE (picture));
187 fh = &picture->frame_hdr;
189 for (i = 0; i < GST_AV1_NUM_REF_FRAMES; i++) {
190 if ((fh->refresh_frame_flags >> i) & 1) {
191 GST_TRACE ("reference frame %p to ref slot:%d", picture, i);
192 gst_av1_picture_replace (&dpb->pic_list[i], picture);
196 gst_av1_picture_unref (picture);