* [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: support AV_PIX_FMT_GBRP
@ 2025-04-29 8:07 Lynne
2025-04-29 8:07 ` [FFmpeg-devel] [PATCH 2/2] ffv1enc_vulkan: support 2-plane YUV formats Lynne
0 siblings, 1 reply; 2+ messages in thread
From: Lynne @ 2025-04-29 8:07 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Lynne
Support was partially added previously in vulkan.c, but now it's fully
supported.
---
libavutil/hwcontext_vulkan.c | 1 +
libavutil/vulkan.c | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index ade0235ef1..e5b139132c 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -351,6 +351,7 @@ static const struct FFVkFormatEntry {
{ VK_FORMAT_R32G32B32A32_UINT, AV_PIX_FMT_RGBA128, VK_IMAGE_ASPECT_COLOR_BIT, 1, 1, 1, { VK_FORMAT_R32G32B32A32_UINT } },
/* Planar RGB */
+ { VK_FORMAT_R8_UNORM, AV_PIX_FMT_GBRP, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM, VK_FORMAT_R8_UNORM } },
{ VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP10, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } },
{ VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP12, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } },
{ VK_FORMAT_R16_UNORM, AV_PIX_FMT_GBRP14, VK_IMAGE_ASPECT_COLOR_BIT, 3, 3, 3, { VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM, VK_FORMAT_R16_UNORM } },
diff --git a/libavutil/vulkan.c b/libavutil/vulkan.c
index 55e3bbfd8e..2cc8ec110e 100644
--- a/libavutil/vulkan.c
+++ b/libavutil/vulkan.c
@@ -1493,7 +1493,8 @@ int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
pix_fmt == AV_PIX_FMT_GBRPF32 || pix_fmt == AV_PIX_FMT_GBRAPF32 ||
pix_fmt == AV_PIX_FMT_X2RGB10 || pix_fmt == AV_PIX_FMT_X2BGR10 ||
pix_fmt == AV_PIX_FMT_RGBAF32 || pix_fmt == AV_PIX_FMT_RGBF32 ||
- pix_fmt == AV_PIX_FMT_RGBA128 || pix_fmt == AV_PIX_FMT_RGB96)
+ pix_fmt == AV_PIX_FMT_RGBA128 || pix_fmt == AV_PIX_FMT_RGB96 ||
+ pix_fmt == AV_PIX_FMT_GBRP)
return 1;
return 0;
}
@@ -1501,8 +1502,8 @@ int ff_vk_mt_is_np_rgb(enum AVPixelFormat pix_fmt)
void ff_vk_set_perm(enum AVPixelFormat pix_fmt, int lut[4], int inv)
{
switch (pix_fmt) {
- case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRP:
+ case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_GBRAP10:
case AV_PIX_FMT_GBRAP12:
case AV_PIX_FMT_GBRAP14:
@@ -1605,6 +1606,7 @@ const char *ff_vk_shader_rep_fmt(enum AVPixelFormat pix_fmt,
};
return rep_tab[rep_fmt];
}
+ case AV_PIX_FMT_GBRP:
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_GBRAP:
case AV_PIX_FMT_YUV420P:
--
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] 2+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] ffv1enc_vulkan: support 2-plane YUV formats
2025-04-29 8:07 [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: support AV_PIX_FMT_GBRP Lynne
@ 2025-04-29 8:07 ` Lynne
0 siblings, 0 replies; 2+ messages in thread
From: Lynne @ 2025-04-29 8:07 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Lynne
This adds support for NV12 and P010.
More will be added later.
---
libavcodec/ffv1enc.c | 2 ++
libavcodec/ffv1enc_vulkan.c | 8 ++++++--
libavcodec/vulkan/ffv1_enc.comp | 21 ++++++++++++++-------
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 6ab648fd80..e215ab20a4 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -813,6 +813,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
if (!avctx->bits_per_raw_sample)
s->bits_per_raw_sample = 9;
case AV_PIX_FMT_GRAY10:
+ case AV_PIX_FMT_P010:
case AV_PIX_FMT_YUV444P10:
case AV_PIX_FMT_YUV440P10:
case AV_PIX_FMT_YUV420P10:
@@ -859,6 +860,7 @@ av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx,
s->version = FFMAX(s->version, 1);
case AV_PIX_FMT_GRAY8:
case AV_PIX_FMT_YA8:
+ case AV_PIX_FMT_NV12:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV440P:
case AV_PIX_FMT_YUV422P:
diff --git a/libavcodec/ffv1enc_vulkan.c b/libavcodec/ffv1enc_vulkan.c
index 688c14fb81..42a98a5efa 100644
--- a/libavcodec/ffv1enc_vulkan.c
+++ b/libavcodec/ffv1enc_vulkan.c
@@ -141,6 +141,7 @@ typedef struct FFv1VkParameters {
uint8_t micro_version;
uint8_t force_pcm;
uint8_t key_frame;
+ uint8_t components;
uint8_t planes;
uint8_t codec_planes;
uint8_t transparency;
@@ -149,7 +150,7 @@ typedef struct FFv1VkParameters {
uint8_t ec;
uint8_t ppi;
uint8_t chunks;
- uint8_t padding[2];
+ uint8_t padding[1];
} FFv1VkParameters;
static void add_push_data(FFVulkanShader *shd)
@@ -173,6 +174,7 @@ static void add_push_data(FFVulkanShader *shd)
GLSLC(1, uint8_t micro_version; );
GLSLC(1, uint8_t force_pcm; );
GLSLC(1, uint8_t key_frame; );
+ GLSLC(1, uint8_t components; );
GLSLC(1, uint8_t planes; );
GLSLC(1, uint8_t codec_planes; );
GLSLC(1, uint8_t transparency; );
@@ -181,7 +183,7 @@ static void add_push_data(FFVulkanShader *shd)
GLSLC(1, uint8_t ec; );
GLSLC(1, uint8_t ppi; );
GLSLC(1, uint8_t chunks; );
- GLSLC(1, uint8_t padding[2]; );
+ GLSLC(1, uint8_t padding[1]; );
GLSLC(0, }; );
ff_vk_shader_add_push_const(shd, 0, sizeof(FFv1VkParameters),
VK_SHADER_STAGE_COMPUTE_BIT);
@@ -326,6 +328,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx,
int has_inter = avctx->gop_size > 1;
uint32_t context_count = f->context_count[f->context_model];
+ const AVPixFmtDescriptor *fmt_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
VkImageView in_views[AV_NUM_DATA_POINTERS];
VkImageView intermediate_views[AV_NUM_DATA_POINTERS];
@@ -498,6 +501,7 @@ static int vulkan_encode_ffv1_submit_frame(AVCodecContext *avctx,
.micro_version = f->micro_version,
.force_pcm = fv->force_pcm,
.key_frame = f->key_frame,
+ .components = fmt_desc->nb_components,
.planes = av_pix_fmt_count_planes(avctx->sw_pix_fmt),
.codec_planes = f->plane_count,
.transparency = f->transparency,
diff --git a/libavcodec/vulkan/ffv1_enc.comp b/libavcodec/vulkan/ffv1_enc.comp
index 880d3a37f0..4b851fd711 100644
--- a/libavcodec/vulkan/ffv1_enc.comp
+++ b/libavcodec/vulkan/ffv1_enc.comp
@@ -26,14 +26,18 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
#ifndef GOLOMB
if (sc.slice_coding_mode == 1) {
- for (int p = 0; p < planes; p++) {
+ for (int c = 0; c < components; c++) {
int h = sc.slice_dim.y;
- if (p > 0 && p < 3)
+ if (c > 0 && c < 3)
h >>= chroma_shift.y;
+ /* Takes into account dual-plane YUV formats */
+ int p = min(c, planes - 1);
+ int comp = c - p;
+
for (int y = 0; y < h; y++)
- encode_line_pcm(sc, y, p, 0, bits);
+ encode_line_pcm(sc, y, p, comp, bits);
}
} else
#endif
@@ -41,18 +45,21 @@ void encode_slice(inout SliceContext sc, const uint slice_idx)
uint64_t slice_state_off = uint64_t(slice_state) +
slice_idx*plane_state_size*codec_planes;
- for (int p = 0; p < planes; p++) {
+ for (int c = 0; c < components; c++) {
int run_index = 0;
int h = sc.slice_dim.y;
- if (p > 0 && p < 3)
+ if (c > 0 && c < 3)
h >>= chroma_shift.y;
+ int p = min(c, planes - 1);
+ int comp = c - p;
+
for (int y = 0; y < h; y++)
- encode_line(sc, slice_state_off, y, p, 0, bits, run_index);
+ encode_line(sc, slice_state_off, y, p, comp, bits, run_index);
/* For the second chroma plane, reuse the first plane's state */
- if (p != 1)
+ if (c != 1)
slice_state_off += plane_state_size;
}
}
--
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] 2+ messages in thread
end of thread, other threads:[~2025-04-29 8:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-29 8:07 [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: support AV_PIX_FMT_GBRP Lynne
2025-04-29 8:07 ` [FFmpeg-devel] [PATCH 2/2] ffv1enc_vulkan: support 2-plane YUV formats Lynne
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