2020-04-16 14:27:31 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2020 Seungha Yang <seungha@centricular.com>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GST_NV_DECODER_H__
|
|
|
|
#define __GST_NV_DECODER_H__
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/video/video.h>
|
2022-12-21 14:57:15 +00:00
|
|
|
#include <gst/cuda/gstcuda.h>
|
2020-04-16 14:27:31 +00:00
|
|
|
#include "gstcuvidloader.h"
|
2023-02-07 17:25:35 +00:00
|
|
|
#include "gstnvdecobject.h"
|
2020-04-16 14:27:31 +00:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
#define GST_TYPE_NV_DECODER (gst_nv_decoder_get_type())
|
|
|
|
G_DECLARE_FINAL_TYPE (GstNvDecoder,
|
|
|
|
gst_nv_decoder, GST, NV_DECODER, GstObject);
|
|
|
|
|
2022-06-26 13:26:29 +00:00
|
|
|
typedef struct _GstNvDecoderClassData
|
|
|
|
{
|
|
|
|
GstCaps *sink_caps;
|
|
|
|
GstCaps *src_caps;
|
|
|
|
guint cuda_device_id;
|
2023-02-13 12:59:05 +00:00
|
|
|
guint max_width;
|
|
|
|
guint max_height;
|
2022-06-26 13:26:29 +00:00
|
|
|
} GstNvDecoderClassData;
|
|
|
|
|
2021-03-17 05:30:09 +00:00
|
|
|
GstNvDecoder * gst_nv_decoder_new (GstCudaContext * context);
|
|
|
|
|
|
|
|
gboolean gst_nv_decoder_is_configured (GstNvDecoder * decoder);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
2021-03-17 05:30:09 +00:00
|
|
|
gboolean gst_nv_decoder_configure (GstNvDecoder * decoder,
|
|
|
|
cudaVideoCodec codec,
|
|
|
|
GstVideoInfo * info,
|
|
|
|
gint coded_width,
|
|
|
|
gint coded_height,
|
2022-01-31 15:12:06 +00:00
|
|
|
guint coded_bitdepth,
|
2022-05-02 13:59:59 +00:00
|
|
|
guint pool_size,
|
2023-02-07 17:25:35 +00:00
|
|
|
gboolean alloc_aux_frame,
|
2023-02-13 12:59:05 +00:00
|
|
|
guint num_output_surfaces,
|
|
|
|
guint init_max_width,
|
|
|
|
guint init_max_height);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
2023-02-07 17:25:35 +00:00
|
|
|
GstFlowReturn gst_nv_decoder_acquire_surface (GstNvDecoder * decoder,
|
|
|
|
GstNvDecSurface ** surface);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
2023-02-07 17:25:35 +00:00
|
|
|
gboolean gst_nv_decoder_decode (GstNvDecoder * decoder,
|
|
|
|
CUVIDPICPARAMS * params);
|
2020-10-30 12:20:57 +00:00
|
|
|
|
2023-02-07 17:25:35 +00:00
|
|
|
GstFlowReturn gst_nv_decoder_finish_surface (GstNvDecoder * decoder,
|
|
|
|
GstVideoDecoder * videodec,
|
|
|
|
GstVideoCodecState * input_state,
|
|
|
|
GstNvDecSurface *surface,
|
|
|
|
GstBuffer ** buffer);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
2023-02-07 17:25:35 +00:00
|
|
|
void gst_nv_decoder_set_flushing (GstNvDecoder * decoder,
|
|
|
|
gboolean flushing);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
2023-02-07 17:25:35 +00:00
|
|
|
void gst_nv_decoder_reset (GstNvDecoder * decoder);
|
2020-04-16 14:27:31 +00:00
|
|
|
|
|
|
|
/* utils for class registration */
|
|
|
|
gboolean gst_nv_decoder_check_device_caps (CUcontext cuda_ctx,
|
|
|
|
cudaVideoCodec codec,
|
|
|
|
GstCaps **sink_template,
|
|
|
|
GstCaps **src_template);
|
|
|
|
|
|
|
|
const gchar * gst_cuda_video_codec_to_string (cudaVideoCodec codec);
|
|
|
|
|
2020-06-18 19:50:26 +00:00
|
|
|
/* helper methods */
|
2021-03-17 05:30:09 +00:00
|
|
|
gboolean gst_nv_decoder_handle_set_context (GstNvDecoder * decoder,
|
|
|
|
GstElement * videodec,
|
|
|
|
GstContext * context);
|
|
|
|
|
|
|
|
gboolean gst_nv_decoder_handle_context_query (GstNvDecoder * decoder,
|
|
|
|
GstVideoDecoder * videodec,
|
|
|
|
GstQuery * query);
|
|
|
|
|
|
|
|
gboolean gst_nv_decoder_negotiate (GstNvDecoder * decoder,
|
|
|
|
GstVideoDecoder * videodec,
|
2022-11-05 12:00:43 +00:00
|
|
|
GstVideoCodecState * input_state);
|
2021-03-17 05:30:09 +00:00
|
|
|
|
|
|
|
gboolean gst_nv_decoder_decide_allocation (GstNvDecoder * decoder,
|
|
|
|
GstVideoDecoder * videodec,
|
|
|
|
GstQuery * query);
|
2020-06-18 19:50:26 +00:00
|
|
|
|
2023-02-13 12:59:05 +00:00
|
|
|
guint gst_nv_decoder_get_max_output_size (guint coded_size,
|
|
|
|
guint user_requested,
|
|
|
|
guint device_max);
|
|
|
|
|
2020-04-16 14:27:31 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
|
|
|
#endif /* __GST_NV_DECODER_H__ */
|