2f782495f6959a22dbef50b9afdf6b6f7ba8bbb6
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / sys / nvcodec / gstnvdecoder.h
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_NV_DECODER_H__
21 #define __GST_NV_DECODER_H__
22
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25 #include "gstcudautils.h"
26 #include "gstcuvidloader.h"
27
28 G_BEGIN_DECLS
29
30 #define GST_TYPE_NV_DECODER (gst_nv_decoder_get_type())
31 G_DECLARE_FINAL_TYPE (GstNvDecoder,
32     gst_nv_decoder, GST, NV_DECODER, GstObject);
33
34 typedef struct _GstNvDecoderFrame
35 {
36   /* CUVIDPICPARAMS::CurrPicIdx */
37   gint index;
38   guintptr devptr;
39   guint pitch;
40
41   gboolean mapped;
42
43   /*< private >*/
44   GstNvDecoder *decoder;
45
46   gint ref_count;
47 } GstNvDecoderFrame;
48
49 GstNvDecoder * gst_nv_decoder_new (GstCudaContext * context);
50
51 gboolean       gst_nv_decoder_is_configured (GstNvDecoder * decoder);
52
53 gboolean       gst_nv_decoder_configure (GstNvDecoder * decoder,
54                                          cudaVideoCodec codec,
55                                          GstVideoInfo * info,
56                                          gint coded_width,
57                                          gint coded_height,
58                                          guint pool_size);
59
60 GstNvDecoderFrame * gst_nv_decoder_new_frame (GstNvDecoder * decoder);
61
62 GstNvDecoderFrame * gst_nv_decoder_frame_ref (GstNvDecoderFrame * frame);
63
64 void gst_nv_decoder_frame_unref (GstNvDecoderFrame * frame);
65
66 gboolean gst_nv_decoder_decode_picture (GstNvDecoder * decoder,
67                                         CUVIDPICPARAMS * params);
68
69 gboolean gst_nv_decoder_finish_frame   (GstNvDecoder * decoder,
70                                         GstVideoDecoder * videodec,
71                                         GstNvDecoderFrame *frame,
72                                         GstBuffer ** buffer);
73
74 /* utils for class registration */
75 gboolean gst_nv_decoder_check_device_caps (CUcontext cuda_ctx,
76                                            cudaVideoCodec codec,
77                                            GstCaps **sink_template,
78                                            GstCaps **src_template);
79
80 const gchar * gst_cuda_video_codec_to_string (cudaVideoCodec codec);
81
82 /* helper methods */
83 gboolean gst_nv_decoder_handle_set_context   (GstNvDecoder * decoder,
84                                               GstElement * videodec,
85                                               GstContext * context);
86
87 gboolean gst_nv_decoder_handle_context_query (GstNvDecoder * decoder,
88                                               GstVideoDecoder * videodec,
89                                               GstQuery * query);
90
91 gboolean gst_nv_decoder_negotiate            (GstNvDecoder * decoder,
92                                               GstVideoDecoder * videodec,
93                                               GstVideoCodecState * input_state,
94                                               GstVideoCodecState ** output_state);
95
96 gboolean gst_nv_decoder_decide_allocation    (GstNvDecoder * decoder,
97                                               GstVideoDecoder * videodec,
98                                               GstQuery * query);
99
100 G_END_DECLS
101
102 #endif /* __GST_NV_DECODER_H__ */