• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_H265_DECODER_H__
21 #define __GST_H265_DECODER_H__
22 
23 #include <gst/codecs/codecs-prelude.h>
24 
25 #include <gst/video/video.h>
26 #include <gst/codecparsers/gsth265parser.h>
27 #include <gst/codecs/gsth265picture.h>
28 
29 G_BEGIN_DECLS
30 
31 #define GST_TYPE_H265_DECODER            (gst_h265_decoder_get_type())
32 #define GST_H265_DECODER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_H265_DECODER,GstH265Decoder))
33 #define GST_H265_DECODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_H265_DECODER,GstH265DecoderClass))
34 #define GST_H265_DECODER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_H265_DECODER,GstH265DecoderClass))
35 #define GST_IS_H265_DECODER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_H265_DECODER))
36 #define GST_IS_H265_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_H265_DECODER))
37 #define GST_H265_DECODER_CAST(obj)       ((GstH265Decoder*)obj)
38 
39 typedef struct _GstH265Decoder GstH265Decoder;
40 typedef struct _GstH265DecoderClass GstH265DecoderClass;
41 typedef struct _GstH265DecoderPrivate GstH265DecoderPrivate;
42 
43 /**
44  * GstH265Decoder:
45  *
46  * The opaque #GstH265Decoder data structure.
47  */
48 struct _GstH265Decoder
49 {
50   /*< private >*/
51   GstVideoDecoder parent;
52 
53   /*< protected >*/
54   GstVideoCodecState * input_state;
55 
56   GstH265Picture *RefPicSetStCurrBefore[16];
57   GstH265Picture *RefPicSetStCurrAfter[16];
58   GstH265Picture *RefPicSetStFoll[16];
59   GstH265Picture *RefPicSetLtCurr[16];
60   GstH265Picture *RefPicSetLtFoll[16];
61 
62   guint NumPocStCurrBefore;
63   guint NumPocStCurrAfter;
64   guint NumPocStFoll;
65   guint NumPocLtCurr;
66   guint NumPocLtFoll;
67   guint NumPicTotalCurr;
68 
69   /*< private >*/
70   GstH265DecoderPrivate *priv;
71   gpointer padding[GST_PADDING_LARGE];
72 };
73 
74 /**
75  * GstH265DecoderClass:
76  * @new_sequence:   Notifies subclass of SPS update
77  * @new_picture:    Optional.
78  *                  Called whenever new #GstH265Picture is created.
79  *                  Subclass can set implementation specific user data
80  *                  on the #GstH265Picture via gst_h265_picture_set_user_data()
81  * @start_picture:  Optional.
82  *                  Called per one #GstH265Picture to notify subclass to prepare
83  *                  decoding process for the #GstH265Picture
84  * @decode_slice:   Provides per slice data with parsed slice header and
85  *                  required raw bitstream for subclass to decode it
86  * @end_picture:    Optional.
87  *                  Called per one #GstH265Picture to notify subclass to finish
88  *                  decoding process for the #GstH265Picture
89  * @output_picture: Called with a #GstH265Picture which is required to be outputted.
90  *                  The #GstVideoCodecFrame must be consumed by subclass via
91  *                  gst_video_decoder_{finish,drop,release}_frame().
92  */
93 struct _GstH265DecoderClass
94 {
95   GstVideoDecoderClass parent_class;
96 
97   GstFlowReturn (*new_sequence)     (GstH265Decoder * decoder,
98                                      const GstH265SPS * sps,
99                                      gint max_dpb_size);
100   /**
101    * GstH265Decoder:new_picture:
102    * @decoder: a #GstH265Decoder
103    * @frame: (transfer none): a #GstVideoCodecFrame
104    * @picture: (transfer none): a #GstH265Picture
105    */
106   GstFlowReturn (*new_picture)      (GstH265Decoder * decoder,
107                                      GstVideoCodecFrame * frame,
108                                      GstH265Picture * picture);
109 
110   GstFlowReturn (*start_picture)    (GstH265Decoder * decoder,
111                                      GstH265Picture * picture,
112                                      GstH265Slice * slice,
113                                      GstH265Dpb * dpb);
114 
115   GstFlowReturn (*decode_slice)     (GstH265Decoder * decoder,
116                                      GstH265Picture * picture,
117                                      GstH265Slice * slice,
118                                      GArray * ref_pic_list0,
119                                      GArray * ref_pic_list1);
120 
121   GstFlowReturn (*end_picture)      (GstH265Decoder * decoder,
122                                      GstH265Picture * picture);
123   /**
124    * GstH265Decoder:output_picture:
125    * @decoder: a #GstH265Decoder
126    * @frame: (transfer full): a #GstVideoCodecFrame
127    * @picture: (transfer full): a #GstH265Picture
128    */
129   GstFlowReturn (*output_picture)   (GstH265Decoder * decoder,
130                                      GstVideoCodecFrame * frame,
131                                      GstH265Picture * picture);
132 
133   /*< private >*/
134   gpointer padding[GST_PADDING_LARGE];
135 };
136 
137 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstH265Decoder, gst_object_unref)
138 
139 GST_CODECS_API
140 GType gst_h265_decoder_get_type (void);
141 
142 GST_CODECS_API
143 void gst_h265_decoder_set_process_ref_pic_lists (GstH265Decoder * decoder,
144                                                  gboolean process);
145 
146 GST_CODECS_API
147 GstH265Picture * gst_h265_decoder_get_picture   (GstH265Decoder * decoder,
148                                                  guint32 system_frame_number);
149 
150 G_END_DECLS
151 
152 #endif /* __GST_H265_DECODER_H__ */
153