Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] cuda: add support for yuv420p10
@ 2025-04-25 11:02 Lynne
  2025-04-25 17:16 ` Timo Rothenpieler
  0 siblings, 1 reply; 3+ messages in thread
From: Lynne @ 2025-04-25 11:02 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne

This patch adds support for accepting yuv420p10 in encoders and cuda.
---
 libavcodec/nvenc.c         | 2 ++
 libavutil/hwcontext_cuda.c | 7 +++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 41a4dc55f4..ccf8cc6d39 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -57,6 +57,7 @@
 
 const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
     AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_NV12,
     AV_PIX_FMT_P010,
     AV_PIX_FMT_YUV444P,
@@ -99,6 +100,7 @@ const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[] = {
                             pix_fmt == AV_PIX_FMT_YUV444P16 || \
                             pix_fmt == AV_PIX_FMT_X2RGB10   || \
                             pix_fmt == AV_PIX_FMT_X2BGR10   || \
+                            pix_fmt == AV_PIX_FMT_YUV420P10 || \
                             pix_fmt == AV_PIX_FMT_GBRP16)
 
 #define IS_RGB(pix_fmt)    (pix_fmt == AV_PIX_FMT_0RGB32  || \
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index 5721612225..495d3687c2 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -44,6 +44,7 @@ static const enum AVPixelFormat supported_formats[] = {
     AV_PIX_FMT_NV12,
     AV_PIX_FMT_NV16,
     AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV420P10,
     AV_PIX_FMT_YUVA420P,
     AV_PIX_FMT_YUV444P,
     AV_PIX_FMT_P010,
@@ -162,7 +163,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
     // YUV420P is a special case.
     // Since nvenc expects the U/V planes to have half the linesize of the Y plane
     // alignment has to be doubled to ensure the U/V planes still end up aligned.
-    if (ctx->sw_format == AV_PIX_FMT_YUV420P)
+    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
+        ctx->sw_format == AV_PIX_FMT_YUV420P10)
         priv->tex_alignment *= 2;
 
     av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, &priv->shift_height);
@@ -197,7 +199,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
 
     // YUV420P is a special case.
     // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
-    if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
+    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
+        ctx->sw_format == AV_PIX_FMT_YUV420P10) {
         frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
         frame->data[2]     = frame->data[1];
         frame->data[1]     = frame->data[2] + frame->linesize[2] * (ctx->height / 2);
-- 
2.49.0.395.g12beb8f557c
_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] cuda: add support for yuv420p10
  2025-04-25 11:02 [FFmpeg-devel] [PATCH] cuda: add support for yuv420p10 Lynne
@ 2025-04-25 17:16 ` Timo Rothenpieler
  2025-04-25 18:09   ` Diego de Souza via ffmpeg-devel
  0 siblings, 1 reply; 3+ messages in thread
From: Timo Rothenpieler @ 2025-04-25 17:16 UTC (permalink / raw)
  To: ffmpeg-devel

On 25.04.2025 13:02, Lynne wrote:
> This patch adds support for accepting yuv420p10 in encoders and cuda.
> ---
>   libavcodec/nvenc.c         | 2 ++
>   libavutil/hwcontext_cuda.c | 7 +++++--
>   2 files changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index 41a4dc55f4..ccf8cc6d39 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -57,6 +57,7 @@
>   
>   const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
>       AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_YUV420P10,
>       AV_PIX_FMT_NV12,
>       AV_PIX_FMT_P010,
>       AV_PIX_FMT_YUV444P,
> @@ -99,6 +100,7 @@ const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[] = {
>                               pix_fmt == AV_PIX_FMT_YUV444P16 || \
>                               pix_fmt == AV_PIX_FMT_X2RGB10   || \
>                               pix_fmt == AV_PIX_FMT_X2BGR10   || \
> +                            pix_fmt == AV_PIX_FMT_YUV420P10 || \
>                               pix_fmt == AV_PIX_FMT_GBRP16)
>   
>   #define IS_RGB(pix_fmt)    (pix_fmt == AV_PIX_FMT_0RGB32  || \

Appears to be missing the entry in nvenc_map_buffer_format().

> diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
> index 5721612225..495d3687c2 100644
> --- a/libavutil/hwcontext_cuda.c
> +++ b/libavutil/hwcontext_cuda.c
> @@ -44,6 +44,7 @@ static const enum AVPixelFormat supported_formats[] = {
>       AV_PIX_FMT_NV12,
>       AV_PIX_FMT_NV16,
>       AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_YUV420P10,
>       AV_PIX_FMT_YUVA420P,
>       AV_PIX_FMT_YUV444P,
>       AV_PIX_FMT_P010,
> @@ -162,7 +163,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
>       // YUV420P is a special case.
>       // Since nvenc expects the U/V planes to have half the linesize of the Y plane
>       // alignment has to be doubled to ensure the U/V planes still end up aligned.
> -    if (ctx->sw_format == AV_PIX_FMT_YUV420P)
> +    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
> +        ctx->sw_format == AV_PIX_FMT_YUV420P10)
>           priv->tex_alignment *= 2;
>   
>       av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, &priv->shift_height);
> @@ -197,7 +199,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
>   
>       // YUV420P is a special case.
>       // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
> -    if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
> +    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
> +        ctx->sw_format == AV_PIX_FMT_YUV420P10) {
>           frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
>           frame->data[2]     = frame->data[1];
>           frame->data[1]     = frame->data[2] + frame->linesize[2] * (ctx->height / 2);

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] cuda: add support for yuv420p10
  2025-04-25 17:16 ` Timo Rothenpieler
