mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 04:00:37 +00:00
nvcodec: Add AV1 encoder
Adding CUDA mode "nvav1enc", D3D11 mode "nvd3d11av1enc" and auto GPU mode "nvautogpuav1enc" elements Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6754>
This commit is contained in:
parent
da019bf137
commit
15c24abf5d
6 changed files with 1889 additions and 3 deletions
1819
subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp
Normal file
1819
subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.cpp
Normal file
File diff suppressed because it is too large
Load diff
41
subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.h
Normal file
41
subprojects/gst-plugins-bad/sys/nvcodec/gstnvav1encoder.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2024 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gstnvencoder.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GstNvEncoderClassData * gst_nv_av1_encoder_register_cuda (GstPlugin * plugin,
|
||||
GstCudaContext * context,
|
||||
guint rank);
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
GstNvEncoderClassData * gst_nv_av1_encoder_register_d3d11 (GstPlugin * plugin,
|
||||
GstD3D11Device * device,
|
||||
guint rank);
|
||||
#endif
|
||||
|
||||
void gst_nv_av1_encoder_register_auto_select (GstPlugin * plugin,
|
||||
GList * device_caps_list,
|
||||
guint rank);
|
||||
|
||||
|
||||
G_END_DECLS
|
|
@ -145,11 +145,14 @@ GstNvEncObject::IsSuccess (NVENCSTATUS status, GstNvEncObject * self,
|
|||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
const gchar *status_str = nvenc_status_to_string (status);
|
||||
const gchar *error_detail = nullptr;
|
||||
if (self && self->session_)
|
||||
error_detail = NvEncGetLastErrorString (self->session_);
|
||||
|
||||
if (self) {
|
||||
gst_debug_log_id (GST_CAT_DEFAULT, GST_LEVEL_ERROR, file, function,
|
||||
line, self->id_.c_str (), "NvEnc API call failed: 0x%x, %s",
|
||||
(guint) status, status_str);
|
||||
line, self->id_.c_str (), "NvEnc API call failed: 0x%x, %s (%s)",
|
||||
(guint) status, status_str, GST_STR_NULL (error_detail));
|
||||
} else {
|
||||
gst_debug_log (GST_CAT_DEFAULT, GST_LEVEL_ERROR, file, function,
|
||||
line, nullptr, "NvEnc API call failed: 0x%x, %s",
|
||||
|
@ -293,8 +296,11 @@ GstNvEncObject::InitSession (NV_ENC_INITIALIZE_PARAMS * params,
|
|||
|
||||
if (memcmp (¶ms->encodeGUID, &NV_ENC_CODEC_H264_GUID, sizeof (GUID)) == 0) {
|
||||
codec_ = GST_NV_ENC_CODEC_H264;
|
||||
} else {
|
||||
} else if (memcmp (¶ms->encodeGUID,
|
||||
&NV_ENC_CODEC_HEVC_GUID, sizeof (GUID)) == 0) {
|
||||
codec_ = GST_NV_ENC_CODEC_H265;
|
||||
} else {
|
||||
codec_ = GST_NV_ENC_CODEC_AV1;
|
||||
}
|
||||
|
||||
info_ = *info;
|
||||
|
|
|
@ -138,6 +138,7 @@ enum GstNvEncCodec
|
|||
{
|
||||
GST_NV_ENC_CODEC_H264,
|
||||
GST_NV_ENC_CODEC_H265,
|
||||
GST_NV_ENC_CODEC_AV1,
|
||||
};
|
||||
|
||||
class GstNvEncObject : public std::enable_shared_from_this <GstNvEncObject>
|
||||
|
|
|
@ -10,6 +10,7 @@ nvcodec_sources = [
|
|||
'gstcudamemorycopy.c',
|
||||
'gstcuvidloader.c',
|
||||
'gstnvav1dec.cpp',
|
||||
'gstnvav1encoder.cpp',
|
||||
'gstnvdec.c',
|
||||
'gstnvdecobject.cpp',
|
||||
'gstnvdecoder.cpp',
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#endif
|
||||
#include "gstnvh264encoder.h"
|
||||
#include "gstnvh265encoder.h"
|
||||
#include "gstnvav1encoder.h"
|
||||
#include "gstcudaipcsink.h"
|
||||
#include "gstcudaipcsrc.h"
|
||||
#include "gstnvcodecutils.h"
|
||||
|
@ -126,6 +127,7 @@ plugin_init (GstPlugin * plugin)
|
|||
guint api_minor_ver = 1;
|
||||
GList *h264_enc_cdata = NULL;
|
||||
GList *h265_enc_cdata = NULL;
|
||||
GList *av1_enc_cdata = NULL;
|
||||
gboolean have_nvrtc = FALSE;
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_nvcodec_debug, "nvcodec", 0, "nvcodec");
|
||||
|
@ -291,6 +293,11 @@ plugin_init (GstPlugin * plugin)
|
|||
if (cdata)
|
||||
h265_enc_cdata = g_list_append (h265_enc_cdata, cdata);
|
||||
|
||||
cdata = gst_nv_av1_encoder_register_d3d11 (plugin,
|
||||
d3d11_device, GST_RANK_NONE);
|
||||
if (cdata)
|
||||
av1_enc_cdata = g_list_append (av1_enc_cdata, cdata);
|
||||
|
||||
gst_object_unref (d3d11_device);
|
||||
}
|
||||
}
|
||||
|
@ -304,6 +311,11 @@ plugin_init (GstPlugin * plugin)
|
|||
context, GST_RANK_PRIMARY + 1);
|
||||
if (cdata)
|
||||
h265_enc_cdata = g_list_append (h265_enc_cdata, cdata);
|
||||
|
||||
cdata = gst_nv_av1_encoder_register_cuda (plugin,
|
||||
context, GST_RANK_PRIMARY + 1);
|
||||
if (cdata)
|
||||
av1_enc_cdata = g_list_append (av1_enc_cdata, cdata);
|
||||
}
|
||||
|
||||
gst_nv_jpeg_enc_register (plugin, context, GST_RANK_NONE, have_nvrtc);
|
||||
|
@ -315,11 +327,17 @@ plugin_init (GstPlugin * plugin)
|
|||
gst_nv_h264_encoder_register_auto_select (plugin, h264_enc_cdata,
|
||||
GST_RANK_NONE);
|
||||
}
|
||||
|
||||
if (h265_enc_cdata) {
|
||||
gst_nv_h265_encoder_register_auto_select (plugin, h265_enc_cdata,
|
||||
GST_RANK_NONE);
|
||||
}
|
||||
|
||||
if (av1_enc_cdata) {
|
||||
gst_nv_av1_encoder_register_auto_select (plugin, av1_enc_cdata,
|
||||
GST_RANK_NONE);
|
||||
}
|
||||
|
||||
gst_cuda_memory_copy_register (plugin, GST_RANK_NONE);
|
||||
|
||||
if (have_nvrtc) {
|
||||
|
|
Loading…
Reference in a new issue