* [FFmpeg-devel] [PATCH] libavcodec/nvenc.c: memset NV_ENC_REGISTER_RESOURCE structure with zeros
@ 2022-01-10 12:49 Roman Arzumanyan
2022-01-10 14:55 ` Timo Rothenpieler
0 siblings, 1 reply; 2+ messages in thread
From: Roman Arzumanyan @ 2022-01-10 12:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Yogender Gupta, timo, Ricardo Monteiro
[-- Attachment #1: Type: text/plain, Size: 269 bytes --]
Hello,
This patch memsets NV_ENC_REGISTER_RESOURCE structure with zeros.
Without that, in rare occasions NV_ENC_REGISTER_RESOURCE::bufferUsage structure field may accidentaly take NV_ENC_OUTPUT_MOTION_VECTOR value causing nvEncRegisterResource() function to fail.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-3470660-initializing-NV_ENC_REGISTER_RESOURCE-with-z.patch --]
[-- Type: text/x-patch; name="0001-3470660-initializing-NV_ENC_REGISTER_RESOURCE-with-z.patch", Size: 793 bytes --]
From c655a38fafa1c47d27e2cc4e45d8aa593fd4a0a7 Mon Sep 17 00:00:00 2001
From: Roman Arzumanyan <rarzumanyan@nvidia.com>
Date: Wed, 29 Dec 2021 12:06:25 +0300
Subject: [PATCH] #3470660: initializing NV_ENC_REGISTER_RESOURCE with zeros
---
libavcodec/nvenc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 31dfed9241..e450ac3887 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1870,6 +1870,8 @@ static int nvenc_register_frame(AVCodecContext *avctx, const AVFrame *frame)
if (idx < 0)
return idx;
+ memset((void*)®, 0, sizeof(reg));
+
reg.version = NV_ENC_REGISTER_RESOURCE_VER;
reg.width = frames_ctx->width;
reg.height = frames_ctx->height;
--
2.25.1
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] libavcodec/nvenc.c: memset NV_ENC_REGISTER_RESOURCE structure with zeros
2022-01-10 12:49 [FFmpeg-devel] [PATCH] libavcodec/nvenc.c: memset NV_ENC_REGISTER_RESOURCE structure with zeros Roman Arzumanyan
@ 2022-01-10 14:55 ` Timo Rothenpieler
0 siblings, 0 replies; 2+ messages in thread
From: Timo Rothenpieler @ 2022-01-10 14:55 UTC (permalink / raw)
To: Roman Arzumanyan, ffmpeg-devel; +Cc: Yogender Gupta, Ricardo Monteiro
[-- Attachment #1.1: Type: text/plain, Size: 835 bytes --]
On 10.01.2022 13:49, Roman Arzumanyan wrote:
> Hello,
>
> This patch memsets NV_ENC_REGISTER_RESOURCE structure with zeros.
> Without that, in rare occasions NV_ENC_REGISTER_RESOURCE::bufferUsage
> structure field may accidentaly take NV_ENC_OUTPUT_MOTION_VECTOR value
> causing nvEncRegisterResource() function to fail.
The rest of nvenc.c uses "= { 0 };" to zero-initialize structs.
For some reason this wasn't done here.
This would be the only instance of using memset() in the whole file.
Do you have a way to check if just doing
NV_ENC_REGISTER_RESOURCE reg = { 0 };
Also solves the issue?
I just pushed that change, since it's clearly an oversight.
If it's still causing issues, let me know and memset is definitely an
option.
But any standard-abiding C-Compiler should zero initialize the struct now.
Thanks,
Timo
[-- Attachment #1.2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4494 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-10 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 12:49 [FFmpeg-devel] [PATCH] libavcodec/nvenc.c: memset NV_ENC_REGISTER_RESOURCE structure with zeros Roman Arzumanyan
2022-01-10 14:55 ` Timo Rothenpieler
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git