diff mbox series

[FFmpeg-devel,2/2] lavc/vaapi_encode_h265: Use surface alignment

Message ID 20241022152734.534546-2-nowrep@gmail.com
State New
Headers show
Series None | expand

Commit Message

David Rosca Oct. 22, 2024, 3:26 p.m. UTC
This is needed to correctly set conformance window crop with Mesa AMD.
---
 libavcodec/vaapi_encode_h265.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 2283bcc0b4..0f97c9188b 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -951,8 +951,16 @@  static av_cold int vaapi_encode_h265_get_encoder_caps(AVCodecContext *avctx)
            "min CB size %dx%d.\n", priv->ctu_size, priv->ctu_size,
            priv->min_cb_size, priv->min_cb_size);
 
-    base_ctx->surface_width  = FFALIGN(avctx->width,  priv->min_cb_size);
-    base_ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
+    if (priv->common.surface_alignment_width &&
+        priv->common.surface_alignment_height) {
+        base_ctx->surface_width  =
+            FFALIGN(avctx->width,  priv->common.surface_alignment_width);
+        base_ctx->surface_height =
+            FFALIGN(avctx->height, priv->common.surface_alignment_height);
+    } else {
+        base_ctx->surface_width  = FFALIGN(avctx->width,  priv->min_cb_size);
+        base_ctx->surface_height = FFALIGN(avctx->height, priv->min_cb_size);
+    }
 
     base_ctx->slice_block_width = base_ctx->slice_block_height = priv->ctu_size;