• 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_D3D11_DECODER_H__
21 #define __GST_D3D11_DECODER_H__
22 
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25 #include <gst/d3d11/gstd3d11.h>
26 
27 G_BEGIN_DECLS
28 
29 #define GST_TYPE_D3D11_DECODER (gst_d3d11_decoder_get_type())
30 G_DECLARE_FINAL_TYPE (GstD3D11Decoder,
31     gst_d3d11_decoder, GST, D3D11_DECODER, GstObject);
32 
33 typedef struct _GstD3D11DecoderClassData GstD3D11DecoderClassData;
34 
35 typedef enum
36 {
37   GST_DXVA_CODEC_NONE,
38   GST_DXVA_CODEC_MPEG2,
39   GST_DXVA_CODEC_H264,
40   GST_DXVA_CODEC_H265,
41   GST_DXVA_CODEC_VP8,
42   GST_DXVA_CODEC_VP9,
43   GST_DXVA_CODEC_AV1,
44 
45   /* the last of supported codec */
46   GST_DXVA_CODEC_LAST
47 } GstDXVACodec;
48 
49 typedef struct
50 {
51   GstDXVACodec codec;
52   gint64 adapter_luid;
53   guint device_id;
54   guint vendor_id;
55 } GstD3D11DecoderSubClassData;
56 
57 typedef struct _GstD3D11DecodeInputStreamArgs
58 {
59   gpointer picture_params;
60   gsize picture_params_size;
61 
62   gpointer slice_control;
63   gsize slice_control_size;
64 
65   gpointer bitstream;
66   gsize bitstream_size;
67 
68   gpointer inverse_quantization_matrix;
69   gsize inverse_quantization_matrix_size;
70 } GstD3D11DecodeInputStreamArgs;
71 
72 GstD3D11Decoder * gst_d3d11_decoder_new (GstD3D11Device * device,
73                                          GstDXVACodec codec);
74 
75 gboolean          gst_d3d11_decoder_is_configured (GstD3D11Decoder * decoder);
76 
77 gboolean          gst_d3d11_decoder_configure     (GstD3D11Decoder * decoder,
78                                                    GstVideoCodecState * input_state,
79                                                    GstVideoInfo * info,
80                                                    gint coded_width,
81                                                    gint coded_height,
82                                                    guint dpb_size);
83 
84 gboolean          gst_d3d11_decoder_decode_frame  (GstD3D11Decoder * decoder,
85                                                    ID3D11VideoDecoderOutputView * output_view,
86                                                    GstD3D11DecodeInputStreamArgs * input_args);
87 
88 
89 GstBuffer *       gst_d3d11_decoder_get_output_view_buffer (GstD3D11Decoder * decoder,
90                                                             GstVideoDecoder * videodec);
91 
92 ID3D11VideoDecoderOutputView * gst_d3d11_decoder_get_output_view_from_buffer (GstD3D11Decoder * decoder,
93                                                                               GstBuffer * buffer,
94                                                                               guint8 * view_id);
95 
96 gboolean          gst_d3d11_decoder_process_output      (GstD3D11Decoder * decoder,
97                                                          GstVideoDecoder * videodec,
98                                                          gint display_width,
99                                                          gint display_height,
100                                                          GstBuffer * decoder_buffer,
101                                                          GstBuffer ** output);
102 
103 gboolean          gst_d3d11_decoder_negotiate           (GstD3D11Decoder * decoder,
104                                                          GstVideoDecoder * videodec);
105 
106 gboolean          gst_d3d11_decoder_decide_allocation   (GstD3D11Decoder * decoder,
107                                                          GstVideoDecoder * videodec,
108                                                          GstQuery * query);
109 
110 gboolean          gst_d3d11_decoder_set_flushing        (GstD3D11Decoder * decoder,
111                                                          GstVideoDecoder * videodec,
112                                                          gboolean flushing);
113 
114 /* Utils for class registration */
115 typedef struct _GstDXVAResolution
116 {
117   guint width;
118   guint height;
119 } GstDXVAResolution;
120 
121 static const GstDXVAResolution gst_dxva_resolutions[] = {
122   {1920, 1088}, {2560, 1440}, {3840, 2160}, {4096, 2160},
123   {7680, 4320}, {8192, 4320}
124 };
125 
126 gboolean          gst_d3d11_decoder_util_is_legacy_device (GstD3D11Device * device);
127 
128 gboolean          gst_d3d11_decoder_get_supported_decoder_profile (GstD3D11Device * device,
129                                                                    GstDXVACodec codec,
130                                                                    GstVideoFormat format,
131                                                                    const GUID ** selected_profile);
132 
133 gboolean          gst_d3d11_decoder_supports_format (GstD3D11Device * device,
134                                                      const GUID * decoder_profile,
135                                                      DXGI_FORMAT format);
136 
137 gboolean          gst_d3d11_decoder_supports_resolution (GstD3D11Device * device,
138                                                          const GUID * decoder_profile,
139                                                          DXGI_FORMAT format,
140                                                          guint width,
141                                                          guint height);
142 
143 GstD3D11DecoderClassData *  gst_d3d11_decoder_class_data_new  (GstD3D11Device * device,
144                                                                GstDXVACodec codec,
145                                                                GstCaps * sink_caps,
146                                                                GstCaps * src_caps);
147 
148 void  gst_d3d11_decoder_class_data_fill_subclass_data (GstD3D11DecoderClassData * data,
149                                                        GstD3D11DecoderSubClassData * subclass_data);
150 
151 void  gst_d3d11_decoder_proxy_class_init              (GstElementClass * klass,
152                                                        GstD3D11DecoderClassData * data,
153                                                        const gchar * author);
154 
155 void  gst_d3d11_decoder_proxy_get_property            (GObject * object,
156                                                        guint prop_id,
157                                                        GValue * value,
158                                                        GParamSpec * pspec,
159                                                        GstD3D11DecoderSubClassData * subclass_data);
160 
161 gboolean gst_d3d11_decoder_proxy_open                 (GstVideoDecoder * videodec,
162                                                        GstD3D11DecoderSubClassData * subclass_data,
163                                                        GstD3D11Device ** device,
164                                                        GstD3D11Decoder ** decoder);
165 
166 G_END_DECLS
167 
168 #endif /* __GST_D3D11_DECODER_H__ */
169