From: Lynne <dev@lynne.ee>
To: ffmpeg-devel@ffmpeg.org
Cc: Lynne <dev@lynne.ee>
Subject: [FFmpeg-devel] [PATCH 4/6] vulkan_decode: add a generic start_frame function
Date: Mon, 31 Mar 2025 04:37:40 +0200
Message-ID: <20250331023753.285499-4-dev@lynne.ee> (raw)
In-Reply-To: <20250331023753.285499-1-dev@lynne.ee>
---
libavcodec/vulkan_decode.c | 38 ++++++++++++++++++++++++++++++++++----
libavcodec/vulkan_decode.h | 6 ++++++
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index 058efe3037..893f8fca3d 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -151,8 +151,6 @@ int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic,
int err;
FFVulkanDecodeShared *ctx = dec->shared_ctx;
- vkpic->slices_size = 0;
-
/* If the decoder made a blank frame to make up for a missing ref, or the
* frame is the current frame so it's missing one, create a re-representation */
if (vkpic->view.ref[0])
@@ -209,8 +207,6 @@ int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic,
FFVulkanDecodeShared *ctx = dec->shared_ctx;
AVHWFramesContext *frames = (AVHWFramesContext *)pic->hw_frames_ctx->data;
- vkpic->slices_size = 0;
-
if (vkpic->view.ref[0])
return 0;
@@ -248,6 +244,31 @@ int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic,
return 0;
}
+int ff_vk_decode_start_frame(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
+ const AVBufferRef *buffer_ref, int complete)
+{
+ int err;
+ FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
+ FFVulkanDecodeShared *ctx = dec->shared_ctx;
+
+ vp->nb_slices = 0;
+ vp->slices_size = 0;
+
+ /* Host map the input slices data if supported */
+ if (complete && ctx->s.extensions & FF_VK_EXT_EXTERNAL_HOST_MEMORY) {
+ err = ff_vk_host_map_buffer(&ctx->s, &vp->slices_buf, buffer_ref->data,
+ buffer_ref,
+ DECODER_IS_SDR(avctx->codec_id) ?
+ (VK_BUFFER_USAGE_STORAGE_BUFFER_BIT |
+ VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT) :
+ VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+
int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
const uint8_t *data, size_t size, int add_startcode)
{
@@ -268,6 +289,15 @@ int ff_vk_decode_add_slice(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
return AVERROR(EINVAL);
vkbuf = vp->slices_buf ? (FFVkBuffer *)vp->slices_buf->data : NULL;
+
+ /* Buffer exists, and is a single complete host-mapped buffer. */
+ if (vkbuf && vkbuf->host_ref) {
+ vp->slice_offsets[vp->nb_slices] = vp->slices_size;
+ vp->nb_slices = vp->nb_slices + 1;
+ vp->slices_size += startcode_len + size;
+ return 0;
+ }
+
if (!vkbuf || vkbuf->size < new_size) {
int err;
AVBufferRef *new_ref;
diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h
index 6c3e1486b0..103be09943 100644
--- a/libavcodec/vulkan_decode.h
+++ b/libavcodec/vulkan_decode.h
@@ -145,6 +145,12 @@ int ff_vk_decode_prepare_frame_sdr(FFVulkanDecodeContext *dec, AVFrame *pic,
FFVulkanDecodePicture *vkpic, int is_current,
enum FFVkShaderRepFormat rep_fmt, int alloc_dpb);
+/**
+ * Generic start_frame function.
+ */
+int ff_vk_decode_start_frame(AVCodecContext *avctx, FFVulkanDecodePicture *vp,
+ const AVBufferRef *buffer_ref, int complete);
+
/**
* Add slice data to frame.
*/
--
2.49.0
_______________________________________________
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".
next prev parent reply other threads:[~2025-03-31 2:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 2:37 [FFmpeg-devel] [PATCH 1/6] vulkan_decode: generalize handling of slice offsets/nb Lynne
2025-03-31 2:37 ` [FFmpeg-devel] [PATCH 2/6] vulkan_decode: only create sequence params in end_frame Lynne
2025-03-31 2:37 ` [FFmpeg-devel] [PATCH 3/6] vulkan_decode: move temporary Vulkan structs into each codec Lynne
2025-03-31 2:37 ` Lynne [this message]
2025-03-31 2:37 ` [FFmpeg-devel] [PATCH 5/6] vulkan_h264: make all temporary structs temporary Lynne
2025-03-31 2:37 ` [FFmpeg-devel] [PATCH 6/6] vulkan_hevc: " Lynne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250331023753.285499-4-dev@lynne.ee \
--to=dev@lynne.ee \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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