@ 2025-04-25 18:09   ` Diego de Souza via ffmpeg-devel
  0 siblings, 0 replies; 3+ messages in thread
From: Diego de Souza via ffmpeg-devel @ 2025-04-25 18:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Diego de Souza

Hi Timo and Lynne,

The encoder does not accept yuv420p10 and yuv422p10 pixel formats. Only the semi planar versions of them: P010 and P210.

Best regards,

Diego de Souza
Sr. Video Coding DevTech
NVIDIA<http://www.nvidia.com/>
On 25.04.25, 19:17, "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> wrote:

External email: Use caution opening links or attachments


On 25.04.2025 13:02, Lynne wrote:
> This patch adds support for accepting yuv420p10 in encoders and cuda.
> ---
>   libavcodec/nvenc.c         | 2 ++
>   libavutil/hwcontext_cuda.c | 7 +++++--
>   2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index 41a4dc55f4..ccf8cc6d39 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -57,6 +57,7 @@
>
>   const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
>       AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_YUV420P10,
>       AV_PIX_FMT_NV12,
>       AV_PIX_FMT_P010,
>       AV_PIX_FMT_YUV444P,
> @@ -99,6 +100,7 @@ const AVCodecHWConfigInternal *const ff_nvenc_hw_configs[] = {
>                               pix_fmt == AV_PIX_FMT_YUV444P16 || \
>                               pix_fmt == AV_PIX_FMT_X2RGB10   || \
>                               pix_fmt == AV_PIX_FMT_X2BGR10   || \
> +                            pix_fmt == AV_PIX_FMT_YUV420P10 || \
>                               pix_fmt == AV_PIX_FMT_GBRP16)
>
>   #define IS_RGB(pix_fmt)    (pix_fmt == AV_PIX_FMT_0RGB32  || \

Appears to be missing the entry in nvenc_map_buffer_format().

> diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
> index 5721612225..495d3687c2 100644
> --- a/libavutil/hwcontext_cuda.c
> +++ b/libavutil/hwcontext_cuda.c
> @@ -44,6 +44,7 @@ static const enum AVPixelFormat supported_formats[] = {
>       AV_PIX_FMT_NV12,
>       AV_PIX_FMT_NV16,
>       AV_PIX_FMT_YUV420P,
> +    AV_PIX_FMT_YUV420P10,
>       AV_PIX_FMT_YUVA420P,
>       AV_PIX_FMT_YUV444P,
>       AV_PIX_FMT_P010,
> @@ -162,7 +163,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
>       // YUV420P is a special case.
>       // Since nvenc expects the U/V planes to have half the linesize of the Y plane
>       // alignment has to be doubled to ensure the U/V planes still end up aligned.
> -    if (ctx->sw_format == AV_PIX_FMT_YUV420P)
> +    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
> +        ctx->sw_format == AV_PIX_FMT_YUV420P10)
>           priv->tex_alignment *= 2;
>
>       av_pix_fmt_get_chroma_sub_sample(ctx->sw_format, &priv->shift_width, &priv->shift_height);
> @@ -197,7 +199,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
>
>       // YUV420P is a special case.
>       // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
> -    if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
> +    if (ctx->sw_format == AV_PIX_FMT_YUV420P ||
> +        ctx->sw_format == AV_PIX_FMT_YUV420P10) {
>           frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
>           frame->data[2]     = frame->data[1];
>           frame->data[1]     = frame->data[2] + frame->linesize[2] * (ctx->height / 2);

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=05%7C02%7Cddesouza%40nvidia.com%7C4b00a855d0074468805a08dd841d00cc%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638811982319400744%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=vn02EysjlXKOxF3pYJBIol76BIqmmCUJTDpoxuiW2Tg%3D&reserved=0<https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

-----------------------------------------------------------------------------------
NVIDIA GmbH
Wuerselen
Amtsgericht Aachen
HRB 8361
Managing Directors: Rebecca Peters, Donald Robertson, Janet Hall, Ludwig von Reiche

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information.  Any unauthorized review, use, disclosure or distribution
is prohibited.  If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2025-04-25 18:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-25 11:02 [FFmpeg-devel] [PATCH] cuda: add support for yuv420p10 Lynne
2025-04-25 17:16 ` Timo Rothenpieler
2025-04-25 18:09   ` Diego de Souza via ffmpeg-devel

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