nvdecoder: Fix for HEVC 4:4:4 format decoding
[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 coded_bitdepth,
59                                          guint pool_size);
60
61 GstNvDecoderFrame * gst_nv_decoder_new_frame (GstNvDecoder * decoder);
62
63 GstNvDecoderFrame * gst_nv_decoder_frame_ref (GstNvDecoderFrame * frame);
64
65 void gst_nv_decoder_frame_unref (GstNvDecoderFrame * frame);
66
67 gboolean gst_nv_decoder_decode_picture (GstNvDecoder * decoder,
68                                         CUVIDPICPARAMS * params);
69
70 gboolean gst_nv_decoder_finish_frame   (GstNvDecoder * decoder,
71                                         GstVideoDecoder * videodec,
72                                         GstNvDecoderFrame *frame,
73                                         GstBuffer ** buffer);
74
75 /* utils for class registration */
76 gboolean gst_nv_decoder_check_device_caps (CUcontext cuda_ctx,
77                                            cudaVideoCodec codec,
78                                            GstCaps **sink_template,
79                                            GstCaps **src_template);
80
81 const gchar * gst_cuda_video_codec_to_string (cudaVideoCodec codec);
82
83 /* helper methods */
84 gboolean gst_nv_decoder_handle_set_context   (GstNvDecoder * decoder,
85                                               GstElement * videodec,
86                                               GstContext * context);
87
88 gboolean gst_nv_decoder_handle_context_query (GstNvDecoder * decoder,
89                                               GstVideoDecoder * videodec,
90                                               GstQuery * query);
91
92 gboolean gst_nv_decoder_negotiate            (GstNvDecoder * decoder,
93                                               GstVideoDecoder * videodec,
94                                               GstVideoCodecState * input_state,
95                                               GstVideoCodecState ** output_state);
96
97 gboolean gst_nv_decoder_decide_allocation    (GstNvDecoder * decoder,
98                                               GstVideoDecoder * videodec,
99                                               GstQuery * query);
100
101 G_END_DECLS
102
103 #endif /* __GST_NV_DECODER_H__ */