[FFmpeg-devel] [PATCH] vulkan_encode: do not align DPB buffer size

Lynne dev at lynne.ee
Fri Oct 4 18:21:43 EEST 2024


Per subsection B stroke 165 of Chapter 56,
drivers are required to do the aligning, not users.
---
 libavcodec/vulkan_encode.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/vulkan_encode.c b/libavcodec/vulkan_encode.c
index 6d1743c7d7..9ad02e8c52 100644
--- a/libavcodec/vulkan_encode.c
+++ b/libavcodec/vulkan_encode.c
@@ -220,8 +220,7 @@ static int vulkan_encode_issue(AVCodecContext *avctx,
         .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
         .pNext = NULL,
         .codedOffset = { 0 },
-        .codedExtent = (VkExtent2D){ ctx->base.surface_width,
-                                     ctx->base.surface_height },
+        .codedExtent = (VkExtent2D){ avctx->width, avctx->height },
         .baseArrayLayer = ctx->common.layered_dpb ? slot_index : 0,
         .imageViewBinding = vp->dpb.view,
     };
@@ -565,8 +564,8 @@ static int vulkan_encode_create_dpb(AVCodecContext *avctx, FFVulkanEncodeContext
 
     base_ctx->recon_frames->format    = AV_PIX_FMT_VULKAN;
     base_ctx->recon_frames->sw_format = dpb_format;
-    base_ctx->recon_frames->width     = base_ctx->surface_width;
-    base_ctx->recon_frames->height    = base_ctx->surface_height;
+    base_ctx->recon_frames->width     = avctx->width;
+    base_ctx->recon_frames->height    = avctx->height;
 
     hwfc->format[0]    = ctx->pic_format;
     hwfc->create_pnext = &ctx->profile_list;
@@ -915,9 +914,9 @@ av_cold int ff_vulkan_encode_init(AVCodecContext *avctx, FFVulkanEncodeContext *
 
     /* Setup width/height alignment */
     base_ctx->surface_width = avctx->coded_width =
-        FFALIGN(avctx->width, ctx->caps.pictureAccessGranularity.width);
+        FFALIGN(avctx->width, ctx->enc_caps.encodeInputPictureGranularity.width);
     base_ctx->surface_height = avctx->coded_height =
-        FFALIGN(avctx->height, ctx->caps.pictureAccessGranularity.height);
+        FFALIGN(avctx->height, ctx->enc_caps.encodeInputPictureGranularity.height);
 
     /* Setup slice width/height */
     base_ctx->slice_block_width = ctx->enc_caps.encodeInputPictureGranularity.width;
-- 
2.45.2.753.g447d99e1c3b


More information about the ffmpeg-devel mailing list