mirror of
git://nv-tegra.nvidia.com/tegra/gst-src/gst-nvvideo4linux2.git
synced 2025-12-25 03:35:31 +03:00
Compare commits
1 Commits
l4t/l4t-r3
...
l4t/l4t-r3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60b68e7b4f |
@@ -1,45 +1,45 @@
|
||||
Updating prebuilts and/or headers
|
||||
|
||||
44b0e909f18f7e2f457ba501fc47d80ecedd150b - nvbufsurface.h
|
||||
2c5c20979e5fca5ed70b425187c3d09b39c03171 - v4l2_nv_extensions.h
|
||||
a2b82d590a9e48bc2f838593042f9775ab723057 - nvbufsurface.h
|
||||
46c60aadf6322365d42f70b7f1e1f71219b66d5c - v4l2_nv_extensions.h
|
||||
d27a433ddeaefb9f42d0312c23472514b0cd6a45 - gst-nvcustomevent.h
|
||||
e9519308cbf7b36481da7665e3b74d36569cc3d1 - gst-v4l2/gstv4l2.c
|
||||
ba87c2bc0bea986ef461e1bc2ab3ded89700a986 - gst-v4l2/gstv4l2h264enc.c
|
||||
93eaaa0797c1f1dc21c20fbad1885dc109ccffd3 - gst-v4l2/gstv4l2bufferpool.c
|
||||
9ff38f38c224577c4aaadc4ac4d808429f37ca69 - gst-v4l2/gstv4l2allocator.c
|
||||
3d06f0b9ae8e465e8aecd7ef101e652ff62268c4 - gst-v4l2/Makefile
|
||||
02d142337f4b96fcb0c9f2405a3cbe90c5917cca - gst-v4l2/gstv4l2vp9enc.c
|
||||
34adbcb7d5cf5a360d28432429b735710bfe49c5 - gst-v4l2/wsl_utils.h
|
||||
afc982d855f80b1e21ce1831930a9f327c41832b - gst-v4l2/gstv4l2h265enc.c
|
||||
55a2c81ab3ffd72e07fc680369683d9635a3665c - gst-v4l2/gstv4l2h265enc.h
|
||||
c81eacb7d88c4fb839506dd70055e30d7a9feeec - gst-v4l2/v4l2-utils.h
|
||||
b1cd923335aa60985ff9866fba91a2068e8671c7 - gst-v4l2/LICENSE.gst-nvvideo4linux2
|
||||
aa816d369be13e7cb2f6f5283c74bb00f7f1c76e - gst-v4l2/v4l2_calls.c
|
||||
d89a680415f6ff5acec2571cde0fce9054d8e81f - gst-v4l2/gstv4l2vp9enc.h
|
||||
da6c40e84b3b99e443b76c72cbb433541bdc9bcf - gst-v4l2/gstv4l2videodec.c
|
||||
0d69b17838c57184dace9bfa1d30bbe8f2f83848 - gst-v4l2/gstv4l2object.h
|
||||
c3ac3836a2d29d813c3c274cde82d2a59dd45a5a - gst-v4l2/gstv4l2videodec.h
|
||||
4b70823ac5f9a70cce0c909e284c73aed4bccbd6 - gst-v4l2/gstv4l2h26xparser.c
|
||||
39fcb2f599e6906ab0fd7ab9a46fef3ea58a8cab - gst-v4l2/gstv4l2vp8enc.h
|
||||
08d68910b07d04e1429763ad1e6dbbeb41c5277d - gst-v4l2/gstv4l2av1enc.h
|
||||
a002edef13a3bbbdc41e42a7fca40e574ad1bb3e - gst-v4l2/v4l2-utils.c
|
||||
8ca09a3efa60c291535db5c8c2716db378fbd4e4 - gst-v4l2/gstv4l2object.h
|
||||
21adf9d6e2a3d0d42835767eebd386bb995876f3 - gst-v4l2/gstv4l2h264enc.c
|
||||
870a72e5038dba9f4df37f900d53a059beee9bbc - gst-v4l2/gstv4l2h26xparser.h
|
||||
fac36b61500cf8d1b5f2513d6d2319ef73aa870e - gst-v4l2/sei_parse.c
|
||||
b827fd6cb1e3b8ecebd6a07f8556e846e26cba17 - gst-v4l2/gstv4l2allocator.h
|
||||
e18e54d84e643676bfc88fd559d834f26f5b4d4d - gst-v4l2/wsl_utils.c
|
||||
d0af17fd51ec44b79ef54c1279b631a46cf31f49 - gst-v4l2/gstv4l2videoenc.h
|
||||
a002edef13a3bbbdc41e42a7fca40e574ad1bb3e - gst-v4l2/v4l2-utils.c
|
||||
5948d70c07e87f9b1dc403789dcbed6acfa47ad9 - gst-v4l2/gstv4l2av1enc.c
|
||||
4e79cf75c4fa29791e1f5141318dc8aec13a7835 - gst-v4l2/nalutils.h
|
||||
add535643bbb5c58b7eb98b45496204e4d63ebb1 - gst-v4l2/gstv4l2bufferpool.h
|
||||
5ecd059e5ef9be4014eface37e5e2f7598960f4e - gst-v4l2/nalutils.c
|
||||
719c8569e894b0146a6e027550187df5aaf5adc1 - gst-v4l2/gstv4l2av1enc.c
|
||||
9f726e4439379bb399f29c68736242f21dab3dd0 - gst-v4l2/gstv4l2allocator.c
|
||||
7e2df7e40f3cd0b192e8500e22648d10d15822e3 - gst-v4l2/gstv4l2bufferpool.c
|
||||
b827fd6cb1e3b8ecebd6a07f8556e846e26cba17 - gst-v4l2/gstv4l2allocator.h
|
||||
f19a146a2e3d7993d6408644ec610f209a8a4848 - gst-v4l2/gstv4l2h265enc.c
|
||||
110bd46e7f8753e4471cc9a1836c6ff7bded5ce6 - gst-v4l2/Makefile
|
||||
c81eacb7d88c4fb839506dd70055e30d7a9feeec - gst-v4l2/v4l2-utils.h
|
||||
39fcb2f599e6906ab0fd7ab9a46fef3ea58a8cab - gst-v4l2/gstv4l2vp8enc.h
|
||||
d89a680415f6ff5acec2571cde0fce9054d8e81f - gst-v4l2/gstv4l2vp9enc.h
|
||||
bb104683f5e4f7402e3f765a891e149edc794e02 - gst-v4l2/gstv4l2h264enc.h
|
||||
eb5134c907dd4b25097491e4273591db6ac386fc - gst-v4l2/gstv4l2videoenc.c
|
||||
71be284b547ee68fb0e2cd14b0aeb14734a915a1 - gst-v4l2/gstv4l2bufferpool.h
|
||||
02d142337f4b96fcb0c9f2405a3cbe90c5917cca - gst-v4l2/gstv4l2vp9enc.c
|
||||
aa816d369be13e7cb2f6f5283c74bb00f7f1c76e - gst-v4l2/v4l2_calls.c
|
||||
b1cd923335aa60985ff9866fba91a2068e8671c7 - gst-v4l2/LICENSE.gst-nvvideo4linux2
|
||||
a6bee578dc4c775ddfbd701370f9219c5fe23a39 - gst-v4l2/gstv4l2videodec.c
|
||||
cbc84dccd2506afa4c8f03849c95bb28c83ef4a3 - gst-v4l2/gstv4l2av1enc.h
|
||||
6e63f8b6431493365ed1915ca57670216589159c - gst-v4l2/gstv4l2.c
|
||||
9e9ead69fe6c2fc66eef7a5884c32af2a4a3d3de - gst-v4l2/gstv4l2videoenc.h
|
||||
55a2c81ab3ffd72e07fc680369683d9635a3665c - gst-v4l2/gstv4l2h265enc.h
|
||||
75a906105779c75c2b7a987670e15f6fea44e886 - gst-v4l2/wsl_utils.c
|
||||
5ecd059e5ef9be4014eface37e5e2f7598960f4e - gst-v4l2/nalutils.c
|
||||
807bc9859585a540b0f85e98f147756aab24e1bd - gst-v4l2/gstv4l2vp8enc.c
|
||||
9c3d135576125a6620cc8fa0b249ac73c070110b - gst-v4l2/gstv4l2object.c
|
||||
20c4f7c0cb89c83256650bc3353ed82154cf3a9d - gst-v4l2/gst/gst-i18n-plugin.h
|
||||
0bcc8f3ef6f5786e843c6b479fb7669ede42dfab - gst-v4l2/sei_parse.c
|
||||
4b70823ac5f9a70cce0c909e284c73aed4bccbd6 - gst-v4l2/gstv4l2h26xparser.c
|
||||
5ad8404e34b39627d5f474664e8c5a42e9bfc107 - gst-v4l2/gstv4l2videodec.h
|
||||
f7fa34cb6d4bf1f8fe20e5a4b7ef585ca997be6c - gst-v4l2/wsl_utils.h
|
||||
a696b6b9fcd86d7bd31c57b6f306a1801a117358 - gst-v4l2/gstv4l2videoenc.c
|
||||
39464820676a9de89d0055bf776adf2eda95897a - gst-v4l2/gstv4l2object.c
|
||||
e864ee6647f3572b144403d799f68152e9900da1 - gst-v4l2/gst/gettext.h
|
||||
20c4f7c0cb89c83256650bc3353ed82154cf3a9d - gst-v4l2/gst/gst-i18n-plugin.h
|
||||
499a9feb17ceabf1f1443923dffa1e0180bf5972 - gst-v4l2/gst/glib-compat-private.h
|
||||
72a34a694337f8f6da3bb94c9faced6730cbd2fc - gst-v4l2/ext/types-compat.h
|
||||
583075e89482f1faa08be7f7b278336bf7756def - gst-v4l2/ext/v4l2-controls.h
|
||||
fe847595bb202501a56702a7c602f0514d23c328 - gst-v4l2/ext/v4l2-common.h
|
||||
583075e89482f1faa08be7f7b278336bf7756def - gst-v4l2/ext/v4l2-controls.h
|
||||
72a34a694337f8f6da3bb94c9faced6730cbd2fc - gst-v4l2/ext/types-compat.h
|
||||
2253e5f55e37aace35af706d5662ef017f17e877 - gst-v4l2/ext/videodev2.h
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
#
|
||||
# NVIDIA Corporation and its licensors retain all intellectual property
|
||||
# and proprietary rights in and to this software, related documentation
|
||||
@@ -14,7 +14,7 @@ SO_NAME := libgstnvvideo4linux2.so
|
||||
|
||||
TARGET_DEVICE = $(shell gcc -dumpmachine | cut -f1 -d -)
|
||||
|
||||
NVDS_VERSION:=8.0
|
||||
NVDS_VERSION:=6.0
|
||||
|
||||
ifeq ($(TARGET_DEVICE),aarch64)
|
||||
GST_INSTALL_DIR?=/usr/lib/aarch64-linux-gnu/gstreamer-1.0/
|
||||
@@ -30,7 +30,7 @@ endif
|
||||
LIBS:= -lnvbufsurface -lnvbufsurftransform -lgstnvdsseimeta -lgstnvcustomhelper
|
||||
SRCS := $(wildcard *.c)
|
||||
|
||||
INCLUDES += -I./ -I../ -I/opt/nvidia/deepstream/deepstream-$(NVDS_VERSION)/sources/includes/
|
||||
INCLUDES += -I./ -I../
|
||||
|
||||
PKGS := gstreamer-1.0 \
|
||||
gstreamer-base-1.0 \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
|
||||
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
#
|
||||
# NVIDIA Corporation and its licensors retain all intellectual property
|
||||
# and proprietary rights in and to this software, related documentation
|
||||
@@ -34,4 +34,4 @@ Steps to compile the "gst-nvvideo4linux2" sources natively:
|
||||
Note: For Jetson, "make install" will copy library "libgstnvvideo4linux2.so"
|
||||
into "/usr/lib/aarch64-linux-gnu/gstreamer-1.0" directory. For x86 platforms,
|
||||
make install will copy the library "libgstnvvideo4linux2.so" into
|
||||
/opt/nvidia/deepstream/deepstream/lib/gst-plugins
|
||||
/opt/nvidia/deepstream/deepstream-4.0/lib/gst-plugins
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
*
|
||||
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* gstv4l2.c: plugin for v4l2 elements
|
||||
*
|
||||
@@ -340,32 +339,31 @@ gst_v4l2_is_v4l2_nvenc_present(void)
|
||||
{
|
||||
gboolean ret = TRUE;
|
||||
int fd = -1;
|
||||
long len = -1;
|
||||
struct stat statbuf;
|
||||
char info[128];
|
||||
|
||||
if (access(V4L2_DEVICE_INFO_SOM_EEPROM, F_OK) == 0)
|
||||
{
|
||||
stat(V4L2_DEVICE_INFO_SOM_EEPROM, &statbuf);
|
||||
if (access (V4L2_DEVICE_PATH_TEGRA_INFO, F_OK) == 0) {
|
||||
stat(V4L2_DEVICE_PATH_TEGRA_INFO, &statbuf);
|
||||
if (statbuf.st_size > 0 && statbuf.st_size < 128)
|
||||
{
|
||||
fd = open(V4L2_DEVICE_INFO_SOM_EEPROM, O_RDONLY);
|
||||
fd = open(V4L2_DEVICE_PATH_TEGRA_INFO, O_RDONLY);
|
||||
read(fd, info, statbuf.st_size);
|
||||
for (int i = 0; i <= (statbuf.st_size - 9); i++)
|
||||
len = statbuf.st_size - 10;
|
||||
for (int i = 0; i < len; i ++)
|
||||
{
|
||||
if (strncmp(&info[i], "3767", 4) == 0)
|
||||
if (strncmp(&info[i], "p3767", 5) == 0)
|
||||
{
|
||||
/*
|
||||
* Jetson Orin Nano 8GB (P3767-0003) Commercial module
|
||||
* Jetson Orin Nano 4GB (P3767-0004) Commercial module
|
||||
* Jetson Orin Nano 8GB with SD card slot (P3767-0005) For the Developer Kit only
|
||||
Jetson Orin Nano 8GB (P3767-0003) Commercial module
|
||||
Jetson Orin Nano 4GB (P3767-0004) Commercial module
|
||||
Jetson Orin Nano 8GB with SD card slot (P3767-0005) For the Developer Kit only
|
||||
*/
|
||||
if (strncmp(&info[i + 5], "0003", 4) == 0 ||
|
||||
strncmp(&info[i + 5], "0004", 4) == 0 ||
|
||||
strncmp(&info[i + 5], "0005", 4) == 0)
|
||||
{
|
||||
if (strncmp(&info[i + 6], "0003", 4) == 0 ||
|
||||
strncmp(&info[i + 6], "0004", 4) == 0 ||
|
||||
strncmp(&info[i + 6], "0005", 4) == 0)
|
||||
ret = FALSE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
@@ -384,13 +382,15 @@ plugin_init (GstPlugin * plugin)
|
||||
GST_DEBUG_CATEGORY_INIT (v4l2_debug, "v4l2", 0, "V4L2 API calls");
|
||||
|
||||
#ifndef USE_V4L2_TARGET_NV_X86
|
||||
int result = -1;
|
||||
result = (gboolean)system("lsmod | grep 'nvgpu' > /dev/null");
|
||||
|
||||
if (result == 0)
|
||||
is_cuvid = FALSE;
|
||||
else
|
||||
int igpu = -1, dgpu = -1;
|
||||
igpu = system("lsmod | grep 'nvgpu' > /dev/null");
|
||||
dgpu = system("modprobe -D -q nvidia | grep 'dkms' > /dev/null");
|
||||
if (igpu == -1 || dgpu == -1)
|
||||
return FALSE;
|
||||
else if (dgpu == 0)
|
||||
is_cuvid = TRUE;
|
||||
else
|
||||
is_cuvid = FALSE;
|
||||
|
||||
if (getenv("AARCH64_DGPU"))
|
||||
is_cuvid = TRUE;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Collabora Ltd.
|
||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -1188,7 +1186,7 @@ gst_v4l2_allocator_import_dmabuf (GstV4l2Allocator * allocator,
|
||||
|
||||
for (i = 0; i < group->n_mem; i++) {
|
||||
gint dmafd;
|
||||
gsize size, offset = 0, maxsize = 0;
|
||||
gsize size, offset, maxsize;
|
||||
|
||||
if (!gst_is_dmabuf_memory (dma_mem[i]))
|
||||
goto not_dmabuf;
|
||||
@@ -1369,19 +1367,13 @@ gst_v4l2_allocator_qbuf (GstV4l2Allocator * allocator,
|
||||
if (obj->is_encode) {
|
||||
if ((is_cuvid == true) && (obj->sei_payload != NULL)) {
|
||||
gint ret;
|
||||
struct v4l2_ext_control ctls[2];
|
||||
struct v4l2_ext_control ctl;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
|
||||
ctls[0].id = V4L2_CID_MPEG_VIDEOENC_DS_SEI_DATA;
|
||||
ctls[0].ptr = obj->sei_payload;
|
||||
ctls[0].size = obj->sei_payload_size;
|
||||
|
||||
ctls[1].id = V4L2_CID_MPEG_VIDEOENC_DS_SEI_UUID;
|
||||
ctls[1].string = obj->sei_uuid;
|
||||
ctls[1].size = 16;
|
||||
|
||||
ctrls.count = 2;
|
||||
ctrls.controls = ctls;
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_DS_SEI_DATA;
|
||||
ctl.ptr = obj->sei_payload;
|
||||
ctl.size = obj->sei_payload_size;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = obj->ioctl (obj->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
{
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2021-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -57,7 +56,6 @@ enum
|
||||
PROP_ENABLE_TILE_CONFIG,
|
||||
PROP_DISABLE_CDF,
|
||||
PROP_ENABLE_SSIMRDO,
|
||||
PROP_INSERT_SEQ_HDR,
|
||||
PROP_NUM_REFERENCE_FRAMES,
|
||||
};
|
||||
|
||||
@@ -90,9 +88,6 @@ gst_v4l2_av1_enc_set_property (GObject * object,
|
||||
case PROP_ENABLE_SSIMRDO:
|
||||
self->EnableSsimRdo = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_INSERT_SEQ_HDR:
|
||||
self->insert_sps_pps = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_NUM_REFERENCE_FRAMES:
|
||||
self->nRefFrames = g_value_get_uint (value);
|
||||
break;
|
||||
@@ -120,9 +115,6 @@ gst_v4l2_av1_enc_get_property (GObject * object,
|
||||
case PROP_ENABLE_SSIMRDO:
|
||||
g_value_set_boolean (value, self->EnableSsimRdo);
|
||||
break;
|
||||
case PROP_INSERT_SEQ_HDR:
|
||||
g_value_set_boolean (value, self->insert_sps_pps);
|
||||
break;
|
||||
case PROP_NUM_REFERENCE_FRAMES:
|
||||
g_value_set_uint (value, self->nRefFrames);
|
||||
break;
|
||||
@@ -223,34 +215,23 @@ set_v4l2_av1_encoder_properties (GstVideoEncoder * encoder)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (is_cuvid == FALSE) {
|
||||
|
||||
if (self->EnableTileConfig) {
|
||||
if (!gst_v4l2_av1_enc_tile_configuration (video_enc->v4l2output,
|
||||
self->EnableTileConfig, self->Log2TileRows, self->Log2TileCols)) {
|
||||
g_print ("S_EXT_CTRLS for Tile Configuration failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_AV1_DISABLE_CDF_UPDATE, self->DisableCDFUpdate)) {
|
||||
g_print ("S_EXT_CTRLS for DisableCDF Update failed\n");
|
||||
if (self->EnableTileConfig) {
|
||||
if (!gst_v4l2_av1_enc_tile_configuration (video_enc->v4l2output,
|
||||
self->EnableTileConfig, self->Log2TileRows, self->Log2TileCols)) {
|
||||
g_print ("S_EXT_CTRLS for Tile Configuration failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->EnableSsimRdo) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_AV1_ENABLE_SSIMRDO, self->EnableSsimRdo)) {
|
||||
g_print ("S_EXT_CTRLS for SSIM RDO failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (self->insert_sps_pps) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_AV1_DISABLE_CDF_UPDATE, self->DisableCDFUpdate)) {
|
||||
g_print ("S_EXT_CTRLS for DisableCDF Update failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->EnableSsimRdo) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_INSERT_SPS_PPS_AT_IDR, self->insert_sps_pps)) {
|
||||
V4L2_CID_MPEG_VIDEOENC_AV1_ENABLE_SSIMRDO, self->EnableSsimRdo)) {
|
||||
g_print ("S_EXT_CTRLS for SSIM RDO failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -274,7 +255,6 @@ gst_v4l2_av1_enc_init (GstV4l2Av1Enc * self)
|
||||
self->EnableTileConfig = FALSE;
|
||||
self->DisableCDFUpdate = TRUE;
|
||||
self->EnableSsimRdo = FALSE;
|
||||
self->insert_sps_pps = FALSE;
|
||||
self->Log2TileRows= 0;
|
||||
self->Log2TileCols= 0;
|
||||
}
|
||||
@@ -311,8 +291,6 @@ gst_v4l2_av1_enc_class_init (GstV4l2Av1EncClass * klass)
|
||||
"Enable AV1 file and frame headers, if enabled, dump elementary stream",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_TILE_CONFIG,
|
||||
g_param_spec_string ("tiles", "AV1 Log2 Tile Configuration",
|
||||
"Use string with values of Tile Configuration"
|
||||
@@ -329,12 +307,6 @@ gst_v4l2_av1_enc_class_init (GstV4l2Av1EncClass * klass)
|
||||
"Enable SSIM RDO",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
#endif
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_SEQ_HDR,
|
||||
g_param_spec_boolean ("insert-seq-hdr", "Insert sequence header",
|
||||
"Insert sequence header at every IDR frame",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
g_object_class_install_property (gobject_class, PROP_NUM_REFERENCE_FRAMES,
|
||||
g_param_spec_uint ("num-Ref-Frames",
|
||||
"Sets the number of reference frames for encoder",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -46,7 +45,6 @@ struct _GstV4l2Av1Enc
|
||||
gboolean EnableTileConfig;
|
||||
gboolean DisableCDFUpdate;
|
||||
gboolean EnableSsimRdo;
|
||||
gboolean insert_sps_pps;
|
||||
guint32 Log2TileRows;
|
||||
guint32 Log2TileCols;
|
||||
guint32 nRefFrames;
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
||||
* 2009 Texas Instruments, Inc - http://www.ti.com/
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* gstv4l2bufferpool.c V4L2 buffer pool class
|
||||
*
|
||||
@@ -82,8 +80,6 @@ report_metadata (GstV4l2Object * obj, guint32 buffer_index,
|
||||
static void
|
||||
v4l2_video_dec_get_enable_frame_type_reporting (GstV4l2Object * obj,
|
||||
guint32 buffer_index, v4l2_ctrl_videodec_outputbuf_metadata * dec_metadata);
|
||||
static void
|
||||
v4l2_video_dec_clear_poll_interrupt (GstV4l2Object * obj);
|
||||
#endif
|
||||
|
||||
static gboolean
|
||||
@@ -144,7 +140,11 @@ static NvBufSurfTransform_Error CopySurfTransform(NvBufSurface* src, NvBufSurfac
|
||||
NvBufSurfTransformParams transformParams;
|
||||
NvBufSurfTransformRect srcRect;
|
||||
NvBufSurfTransformRect destRect;
|
||||
|
||||
status = NvBufSurfTransformSetDefaultSession();
|
||||
if (status != NvBufSurfTransformError_Success)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
srcRect.top = srcRect.left = 0;
|
||||
destRect.top = destRect.left = 0;
|
||||
srcRect.width = src->surfaceList[0].width;
|
||||
@@ -415,10 +415,16 @@ gst_v4l2_buffer_pool_import_userptr (GstV4l2BufferPool * pool,
|
||||
for (i = 0; i < GST_VIDEO_FORMAT_INFO_N_PLANES (finfo); i++) {
|
||||
if (GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) {
|
||||
gint tinfo = GST_VIDEO_FRAME_PLANE_STRIDE (&data->frame, i);
|
||||
size[i] = GST_VIDEO_TILE_X_TILES (tinfo) *
|
||||
GST_VIDEO_TILE_Y_TILES (tinfo) *
|
||||
GST_VIDEO_FORMAT_INFO_TILE_SIZE (finfo, i);
|
||||
gint pstride;
|
||||
guint pheight;
|
||||
|
||||
pstride = GST_VIDEO_TILE_X_TILES (tinfo) <<
|
||||
GST_VIDEO_FORMAT_INFO_TILE_WS (finfo);
|
||||
|
||||
pheight = GST_VIDEO_TILE_Y_TILES (tinfo) <<
|
||||
GST_VIDEO_FORMAT_INFO_TILE_HS (finfo);
|
||||
|
||||
size[i] = pstride * pheight;
|
||||
} else {
|
||||
size[i] = GST_VIDEO_FRAME_PLANE_STRIDE (&data->frame, i) *
|
||||
GST_VIDEO_FRAME_COMP_HEIGHT (&data->frame, i);
|
||||
@@ -722,20 +728,6 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
|
||||
|
||||
for (i = 0; i < group->n_mem; i++)
|
||||
gst_buffer_append_memory (newbuf, group->mem[i]);
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
if (!V4L2_TYPE_IS_OUTPUT(obj->type) && is_cuvid == FALSE) {
|
||||
GstMapInfo map = GST_MAP_INFO_INIT;
|
||||
NvBufSurface *nvbuf_surf = NULL;
|
||||
gst_buffer_map (newbuf, &map, GST_MAP_READ);
|
||||
nvbuf_surf = (NvBufSurface *) map.data;
|
||||
if (g_queue_find(pool->allocated_surfaces_queue, nvbuf_surf) == NULL)
|
||||
{
|
||||
g_queue_push_tail (pool->allocated_surfaces_queue, nvbuf_surf);
|
||||
}
|
||||
gst_buffer_unmap (newbuf, &map);
|
||||
}
|
||||
#endif
|
||||
} else if (newbuf == NULL) {
|
||||
goto allocation_failed;
|
||||
}
|
||||
@@ -765,14 +757,13 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
|
||||
GstV4l2BufferPool *pool = GST_V4L2_BUFFER_POOL (bpool);
|
||||
GstV4l2Object *obj = pool->obj;
|
||||
GstCaps *caps;
|
||||
guint size, min_buffers = 0, max_buffers = 0;
|
||||
GstAllocator *allocator = NULL;
|
||||
GstAllocationParams params = { 0, };
|
||||
guint size, min_buffers, max_buffers;
|
||||
GstAllocator *allocator;
|
||||
GstAllocationParams params;
|
||||
gboolean can_allocate = FALSE;
|
||||
gboolean updated = FALSE;
|
||||
gboolean ret;
|
||||
|
||||
gst_allocation_params_init (¶ms);
|
||||
pool->add_videometa =
|
||||
gst_buffer_pool_config_has_option (config,
|
||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||
@@ -879,9 +870,7 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
|
||||
/* Always update the config to ensure the configured size matches */
|
||||
if ((!strcmp (obj->videodev, V4L2_DEVICE_PATH_NVENC) || !strcmp (obj->videodev, V4L2_DEVICE_PATH_NVENC_ALT)) &&
|
||||
(obj->mode == GST_V4L2_IO_DMABUF_IMPORT)) {
|
||||
/*For DMABUF Import, queue size should be kept to max to avoid frame drops coming from decoder*/
|
||||
min_buffers = max_buffers = 24; /* NvMM Encoder has MAX Q size as 24*/
|
||||
gst_buffer_pool_config_set_params(config, caps, sizeof(NvBufSurface), min_buffers,
|
||||
gst_buffer_pool_config_set_params (config, caps, sizeof (NvBufSurface), min_buffers,
|
||||
max_buffers);
|
||||
}
|
||||
else
|
||||
@@ -1073,7 +1062,7 @@ gst_v4l2_buffer_pool_start (GstBufferPool * bpool)
|
||||
GstV4l2Object *obj = pool->obj;
|
||||
GstStructure *config;
|
||||
GstCaps *caps;
|
||||
guint size = 0, min_buffers = 0, max_buffers = 0;
|
||||
guint size, min_buffers, max_buffers;
|
||||
guint max_latency, min_latency, copy_threshold = 0;
|
||||
gboolean can_allocate = FALSE, ret = TRUE;
|
||||
|
||||
@@ -1254,32 +1243,6 @@ gst_v4l2_buffer_pool_stop (GstBufferPool * bpool)
|
||||
|
||||
GST_DEBUG_OBJECT (pool, "stopping pool");
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
/*
|
||||
* On EOS, video_fd becomes -1, this makes VIDIOC_REQBUFS API fail which
|
||||
* internally releases hardware buffers causing memory leak.
|
||||
* In below code NvBufSurfaces are destroyed explicitly.
|
||||
*/
|
||||
if (pool->vallocator) {
|
||||
if (pool->vallocator->obj->video_fd == -1 &&
|
||||
!V4L2_TYPE_IS_OUTPUT (pool->vallocator->obj->type) &&
|
||||
is_cuvid == FALSE) {
|
||||
while(g_queue_get_length(pool->allocated_surfaces_queue) > 0) {
|
||||
int retval = 0;
|
||||
NvBufSurface* allocated_surface = NULL;
|
||||
allocated_surface = g_queue_pop_head (pool->allocated_surfaces_queue);
|
||||
if (allocated_surface) {
|
||||
retval = NvBufSurfaceDestroy(allocated_surface);
|
||||
if(retval < 0) {
|
||||
GST_ERROR_OBJECT (pool, "failed to destroy nvbufsurface");
|
||||
return GST_V4L2_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pool->group_released_handler > 0) {
|
||||
g_signal_handler_disconnect (pool->vallocator,
|
||||
pool->group_released_handler);
|
||||
@@ -1333,11 +1296,6 @@ gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
|
||||
|
||||
#ifndef USE_V4L2_TARGET_NV
|
||||
gst_poll_set_flushing (pool->poll, TRUE);
|
||||
#else
|
||||
if (is_cuvid == TRUE)
|
||||
{
|
||||
v4l2_video_dec_clear_poll_interrupt (pool->obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
GST_OBJECT_LOCK (pool);
|
||||
@@ -1347,8 +1305,6 @@ gst_v4l2_buffer_pool_flush_start (GstBufferPool * bpool)
|
||||
|
||||
if (pool->other_pool)
|
||||
gst_buffer_pool_set_flushing (pool->other_pool, TRUE);
|
||||
|
||||
GST_DEBUG_OBJECT (pool, "End flushing");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1930,9 +1886,7 @@ gst_v4l2_buffer_pool_finalize (GObject * object)
|
||||
if (pool->video_fd >= 0)
|
||||
pool->obj->close (pool->video_fd);
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
g_queue_free(pool->allocated_surfaces_queue);
|
||||
#else
|
||||
#ifndef USE_V4L2_TARGET_NV
|
||||
gst_poll_free (pool->poll);
|
||||
#endif
|
||||
|
||||
@@ -1956,10 +1910,6 @@ gst_v4l2_buffer_pool_init (GstV4l2BufferPool * pool)
|
||||
#endif
|
||||
g_cond_init (&pool->empty_cond);
|
||||
pool->empty = TRUE;
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
pool->allocated_surfaces_queue = g_queue_new();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2084,7 +2034,7 @@ gst_v4l2_do_read (GstV4l2BufferPool * pool, GstBuffer * buf)
|
||||
GstFlowReturn res;
|
||||
GstV4l2Object *obj = pool->obj;
|
||||
gint amount;
|
||||
GstMapInfo map = GST_MAP_INFO_INIT;
|
||||
GstMapInfo map;
|
||||
gint toread;
|
||||
|
||||
toread = obj->info.size;
|
||||
@@ -2613,25 +2563,5 @@ v4l2_video_dec_get_enable_frame_type_reporting (GstV4l2Object * obj,
|
||||
if (ret < 0)
|
||||
g_print ("Error while getting report metadata\n");
|
||||
}
|
||||
|
||||
static void
|
||||
v4l2_video_dec_clear_poll_interrupt (GstV4l2Object * obj)
|
||||
{
|
||||
struct v4l2_ext_control control;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
gint ret = -1;
|
||||
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &control;
|
||||
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
|
||||
|
||||
control.id = V4L2_CID_MPEG_SET_POLL_INTERRUPT;
|
||||
control.value = 0;
|
||||
|
||||
ret = obj->ioctl (obj->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret < 0)
|
||||
g_print ("Error while clearing poll interrupt\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
||||
* 2009 Texas Instruments, Inc - http://www.ti.com/
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* gstv4l2bufferpool.h V4L2 buffer pool class
|
||||
*
|
||||
@@ -95,7 +93,6 @@ struct _GstV4l2BufferPool
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
GstBuffer *buffers[NV_VIDEO_MAX_FRAME];
|
||||
GQueue *allocated_surfaces_queue;
|
||||
#else
|
||||
GstBuffer *buffers[VIDEO_MAX_FRAME];
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 SUMOMO Computer Association
|
||||
* Author: ayaka <ayaka@soulik.info>
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -50,8 +49,6 @@ gst_v4l2_videnc_profile_get_type (void);
|
||||
gboolean gst_v4l2_h264_enc_slice_header_spacing (GstV4l2Object * v4l2object,
|
||||
guint32 slice_header_spacing, enum v4l2_enc_slice_length_type slice_length_type);
|
||||
gboolean set_v4l2_h264_encoder_properties (GstVideoEncoder * encoder);
|
||||
gboolean gst_v4l2_h264_enc_slice_intrarefresh (GstV4l2Object * v4l2object,
|
||||
guint32 slice_count, guint32 slice_interval);
|
||||
#endif
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
@@ -118,7 +115,7 @@ enum
|
||||
#define MAX_NUM_REFERENCE_FRAMES 8
|
||||
#define DEFAULT_BIT_PACKETIZATION FALSE
|
||||
#define DEFAULT_SLICE_HEADER_SPACING 0
|
||||
#define DEFAULT_INTRA_REFRESH_FRAME_INTERVAL 0
|
||||
#define DEFAULT_INTRA_REFRESH_FRAME_INTERVAL 60
|
||||
#define DEFAULT_PIC_ORDER_CNT_TYPE 0
|
||||
#endif
|
||||
|
||||
@@ -456,20 +453,14 @@ gst_v4l2_h264_enc_init (GstV4l2H264Enc * self)
|
||||
self->profile = DEFAULT_PROFILE;
|
||||
self->insert_sps_pps = FALSE;
|
||||
self->insert_aud = FALSE;
|
||||
self->enableLossless = FALSE;
|
||||
self->nRefFrames = 1;
|
||||
if (is_cuvid == TRUE)
|
||||
{
|
||||
self->extended_colorformat = FALSE;
|
||||
self->nRefFrames = 0;
|
||||
self->insert_vui = TRUE;
|
||||
}
|
||||
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
self->insert_vui = FALSE;
|
||||
#endif
|
||||
self->enableLossless = FALSE;
|
||||
|
||||
if (is_cuvid == TRUE)
|
||||
self->extended_colorformat = FALSE;
|
||||
|
||||
self->nBFrames = 0;
|
||||
self->nRefFrames = 1;
|
||||
self->bit_packetization = DEFAULT_BIT_PACKETIZATION;
|
||||
self->slice_header_spacing = DEFAULT_SLICE_HEADER_SPACING;
|
||||
self->poc_type = DEFAULT_PIC_ORDER_CNT_TYPE;
|
||||
@@ -510,16 +501,26 @@ gst_v4l2_h264_enc_class_init (GstV4l2H264EncClass * klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_VUI,
|
||||
if (is_cuvid == TRUE) {
|
||||
g_object_class_install_property (gobject_class, PROP_EXTENDED_COLORFORMAT,
|
||||
g_param_spec_boolean ("extended-colorformat",
|
||||
"Set Extended ColorFormat",
|
||||
"Set Extended ColorFormat pixel values 0 to 255 in VUI Info",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
} else if (is_cuvid == FALSE) {
|
||||
g_object_class_install_property (gobject_class, PROP_PIC_ORDER_CNT_TYPE,
|
||||
g_param_spec_uint ("poc-type",
|
||||
"Picture Order Count type",
|
||||
"Set Picture Order Count type value",
|
||||
0, 2, DEFAULT_PIC_ORDER_CNT_TYPE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_VUI,
|
||||
g_param_spec_boolean ("insert-vui",
|
||||
"Insert H.264 VUI",
|
||||
"Insert H.264 VUI(Video Usability Information) in SPS",
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
FALSE,
|
||||
#else
|
||||
TRUE,
|
||||
#endif
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_SPS_PPS,
|
||||
g_param_spec_boolean ("insert-sps-pps",
|
||||
@@ -561,43 +562,6 @@ gst_v4l2_h264_enc_class_init (GstV4l2H264EncClass * klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_NUM_REFERENCE_FRAMES,
|
||||
g_param_spec_uint ("num-Ref-Frames",
|
||||
"Sets the number of reference frames for encoder",
|
||||
"Number of Reference Frames for encoder",
|
||||
0, MAX_NUM_REFERENCE_FRAMES, (is_cuvid == TRUE) ? 0 : DEFAULT_NUM_REFERENCE_FRAMES,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_LOSSLESS_ENC,
|
||||
g_param_spec_boolean ("enable-lossless",
|
||||
"Enable Lossless encoding",
|
||||
"Enable lossless encoding for YUV444",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_SLICE_INTRA_REFRESH_INTERVAL,
|
||||
g_param_spec_uint ("SliceIntraRefreshInterval",
|
||||
"SliceIntraRefreshInterval", "Set SliceIntraRefreshInterval", 0,
|
||||
G_MAXUINT, DEFAULT_INTRA_REFRESH_FRAME_INTERVAL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
g_object_class_install_property (gobject_class, PROP_EXTENDED_COLORFORMAT,
|
||||
g_param_spec_boolean ("extended-colorformat",
|
||||
"Set Extended ColorFormat",
|
||||
"Set Extended ColorFormat pixel values 0 to 255 in VUI Info",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
} else if (is_cuvid == FALSE) {
|
||||
g_object_class_install_property (gobject_class, PROP_PIC_ORDER_CNT_TYPE,
|
||||
g_param_spec_uint ("poc-type",
|
||||
"Picture Order Count type",
|
||||
"Set Picture Order Count type value",
|
||||
0, 2, DEFAULT_PIC_ORDER_CNT_TYPE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_MV_META,
|
||||
g_param_spec_boolean ("EnableMVBufferMeta",
|
||||
"Enable Motion Vector Meta data",
|
||||
@@ -605,12 +569,35 @@ gst_v4l2_h264_enc_class_init (GstV4l2H264EncClass * klass)
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SLICE_INTRA_REFRESH_INTERVAL,
|
||||
g_param_spec_uint ("SliceIntraRefreshInterval",
|
||||
"SliceIntraRefreshInterval", "Set SliceIntraRefreshInterval", 0,
|
||||
G_MAXUINT, DEFAULT_INTRA_REFRESH_FRAME_INTERVAL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_TWO_PASS_CBR,
|
||||
g_param_spec_boolean ("EnableTwopassCBR",
|
||||
"Enable Two pass CBR",
|
||||
"Enable two pass CBR while encoding",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_NUM_REFERENCE_FRAMES,
|
||||
g_param_spec_uint ("num-Ref-Frames",
|
||||
"Sets the number of reference frames for encoder",
|
||||
"Number of Reference Frames for encoder",
|
||||
0, MAX_NUM_REFERENCE_FRAMES, DEFAULT_NUM_REFERENCE_FRAMES,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_LOSSLESS_ENC,
|
||||
g_param_spec_boolean ("enable-lossless",
|
||||
"Enable Lossless encoding",
|
||||
"Enable lossless encoding for YUV444",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
}
|
||||
#endif
|
||||
baseclass->codec_name = "H264";
|
||||
@@ -724,41 +711,6 @@ gst_v4l2_h264_enc_slice_header_spacing (GstV4l2Object * v4l2object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_v4l2_h264_enc_slice_intrarefresh (GstV4l2Object * v4l2object,
|
||||
guint32 slice_count, guint32 slice_interval)
|
||||
{
|
||||
struct v4l2_ext_control control;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
gint ret;
|
||||
|
||||
v4l2_ctrl_intra_refresh cuvid_param = {1, slice_interval, slice_count};
|
||||
v4l2_enc_slice_intrarefresh_param param = {slice_count};
|
||||
|
||||
memset (&control, 0, sizeof (control));
|
||||
memset (&ctrls, 0, sizeof (ctrls));
|
||||
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &control;
|
||||
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
|
||||
|
||||
control.id = V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM;
|
||||
|
||||
if (is_cuvid)
|
||||
control.string = (gchar *)&cuvid_param;
|
||||
else
|
||||
control.string = (gchar *)¶m;
|
||||
|
||||
ret = v4l2object->ioctl(v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret < 0)
|
||||
{
|
||||
g_print("Error while setting slice intrarefresh params\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
set_v4l2_h264_encoder_properties (GstVideoEncoder * encoder)
|
||||
{
|
||||
@@ -788,10 +740,12 @@ set_v4l2_h264_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
}
|
||||
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_INSERT_VUI, self->insert_vui)) {
|
||||
g_print ("S_EXT_CTRLS for INSERT_VUI failed\n");
|
||||
return FALSE;
|
||||
if (self->insert_vui) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_INSERT_VUI, 1)) {
|
||||
g_print ("S_EXT_CTRLS for INSERT_VUI failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
@@ -851,9 +805,9 @@ set_v4l2_h264_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
|
||||
if (self->SliceIntraRefreshInterval) {
|
||||
if (!gst_v4l2_h264_enc_slice_intrarefresh (video_enc->v4l2output,
|
||||
self->SliceIntraRefreshInterval,
|
||||
video_enc->idrinterval)) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM,
|
||||
self->SliceIntraRefreshInterval)) {
|
||||
g_print ("S_EXT_CTRLS for SLICE_INTRAREFRESH_PARAM failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -54,8 +53,7 @@ gboolean gst_v4l2_h265_enc_slice_header_spacing (GstV4l2Object * v4l2object,
|
||||
guint32 slice_header_spacing, enum v4l2_enc_slice_length_type slice_length_type);
|
||||
void set_h265_video_enc_property (GstV4l2Object * v4l2object, guint label,
|
||||
gint param);
|
||||
gboolean gst_v4l2_h265_enc_slice_intrarefresh (GstV4l2Object * v4l2object,
|
||||
guint32 slice_count, guint32 slice_interval);
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@@ -78,7 +76,7 @@ enum
|
||||
#define DEFAULT_PROFILE V4L2_MPEG_VIDEO_H265_PROFILE_MAIN
|
||||
#define DEFAULT_BIT_PACKETIZATION FALSE
|
||||
#define DEFAULT_SLICE_HEADER_SPACING 0
|
||||
#define DEFAULT_INTRA_REFRESH_FRAME_INTERVAL 0
|
||||
#define DEFAULT_INTRA_REFRESH_FRAME_INTERVAL 60
|
||||
#define DEFAULT_NUM_B_FRAMES 0
|
||||
#define MAX_NUM_B_FRAMES 2
|
||||
#define DEFAULT_NUM_REFERENCE_FRAMES 1
|
||||
@@ -248,6 +246,7 @@ v4l2_level_from_string (const gchar * level)
|
||||
{
|
||||
gint v4l2_level = -1;
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
if (is_cuvid == FALSE) {
|
||||
if (g_str_equal(level, "main_1.0")) {
|
||||
v4l2_level = V4L2_MPEG_VIDEO_H265_LEVEL_1_0_MAIN_TIER;
|
||||
} else if (g_str_equal(level, "high_1.0")) {
|
||||
@@ -304,6 +303,8 @@ v4l2_level_from_string (const gchar * level)
|
||||
{
|
||||
GST_WARNING("Unsupported level string '%s'", level);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return v4l2_level;
|
||||
@@ -314,6 +315,8 @@ v4l2_level_to_string (gint v4l2_level)
|
||||
{
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
|
||||
if (is_cuvid == FALSE)
|
||||
{
|
||||
switch (v4l2_level)
|
||||
{
|
||||
case V4L2_MPEG_VIDEO_H265_LEVEL_1_0_MAIN_TIER:
|
||||
@@ -372,6 +375,7 @@ v4l2_level_to_string (gint v4l2_level)
|
||||
GST_WARNING("Unsupported V4L2 level %i", v4l2_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
@@ -383,22 +387,13 @@ gst_v4l2_h265_enc_init (GstV4l2H265Enc * self)
|
||||
self->insert_sps_pps = FALSE;
|
||||
self->profile = DEFAULT_PROFILE;
|
||||
self->insert_aud = FALSE;
|
||||
self->insert_vui = FALSE;
|
||||
self->extended_colorformat = FALSE;
|
||||
self->bit_packetization = DEFAULT_BIT_PACKETIZATION;
|
||||
self->slice_header_spacing = DEFAULT_SLICE_HEADER_SPACING;
|
||||
self->nRefFrames = 1;
|
||||
self->nBFrames = 0;
|
||||
self->enableLossless = FALSE;
|
||||
if (is_cuvid == TRUE)
|
||||
{
|
||||
self->extended_colorformat = FALSE;
|
||||
self->nRefFrames = 0;
|
||||
self->insert_vui = TRUE;
|
||||
}
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
self->insert_vui = FALSE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -436,17 +431,24 @@ gst_v4l2_h265_enc_class_init (GstV4l2H265EncClass * klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_SPS_PPS,
|
||||
g_param_spec_boolean ("insert-sps-pps",
|
||||
"Insert H.265 SPS, PPS",
|
||||
"Insert H.265 SPS, PPS at every IDR frame",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
if (is_cuvid == TRUE) {
|
||||
g_object_class_install_property (gobject_class, PROP_EXTENDED_COLORFORMAT,
|
||||
g_param_spec_boolean ("extended-colorformat",
|
||||
"Set Extended ColorFormat",
|
||||
"Set Extended ColorFormat pixel values 0 to 255 in VUI info",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
} else if (is_cuvid == FALSE) {
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_SPS_PPS,
|
||||
g_param_spec_boolean ("insert-sps-pps",
|
||||
"Insert H.265 SPS, PPS",
|
||||
"Insert H.265 SPS, PPS at every IDR frame",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_VUI,
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_VUI,
|
||||
g_param_spec_boolean ("insert-vui",
|
||||
"Insert H.265 VUI",
|
||||
"Insert H.265 VUI(Video Usability Information) in SPS",
|
||||
(is_cuvid == TRUE) ? TRUE : FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INSERT_AUD,
|
||||
g_param_spec_boolean ("insert-aud",
|
||||
@@ -468,6 +470,28 @@ gst_v4l2_h265_enc_class_init (GstV4l2H265EncClass * klass)
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_MV_META,
|
||||
g_param_spec_boolean ("EnableMVBufferMeta",
|
||||
"Enable Motion Vector Meta data",
|
||||
"Enable Motion Vector Meta data for encoding",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SLICE_INTRA_REFRESH_INTERVAL,
|
||||
g_param_spec_uint ("SliceIntraRefreshInterval",
|
||||
"SliceIntraRefreshInterval", "Set SliceIntraRefreshInterval", 0,
|
||||
G_MAXUINT, DEFAULT_INTRA_REFRESH_FRAME_INTERVAL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_TWO_PASS_CBR,
|
||||
g_param_spec_boolean ("EnableTwopassCBR",
|
||||
"Enable Two pass CBR",
|
||||
"Enable two pass CBR while encoding",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_NUM_BFRAMES,
|
||||
g_param_spec_uint ("num-B-Frames",
|
||||
"B Frames between two reference frames",
|
||||
@@ -480,7 +504,7 @@ gst_v4l2_h265_enc_class_init (GstV4l2H265EncClass * klass)
|
||||
g_param_spec_uint ("num-Ref-Frames",
|
||||
"Sets the number of reference frames for encoder",
|
||||
"Number of Reference Frames for encoder",
|
||||
0, MAX_NUM_REFERENCE_FRAMES, (is_cuvid == TRUE) ? 0 : DEFAULT_NUM_REFERENCE_FRAMES,
|
||||
0, MAX_NUM_REFERENCE_FRAMES, DEFAULT_NUM_REFERENCE_FRAMES,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
@@ -490,34 +514,6 @@ gst_v4l2_h265_enc_class_init (GstV4l2H265EncClass * klass)
|
||||
"Enable lossless encoding for YUV444",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_SLICE_INTRA_REFRESH_INTERVAL,
|
||||
g_param_spec_uint ("SliceIntraRefreshInterval",
|
||||
"SliceIntraRefreshInterval", "Set SliceIntraRefreshInterval", 0,
|
||||
G_MAXUINT, DEFAULT_INTRA_REFRESH_FRAME_INTERVAL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
g_object_class_install_property (gobject_class, PROP_EXTENDED_COLORFORMAT,
|
||||
g_param_spec_boolean ("extended-colorformat",
|
||||
"Set Extended ColorFormat",
|
||||
"Set Extended ColorFormat pixel values 0 to 255 in VUI info",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
} else if (is_cuvid == FALSE) {
|
||||
g_object_class_install_property (gobject_class, PROP_ENABLE_MV_META,
|
||||
g_param_spec_boolean ("EnableMVBufferMeta",
|
||||
"Enable Motion Vector Meta data",
|
||||
"Enable Motion Vector Meta data for encoding",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_TWO_PASS_CBR,
|
||||
g_param_spec_boolean ("EnableTwopassCBR",
|
||||
"Enable Two pass CBR",
|
||||
"Enable two pass CBR while encoding",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -598,41 +594,6 @@ gst_v4l2_h265_enc_slice_header_spacing (GstV4l2Object * v4l2object,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_v4l2_h265_enc_slice_intrarefresh(GstV4l2Object *v4l2object,
|
||||
guint32 slice_count, guint32 slice_interval)
|
||||
{
|
||||
struct v4l2_ext_control control;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
gint ret;
|
||||
|
||||
v4l2_ctrl_intra_refresh cuvid_param = {1, slice_interval, slice_count};
|
||||
v4l2_enc_slice_intrarefresh_param param = {slice_count};
|
||||
|
||||
memset(&control, 0, sizeof(control));
|
||||
memset(&ctrls, 0, sizeof(ctrls));
|
||||
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &control;
|
||||
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
|
||||
|
||||
control.id = V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM;
|
||||
|
||||
if (is_cuvid)
|
||||
control.string = (gchar *)&cuvid_param;
|
||||
else
|
||||
control.string = (gchar *)¶m;
|
||||
|
||||
ret = v4l2object->ioctl(v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret < 0)
|
||||
{
|
||||
g_print("Error while setting slice intrarefresh params\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
set_v4l2_h265_encoder_properties (GstVideoEncoder * encoder)
|
||||
{
|
||||
@@ -660,10 +621,12 @@ set_v4l2_h265_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
}
|
||||
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_INSERT_VUI, self->insert_vui)) {
|
||||
g_print ("S_EXT_CTRLS for INSERT_VUI failed\n");
|
||||
return FALSE;
|
||||
if (self->insert_vui) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_INSERT_VUI, 1)) {
|
||||
g_print ("S_EXT_CTRLS for INSERT_VUI failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (self->extended_colorformat) {
|
||||
@@ -704,9 +667,9 @@ set_v4l2_h265_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
|
||||
if (self->SliceIntraRefreshInterval) {
|
||||
if (!gst_v4l2_h265_enc_slice_intrarefresh (video_enc->v4l2output,
|
||||
self->SliceIntraRefreshInterval,
|
||||
video_enc->idrinterval)) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM,
|
||||
self->SliceIntraRefreshInterval)) {
|
||||
g_print ("S_EXT_CTRLS for SLICE_INTRAREFRESH_PARAM failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2,26 +2,21 @@
|
||||
*
|
||||
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* gstv4l2object.c: base class for V4L2 elements
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -185,7 +180,6 @@ static const GstV4L2FormatDesc gst_v4l2_formats[] = {
|
||||
{V4L2_PIX_FMT_NV24M, TRUE, GST_V4L2_RAW},
|
||||
{V4L2_PIX_FMT_YUV444_10LE, TRUE, GST_V4L2_RAW},
|
||||
{V4L2_PIX_FMT_YUV444_12LE, TRUE, GST_V4L2_RAW},
|
||||
{V4L2_PIX_FMT_P216M, TRUE, GST_V4L2_RAW},
|
||||
#endif
|
||||
/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
|
||||
{V4L2_PIX_FMT_SBGGR8, TRUE, GST_V4L2_CODEC},
|
||||
@@ -1155,7 +1149,6 @@ gst_v4l2_object_format_get_rank (const struct v4l2_fmtdesc *fmt)
|
||||
case V4L2_PIX_FMT_NV24M:
|
||||
case V4L2_PIX_FMT_YUV444_10LE:
|
||||
case V4L2_PIX_FMT_YUV444_12LE:
|
||||
case V4L2_PIX_FMT_P216M:
|
||||
#endif
|
||||
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
|
||||
case V4L2_PIX_FMT_NV21M: /* Same as NV21 */
|
||||
@@ -1197,9 +1190,6 @@ gst_v4l2_object_format_get_rank (const struct v4l2_fmtdesc *fmt)
|
||||
case V4L2_PIX_FMT_YUV411P: /* Y41B, 12 bits per pixel */
|
||||
rank = YUV_BASE_RANK + 4;
|
||||
break;
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
case V4L2_PIX_FMT_YUV422M:
|
||||
#endif
|
||||
case V4L2_PIX_FMT_YUV422P: /* Y42B, 16 bits per pixel */
|
||||
rank = YUV_BASE_RANK + 8;
|
||||
break;
|
||||
@@ -1449,11 +1439,6 @@ gst_v4l2_object_v4l2fourcc_to_video_format (guint32 fourcc)
|
||||
case V4L2_PIX_FMT_YUV444_12LE:
|
||||
format = GST_VIDEO_FORMAT_Y444_12LE;
|
||||
break;
|
||||
case V4L2_PIX_FMT_P216M:
|
||||
/* NOTE: Gstreamer does not support P216 video format (16bit NV16) yet.
|
||||
Hence, as a WAR it is mapped to GST_VIDEO_FORMAT_NV16_10LE32 for now. */
|
||||
format = GST_VIDEO_FORMAT_NV16_10LE32;
|
||||
break;
|
||||
#endif
|
||||
case V4L2_PIX_FMT_NV12MT:
|
||||
format = GST_VIDEO_FORMAT_NV12_64Z32;
|
||||
@@ -1651,7 +1636,6 @@ gst_v4l2_object_v4l2fourcc_to_bare_struct (guint32 fourcc)
|
||||
case V4L2_PIX_FMT_YUV444:
|
||||
case V4L2_PIX_FMT_YUV444_10LE:
|
||||
case V4L2_PIX_FMT_YUV444_12LE:
|
||||
case V4L2_PIX_FMT_P216M:
|
||||
#endif
|
||||
case V4L2_PIX_FMT_NV24: /* 24 Y/CrCb 4:4:4 */
|
||||
case V4L2_PIX_FMT_YVU410:
|
||||
@@ -1907,9 +1891,6 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_Y42B:
|
||||
fourcc = V4L2_PIX_FMT_YUV422P;
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
fourcc_nc = V4L2_PIX_FMT_YUV422M;
|
||||
#endif
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
fourcc = V4L2_PIX_FMT_NV12;
|
||||
@@ -1930,9 +1911,6 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
case GST_VIDEO_FORMAT_Y444_12LE:
|
||||
fourcc_nc = V4L2_PIX_FMT_YUV444_12LE;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_NV16_10LE32:
|
||||
fourcc = V4L2_PIX_FMT_P216M;
|
||||
break;
|
||||
#endif
|
||||
case GST_VIDEO_FORMAT_NV12_64Z32:
|
||||
fourcc_nc = V4L2_PIX_FMT_NV12MT;
|
||||
@@ -2011,7 +1989,7 @@ gst_v4l2_object_get_caps_info (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
} else if (g_str_equal (mimetype, "image/jpeg")) {
|
||||
fourcc = V4L2_PIX_FMT_JPEG;
|
||||
} else if (g_str_equal (mimetype, "video/mpeg")) {
|
||||
gint version = 0;
|
||||
gint version;
|
||||
if (gst_structure_get_int (structure, "mpegversion", &version)) {
|
||||
switch (version) {
|
||||
case 1:
|
||||
@@ -2766,7 +2744,7 @@ unknown_type:
|
||||
static gint
|
||||
sort_by_frame_size (GstStructure * s1, GstStructure * s2)
|
||||
{
|
||||
int w1 = 0, h1 = 0, w2 = 0, h2 = 0;
|
||||
int w1, h1, w2, h2;
|
||||
|
||||
gst_structure_get_int (s1, "width", &w1);
|
||||
gst_structure_get_int (s1, "height", &h1);
|
||||
@@ -3188,7 +3166,12 @@ gst_v4l2_object_setup_pool (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||
|| !strcmp (v4l2object->videodev, V4L2_DEVICE_PATH_NVENC_ALT))) {
|
||||
/* Currently, DMABUF_IMPORT io mode is used on encoder
|
||||
output plane, when default mode V4L2_IO_AUTO is set */
|
||||
mode = GST_V4L2_IO_DMABUF_IMPORT;
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
mode = GST_V4L2_IO_MMAP; //TODO make this default to dmabuf_import
|
||||
} else if (is_cuvid == FALSE) {
|
||||
mode = GST_V4L2_IO_DMABUF_IMPORT;
|
||||
}
|
||||
} else {
|
||||
if (is_cuvid == TRUE){
|
||||
mode = GST_V4L2_IO_MMAP;
|
||||
@@ -3280,15 +3263,19 @@ gst_v4l2_object_set_stride (GstVideoInfo * info, GstVideoAlignment * align,
|
||||
const GstVideoFormatInfo *finfo = info->finfo;
|
||||
|
||||
if (GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) {
|
||||
gint x_tiles, y_tiles, tile_height, padded_height;
|
||||
gint x_tiles, y_tiles, ws, hs, tile_height, padded_height;
|
||||
|
||||
tile_height = GST_VIDEO_FORMAT_INFO_TILE_HEIGHT (finfo, plane);
|
||||
|
||||
ws = GST_VIDEO_FORMAT_INFO_TILE_WS (finfo);
|
||||
hs = GST_VIDEO_FORMAT_INFO_TILE_HS (finfo);
|
||||
tile_height = 1 << hs;
|
||||
|
||||
padded_height = GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (finfo, plane,
|
||||
info->height + align->padding_top + align->padding_bottom);
|
||||
padded_height = GST_ROUND_UP_N (padded_height, tile_height);
|
||||
|
||||
x_tiles = stride / GST_VIDEO_FORMAT_INFO_TILE_STRIDE (finfo, plane);
|
||||
y_tiles = (padded_height + tile_height - 1) / tile_height;
|
||||
x_tiles = stride >> ws;
|
||||
y_tiles = padded_height >> hs;
|
||||
info->stride[plane] = GST_VIDEO_TILE_MAKE_STRIDE (x_tiles, y_tiles);
|
||||
} else {
|
||||
info->stride[plane] = stride;
|
||||
@@ -3382,10 +3369,12 @@ gst_v4l2_object_save_format (GstV4l2Object * v4l2object,
|
||||
padded_height = format->fmt.pix.height;
|
||||
|
||||
if (GST_VIDEO_FORMAT_INFO_IS_TILED (finfo)) {
|
||||
guint tile_height;
|
||||
tile_height = GST_VIDEO_FORMAT_INFO_TILE_HEIGHT (finfo,0);
|
||||
/* Round-up to tile_height as drivers are not forced to do so */
|
||||
padded_height = (padded_height + tile_height - 1) / tile_height * tile_height;
|
||||
guint hs, tile_height;
|
||||
|
||||
hs = GST_VIDEO_FORMAT_INFO_TILE_HS (finfo);
|
||||
tile_height = 1 << hs;
|
||||
|
||||
padded_height = GST_ROUND_UP_N (padded_height, tile_height);
|
||||
}
|
||||
|
||||
align->padding_bottom = padded_height - info->height - align->padding_top;
|
||||
@@ -3497,10 +3486,9 @@ gst_v4l2_object_extrapolate_stride (const GstVideoFormatInfo * finfo,
|
||||
case GST_VIDEO_FORMAT_NV16:
|
||||
case GST_VIDEO_FORMAT_NV61:
|
||||
case GST_VIDEO_FORMAT_NV24:
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
case GST_VIDEO_FORMAT_P010_10LE:
|
||||
case GST_VIDEO_FORMAT_I420_12LE:
|
||||
case GST_VIDEO_FORMAT_NV16_10LE32:
|
||||
#endif
|
||||
estride = (plane == 0 ? 1 : 2) *
|
||||
GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (finfo, plane, stride);
|
||||
@@ -3534,8 +3522,8 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
enum v4l2_field field;
|
||||
guint32 pixelformat;
|
||||
struct v4l2_fmtdesc *fmtdesc;
|
||||
GstVideoInfo info = { 0, };
|
||||
GstVideoAlignment align = { 0, };
|
||||
GstVideoInfo info;
|
||||
GstVideoAlignment align;
|
||||
#ifndef USE_V4L2_TARGET_NV
|
||||
gint width, height, fps_n, fps_d;
|
||||
#else
|
||||
@@ -3545,9 +3533,6 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
guint width, height, fps_n, fps_d;
|
||||
GstV4l2VideoEnc *videoenc = NULL;
|
||||
GstV4l2VideoDec *videodec = NULL;
|
||||
|
||||
gst_video_info_init (&info);
|
||||
gst_video_alignment_reset (&align);
|
||||
if (!strcmp (v4l2object->videodev, V4L2_DEVICE_PATH_NVENC)
|
||||
|| !strcmp (v4l2object->videodev, V4L2_DEVICE_PATH_NVENC_ALT)) {
|
||||
videoenc = GST_V4L2_VIDEO_ENC (v4l2object->element);
|
||||
@@ -3556,7 +3541,7 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
videodec = GST_V4L2_VIDEO_DEC (v4l2object->element);
|
||||
}
|
||||
GstV4l2VideoEncClass *klass = NULL;
|
||||
{
|
||||
if (is_cuvid == FALSE) {
|
||||
if (!strcmp (v4l2object->videodev, V4L2_DEVICE_PATH_NVENC)
|
||||
|| !strcmp (v4l2object->videodev, V4L2_DEVICE_PATH_NVENC_ALT)) {
|
||||
klass = GST_V4L2_VIDEO_ENC_GET_CLASS (v4l2object->element);
|
||||
@@ -3763,8 +3748,8 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
gint stride = GST_VIDEO_INFO_PLANE_STRIDE (&info, i);
|
||||
|
||||
if (GST_VIDEO_FORMAT_INFO_IS_TILED (info.finfo))
|
||||
stride = GST_VIDEO_TILE_X_TILES (stride) *
|
||||
GST_VIDEO_FORMAT_INFO_TILE_STRIDE (info.finfo, i);
|
||||
stride = GST_VIDEO_TILE_X_TILES (stride) <<
|
||||
GST_VIDEO_FORMAT_INFO_TILE_WS (info.finfo);
|
||||
|
||||
format.fmt.pix_mp.plane_fmt[i].bytesperline = stride;
|
||||
}
|
||||
@@ -3782,8 +3767,8 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
format.fmt.pix.field = field;
|
||||
|
||||
if (GST_VIDEO_FORMAT_INFO_IS_TILED (info.finfo))
|
||||
stride = GST_VIDEO_TILE_X_TILES (stride) *
|
||||
GST_VIDEO_FORMAT_INFO_TILE_STRIDE (info.finfo, i);
|
||||
stride = GST_VIDEO_TILE_X_TILES (stride) <<
|
||||
GST_VIDEO_FORMAT_INFO_TILE_WS (info.finfo);
|
||||
|
||||
/* try to ask our prefered stride */
|
||||
format.fmt.pix.bytesperline = stride;
|
||||
@@ -3897,128 +3882,23 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
if (ret < 0)
|
||||
goto invalid_ctrl;
|
||||
|
||||
if (videoenc)
|
||||
{
|
||||
if (V4L2_TYPE_IS_OUTPUT(v4l2object->type))
|
||||
{
|
||||
if (strcmp(klass->codec_name, "H264") == 0 || strcmp(klass->codec_name, "H265") == 0 || strcmp(klass->codec_name, "AV1") == 0)
|
||||
{
|
||||
if (!klass->set_encoder_properties(&videoenc->parent))
|
||||
{
|
||||
g_print("set_encoder_properties failed\n");
|
||||
if (is_cuvid == FALSE) {
|
||||
if (videoenc) {
|
||||
if (V4L2_TYPE_IS_OUTPUT (v4l2object->type)) {
|
||||
if (strcmp (klass->codec_name, "H264") == 0
|
||||
|| strcmp (klass->codec_name, "H265") == 0
|
||||
|| strcmp (klass->codec_name, "AV1") == 0) {
|
||||
if (!klass->set_encoder_properties (&videoenc->parent)) {
|
||||
g_print ("set_encoder_properties failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!klass->set_video_encoder_properties (&videoenc->parent)) {
|
||||
g_print ("set_video_encoder_properties failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!klass->set_video_encoder_properties(&videoenc->parent))
|
||||
{
|
||||
g_print("set_video_encoder_properties failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (is_cuvid)
|
||||
{
|
||||
/* CUDA PRESETS are overridden if HW presets are set.*/
|
||||
if (!videoenc->hw_preset_level)
|
||||
{
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_PRESET_ID;
|
||||
ctl.value = videoenc->cudaenc_preset_id;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_TUNING_INFO;
|
||||
ctl.value = videoenc->cudaenc_tuning_info_id;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
}
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEO_CUDA_MEM_TYPE;
|
||||
ctl.value = videoenc->cudaenc_mem_type;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
v4l2_ctrl_video_constqp constqp;
|
||||
constqp.constQpI = videoenc->constQpI;
|
||||
constqp.constQpP = videoenc->constQpP;
|
||||
constqp.constQpB = videoenc->constQpB;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_CONSTQP;
|
||||
ctl.string = (gchar *)&constqp;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
v4l2_ctrl_video_init_qp init_qp;
|
||||
init_qp.IInitQP = videoenc->IInitQP;
|
||||
init_qp.PInitQP = videoenc->PInitQP;
|
||||
init_qp.BInitQP = videoenc->BInitQP;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_INIT_FRAME_QP;
|
||||
ctl.string = (gchar *)&init_qp;
|
||||
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEO_MAXBITRATE;
|
||||
ctl.value = videoenc->maxbitrate;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_VBVBUFSIZE;
|
||||
ctl.value = videoenc->vbvbufsize;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_VBVINIT;
|
||||
ctl.value = videoenc->vbvinit;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_ENABLE_AQ;
|
||||
ctl.value = videoenc->aqStrength;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_ENABLE_TEMPORAL_AQ;
|
||||
ctl.value = videoenc->enableTemporalAQ;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_TARGET_QUALITY;
|
||||
ctl.value = videoenc->targetQuality;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl;
|
||||
ret = v4l2object->ioctl(fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4037,6 +3917,108 @@ gst_v4l2_object_set_format_full (GstV4l2Object * v4l2object, GstCaps * caps,
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (is_cuvid == TRUE) {
|
||||
if (videoenc) {
|
||||
ctl.id = V4L2_CID_MPEG_VIDEO_CUDA_GPU_ID;
|
||||
ctl.value = videoenc->cudaenc_gpu_id;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_PRESET_ID;
|
||||
ctl.value = videoenc->cudaenc_preset_id;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
v4l2_ctrl_video_constqp constqp;
|
||||
constqp.constQpI = videoenc->constQpI;
|
||||
constqp.constQpP = videoenc->constQpP;
|
||||
constqp.constQpB = videoenc->constQpB;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_CONSTQP;
|
||||
ctl.string = (gchar *) &constqp;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
v4l2_ctrl_video_init_qp init_qp;
|
||||
init_qp.IInitQP = videoenc->IInitQP;
|
||||
init_qp.PInitQP = videoenc->PInitQP;
|
||||
init_qp.BInitQP = videoenc->BInitQP;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_INIT_FRAME_QP;
|
||||
ctl.string = (gchar *) &init_qp;
|
||||
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_CUDA_TUNING_INFO;
|
||||
ctl.value = videoenc->cudaenc_tuning_info_id;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEO_MAXBITRATE;
|
||||
ctl.value = videoenc->maxbitrate;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_VBVBUFSIZE;
|
||||
ctl.value = videoenc->vbvbufsize;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_VBVINIT;
|
||||
ctl.value = videoenc->vbvinit;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_ENABLE_AQ;
|
||||
ctl.value = videoenc->aqStrength;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_ENABLE_TEMPORAL_AQ;
|
||||
ctl.value = videoenc->enableTemporalAQ;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
ctl.id = V4L2_CID_MPEG_VIDEOENC_TARGET_QUALITY;
|
||||
ctl.value = videoenc->targetQuality;
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &ctl ;
|
||||
ret = v4l2object->ioctl (fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret)
|
||||
goto invalid_ctrl;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GST_DEBUG_OBJECT (v4l2object->dbg_obj, "Got format of %dx%d, format "
|
||||
@@ -4442,7 +4424,7 @@ gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, GstVideoInfo * info)
|
||||
struct v4l2_rect *r = NULL;
|
||||
GstVideoFormat format;
|
||||
guint width, height;
|
||||
GstVideoAlignment align = { 0, };
|
||||
GstVideoAlignment align;
|
||||
|
||||
gst_video_info_init (info);
|
||||
gst_video_alignment_reset (&align);
|
||||
@@ -4602,7 +4584,7 @@ gboolean
|
||||
gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||
{
|
||||
GstStructure *config;
|
||||
GstCaps *oldcaps = NULL;
|
||||
GstCaps *oldcaps;
|
||||
gboolean ret;
|
||||
|
||||
if (!v4l2object->pool)
|
||||
@@ -4773,7 +4755,7 @@ gst_v4l2_object_decide_allocation (GstV4l2Object * obj, GstQuery * query)
|
||||
GstCaps *caps;
|
||||
GstBufferPool *pool = NULL, *other_pool = NULL;
|
||||
GstStructure *config;
|
||||
guint size = 0, min = 0, max = 0, own_min = 0;
|
||||
guint size, min, max, own_min = 0;
|
||||
gboolean update;
|
||||
gboolean has_video_meta;
|
||||
gboolean can_share_own_pool, pushing_from_our_pool = FALSE;
|
||||
@@ -5078,7 +5060,7 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query)
|
||||
GstBufferPool *pool;
|
||||
/* we need at least 2 buffers to operate */
|
||||
guint size, min, max;
|
||||
GstCaps *caps = NULL;
|
||||
GstCaps *caps;
|
||||
gboolean need_pool;
|
||||
|
||||
/* Set defaults allocation parameters */
|
||||
@@ -5099,7 +5081,7 @@ gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query)
|
||||
gst_object_ref (pool);
|
||||
|
||||
if (pool != NULL) {
|
||||
GstCaps *pcaps = NULL;
|
||||
GstCaps *pcaps;
|
||||
GstStructure *config;
|
||||
|
||||
/* we had a pool, check caps */
|
||||
@@ -5169,7 +5151,8 @@ set_v4l2_video_mpeg_class (GstV4l2Object * v4l2object, guint label,
|
||||
|
||||
if (control.id == V4L2_CID_MPEG_VIDEOENC_VIRTUALBUFFER_SIZE) {
|
||||
control.string = (gchar *) &buffer_size;
|
||||
} else if (control.id == V4L2_CID_MPEG_VIDEOENC_NUM_REFERENCE_FRAMES) {
|
||||
} else if ((control.id == V4L2_CID_MPEG_VIDEOENC_SLICE_INTRAREFRESH_PARAM) ||
|
||||
(control.id == V4L2_CID_MPEG_VIDEOENC_NUM_REFERENCE_FRAMES)) {
|
||||
control.string = (gchar *) ¶ms;
|
||||
} else {
|
||||
control.value = params;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
*
|
||||
* Copyright (C) 2001-2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||
* 2006 Edgard Lima <edgard.lima@gmail.com>
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* gstv4l2object.h: base class for V4L2 elements
|
||||
*
|
||||
@@ -60,7 +59,6 @@ typedef struct _GstV4l2ObjectClassHelper GstV4l2ObjectClassHelper;
|
||||
#define V4L2_DEVICE_PATH_NVENC "/dev/nvhost-msenc"
|
||||
#define V4L2_DEVICE_PATH_NVENC_ALT "/dev/v4l2-nvenc"
|
||||
#define V4L2_DEVICE_PATH_TEGRA_INFO "/sys/firmware/devicetree/base/compatible"
|
||||
#define V4L2_DEVICE_INFO_SOM_EEPROM "/sys/firmware/devicetree/base/chosen/ids"
|
||||
#endif
|
||||
|
||||
/* max frame width/height */
|
||||
@@ -228,7 +226,6 @@ struct _GstV4l2Object {
|
||||
GMutex cplane_stopped_lock;
|
||||
guint sei_payload_size;
|
||||
void* sei_payload;
|
||||
gchar *sei_uuid;
|
||||
#endif
|
||||
|
||||
/* funcs */
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014-2023 Collabora Ltd.
|
||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -19,6 +17,7 @@
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -74,8 +73,7 @@ gboolean default_sei_extract_data;
|
||||
gint default_num_extra_surfaces;
|
||||
|
||||
static gboolean enable_latency_measurement = FALSE;
|
||||
extern uint8_t *parse_sei_data (uint8_t *bs, guint size, uint32_t *payload_size,
|
||||
char *sei_uuid_string, guint32 pixelformat);
|
||||
extern uint8_t *parse_sei_data (uint8_t *bs, guint size, uint32_t *payload_size, char *sei_uuid_string);
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
GstVideoCodecFrame *
|
||||
@@ -161,10 +159,6 @@ gst_video_cudadec_mem_type (void)
|
||||
"memtype_pinned"},
|
||||
{V4L2_CUDA_MEM_TYPE_UNIFIED, "Memory type Unified",
|
||||
"memtype_unified"},
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
{V4L2_CUDA_MEM_TYPE_SURFACE_ARRAY, "Memory type Surface Array",
|
||||
"memtype_surface_array"},
|
||||
#endif
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -212,9 +206,7 @@ static GstStaticPadTemplate gst_v4l2dec_sink_template =
|
||||
"divxversion=(int) [4, 5], "
|
||||
"width=(int) [1,MAX], " "height=(int) [1,MAX]"
|
||||
";"
|
||||
"video/x-av1,"
|
||||
"stream-format = (string) { obu-stream },"
|
||||
"alignment = (string) { frame }"
|
||||
"video/x-av1"
|
||||
";"
|
||||
"video/x-vp8"
|
||||
";" "video/x-vp9," "width=(gint) [1,MAX]," "height=(gint) [1,MAX]" ";")
|
||||
@@ -459,7 +451,6 @@ gst_v4l2_video_dec_set_property_cuvid (GObject * object,
|
||||
break;
|
||||
|
||||
case PROP_CUDADEC_LOW_LATENCY:
|
||||
case PROP_DISABLE_DPB:
|
||||
self->cudadec_low_latency = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
@@ -590,7 +581,6 @@ gst_v4l2_video_dec_get_property_cuvid (GObject * object,
|
||||
break;
|
||||
|
||||
case PROP_CUDADEC_LOW_LATENCY:
|
||||
case PROP_DISABLE_DPB:
|
||||
g_value_set_boolean (value, self->cudadec_low_latency);
|
||||
break;
|
||||
|
||||
@@ -708,7 +698,7 @@ gst_v4l2_video_dec_start (GstVideoDecoder * decoder)
|
||||
self->decoded_picture_cnt = 0;
|
||||
#endif
|
||||
|
||||
self->hash_pts_systemtime = g_hash_table_new_full (NULL, NULL, NULL, NULL);
|
||||
self->hash_pts_systemtime = g_hash_table_new(NULL, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -739,7 +729,6 @@ gst_v4l2_video_dec_stop (GstVideoDecoder * decoder)
|
||||
gst_v4l2_object_stop (self->v4l2output);
|
||||
gst_v4l2_object_stop (self->v4l2capture);
|
||||
|
||||
g_hash_table_remove_all (self->hash_pts_systemtime);
|
||||
g_hash_table_destroy (self->hash_pts_systemtime);
|
||||
|
||||
if (self->input_state) {
|
||||
@@ -967,13 +956,6 @@ gst_v4l2_video_dec_flush (GstVideoDecoder * decoder)
|
||||
gst_v4l2_object_unlock_stop (self->v4l2output);
|
||||
gst_v4l2_object_unlock_stop (self->v4l2capture);
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
if (is_cuvid == TRUE) {
|
||||
/* Flush out low-level cuvid decoder buffers */
|
||||
set_v4l2_video_mpeg_class (self->v4l2output, V4L2_CID_MPEG_VIDEODEC_FLUSH_BUFFERS, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (self->v4l2output->pool)
|
||||
gst_v4l2_buffer_pool_flush (self->v4l2output->pool);
|
||||
|
||||
@@ -1291,12 +1273,10 @@ gst_v4l2_video_dec_loop (GstVideoDecoder * decoder)
|
||||
|
||||
if(enable_latency_measurement) /* TODO with better option */
|
||||
{
|
||||
g_mutex_lock(&self->pts_hashtable_lock);
|
||||
gsize frame_pts = frame->pts;
|
||||
gpointer in_time = g_hash_table_lookup (self->hash_pts_systemtime, GSIZE_TO_POINTER(frame_pts));
|
||||
gdouble input_time = (gdouble) GPOINTER_TO_SIZE(in_time);
|
||||
gpointer in_time = g_hash_table_lookup (self->hash_pts_systemtime,
|
||||
&frame->pts);
|
||||
gdouble input_time = *((gdouble*)in_time);
|
||||
gdouble output_time = get_current_system_timestamp ();
|
||||
|
||||
if (output_time < input_time)
|
||||
{
|
||||
gdouble time = G_MAXDOUBLE - input_time;
|
||||
@@ -1308,11 +1288,6 @@ gst_v4l2_video_dec_loop (GstVideoDecoder * decoder)
|
||||
GST_DEBUG_OBJECT (self, "True Decode Latency = %f \n",
|
||||
(output_time - input_time));
|
||||
}
|
||||
|
||||
//Remove the hash table entry for the frame pts
|
||||
g_hash_table_remove (self->hash_pts_systemtime, GSIZE_TO_POINTER(frame_pts));
|
||||
g_mutex_unlock(&self->pts_hashtable_lock);
|
||||
|
||||
GstCaps *reference = gst_caps_new_simple ("video/x-raw",
|
||||
"component_name", G_TYPE_STRING, GST_ELEMENT_NAME(self),
|
||||
"frame_num", G_TYPE_INT, self->frame_num++,
|
||||
@@ -1382,7 +1357,7 @@ gst_v4l2_video_remove_padding (GstCapsFeatures * features,
|
||||
if (!gst_structure_get_int (structure, "height", &height))
|
||||
return TRUE;
|
||||
#else
|
||||
guint width = 0, height = 0;
|
||||
guint width, height;
|
||||
|
||||
if (!gst_structure_get_int (structure, "width", (gint *) & width))
|
||||
return TRUE;
|
||||
@@ -1534,12 +1509,18 @@ gst_v4l2_h265_stream_parser (GstV4l2VideoDec *self, gpointer data, guint32 size)
|
||||
break;
|
||||
case H265_PARSER_ERROR:
|
||||
/* should not really occur either */
|
||||
GST_WARNING_OBJECT (self, "Error parsing H.265 stream. Invalid H.265 stream");
|
||||
GST_ELEMENT_ERROR (self, STREAM, FORMAT,
|
||||
("Error parsing H.265 stream"), ("Invalid H.265 stream"));
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
case H265_PARSER_NO_NAL:
|
||||
GST_WARNING_OBJECT (self, "No H.265 NAL unit found");
|
||||
GST_ELEMENT_ERROR (self, STREAM, FORMAT,
|
||||
("Error parsing H.265 stream"), ("No H.265 NAL unit found"));
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
default:
|
||||
ret = GST_FLOW_ERROR;
|
||||
//g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1587,12 +1568,18 @@ gst_v4l2_h264_stream_parser (GstV4l2VideoDec *self, gpointer data, guint32 size)
|
||||
break;
|
||||
case H264_PARSER_ERROR:
|
||||
/* should not really occur either */
|
||||
GST_WARNING_OBJECT(self, "Error parsing H.264 stream. Invalid H.264 stream");
|
||||
GST_ELEMENT_ERROR(self, STREAM, FORMAT,
|
||||
("Error parsing H.264 stream"), ("Invalid H.264 stream"));
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
case H264_PARSER_NO_NAL:
|
||||
GST_WARNING_OBJECT(self, "Error parsing H.264 stream. No H.264 NAL unit found");
|
||||
GST_ELEMENT_ERROR(self, STREAM, FORMAT,
|
||||
("Error parsing H.264 stream"), ("No H.264 NAL unit found"));
|
||||
ret = GST_FLOW_ERROR;
|
||||
break;
|
||||
default:
|
||||
ret = GST_FLOW_ERROR;
|
||||
// g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1856,8 +1843,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
* decodable independently until we receive I / IDR frame.
|
||||
*/
|
||||
if (((GST_V4L2_PIXELFORMAT(obj) == V4L2_PIX_FMT_H264) ||
|
||||
(GST_V4L2_PIXELFORMAT(obj) == V4L2_PIX_FMT_H265) ||
|
||||
(GST_V4L2_PIXELFORMAT(obj) == V4L2_PIX_FMT_MPEG4)) &&
|
||||
(GST_V4L2_PIXELFORMAT(obj) == V4L2_PIX_FMT_H265)) &&
|
||||
self->is_gdr_stream == FALSE)
|
||||
{
|
||||
if ((GST_BUFFER_FLAG_IS_SET (GST_BUFFER_CAST(frame->input_buffer),
|
||||
@@ -1877,7 +1863,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
// Decode only I Frames and drop others.
|
||||
if (GST_BUFFER_FLAG_IS_SET (GST_BUFFER_CAST(frame->input_buffer),
|
||||
GST_BUFFER_FLAG_DELTA_UNIT)) {
|
||||
gst_video_decoder_release_frame (GST_VIDEO_DECODER(self), frame);
|
||||
gst_video_decoder_drop_frame (decoder, frame);
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
}
|
||||
@@ -1885,12 +1871,8 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
|
||||
if (enable_latency_measurement)
|
||||
{
|
||||
g_mutex_lock(&self->pts_hashtable_lock);
|
||||
gsize frame_pts = frame->pts;
|
||||
gsize current_time = get_current_system_timestamp ();;
|
||||
g_hash_table_insert (self->hash_pts_systemtime, GSIZE_TO_POINTER(frame_pts),
|
||||
GSIZE_TO_POINTER(current_time));
|
||||
g_mutex_unlock(&self->pts_hashtable_lock);
|
||||
self->buffer_in_time = get_current_system_timestamp ();
|
||||
g_hash_table_insert (self->hash_pts_systemtime, &frame->pts, &self->buffer_in_time);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (!g_atomic_int_get (&self->active)))
|
||||
@@ -1908,7 +1890,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
GstBufferPool *pool = GST_BUFFER_POOL (self->v4l2output->pool);
|
||||
GstVideoInfo info = {0};
|
||||
GstVideoCodecState *output_state;
|
||||
GstBuffer *codec_data = NULL;
|
||||
GstBuffer *codec_data;
|
||||
GstCaps *acquired_caps, *available_caps, *caps, *filter;
|
||||
GstStructure *st;
|
||||
|
||||
@@ -1916,21 +1898,11 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
|
||||
codec_data = self->input_state->codec_data;
|
||||
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
/* For av1 stream with webm container, we have observed that codec_data field is received
|
||||
along with the caps and is a part of input_state, thus sending this to cuvidparser as
|
||||
first frame. cuvidparser does not require it. We should send the input frame directly */
|
||||
if ((GST_V4L2_PIXELFORMAT(obj) == V4L2_PIX_FMT_AV1)) {
|
||||
codec_data = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We are running in byte-stream mode, so we don't know the headers, but
|
||||
* we need to send something, otherwise the decoder will refuse to
|
||||
* intialize.
|
||||
*/
|
||||
if (codec_data) {
|
||||
GST_DEBUG_OBJECT (self, "codec_data field is valid. Using that as input for cuvidparser");
|
||||
gst_buffer_ref (codec_data);
|
||||
} else {
|
||||
codec_data = gst_buffer_ref (frame->input_buffer);
|
||||
@@ -1987,7 +1959,6 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
ret = self->output_flow;
|
||||
goto drop;
|
||||
} else if (ret != GST_FLOW_OK) {
|
||||
GST_DEBUG_OBJECT (self, "gst_v4l2_buffer_pool_process failed\n");
|
||||
goto process_failed;
|
||||
}
|
||||
}
|
||||
@@ -2001,27 +1972,25 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
if(!processed)
|
||||
{
|
||||
processed = TRUE;
|
||||
/* Wait for DQEVENT for 1 sec */
|
||||
/* Wait for DQEVENT for 0.6 sec */
|
||||
while (dqevent_loop_count < LOOP_COUNT_TO_WAIT_FOR_DQEVENT) {
|
||||
memset (&ev, 0, sizeof (ev));
|
||||
retval = obj->ioctl (obj->video_fd, VIDIOC_DQEVENT, &ev);
|
||||
dqevent_loop_count ++;
|
||||
if (retval != 0)
|
||||
{
|
||||
if (errno == EINVAL) {
|
||||
GST_DEBUG_OBJECT (self, "VIDIOC_DQEVENT failed. Event Type: %d\n", ev.type);
|
||||
if (errno == EINVAL)
|
||||
goto process_failed;
|
||||
}
|
||||
if (dqevent_loop_count == LOOP_COUNT_TO_WAIT_FOR_DQEVENT) {
|
||||
GST_DEBUG_OBJECT (self, "Stream format not found, dropping the frame\n");
|
||||
goto drop;
|
||||
}
|
||||
usleep (WAIT_TIME_PER_LOOP_FOR_DQEVENT); //TODO is this needed ?
|
||||
continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if (dqevent_loop_count == LOOP_COUNT_TO_WAIT_FOR_DQEVENT) {
|
||||
g_print ("Stream format not found, dropping the frame\n");
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -2031,13 +2000,11 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
retval = obj->ioctl (obj->video_fd, VIDIOC_DQEVENT, &ev);
|
||||
if (retval != 0)
|
||||
{
|
||||
if (errno == EINVAL) {
|
||||
GST_DEBUG_OBJECT (self, "VIDIOC_DQEVENT failed. Event Type: %d\n", ev.type);
|
||||
if (errno == EINVAL)
|
||||
goto process_failed;
|
||||
}
|
||||
if (is_cuvid != TRUE) {
|
||||
if (ev.sequence == 0) {
|
||||
GST_DEBUG_OBJECT (self, "Stream format not found, dropping the frame\n");
|
||||
g_print ("Stream format not found, dropping the frame\n");
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
@@ -2230,7 +2197,6 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
ret = GST_FLOW_OK;
|
||||
goto drop;
|
||||
}
|
||||
GST_DEBUG_OBJECT (self, "gst_v4l2_buffer_pool_process failed\n");
|
||||
goto process_failed;
|
||||
}
|
||||
}
|
||||
@@ -2244,8 +2210,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
GST_BUFFER_COPY_META, 0, 0);
|
||||
|
||||
/* Parse SEI data from the bitsream */
|
||||
if ((is_cuvid == TRUE) && (self->extract_sei_type5_data == TRUE) &&
|
||||
((obj->fmtdesc->pixelformat == V4L2_PIX_FMT_H264) || (obj->fmtdesc->pixelformat == V4L2_PIX_FMT_H265)))
|
||||
if ((is_cuvid == TRUE) && (self->extract_sei_type5_data == TRUE))
|
||||
{
|
||||
uint8_t *sei_type5_payload = NULL;
|
||||
GstMapInfo map = {0};
|
||||
@@ -2259,7 +2224,7 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
|
||||
uint32_t payload_size = 0;
|
||||
uint8_t *stream_data = (uint8_t *)map.data;
|
||||
sei_type5_payload = parse_sei_data (stream_data, map.size,
|
||||
&payload_size, self->sei_uuid_string, obj->fmtdesc->pixelformat);
|
||||
&payload_size, self->sei_uuid_string);
|
||||
if (sei_type5_payload != NULL)
|
||||
{
|
||||
GST_DEBUG_OBJECT (self, "sei_type5_payload found\n");
|
||||
@@ -2312,7 +2277,8 @@ start_task_failed:
|
||||
process_failed:
|
||||
{
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, FAILED,
|
||||
(_("Failed to process frame.")), (NULL));
|
||||
(_("Failed to process frame.")),
|
||||
("Maybe be due to not enough memory or failing driver"));
|
||||
ret = GST_FLOW_ERROR;
|
||||
goto drop;
|
||||
}
|
||||
@@ -2356,7 +2322,7 @@ gst_v4l2_video_dec_src_query (GstVideoDecoder * decoder, GstQuery * query)
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:{
|
||||
GstCaps *filter = NULL, *result = NULL;
|
||||
GstCaps *filter, *result = NULL;
|
||||
GstPad *pad = GST_VIDEO_DECODER_SRC_PAD (decoder);
|
||||
|
||||
gst_query_parse_caps (query, &filter);
|
||||
@@ -2482,7 +2448,7 @@ gst_v4l2_video_dec_src_event (GstVideoDecoder * decoder, GstEvent * event)
|
||||
case GST_EVENT_SEEK:
|
||||
{
|
||||
GstFormat format;
|
||||
gdouble rate = 0.0;
|
||||
gdouble rate;
|
||||
GstSeekFlags flags;
|
||||
GstSeekType start_type, stop_type;
|
||||
gint64 start, stop;
|
||||
@@ -2560,7 +2526,6 @@ gst_v4l2_video_dec_finalize (GObject * object)
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
g_cond_clear (&self->v4l2capture->cplane_stopped_cond);
|
||||
g_mutex_clear (&self->v4l2capture->cplane_stopped_lock);
|
||||
g_mutex_clear (&self->pts_hashtable_lock);
|
||||
#endif
|
||||
|
||||
gst_v4l2_object_destroy (self->v4l2capture);
|
||||
@@ -2637,7 +2602,6 @@ gst_v4l2_video_dec_subinstance_init (GTypeInstance * instance, gpointer g_class)
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
g_mutex_init (&self->v4l2capture->cplane_stopped_lock);
|
||||
g_cond_init (&self->v4l2capture->cplane_stopped_cond);
|
||||
g_mutex_init (&self->pts_hashtable_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2777,12 +2741,6 @@ gst_v4l2_video_dec_class_init (GstV4l2VideoDecClass * klass)
|
||||
default_cudadec_low_latency,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_DISABLE_DPB,
|
||||
g_param_spec_boolean ("disable-dpb",
|
||||
"Disable DPB buffer",
|
||||
"Set to disable DPB buffer for low latency",
|
||||
DEFAULT_DISABLE_DPB, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_EXTRACT_SEI_TYPE5_DATA,
|
||||
g_param_spec_boolean ("extract-sei-type5-data",
|
||||
"extract-sei-type5-data",
|
||||
@@ -3010,7 +2968,7 @@ void
|
||||
gst_v4l2_video_dec_register (GstPlugin * plugin, const gchar * basename,
|
||||
const gchar * device_path, GstCaps * sink_caps, GstCaps * src_caps)
|
||||
{
|
||||
GTypeQuery type_query = { 0, };
|
||||
GTypeQuery type_query;
|
||||
GTypeInfo type_info = { 0, };
|
||||
GType type, subtype;
|
||||
GstV4l2VideoDecCData *cdata;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Collabora Ltd.
|
||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk>
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -49,7 +48,7 @@ G_BEGIN_DECLS
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
#define GstV4l2VideoDec GstNvV4l2VideoDec
|
||||
#define GstV4l2VideoDecClass GstNvV4l2VideoDecClass
|
||||
#define LOOP_COUNT_TO_WAIT_FOR_DQEVENT 10
|
||||
#define LOOP_COUNT_TO_WAIT_FOR_DQEVENT 6
|
||||
#define WAIT_TIME_PER_LOOP_FOR_DQEVENT 100*1000
|
||||
|
||||
#define VP8_START_BYTE_0 0x9D
|
||||
@@ -83,6 +82,7 @@ struct _GstV4l2VideoDec
|
||||
guint64 frame_num;
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
GHashTable* hash_pts_systemtime;
|
||||
gdouble buffer_in_time;
|
||||
guint64 decoded_picture_cnt;
|
||||
guint32 skip_frames;
|
||||
gboolean idr_received;
|
||||
@@ -109,7 +109,6 @@ struct _GstV4l2VideoDec
|
||||
guint32 old_width;
|
||||
guint32 old_height;
|
||||
gboolean valid_vpx;
|
||||
GMutex pts_hashtable_lock;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* Authors Ayaka <ayaka@soulik.info>
|
||||
* Copyright (C) 2017 Collabora Ltd.
|
||||
* Author: Nicolas Dufresne <nicolas.dufresne@collabora.com>
|
||||
*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -85,8 +83,6 @@ gboolean setIntraRefreshParams (GstV4l2Object * v4l2object, guint label, guint e
|
||||
guint intraRefreshPeriod, guint intraRefreshCnt);
|
||||
gboolean setHWPresetType (GstV4l2Object * v4l2object, guint label,
|
||||
enum v4l2_enc_hw_preset_type type);
|
||||
gboolean setInitQPParams (GstV4l2Object * v4l2object,
|
||||
guint32 quantI, guint32 quantP, guint32 quantB);
|
||||
gint gst_v4l2_trace_file_open (FILE ** file);
|
||||
void gst_v4l2_trace_file_close (FILE * file);
|
||||
void gst_v4l2_trace_printf (FILE * file, const gchar *fmt, ...);
|
||||
@@ -101,22 +97,20 @@ gst_v4l2_video_enc_parse_quantization_range (GstV4l2VideoEnc * self,
|
||||
static gboolean
|
||||
gst_v4l2_video_enc_parse_intra_refresh_params (GstV4l2VideoEnc * self,
|
||||
const gchar * arr);
|
||||
static GType gst_v4l2_videnc_tuning_info_get_type (void);
|
||||
static GType gst_v4l2_videnc_ratecontrol_get_type (void);
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
static GType gst_v4l2_videnc_hw_preset_level_get_type (void);
|
||||
static GType gst_v4l2_videnc_tuning_info_get_type (void);
|
||||
static void gst_v4l2_video_encoder_forceIDR (GstV4l2VideoEnc * self);
|
||||
#endif
|
||||
|
||||
static GType gst_v4l2_videnc_ratecontrol_get_type (void);
|
||||
enum
|
||||
{
|
||||
/* actions */
|
||||
SIGNAL_FORCE_IDR,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
|
||||
static guint gst_v4l2_signals[LAST_SIGNAL] = { 0 };
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
enum
|
||||
@@ -134,7 +128,6 @@ enum
|
||||
PROP_CUDAENC_CONSTQP,
|
||||
PROP_CUDAENC_INITQP,
|
||||
PROP_CUDAENC_TUNING_INFO_ID,
|
||||
PROP_CUDAENC_MEM_TYPE,
|
||||
PROP_MAXBITRATE,
|
||||
PROP_VBVBUFSIZE,
|
||||
PROP_VBVINIT,
|
||||
@@ -142,8 +135,7 @@ enum
|
||||
PROP_TEMPORAL_AQ,
|
||||
PROP_CQ,
|
||||
PROP_INTRA_REFRESH,
|
||||
PROP_SEI_UUID,
|
||||
/* TEGRA PROPERTIES */
|
||||
/* Properties exposed on Tegra only */
|
||||
PROP_PEAK_BITRATE,
|
||||
PROP_QUANT_I_FRAMES,
|
||||
PROP_QUANT_P_FRAMES,
|
||||
@@ -182,18 +174,12 @@ enum
|
||||
#define GST_V4L2_VIDEO_ENC_QUANT_P_FRAMES_DEFAULT (0xffffffff)
|
||||
#define GST_V4L2_VIDEO_ENC_QUANT_B_FRAMES_DEFAULT (0xffffffff)
|
||||
#define DEFAULT_HW_PRESET_LEVEL V4L2_ENC_HW_PRESET_ULTRAFAST
|
||||
#define DEFAULT_HW_PRESET_LEVEL_CUVID 0
|
||||
#define DEFAULT_TUNING_INFO_PRESET V4L2_ENC_TUNING_INFO_LOW_LATENCY
|
||||
#define DEFAULT_CUDAENC_MEM_TYPE V4L2_CUDA_MEM_TYPE_DEVICE
|
||||
|
||||
#define GST_TYPE_V4L2_VID_CUDAENC_MEM_TYPE (gst_video_cudaenc_mem_type())
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
#define GST_TYPE_V4L2_VID_ENC_HW_PRESET_LEVEL (gst_v4l2_videnc_hw_preset_level_get_type ())
|
||||
#endif
|
||||
#define GST_TYPE_V4L2_VID_ENC_TUNING_INFO_PRESET (gst_v4l2_videnc_tuning_info_get_type ())
|
||||
#define GST_TYPE_V4L2_VID_ENC_RATECONTROL (gst_v4l2_videnc_ratecontrol_get_type())
|
||||
#define DEFAULT_VBV_SIZE 4000000
|
||||
#define DEFAULT_SEI_UUID "NVDS_CUSTOMMETA"
|
||||
#endif
|
||||
|
||||
#define gst_v4l2_video_enc_parent_class parent_class
|
||||
@@ -247,31 +233,6 @@ gst_v4l2_enc_capture_io_mode_get_type (void)
|
||||
}
|
||||
return v4l2_enc_capture_io_mode;
|
||||
}
|
||||
|
||||
static GType
|
||||
gst_video_cudaenc_mem_type (void)
|
||||
{
|
||||
static GType qtype = 0;
|
||||
|
||||
if (qtype == 0) {
|
||||
static const GEnumValue values[] = {
|
||||
{V4L2_CUDA_MEM_TYPE_DEVICE, "Memory type Device", "memtype_device"},
|
||||
{V4L2_CUDA_MEM_TYPE_PINNED, "Memory type Host Pinned",
|
||||
"memtype_pinned"},
|
||||
{V4L2_CUDA_MEM_TYPE_UNIFIED, "Memory type Unified",
|
||||
"memtype_unified"},
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
{V4L2_CUDA_MEM_TYPE_SURFACE_ARRAY, "Memory type Surface Array",
|
||||
"memtype_surface_array"},
|
||||
#endif
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
qtype = g_enum_register_static ("CudaEncMemType", values);
|
||||
}
|
||||
return qtype;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
@@ -314,13 +275,7 @@ gst_v4l2_video_enc_set_property_tegra (GObject * object,
|
||||
case PROP_QUANT_RANGE:
|
||||
gst_v4l2_video_enc_parse_quantization_range (self,
|
||||
g_value_get_string (value));
|
||||
if (self->MinQpP == (guint)-1 && self->MaxQpP == (guint)-1 &&
|
||||
self->MinQpI == (guint)-1 && self->MaxQpI == (guint)-1 &&
|
||||
self->MinQpB == (guint)-1 && self->MaxQpB == (guint)-1) {
|
||||
self->set_qpRange = FALSE;
|
||||
}
|
||||
else
|
||||
self->set_qpRange = TRUE;
|
||||
self->set_qpRange = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_QUANT_I_FRAMES:
|
||||
@@ -408,9 +363,6 @@ gst_v4l2_video_enc_set_property_cuvid (GObject * object,
|
||||
break;
|
||||
|
||||
case PROP_VBVBUFSIZE:
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
case PROP_VIRTUAL_BUFFER_SIZE:
|
||||
#endif
|
||||
self->vbvbufsize = g_value_get_uint (value);
|
||||
break;
|
||||
|
||||
@@ -443,16 +395,7 @@ gst_v4l2_video_enc_set_property_cuvid (GObject * object,
|
||||
case PROP_INTRA_REFRESH:
|
||||
gst_v4l2_video_enc_parse_intra_refresh_params (self,
|
||||
g_value_get_string (value));
|
||||
if (self->enableIntraRefresh)
|
||||
self->set_intrarefresh = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_SEI_UUID:
|
||||
self->sei_uuid = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_CUDAENC_MEM_TYPE:
|
||||
self->cudaenc_mem_type = g_value_get_enum(value);
|
||||
self->set_intrarefresh = TRUE;
|
||||
break;
|
||||
|
||||
case PROP_CUDAENC_GPU_ID:
|
||||
@@ -492,35 +435,6 @@ gst_v4l2_video_enc_set_property_cuvid (GObject * object,
|
||||
case PROP_COPY_METADATA:
|
||||
self->copy_meta = g_value_get_boolean (value);
|
||||
break;
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
case PROP_PEAK_BITRATE:
|
||||
self->peak_bitrate = g_value_get_uint(value);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_I_FRAMES:
|
||||
self->quant_i_frames = g_value_get_uint(value);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_P_FRAMES:
|
||||
self->quant_p_frames = g_value_get_uint(value);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_B_FRAMES:
|
||||
self->quant_b_frames = g_value_get_uint(value);
|
||||
break;
|
||||
|
||||
case PROP_HW_PRESET_LEVEL:
|
||||
self->hw_preset_level = g_value_get_enum(value);
|
||||
break;
|
||||
|
||||
case PROP_MEASURE_LATENCY:
|
||||
self->measure_latency = g_value_get_boolean(value);
|
||||
break;
|
||||
|
||||
case PROP_RC_ENABLE:
|
||||
self->ratecontrol_enable = g_value_get_boolean(value);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* By default, only set on output */
|
||||
@@ -647,9 +561,6 @@ gst_v4l2_video_enc_get_property_cuvid (GObject * object,
|
||||
break;
|
||||
|
||||
case PROP_VBVBUFSIZE:
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
case PROP_VIRTUAL_BUFFER_SIZE:
|
||||
#endif
|
||||
g_value_set_uint (value, self->vbvbufsize);
|
||||
break;
|
||||
|
||||
@@ -669,8 +580,8 @@ gst_v4l2_video_enc_get_property_cuvid (GObject * object,
|
||||
g_value_set_uint (value, self->targetQuality);
|
||||
break;
|
||||
|
||||
case PROP_CUDAENC_MEM_TYPE:
|
||||
g_value_set_enum(value, self->cudaenc_mem_type);
|
||||
case PROP_INTRA_FRAME_INTERVAL:
|
||||
g_value_set_uint (value, self->iframeinterval);
|
||||
break;
|
||||
|
||||
case PROP_CUDAENC_GPU_ID:
|
||||
@@ -689,10 +600,6 @@ gst_v4l2_video_enc_get_property_cuvid (GObject * object,
|
||||
g_value_set_string(value, "1,30,1");
|
||||
break;
|
||||
|
||||
case PROP_SEI_UUID:
|
||||
g_value_set_string (value, self->sei_uuid);
|
||||
break;
|
||||
|
||||
case PROP_CUDAENC_CONSTQP:
|
||||
break;
|
||||
|
||||
@@ -718,40 +625,6 @@ gst_v4l2_video_enc_get_property_cuvid (GObject * object,
|
||||
case PROP_COPY_METADATA:
|
||||
g_value_set_boolean (value, self->copy_meta);
|
||||
break;
|
||||
|
||||
case PROP_INTRA_FRAME_INTERVAL:
|
||||
g_value_set_uint(value, self->iframeinterval);
|
||||
break;
|
||||
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
case PROP_PEAK_BITRATE:
|
||||
g_value_set_uint(value, self->peak_bitrate);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_I_FRAMES:
|
||||
g_value_set_uint(value, self->quant_i_frames);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_P_FRAMES:
|
||||
g_value_set_uint(value, self->quant_p_frames);
|
||||
break;
|
||||
|
||||
case PROP_QUANT_B_FRAMES:
|
||||
g_value_set_uint(value, self->quant_b_frames);
|
||||
break;
|
||||
|
||||
case PROP_HW_PRESET_LEVEL:
|
||||
g_value_set_enum(value, self->hw_preset_level);
|
||||
break;
|
||||
|
||||
case PROP_MEASURE_LATENCY:
|
||||
g_value_set_boolean(value, self->measure_latency);
|
||||
break;
|
||||
|
||||
case PROP_RC_ENABLE:
|
||||
g_value_set_boolean(value, self->ratecontrol_enable);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* By default read from output */
|
||||
@@ -772,6 +645,10 @@ gst_v4l2_video_enc_open (GstVideoEncoder * encoder)
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
const gchar *mimetype;
|
||||
GstStructure *s;
|
||||
GstV4l2VideoEncClass *klass = NULL;
|
||||
if (is_cuvid == TRUE)
|
||||
klass = GST_V4L2_VIDEO_ENC_GET_CLASS (encoder);
|
||||
|
||||
#endif
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Opening");
|
||||
@@ -811,6 +688,19 @@ gst_v4l2_video_enc_open (GstVideoEncoder * encoder)
|
||||
} else
|
||||
g_print ("%s: failed to open trace file\n", __func__);
|
||||
}
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
if (strcmp (klass->codec_name, "H264") == 0
|
||||
|| strcmp (klass->codec_name, "H265") == 0){
|
||||
if (!klass->set_encoder_properties (encoder)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!set_v4l2_video_encoder_properties (encoder)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
|
||||
@@ -1010,10 +900,8 @@ gboolean is_drc (GstVideoEncoder *encoder, GstCaps *input_caps)
|
||||
gst_structure_get_int(input_caps_st, "height", &new_height);
|
||||
|
||||
GST_INFO_OBJECT(encoder, "curr resolution: [%dx%d], new resolution: [%dx%d]", curr_width, curr_height, new_width, new_height);
|
||||
if ((curr_width != new_width) || (curr_height != new_height)) {
|
||||
gst_caps_unref(sink_caps);
|
||||
if ((curr_width != new_width) || (curr_height != new_height))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gst_caps_unref(sink_caps);
|
||||
return FALSE;
|
||||
@@ -1024,20 +912,13 @@ void set_encoder_src_caps (GstVideoEncoder *encoder, GstCaps *input_caps)
|
||||
GstStructure *src_caps_st, *input_caps_st;
|
||||
const GValue *framerate = NULL;
|
||||
GstCaps *src_caps = gst_caps_make_writable(gst_pad_get_current_caps(encoder->srcpad));
|
||||
if (!src_caps) {
|
||||
GST_WARNING_OBJECT(encoder, "No current caps available on srcpad");
|
||||
return;
|
||||
}
|
||||
|
||||
src_caps_st = gst_caps_get_structure(src_caps, 0);
|
||||
input_caps_st = gst_caps_get_structure(input_caps, 0);
|
||||
framerate = gst_structure_get_value(input_caps_st, "framerate");
|
||||
if (framerate)
|
||||
gst_structure_set_value(src_caps_st, "framerate", framerate);
|
||||
|
||||
gchar *caps_str = gst_caps_to_string(src_caps);
|
||||
GST_DEBUG_OBJECT(encoder, "enc_src_caps: %s", caps_str);
|
||||
g_free(caps_str);
|
||||
GST_DEBUG_OBJECT(encoder, "enc_src_caps: %s", gst_caps_to_string(src_caps));
|
||||
gst_pad_set_caps(encoder->srcpad, src_caps);
|
||||
gst_caps_unref(src_caps);
|
||||
}
|
||||
@@ -1057,11 +938,6 @@ reconfigure_fps (GstVideoEncoder *encoder, GstCaps *input_caps, guint label)
|
||||
/*Check if current fps is same as in newly received caps */
|
||||
GstStructure *sink_pad_st, *input_caps_st;
|
||||
GstCaps *sink_caps = gst_pad_get_current_caps(encoder->sinkpad);
|
||||
if (!sink_caps) {
|
||||
GST_WARNING_OBJECT(encoder, "No current caps available on sinkpad");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sink_pad_st = gst_caps_get_structure(sink_caps, 0);
|
||||
input_caps_st = gst_caps_get_structure(input_caps, 0);
|
||||
gst_structure_get_fraction (sink_pad_st, "framerate", &curr_fps_n, &curr_fps_d);
|
||||
@@ -1072,7 +948,6 @@ reconfigure_fps (GstVideoEncoder *encoder, GstCaps *input_caps, guint label)
|
||||
enc_config.fps_d = new_fps_d;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT(encoder, "No change in framerate");
|
||||
gst_caps_unref(sink_caps);
|
||||
return TRUE;
|
||||
}
|
||||
memset (&control, 0, sizeof (control));
|
||||
@@ -1088,11 +963,9 @@ reconfigure_fps (GstVideoEncoder *encoder, GstCaps *input_caps, guint label)
|
||||
ret = v4l2object->ioctl (v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret < 0) {
|
||||
GST_WARNING_OBJECT (encoder, "Error in reconfiguring fps\n");
|
||||
gst_caps_unref(sink_caps);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gst_caps_unref(sink_caps);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
@@ -1109,7 +982,6 @@ gst_v4l2_video_enc_set_format (GstVideoEncoder * encoder,
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
const gchar *mimetype;
|
||||
GstStructure *s;
|
||||
gboolean drc = FALSE;
|
||||
#endif
|
||||
|
||||
GST_DEBUG_OBJECT (self, "Setting format: %" GST_PTR_FORMAT, state->caps);
|
||||
@@ -1125,7 +997,6 @@ gst_v4l2_video_enc_set_format (GstVideoEncoder * encoder,
|
||||
if (is_cuvid == TRUE) {
|
||||
if (is_drc (encoder, state->caps)) {
|
||||
/*TODO: Reset encoder to allocate new buffer size at encoder output plane*/
|
||||
drc = TRUE;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (self, "Not DRC. Reconfigure encoder with new fps if required");
|
||||
if (!reconfigure_fps(encoder, state->caps, V4L2_CID_MPEG_VIDEOENC_RECONFIG_FPS))
|
||||
@@ -1145,12 +1016,6 @@ gst_v4l2_video_enc_set_format (GstVideoEncoder * encoder,
|
||||
|
||||
gst_video_codec_state_unref (self->input_state);
|
||||
self->input_state = NULL;
|
||||
|
||||
if (drc == TRUE) {
|
||||
g_print("Drc detected, reconfiguring encoder\n");
|
||||
gst_v4l2_video_enc_close(encoder);
|
||||
gst_v4l2_video_enc_open(encoder);
|
||||
}
|
||||
}
|
||||
|
||||
outcaps = gst_pad_get_pad_template_caps (encoder->srcpad);
|
||||
@@ -1322,7 +1187,7 @@ negotiate_profile_and_level (GstCapsFeatures * features, GstStructure * s,
|
||||
|
||||
if (!failed && klass->level_cid && get_string_list (s, "level", &levels)) {
|
||||
GList *l;
|
||||
gchar *tier = NULL;
|
||||
gchar *tier;
|
||||
GQueue tiers = G_QUEUE_INIT;
|
||||
|
||||
for (l = levels.head; l; l = l->next) {
|
||||
@@ -1332,27 +1197,29 @@ negotiate_profile_and_level (GstCapsFeatures * features, GstStructure * s,
|
||||
|
||||
GST_TRACE_OBJECT (ctx->self, "Trying level %s", level);
|
||||
|
||||
if (!strcmp (klass->codec_name, "H265")) {
|
||||
/* Setting default tier*/
|
||||
tier = "main";
|
||||
}
|
||||
|
||||
if (!failed && get_string_list(s, "tier", &tiers)) {
|
||||
GList *lt;
|
||||
|
||||
for (lt = tiers.head; lt; lt = lt->next) {
|
||||
tier = lt->data;
|
||||
GST_TRACE_OBJECT(ctx->self, "Trying tier %s", tier);
|
||||
if (is_cuvid == FALSE) {
|
||||
if (!strcmp (klass->codec_name, "H265")) {
|
||||
/* Setting default tier*/
|
||||
tier = "main";
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp (klass->codec_name, "H265")) {
|
||||
gchar *separator = "_";
|
||||
gint size = strlen(level) + strlen(separator) + strlen(tier) + 1;
|
||||
gchar tier_level[size];
|
||||
if (!failed && get_string_list(s, "tier", &tiers)) {
|
||||
GList *lt;
|
||||
|
||||
stpcpy(stpcpy(stpcpy(tier_level, tier), separator), level);
|
||||
level = tier_level;
|
||||
for (lt = tiers.head; lt; lt = lt->next) {
|
||||
tier = lt->data;
|
||||
GST_TRACE_OBJECT(ctx->self, "Trying tier %s", tier);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp (klass->codec_name, "H265")) {
|
||||
gchar *separator = "_";
|
||||
gint size = strlen(level) + strlen(separator) + strlen(tier) + 1;
|
||||
gchar tier_level[size];
|
||||
|
||||
stpcpy(stpcpy(stpcpy(tier_level, tier), separator), level);
|
||||
level = tier_level;
|
||||
}
|
||||
}
|
||||
|
||||
control.id = klass->level_cid;
|
||||
@@ -1440,27 +1307,6 @@ gst_v4l2_video_enc_negotiate (GstVideoEncoder * encoder)
|
||||
}
|
||||
}
|
||||
|
||||
/* Set CUDA ENC GPU ID. This should be set before calling S_FMT on the capture plane*/
|
||||
if (is_cuvid == TRUE) {
|
||||
GstV4l2Object *v4l2object = self->v4l2output;
|
||||
struct v4l2_ext_control control;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
memset(&control, 0, sizeof(control));
|
||||
memset(&ctrls, 0, sizeof(ctrls));
|
||||
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &control;
|
||||
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
|
||||
|
||||
control.id = V4L2_CID_MPEG_VIDEO_CUDA_GPU_ID;
|
||||
control.value = self->cudaenc_gpu_id;
|
||||
|
||||
if (v4l2object->ioctl(v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0) {
|
||||
GST_WARNING_OBJECT(self, "Error in setting CUDA ENC GPU ID\n");
|
||||
goto not_negotiated;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_V4L2_TARGET_NV
|
||||
if (klass->profile_cid && !ctx.profile) {
|
||||
struct v4l2_control control = { 0, };
|
||||
@@ -1871,7 +1717,6 @@ gst_v4l2_video_enc_handle_frame (GstVideoEncoder * encoder,
|
||||
self->v4l2output->sei_payload = NULL;
|
||||
if (meta->sei_metadata_type == (guint)GST_USER_SEI_META)
|
||||
{
|
||||
self->v4l2output->sei_uuid = g_strdup (self->sei_uuid);
|
||||
self->v4l2output->sei_payload_size = meta->sei_metadata_size;
|
||||
self->v4l2output->sei_payload = (void *) meta->sei_metadata_ptr;
|
||||
}
|
||||
@@ -1899,13 +1744,6 @@ gst_v4l2_video_enc_handle_frame (GstVideoEncoder * encoder,
|
||||
/* ERRORS */
|
||||
activate_failed:
|
||||
{
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
/* Release the entry added to the queue in the case of failure */
|
||||
if (self->tracing_file_enc) {
|
||||
in_time = g_queue_pop_tail (self->got_frame_pt);
|
||||
g_free (in_time);
|
||||
}
|
||||
#endif
|
||||
GST_ELEMENT_ERROR (self, RESOURCE, SETTINGS,
|
||||
(_("Failed to allocate required memory.")),
|
||||
("Buffer pool activation failed"));
|
||||
@@ -1935,13 +1773,6 @@ process_failed:
|
||||
}
|
||||
drop:
|
||||
{
|
||||
#ifdef USE_V4L2_TARGET_NV
|
||||
/* Release the entry added to the queue in the case of failure */
|
||||
if (self->tracing_file_enc) {
|
||||
in_time = g_queue_pop_tail (self->got_frame_pt);
|
||||
g_free (in_time);
|
||||
}
|
||||
#endif
|
||||
gst_video_encoder_finish_frame (encoder, frame);
|
||||
return ret;
|
||||
}
|
||||
@@ -2253,14 +2084,12 @@ gst_v4l2_video_enc_init (GstV4l2VideoEnc * self)
|
||||
self->slice_output = FALSE;
|
||||
self->best_prev = NULL;
|
||||
self->buf_pts_prev = GST_CLOCK_STIME_NONE;
|
||||
self->sei_uuid = DEFAULT_SEI_UUID;
|
||||
if (is_cuvid == TRUE)
|
||||
{
|
||||
self->cudaenc_gpu_id = DEFAULT_CUDAENC_GPU_ID;
|
||||
self->cudaenc_preset_id = DEFAULT_CUDAENC_PRESET_ID;
|
||||
self->cudaenc_tuning_info_id = DEFAULT_TUNING_INFO_PRESET;
|
||||
self->iframeinterval = DEFAULT_INTRA_FRAME_INTERVAL_CUVID;
|
||||
self->hw_preset_level = 0;
|
||||
}
|
||||
|
||||
const gchar * latency = g_getenv("NVDS_ENABLE_LATENCY_MEASUREMENT");
|
||||
@@ -2335,7 +2164,7 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
"Set bitrate for v4l2 encode",
|
||||
0, G_MAXUINT, GST_V4L2_VIDEO_ENC_BITRATE_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_PLAYING));
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INTRA_FRAME_INTERVAL,
|
||||
g_param_spec_uint ("iframeinterval", "Intra Frame interval",
|
||||
@@ -2347,9 +2176,9 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_QUANT_RANGE,
|
||||
g_param_spec_string ("qp-range", "qpp-range",
|
||||
"Quantization range for P, I and B frame,\n"
|
||||
"\t\t\tUse string with unsigned integer values of Qunatization Range \n"
|
||||
"\t\t\tin MinQpP,MaxQpP:MinQpI,MaxQpI:MinQpB,MaxQpB order, to set the property.",
|
||||
"Qunatization range for P, I and B frame,\n"
|
||||
"\t\t\t Use string with unsigned integer values of Qunatization Range \n"
|
||||
"\t\t\t in MinQpP,MaxQpP:MinQpI,MaxQpI:MinQpB,MaxQpB order, to set the property.",
|
||||
"-1,-1:-1,-1:-1,-1",
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
|
||||
|
||||
@@ -2362,27 +2191,14 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
|
||||
if (is_cuvid == TRUE) {
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CUDAENC_MEM_TYPE,
|
||||
g_param_spec_enum ("cudaenc-memtype",
|
||||
"Memory type for cuda encoder YUV buffers",
|
||||
"Set to specify memory type for cuda input buffers",
|
||||
GST_TYPE_V4L2_VID_CUDAENC_MEM_TYPE, DEFAULT_CUDAENC_MEM_TYPE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_INTRA_REFRESH,
|
||||
g_param_spec_string ("intra-refresh", "intra-refresh",
|
||||
"Intra Refresh Parameters,\n"
|
||||
"\t\t\tUse string with unsigned integer values of Intra Refresh \n"
|
||||
"\t\t\tin enableIntraRefresh,intraRefreshPeriod,intraRefreshCnt in same order to set the property. e.g. 1,30,1",
|
||||
"0,0,0",
|
||||
"1,30,1",
|
||||
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT)));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_SEI_UUID,
|
||||
g_param_spec_string ("sei-uuid",
|
||||
"SEI UUID String of 16 bytes",
|
||||
"SEI UUID String of 16 bytes to be set into SEI data",
|
||||
DEFAULT_SEI_UUID, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_CUDAENC_GPU_ID,
|
||||
g_param_spec_uint ("gpu-id",
|
||||
"GPU Device ID",
|
||||
@@ -2487,30 +2303,11 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
} else if (is_cuvid == FALSE) {
|
||||
g_object_class_install_property (gobject_class, PROP_COPY_TIMESTAMP,
|
||||
g_param_spec_boolean ("copy-timestamp",
|
||||
"Set the copy timestamp flag",
|
||||
"Enabling the flag allows to copy the timestamps from input to the capture stream.",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_MAX_PERF,
|
||||
g_param_spec_boolean ("maxperf-enable",
|
||||
"Enable or Disable Max Performance mode. [Deprecated]",
|
||||
"Enable or Disable Max Performance mode [Deprecated]",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
}
|
||||
|
||||
/* Common properties */
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
{
|
||||
g_object_class_install_property (gobject_class, PROP_PEAK_BITRATE,
|
||||
g_param_spec_uint ("peak-bitrate", "Peak Bitrate",
|
||||
"Peak bitrate in variable control-rate\n"
|
||||
"\t\t\tThe value must be >= bitrate\n"
|
||||
"\t\t\t(1.2*bitrate) is set by default(Default: 0)\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"maxbitrate\"",
|
||||
"\t\t\t The value must be >= bitrate\n"
|
||||
"\t\t\t (1.2*bitrate) is set by default(Default: 0)",
|
||||
0, G_MAXUINT, GST_V4L2_VIDEO_ENC_PEAK_BITRATE_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_PLAYING));
|
||||
@@ -2518,9 +2315,8 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
g_object_class_install_property (gobject_class, PROP_QUANT_I_FRAMES,
|
||||
g_param_spec_uint ("quant-i-frames", "I-Frame Quantization",
|
||||
"Quantization parameter for I-frames (0xffffffff=component default),\n"
|
||||
"\t\t\tuse with ratecontrol-enable = 0\n"
|
||||
"\t\t\tand preset-level = 0\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"initqp\"",
|
||||
"\t\t\t use with ratecontrol-enable = 0\n"
|
||||
"\t\t\t and preset-level = 0",
|
||||
0, G_MAXUINT, GST_V4L2_VIDEO_ENC_QUANT_I_FRAMES_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
@@ -2528,9 +2324,8 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
g_object_class_install_property (gobject_class, PROP_QUANT_P_FRAMES,
|
||||
g_param_spec_uint ("quant-p-frames", "P-Frame Quantization",
|
||||
"Quantization parameter for P-frames (0xffffffff=component default),\n"
|
||||
"\t\t\tuse with ratecontrol-enable = 0\n"
|
||||
"\t\t\tand preset-level = 0\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"initqp\"",
|
||||
"\t\t\t use with ratecontrol-enable = 0\n"
|
||||
"\t\t\t and preset-level = 0",
|
||||
0, G_MAXUINT, GST_V4L2_VIDEO_ENC_QUANT_P_FRAMES_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
@@ -2538,26 +2333,23 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
g_object_class_install_property (gobject_class, PROP_QUANT_B_FRAMES,
|
||||
g_param_spec_uint ("quant-b-frames", "B-Frame Quantization",
|
||||
"Quantization parameter for B-frames (0xffffffff=component default),\n"
|
||||
"\t\t\tuse with ratecontrol-enable = 0\n"
|
||||
"\t\t\tand preset-level = 0\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"initqp\"",
|
||||
"\t\t\t use with ratecontrol-enable = 0\n"
|
||||
"\t\t\t and preset-level = 0",
|
||||
0, G_MAXUINT, GST_V4L2_VIDEO_ENC_QUANT_B_FRAMES_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_HW_PRESET_LEVEL,
|
||||
g_param_spec_enum ("preset-level", "HWpresetlevelforencoder",
|
||||
"HW preset level for encoder\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"preset-id\" and \"tuning-info-id\"",
|
||||
GST_TYPE_V4L2_VID_ENC_HW_PRESET_LEVEL, (is_cuvid == TRUE) ? 0 :
|
||||
"HW preset level for encoder",
|
||||
GST_TYPE_V4L2_VID_ENC_HW_PRESET_LEVEL,
|
||||
DEFAULT_HW_PRESET_LEVEL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_VIRTUAL_BUFFER_SIZE,
|
||||
g_param_spec_uint ("vbv-size", "vb size attribute",
|
||||
"virtual buffer size\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"vbvbufsize\"",
|
||||
"virtual buffer size ",
|
||||
0, G_MAXUINT, DEFAULT_VBV_SIZE,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
@@ -2572,10 +2364,24 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
g_object_class_install_property (gobject_class, PROP_RC_ENABLE,
|
||||
g_param_spec_boolean ("ratecontrol-enable",
|
||||
"Enable or Disable rate control mode",
|
||||
"Enable or Disable rate control mode\n"
|
||||
"\t\t\tThis will be deprecated in future for Thor. Use the new defined property \"constqp\"",
|
||||
"Enable or Disable rate control mode",
|
||||
TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_COPY_TIMESTAMP,
|
||||
g_param_spec_boolean ("copy-timestamp",
|
||||
"Set the copy timestamp flag",
|
||||
"Enabling the flag allows to copy the timestamps from input to the capture stream.",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
g_object_class_install_property (gobject_class, PROP_MAX_PERF,
|
||||
g_param_spec_boolean ("maxperf-enable",
|
||||
"Enable or Disable Max Performance mode",
|
||||
"Enable or Disable Max Performance mode",
|
||||
FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
||||
GST_PARAM_MUTABLE_READY));
|
||||
|
||||
/* Signals */
|
||||
gst_v4l2_signals[SIGNAL_FORCE_IDR] =
|
||||
g_signal_new ("force-IDR",
|
||||
@@ -2586,7 +2392,6 @@ gst_v4l2_video_enc_class_init (GstV4l2VideoEncClass * klass)
|
||||
|
||||
klass->force_IDR = gst_v4l2_video_encoder_forceIDR;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
video_encoder_class->open = GST_DEBUG_FUNCPTR (gst_v4l2_video_enc_open);
|
||||
@@ -2696,7 +2501,7 @@ gst_v4l2_video_enc_register (GstPlugin * plugin, GType type,
|
||||
const char *codec, const gchar * basename, const gchar * device_path,
|
||||
GstCaps * sink_caps, GstCaps * codec_caps, GstCaps * src_caps)
|
||||
{
|
||||
GTypeQuery type_query = { 0, };
|
||||
GTypeQuery type_query;
|
||||
GTypeInfo type_info = { 0, };
|
||||
GType subtype;
|
||||
gchar *type_name;
|
||||
@@ -2821,7 +2626,6 @@ gst_v4l2_videnc_tuning_info_get_type (void)
|
||||
return qtype;
|
||||
}
|
||||
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
static GType
|
||||
gst_v4l2_videnc_hw_preset_level_get_type (void)
|
||||
{
|
||||
@@ -2843,7 +2647,6 @@ gst_v4l2_videnc_hw_preset_level_get_type (void)
|
||||
}
|
||||
return qtype;
|
||||
}
|
||||
#endif
|
||||
|
||||
static GType
|
||||
gst_v4l2_videnc_ratecontrol_get_type (void)
|
||||
@@ -2972,39 +2775,6 @@ setHWPresetType (GstV4l2Object * v4l2object, guint label,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
setInitQPParams(GstV4l2Object *v4l2object,
|
||||
guint32 quantI, guint32 quantP, guint32 quantB)
|
||||
{
|
||||
struct v4l2_ext_control control;
|
||||
struct v4l2_ext_controls ctrls;
|
||||
gint ret;
|
||||
v4l2_ctrl_video_init_qp init_qp;
|
||||
|
||||
memset(&control, 0, sizeof(control));
|
||||
memset(&ctrls, 0, sizeof(ctrls));
|
||||
|
||||
ctrls.count = 1;
|
||||
ctrls.controls = &control;
|
||||
ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
|
||||
|
||||
init_qp.IInitQP = quantI;
|
||||
init_qp.PInitQP = quantP;
|
||||
init_qp.BInitQP = quantB;
|
||||
|
||||
control.id = V4L2_CID_MPEG_VIDEOENC_INIT_FRAME_QP;
|
||||
control.string = (gchar *)&init_qp;
|
||||
|
||||
ret = v4l2object->ioctl(v4l2object->video_fd, VIDIOC_S_EXT_CTRLS, &ctrls);
|
||||
if (ret < 0)
|
||||
{
|
||||
g_print("Error while setting Init Frame QP params\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
setIntraRefreshParams (GstV4l2Object * v4l2object, guint label, guint enableIntraRefresh,
|
||||
guint intraRefreshPeriod, guint intraRefreshCnt)
|
||||
@@ -3070,7 +2840,6 @@ setQpRange (GstV4l2Object * v4l2object, guint label, guint MinQpI, guint MaxQpI,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if !defined(USE_V4L2_TARGET_NV_X86) && !defined(AARCH64_IS_SBSA)
|
||||
static void
|
||||
gst_v4l2_video_encoder_forceIDR (GstV4l2VideoEnc * self)
|
||||
{
|
||||
@@ -3094,7 +2863,7 @@ gst_v4l2_video_encoder_forceIDR (GstV4l2VideoEnc * self)
|
||||
if (ret < 0)
|
||||
g_print ("Error while signalling force IDR\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
gboolean
|
||||
set_v4l2_video_encoder_properties (GstVideoEncoder * encoder)
|
||||
{
|
||||
@@ -3156,14 +2925,11 @@ set_v4l2_video_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
}
|
||||
|
||||
/* Only one of either HW PRESETS or CUDA PRESETS are set at a time.
|
||||
* If CUDA Presets are given, HW Preset in overridden in CUVID path
|
||||
*/
|
||||
if (video_enc->hw_preset_level) {
|
||||
if (!setHWPresetType(video_enc->v4l2output,
|
||||
if (!setHWPresetType (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_HW_PRESET_TYPE_PARAM,
|
||||
video_enc->hw_preset_level)) {
|
||||
g_print("S_EXT_CTRLS for HW_PRESET_TYPE_PARAM failed\n");
|
||||
g_print ("S_EXT_CTRLS for HW_PRESET_TYPE_PARAM failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -3178,23 +2944,33 @@ set_v4l2_video_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
|
||||
if (video_enc->set_intrarefresh) {
|
||||
if (!setIntraRefreshParams(video_enc->v4l2output, V4L2_CID_MPEG_VIDEOENC_INTRA_REFRESH,
|
||||
video_enc->enableIntraRefresh, video_enc->intraRefreshPeriod,
|
||||
video_enc->intraRefreshCnt))
|
||||
{
|
||||
if (!setIntraRefreshParams (video_enc->v4l2output, V4L2_CID_MPEG_VIDEOENC_INTRA_REFRESH,
|
||||
video_enc->enableIntraRefresh, video_enc->intraRefreshPeriod, video_enc->intraRefreshCnt)) {
|
||||
g_print ("S_EXT_CTRLS for INTRA_REFRESH failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (video_enc->quant_i_frames != 0xffffffff &&
|
||||
video_enc->quant_p_frames != 0xffffffff &&
|
||||
video_enc->quant_b_frames != 0xffffffff)
|
||||
{
|
||||
if (!setInitQPParams (video_enc->v4l2output,
|
||||
video_enc->quant_i_frames, video_enc->quant_p_frames,
|
||||
video_enc->quant_b_frames)) {
|
||||
g_print ("S_EXT_CTRLS for V4L2_CID_MPEG_VIDEOENC_INIT_FRAME_QP failed\n");
|
||||
if (video_enc->quant_i_frames != 0xffffffff && !video_enc->ratecontrol_enable) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, video_enc->quant_i_frames)) {
|
||||
g_print ("S_EXT_CTRLS for H264_I_FRAME_QP failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (video_enc->quant_p_frames != 0xffffffff && !video_enc->ratecontrol_enable) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP, video_enc->quant_p_frames)) {
|
||||
g_print ("S_EXT_CTRLS for H264_P_FRAME_QP failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (video_enc->quant_b_frames != 0xffffffff && !video_enc->ratecontrol_enable) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP, video_enc->quant_b_frames)) {
|
||||
g_print ("S_EXT_CTRLS for H264_B_FRAME_QP failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -3215,13 +2991,11 @@ set_v4l2_video_encoder_properties (GstVideoEncoder * encoder)
|
||||
}
|
||||
}
|
||||
|
||||
if (is_cuvid == false) {
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_VIRTUALBUFFER_SIZE,
|
||||
video_enc->virtual_buffer_size)) {
|
||||
g_print ("S_EXT_CTRLS for VIRTUALBUFFER_SIZE failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!set_v4l2_video_mpeg_class (video_enc->v4l2output,
|
||||
V4L2_CID_MPEG_VIDEOENC_VIRTUALBUFFER_SIZE,
|
||||
video_enc->virtual_buffer_size)) {
|
||||
g_print ("S_EXT_CTRLS for VIRTUALBUFFER_SIZE failed\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/*
|
||||
* Copyright (C) 2014 SUMOMO Computer Association.
|
||||
* Author: ayaka <ayaka@soulik.info>
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2018-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LGPL-2.0-only
|
||||
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -90,12 +89,10 @@ struct _GstV4l2VideoEnc
|
||||
gboolean ratecontrol_enable;
|
||||
gboolean force_idr;
|
||||
gboolean force_intra;
|
||||
gchar *sei_uuid;
|
||||
gboolean maxperf_enable;
|
||||
gboolean copy_timestamp;
|
||||
FILE *tracing_file_enc;
|
||||
GQueue *got_frame_pt;
|
||||
guint32 cudaenc_mem_type;
|
||||
guint32 cudaenc_gpu_id;
|
||||
guint32 cudaenc_preset_id;
|
||||
guint32 cudaenc_tuning_info_id;
|
||||
@@ -105,7 +102,6 @@ struct _GstV4l2VideoEnc
|
||||
gdouble buffer_in_time;
|
||||
GHashTable* hash_pts_systemtime;
|
||||
gboolean copy_meta;
|
||||
gboolean enable_hwpreset;
|
||||
#endif
|
||||
|
||||
/* < private > */
|
||||
|
||||
@@ -26,15 +26,13 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include "gstv4l2object.h"
|
||||
|
||||
#define UUID_SIZE 16
|
||||
#define USER_DATA_UNREGISTERED_TYPE 5
|
||||
|
||||
gboolean check_uuid(uint8_t *stream, char *sei_uuid_string);
|
||||
uint8_t* parse_sei_unit(uint8_t * bs_ptr, guint *size, char *sei_uuid_string);
|
||||
uint8_t *parse_sei_data (uint8_t *bs, uint32_t size, uint32_t *payload_size,
|
||||
char *sei_uuid_string, guint32 pixelformat);
|
||||
uint8_t *parse_sei_data (uint8_t *bs, uint32_t size, uint32_t *payload_size, char *sei_uuid_string);
|
||||
|
||||
gboolean check_uuid(uint8_t *stream, char *sei_uuid_string)
|
||||
{
|
||||
@@ -109,25 +107,7 @@ uint8_t* parse_sei_unit(uint8_t * bs_ptr, guint *size, char *sei_uuid_string)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************
|
||||
|
||||
+------H264-----+
|
||||
|0|1|2|3|4|5|6|7|
|
||||
+-+-+-+-+-+-+-+-+
|
||||
|F|NRI| Type |
|
||||
+---------------+
|
||||
|
||||
+------------H265---------------+
|
||||
|0|1|2|3|4|5|6|7|0|1|2|3|4|5|6|7|
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||
|F| Type | LayerId | TID |
|
||||
+-------------+-----------------+
|
||||
|
||||
*************************************************************/
|
||||
|
||||
uint8_t *parse_sei_data (uint8_t *bs, uint32_t size, uint32_t *payload_size,
|
||||
char *sei_uuid_string, guint32 pixelformat)
|
||||
uint8_t *parse_sei_data (uint8_t *bs, uint32_t size, uint32_t *payload_size, char *sei_uuid_string)
|
||||
{
|
||||
if (sei_uuid_string == NULL)
|
||||
return NULL;
|
||||
@@ -144,11 +124,8 @@ uint8_t *parse_sei_data (uint8_t *bs, uint32_t size, uint32_t *payload_size,
|
||||
checklen++;
|
||||
else if (checklen == 3 && *bs_ptr++ == 0x01)
|
||||
checklen++;
|
||||
else if (checklen == 4 && ((pixelformat == V4L2_PIX_FMT_H264) ? *bs_ptr == 0x06 : (((*bs_ptr >> 1) & 0x3f) == 0x27)))
|
||||
else if (checklen == 4 && *bs_ptr++ == 0x06)
|
||||
{
|
||||
bs_ptr++;
|
||||
if (pixelformat == V4L2_PIX_FMT_H265)
|
||||
bs_ptr++;
|
||||
payload = parse_sei_unit(bs_ptr, &sei_payload_size, sei_uuid_string);
|
||||
checklen = 0;
|
||||
if (payload != NULL)
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2024-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
|
||||
/* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*/
|
||||
|
||||
#include "wsl_utils.h"
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2024-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
|
||||
/* Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*/
|
||||
|
||||
#ifndef _WSL_UTILS_
|
||||
|
||||
255
nvbufsurface.h
255
nvbufsurface.h
@@ -1,13 +1,11 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: Copyright (c) 2019-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
|
||||
* Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
|
||||
* property and proprietary rights in and to this material, related
|
||||
* documentation and any modifications thereto. Any use, reproduction,
|
||||
* disclosure or distribution of this material and related documentation
|
||||
* without an express license agreement from NVIDIA CORPORATION or
|
||||
* its affiliates is strictly prohibited.
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -288,30 +286,6 @@ typedef enum
|
||||
NVBUF_COLOR_FORMAT_UYVY_709_ER,
|
||||
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 planar */
|
||||
NVBUF_COLOR_FORMAT_UYVY_2020,
|
||||
/** Specifies 16 bit GRAY scale - single plane */
|
||||
NVBUF_COLOR_FORMAT_GRAY16_LE,
|
||||
/** Specifies 64 bit BGRA (B16 G16 R16 A16) interleaved */
|
||||
NVBUF_COLOR_FORMAT_BGRA64_LE,
|
||||
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 multi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_2020,
|
||||
/** Specifies BT.601_ER colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_10LE_ER,
|
||||
/** Specifies BT.709 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_10LE_709,
|
||||
/** Specifies BT.709_ER colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_10LE_709_ER,
|
||||
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 10-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_10LE_2020,
|
||||
/** Specifies BT.601 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_12LE,
|
||||
/** Specifies BT.601_ER colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_12LE_ER,
|
||||
/** Specifies BT.709 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_12LE_709,
|
||||
/** Specifies BT.709_ER colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_12LE_709_ER,
|
||||
/** Specifies BT.2020 colorspace - Y/CbCr 4:2:2 12-bit semi-planar. */
|
||||
NVBUF_COLOR_FORMAT_NV16_12LE_2020,
|
||||
NVBUF_COLOR_FORMAT_LAST
|
||||
} NvBufSurfaceColorFormat;
|
||||
|
||||
@@ -375,9 +349,7 @@ typedef struct NvBufSurfacePlaneParamsEx
|
||||
uint32_t physicaladdress[NVBUF_MAX_PLANES];
|
||||
/** flags associated with planes */
|
||||
uint64_t flags[NVBUF_MAX_PLANES];
|
||||
/** DRM modifier for plane */
|
||||
uint64_t drmModifier[NVBUF_MAX_PLANES];
|
||||
/** Holds the reserved space for future use. */
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
|
||||
} NvBufSurfacePlaneParamsEx;
|
||||
|
||||
@@ -400,25 +372,19 @@ typedef struct NvBufSurfacePlaneParams
|
||||
uint32_t psize[NVBUF_MAX_PLANES];
|
||||
/** Holds the number of bytes occupied by a pixel in each plane. */
|
||||
uint32_t bytesPerPix[NVBUF_MAX_PLANES];
|
||||
/** Holds the reserved space for future use. */
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING * NVBUF_MAX_PLANES];
|
||||
} NvBufSurfacePlaneParams;
|
||||
|
||||
|
||||
/**
|
||||
* Holds Chroma Subsampling parameters for NvBufSurface allocation.
|
||||
* The members chromaLocHoriz and chromaLocVert accept these values:
|
||||
* 0: Left horizontal or top vertical position
|
||||
* 1: Center horizontal or center vertical position
|
||||
* 2: Right horizontal or bottom vertical position
|
||||
*/
|
||||
typedef struct NvBufSurfaceChromaSubsamplingParams
|
||||
{
|
||||
/** location settings */
|
||||
uint8_t chromaLocHoriz;
|
||||
uint8_t chromaLocVert;
|
||||
/** Reserved for alignment */
|
||||
uint8_t _reserved[6];
|
||||
} NvBufSurfaceChromaSubsamplingParams;
|
||||
|
||||
/**
|
||||
@@ -444,8 +410,6 @@ typedef struct NvBufSurfaceCreateParams {
|
||||
NvBufSurfaceLayout layout;
|
||||
/** Holds the type of memory to be allocated. */
|
||||
NvBufSurfaceMemType memType;
|
||||
/** Holds the reserved space for future use. */
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
} NvBufSurfaceCreateParams;
|
||||
|
||||
/**
|
||||
@@ -453,24 +417,24 @@ typedef struct NvBufSurfaceCreateParams {
|
||||
* (Applicable for NvBufSurfaceAllocate API)
|
||||
*/
|
||||
typedef struct NvBufSurfaceAllocateParams {
|
||||
/** Hold legacy NvBufSurface creation parameters */
|
||||
/** Hold legacy NvBufSurface creation parameters */
|
||||
NvBufSurfaceCreateParams params;
|
||||
/** Display scan format */
|
||||
/** Display scan format */
|
||||
NvBufSurfaceDisplayScanFormat displayscanformat;
|
||||
/** Chroma Subsampling parameters */
|
||||
/** Chroma Subsampling parameters */
|
||||
NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
|
||||
/** components tag to be used for memory allocation */
|
||||
/** components tag to be used for memory allocation */
|
||||
NvBufSurfaceTag memtag;
|
||||
/** disable pitch padding allocation only applicable for cuda and system memory allocation
|
||||
pitch would be width times bytes per pixel for the plane, for odd width it would be
|
||||
multiple of 2, also note for some non standard video resolution cuda kernels may fail
|
||||
/** disable pitch padding allocation only applicable for cuda and system memory allocation
|
||||
pitch would be width times bytes per pixel for the plane, for odd width it would be
|
||||
multiple of 2, also note for some non standard video resolution cuda kernels may fail
|
||||
due to unaligned pitch
|
||||
*/
|
||||
*/
|
||||
bool disablePitchPadding;
|
||||
/** Used void* from custom param for 64 bit machine, using other uint32_t param */
|
||||
/** Used void* from custom param for 64 bit machine, using other uint32_t param */
|
||||
uint32_t _reservedParam;
|
||||
/** Holds the reserved space for future use. */
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING-1];
|
||||
} NvBufSurfaceAllocateParams;
|
||||
|
||||
/**
|
||||
@@ -481,11 +445,7 @@ typedef struct NvBufSurfaceMappedAddr {
|
||||
void * addr[NVBUF_MAX_PLANES];
|
||||
/** Holds a pointer to a mapped EGLImage. */
|
||||
void *eglImage;
|
||||
/** Holds a pointer to a mapped NVRM memory */
|
||||
void *nvmmPtr;
|
||||
/** Holds a pointer to a mapped CUDA memory */
|
||||
void *cudaPtr;
|
||||
/** Holds the reserved space for future use. */
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
} NvBufSurfaceMappedAddr;
|
||||
|
||||
@@ -510,32 +470,6 @@ typedef struct NvBufSurfaceParamsEx {
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
} NvBufSurfaceParamsEx;
|
||||
|
||||
/**
|
||||
* Holds information of CUDA buffer.
|
||||
* Applicable for tegra OpenRM only.
|
||||
*/
|
||||
typedef struct NvBufSurfaceCudaBuffer {
|
||||
/**
|
||||
* Holds a base pointer to allocated CUDA memory.
|
||||
* It is different from dataPtr when CUDA allocated
|
||||
* address is not page aligned for image buffers.
|
||||
* It is same as dataPtr for other buffers.
|
||||
*/
|
||||
void *basePtr;
|
||||
/**
|
||||
* Holds a page aligned data pointer to CUDA memory for image buffers
|
||||
* if CUDA allocated address is not page aligned.
|
||||
* It is same as basePtr for other buffers.
|
||||
*/
|
||||
void *dataPtr;
|
||||
/** Holds a pointer to external CUDA memory for imported CUDA buffers */
|
||||
void *extMem;
|
||||
/** Holds a pointer to external CUDA mipmaped array for imported CUDA buffers */
|
||||
void *mipmap;
|
||||
/** Reserved */
|
||||
uint8_t reserved[64];
|
||||
} NvBufSurfaceCudaBuffer;
|
||||
|
||||
/**
|
||||
* Hold the information of single buffer in the batch.
|
||||
*/
|
||||
@@ -565,10 +499,8 @@ typedef struct NvBufSurfaceParams {
|
||||
NvBufSurfaceMappedAddr mappedAddr;
|
||||
/** pointers of extended parameters of single buffer in the batch.*/
|
||||
NvBufSurfaceParamsEx *paramex;
|
||||
/** Holds a pointer to CUDA buffer. Applicable for only CUDA Device and CUDA Host memory on tegra OpenRM.*/
|
||||
NvBufSurfaceCudaBuffer *cudaBuffer;
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
void * _reserved[STRUCTURE_PADDING - 1];
|
||||
} NvBufSurfaceParams;
|
||||
|
||||
/**
|
||||
@@ -589,8 +521,6 @@ typedef struct NvBufSurface {
|
||||
NvBufSurfaceMemType memType;
|
||||
/** Holds a pointer to an array of batched buffers. */
|
||||
NvBufSurfaceParams *surfaceList;
|
||||
/** Holds a flag for Imported buffer. */
|
||||
bool isImportedBuf;
|
||||
|
||||
void * _reserved[STRUCTURE_PADDING];
|
||||
} NvBufSurface;
|
||||
@@ -620,23 +550,6 @@ typedef struct NvBufSurfaceMapPlaneParams
|
||||
uint8_t reserved[64];
|
||||
} NvBufSurfaceMapPlaneParams;
|
||||
|
||||
/**
|
||||
* CUDA IPC memory handle for NvBufSurface
|
||||
*/
|
||||
typedef struct NvBufSurfaceCudaIpcMemHandle_t
|
||||
{
|
||||
char reserved[64];
|
||||
} NvBufSurfaceCudaIpcMemHandle;
|
||||
|
||||
/**
|
||||
* The extended map parameters NvBufSurface
|
||||
*/
|
||||
typedef struct NvBufSurfaceExtendedMapParams_t
|
||||
{
|
||||
NvBufSurfaceCudaIpcMemHandle memHandle;
|
||||
void *reserved[64];
|
||||
} NvBufSurfaceExtendedMapParams;
|
||||
|
||||
/**
|
||||
* Holds buffer parameters to map the buffer received from another process.
|
||||
*/
|
||||
@@ -661,44 +574,9 @@ typedef struct NvBufSurfaceMapParams {
|
||||
NvBufSurfaceChromaSubsamplingParams chromaSubsampling;
|
||||
/** Holds plane parameters */
|
||||
NvBufSurfaceMapPlaneParams planes[NVBUF_MAX_PLANES];
|
||||
/** Holds the extended Map parameters */
|
||||
void *extendedMapParams;
|
||||
/** Holds the reserved space for future use. */
|
||||
void *_reserved[STRUCTURE_PADDING];
|
||||
} NvBufSurfaceMapParams;
|
||||
|
||||
/**
|
||||
* Holds information about mapped CUDA buffer
|
||||
*/
|
||||
typedef struct NvBufSurfaceNvmmBuffer {
|
||||
/** Holds a pointer to mapped nvmm memory */
|
||||
void *dataPtr;
|
||||
/** Holds a DMABUF FD */
|
||||
uint64_t bufferDesc;
|
||||
/** Reserved */
|
||||
uint8_t reserved[64];
|
||||
} NvBufSurfaceNvmmBuffer;
|
||||
|
||||
/**
|
||||
* Defines the type of underlying kernel driver detected for GPU access.
|
||||
*/
|
||||
typedef enum {
|
||||
NVBUF_DRIVER_TYPE_UNKNOWN = 0,
|
||||
NVBUF_DRIVER_TYPE_NVGPU,
|
||||
NVBUF_DRIVER_TYPE_RM
|
||||
} NvBufSurfaceDriverType;
|
||||
|
||||
/**
|
||||
* Holds information about the underlying device.
|
||||
*/
|
||||
typedef struct NvBufSurfaceDeviceInfo {
|
||||
/** The detected device type (nvgpu, OpenRM, etc.). */
|
||||
NvBufSurfaceDriverType driverType;
|
||||
/** Indicates if VIC is present on the platform. */
|
||||
bool isVicPresent;
|
||||
/** Reserved for future use. */
|
||||
uint8_t reserved[64];
|
||||
} NvBufSurfaceDeviceInfo;
|
||||
} NvBufSurfaceMapParams;
|
||||
|
||||
/**
|
||||
* \brief Allocates a batch of buffers.
|
||||
@@ -980,94 +858,7 @@ int NvBufSurfaceImport (NvBufSurface **out_nvbuf_surf, const NvBufSurfaceMapPara
|
||||
*/
|
||||
int NvBufSurfaceGetMapParams (const NvBufSurface *surf, int index, NvBufSurfaceMapParams *params);
|
||||
|
||||
/**
|
||||
* \brief Creates an CUDA buffer from the memory of one or more
|
||||
* \ref NvBufSurface buffers.
|
||||
*
|
||||
* Only memory type \ref NVBUF_MEM_SURFACE_ARRAY is supported.
|
||||
*
|
||||
* This function returns the created CUDA buffer by storing its address at
|
||||
* \a surf->surfaceList->mappedAddr->cudaPtr. (\a surf is a pointer to
|
||||
* an NvBufSurface. \a surfaceList is a pointer to an \ref NvBufSurfaceParams.
|
||||
* \a mappedAddr is a pointer to an \ref NvBufSurfaceMappedAddr.
|
||||
* \a cudaPtr is a pointer to an \ref NvBufSurfaceCudaBuffer.
|
||||
*
|
||||
* You can use this function in scenarios where a CUDA operation on Jetson
|
||||
* hardware memory (identified by \ref NVBUF_MEM_SURFACE_ARRAY) is required.
|
||||
* The NvBufSurfaceCudaBuffer struct provided by this function can be used
|
||||
* to get dataPtr of CUDA memory.
|
||||
*
|
||||
* @param[in,out] surf A pointer to an NvBufSurface structure. The function
|
||||
* stores a pointer to the created CUDA buffer in
|
||||
* a descendant of this structure; see the notes above.
|
||||
* @param[in] index Index of a buffer in the batch. -1 specifies all buffers
|
||||
* in the batch.
|
||||
*
|
||||
* @return 0 for success, or -1 otherwise.
|
||||
*/
|
||||
int NvBufSurfaceMapCudaBuffer (NvBufSurface *surf, int index);
|
||||
|
||||
/**
|
||||
* \brief Destroys the previously created CUDA buffer.
|
||||
*
|
||||
* @param[in] surf A pointer to an \ref NvBufSurface structure.
|
||||
* @param[in] index The index of a buffer in the batch. -1 specifies all
|
||||
* buffers in the batch.
|
||||
*
|
||||
* @return 0 if successful, or -1 otherwise.
|
||||
*/
|
||||
int NvBufSurfaceUnMapCudaBuffer (NvBufSurface *surf, int index);
|
||||
|
||||
/**
|
||||
* \brief Creates an NVMM buffer from the memory of one or more
|
||||
* \ref NvBufSurface buffers.
|
||||
*
|
||||
* Only memory type \ref NVBUF_MEM_CUDA_DEVICE and \ref NVBUF_MEM_CUDA_PINNED
|
||||
* are supported.
|
||||
*
|
||||
* This function returns the created NVMM buffer by storing its address at
|
||||
* \a surf->surfaceList->mappedAddr->nvmmPtr. (\a surf is a pointer to
|
||||
* an NvBufSurface. \a surfaceList is a pointer to an \ref NvBufSurfaceParams.
|
||||
* \a mappedAddr is a pointer to an \ref NvBufSurfaceMappedAddr.
|
||||
* \a nvmmPtr is a pointer to NVMM buffer of memory type \ref NVBUF_MEM_SURFACE_ARRAY.
|
||||
*
|
||||
* You can use this function in scenarios where a NVBUF_MEM_SURFACE_ARRAY operation
|
||||
* on Jetson hardware memory identified by \ref NVBUF_MEM_CUDA_DEVICE and
|
||||
* \ref NVBUF_MEM_CUDA_PINNED are required.
|
||||
*
|
||||
* @param[in,out] surf A pointer to an NvBufSurface structure. The function
|
||||
* stores a pointer to the created NVMM buffer in
|
||||
* a descendant of this structure; see the notes above.
|
||||
* @param[in] index Index of a buffer in the batch. -1 specifies all buffers
|
||||
* in the batch.
|
||||
*
|
||||
* @return 0 for success, or -1 otherwise.
|
||||
*/
|
||||
int NvBufSurfaceMapNvmmBuffer (NvBufSurface *surf, int index);
|
||||
|
||||
/**
|
||||
* \brief Destroys the previously created NVMM buffer.
|
||||
*
|
||||
* @param[in] surf A pointer to an \ref NvBufSurface structure.
|
||||
* @param[in] index The index of a buffer in the batch. -1 specifies all
|
||||
* buffers in the batch.
|
||||
*
|
||||
* @return 0 if successful, or -1 otherwise.
|
||||
*/
|
||||
int NvBufSurfaceUnMapNvmmBuffer (NvBufSurface *surf, int index);
|
||||
|
||||
/**
|
||||
* \brief Retrieves information about the underlying GPU device driver.
|
||||
*
|
||||
* @param[out] info Pointer to NvBufSurfaceDeviceInfo structure.
|
||||
*
|
||||
* @return 0 if successful, or -1 otherwise.
|
||||
*
|
||||
* This function attempts to determine if the system is using 'nvgpu' or
|
||||
* an OpenRM-based driver by checking loaded kernel modules. Also it checks
|
||||
* if VIC is present on the platform.
|
||||
*/
|
||||
int NvBufSurfaceGetDeviceInfo (NvBufSurfaceDeviceInfo *info);
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
daily-2025.08.25.1_l4t/l4t-r38.2
|
||||
jetson_36.3
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user