From fa094782c742303cd853bd64b7c8f69b46007b47 Mon Sep 17 00:00:00 2001 From: patcarter883 <33055183+patcarter883@users.noreply.github.com> Date: Fri, 22 Mar 2024 12:35:45 +0000 Subject: [PATCH] Add AV1 to decoders --- src/misc/coders/Decoders/index.js | 2 + src/misc/coders/Decoders/video/AV1NVDEC.js | 72 ++++++++++++++++++++++ src/misc/coders/Decoders/video/NVDEC.js | 2 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/misc/coders/Decoders/video/AV1NVDEC.js diff --git a/src/misc/coders/Decoders/index.js b/src/misc/coders/Decoders/index.js index 921a0e7..0ea51bf 100644 --- a/src/misc/coders/Decoders/index.js +++ b/src/misc/coders/Decoders/index.js @@ -16,6 +16,7 @@ import * as VideoDefault from './video/Default'; import * as VideoToolbox from './video/VideoToolbox'; import * as VP8CUVID from './video/VP8CUVID'; import * as VP9CUVID from './video/VP9CUVID'; +import * as AV1NVDEC from './video/AV1NVDEC'; class Registry { constructor(type) { @@ -112,6 +113,7 @@ const videoRegistry = new Registry('video'); videoRegistry.Register(VideoDefault); videoRegistry.Register(VideoToolbox); +videoRegistry.Register(AV1NVDEC); videoRegistry.Register(NVDEC); videoRegistry.Register(H264MMAL); videoRegistry.Register(H264CUVID); diff --git a/src/misc/coders/Decoders/video/AV1NVDEC.js b/src/misc/coders/Decoders/video/AV1NVDEC.js new file mode 100644 index 0000000..fd8f3cc --- /dev/null +++ b/src/misc/coders/Decoders/video/AV1NVDEC.js @@ -0,0 +1,72 @@ +import React from 'react'; + +import Helper from '../../helper'; + +function init(initialState) { + const state = { + ...initialState, + }; + + return state; +} + +function createMapping(settings, stream, skills) { + stream = Helper.InitStream(stream); + skills = Helper.InitSkills(skills); + + const mapping = { + global: [], + local: ['-hwaccel', 'nvdec', '-c:v', 'av1'], + }; + + return mapping; +} + +function Coder(props) { + const settings = init(props.settings); + const stream = Helper.InitStream(props.stream); + const skills = Helper.InitSkills(props.skills); + + const handleChange = (newSettings) => { + let automatic = false; + if (!newSettings) { + newSettings = settings; + automatic = true; + } + + props.onChange(newSettings, createMapping(newSettings, stream, skills), automatic); + }; + + React.useEffect(() => { + handleChange(null); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + return null; +} + +Coder.defaultProps = { + stream: {}, + settings: {}, + skills: {}, + onChange: function (settings, mapping) {}, +}; + +// -hwaccel nvdec + +const coder = 'cuda'; +const name = 'AV1 NVDEC (CUDA)'; +const codecs = ['av1']; +const type = 'video'; +const hwaccel = true; + +function defaults(stream, skills) { + const settings = init({}); + + return { + settings: settings, + mapping: createMapping(settings, stream, skills), + }; +} + +export { coder, name, codecs, type, hwaccel, defaults, Coder as component }; diff --git a/src/misc/coders/Decoders/video/NVDEC.js b/src/misc/coders/Decoders/video/NVDEC.js index 8e92653..01472fc 100644 --- a/src/misc/coders/Decoders/video/NVDEC.js +++ b/src/misc/coders/Decoders/video/NVDEC.js @@ -16,7 +16,7 @@ function createMapping(settings, stream, skills) { const mapping = { global: [], - local: ['-hwaccel', 'cuda', '-hwaccel_output_format', 'cuda'], + local: ['-hwaccel', 'cuda', '-hwaccel_output_format', 'cuda', '-noautoscale'], }; return mapping;