• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2020 Seungha Yang <seungha@centricular.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_VP8_DECODER_H__
21 #define __GST_VP8_DECODER_H__
22 
23 #include <gst/codecs/codecs-prelude.h>
24 
25 #include <gst/video/video.h>
26 #include <gst/codecparsers/gstvp8parser.h>
27 #include <gst/codecs/gstvp8picture.h>
28 
29 G_BEGIN_DECLS
30 
31 #define GST_TYPE_VP8_DECODER            (gst_vp8_decoder_get_type())
32 #define GST_VP8_DECODER(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VP8_DECODER,GstVp8Decoder))
33 #define GST_VP8_DECODER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VP8_DECODER,GstVp8DecoderClass))
34 #define GST_VP8_DECODER_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_VP8_DECODER,GstVp8DecoderClass))
35 #define GST_IS_VP8_DECODER(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VP8_DECODER))
36 #define GST_IS_VP8_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VP8_DECODER))
37 #define GST_VP8_DECODER_CAST(obj)       ((GstVp8Decoder*)obj)
38 
39 typedef struct _GstVp8Decoder GstVp8Decoder;
40 typedef struct _GstVp8DecoderClass GstVp8DecoderClass;
41 typedef struct _GstVp8DecoderPrivate GstVp8DecoderPrivate;
42 
43 /**
44  * GstVp8Decoder:
45  *
46  * The opaque #GstVp8Decoder data structure.
47  */
48 struct _GstVp8Decoder
49 {
50   /*< private >*/
51   GstVideoDecoder parent;
52 
53   /*< protected >*/
54   GstVideoCodecState * input_state;
55 
56   /* reference frames */
57   GstVp8Picture *last_picture;
58   GstVp8Picture *golden_ref_picture;
59   GstVp8Picture *alt_ref_picture;
60 
61   /*< private >*/
62   GstVp8DecoderPrivate *priv;
63   gpointer padding[GST_PADDING_LARGE];
64 };
65 
66 /**
67  * GstVp8DecoderClass:
68  * @new_sequence:      Notifies subclass of SPS update
69  * @new_picture:       Optional.
70  *                     Called whenever new #GstVp8Picture is created.
71  *                     Subclass can set implementation specific user data
72  *                     on the #GstVp8Picture via gst_vp8_picture_set_user_data()
73  * @start_picture:     Optional.
74  *                     Called per one #GstVp8Picture to notify subclass to prepare
75  *                     decoding process for the #GstVp8Picture
76  * @decode_slice:      Provides per slice data with parsed slice header and
77  *                     required raw bitstream for subclass to decode it
78  * @end_picture:       Optional.
79  *                     Called per one #GstVp8Picture to notify subclass to finish
80  *                     decoding process for the #GstVp8Picture
81  * @output_picture:    Called with a #GstVp8Picture which is required to be outputted.
82  *                     Subclass can retrieve parent #GstVideoCodecFrame by using
83  *                     gst_video_decoder_get_frame() with system_frame_number
84  *                     and the #GstVideoCodecFrame must be consumed by subclass via
85  *                     gst_video_decoder_{finish,drop,release}_frame().
86  */
87 struct _GstVp8DecoderClass
88 {
89   GstVideoDecoderClass parent_class;
90 
91   GstFlowReturn   (*new_sequence)      (GstVp8Decoder * decoder,
92                                         const GstVp8FrameHdr * frame_hdr);
93 
94   /**
95    * GstVp8DecoderClass:new_picture:
96    * @decoder: a #GstVp8Decoder
97    * @frame: (transfer none): a #GstVideoCodecFrame
98    * @picture: (transfer none): a #GstVp8Picture
99    */
100   GstFlowReturn   (*new_picture)       (GstVp8Decoder * decoder,
101                                         GstVideoCodecFrame * frame,
102                                         GstVp8Picture * picture);
103 
104   GstFlowReturn   (*start_picture)     (GstVp8Decoder * decoder,
105                                         GstVp8Picture * picture);
106 
107   GstFlowReturn   (*decode_picture)    (GstVp8Decoder * decoder,
108                                         GstVp8Picture * picture,
109                                         GstVp8Parser * parser);
110 
111   GstFlowReturn   (*end_picture)       (GstVp8Decoder * decoder,
112                                         GstVp8Picture * picture);
113 
114   /**
115    * GstVp8DecoderClass:output_picture:
116    * @decoder: a #GstVp8Decoder
117    * @frame: (transfer full): a #GstVideoCodecFrame
118    * @picture: (transfer full): a #GstVp8Picture
119    */
120   GstFlowReturn   (*output_picture)    (GstVp8Decoder * decoder,
121                                         GstVideoCodecFrame * frame,
122                                         GstVp8Picture * picture);
123 
124   /**
125    * GstVp8DecoderClass::get_preferred_output_delay:
126    * @decoder: a #GstVp8Decoder
127    * @is_live: whether upstream is live or not
128    *
129    * Optional. Called by baseclass to query whether delaying output is
130    * preferred by subclass or not.
131    *
132    * Returns: the number of perferred delayed output frame
133    *
134    * Since: 1.20
135    */
136   guint           (*get_preferred_output_delay)   (GstVp8Decoder * decoder,
137                                                    gboolean is_live);
138 
139   /*< private >*/
140   gpointer padding[GST_PADDING_LARGE];
141 };
142 
143 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVp8Decoder, gst_object_unref)
144 
145 GST_CODECS_API
146 GType gst_vp8_decoder_get_type (void);
147 
148 G_END_DECLS
149 
150 #endif /* __GST_VP8_DECODER_H__ */
151