2 * Copyright (C) 2019 Seungha Yang <seungha.yang@navercorp.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.
20 #ifndef __GST_H264_PICTURE_H__
21 #define __GST_H264_PICTURE_H__
23 #include <gst/codecs/codecs-prelude.h>
25 #include <gst/codecparsers/gsth264parser.h>
29 #define GST_TYPE_H264_PICTURE (gst_h264_picture_get_type())
30 #define GST_IS_H264_PICTURE(obj) (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_H264_PICTURE))
31 #define GST_H264_PICTURE(obj) ((GstH264Picture *)obj)
32 #define GST_H264_PICTURE_CAST(obj) (GST_H264_PICTURE(obj))
34 typedef struct _GstH264Slice GstH264Slice;
35 typedef struct _GstH264Picture GstH264Picture;
37 #define GST_H264_DPB_MAX_SIZE 32
41 GstH264SliceHdr header;
43 /* parsed nal unit (doesn't take ownership of raw data) */
49 GST_H264_PICTURE_FIELD_FRAME,
50 GST_H264_PICTURE_FILED_TOP_FIELD,
51 GST_H264_PICTURE_FIELD_BOTTOM_FIELD,
52 } GstH264PictureField;
54 struct _GstH264Picture
58 GstH264SliceType type;
62 guint8 pic_order_cnt_type; /* SPS */
63 gint32 top_field_order_cnt;
64 gint32 bottom_field_order_cnt;
67 gint pic_order_cnt_msb;
68 gint pic_order_cnt_lsb;
69 gint delta_pic_order_cnt_bottom;
70 gint delta_pic_order_cnt0;
71 gint delta_pic_order_cnt1;
74 gint long_term_pic_num;
76 gint frame_num_offset;
78 gint long_term_frame_idx;
90 GstH264PictureField field;
92 GstH264DecRefPicMarking dec_ref_pic_marking;
95 GDestroyNotify notify;
99 GType gst_h264_picture_get_type (void);
102 GstH264Picture * gst_h264_picture_new (void);
104 static inline GstH264Picture *
105 gst_h264_picture_ref (GstH264Picture * picture)
107 return (GstH264Picture *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (picture));
111 gst_h264_picture_unref (GstH264Picture * picture)
113 gst_mini_object_unref (GST_MINI_OBJECT_CAST (picture));
116 static inline gboolean
117 gst_h264_picture_replace (GstH264Picture ** old_picture,
118 GstH264Picture * new_picture)
120 return gst_mini_object_replace ((GstMiniObject **) old_picture,
121 (GstMiniObject *) new_picture);
125 gst_h264_picture_clear (GstH264Picture ** picture)
127 if (picture && *picture) {
128 gst_h264_picture_unref (*picture);
134 void gst_h264_picture_set_user_data (GstH264Picture * picture,
136 GDestroyNotify notify);
139 gpointer gst_h264_picture_get_user_data (GstH264Picture * picture);
144 typedef struct _GstH264Dpb GstH264Dpb;
147 GstH264Dpb * gst_h264_dpb_new (void);
150 void gst_h264_dpb_set_max_num_pics (GstH264Dpb * dpb,
154 gint gst_h264_dpb_get_max_num_pics (GstH264Dpb * dpb);
157 void gst_h264_dpb_free (GstH264Dpb * dpb);
160 void gst_h264_dpb_clear (GstH264Dpb * dpb);
163 void gst_h264_dpb_add (GstH264Dpb * dpb,
164 GstH264Picture * picture);
167 void gst_h264_dpb_delete_unused (GstH264Dpb * dpb);
170 void gst_h264_dpb_delete_by_poc (GstH264Dpb * dpb,
174 gint gst_h264_dpb_num_ref_pictures (GstH264Dpb * dpb);
177 void gst_h264_dpb_mark_all_non_ref (GstH264Dpb * dpb);
180 GstH264Picture * gst_h264_dpb_get_short_ref_by_pic_num (GstH264Dpb * dpb,
184 GstH264Picture * gst_h264_dpb_get_long_ref_by_pic_num (GstH264Dpb * dpb,
188 GstH264Picture * gst_h264_dpb_get_lowest_frame_num_short_ref (GstH264Dpb * dpb);
191 void gst_h264_dpb_get_pictures_not_outputted (GstH264Dpb * dpb,
195 void gst_h264_dpb_get_pictures_short_term_ref (GstH264Dpb * dpb,
199 void gst_h264_dpb_get_pictures_long_term_ref (GstH264Dpb * dpb,
203 GArray * gst_h264_dpb_get_pictures_all (GstH264Dpb * dpb);
206 gint gst_h264_dpb_get_size (GstH264Dpb * dpb);
209 gboolean gst_h264_dpb_is_full (GstH264Dpb * dpb);
213 #endif /* __GST_H264_PICTURE_H__ */