diff mbox series

[FFmpeg-devel] vulkan_decode: use coded_width/height instead of the non-coded width and h

Message ID NhUyBpG--3-9@lynne.ee
State New
Headers show
Series [FFmpeg-devel] vulkan_decode: use coded_width/height instead of the non-coded width and h | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lynne Oct. 24, 2023, 4:37 a.m. UTC
Fixes several samples.

There may be issues with cropping, but so far, I have not found any
in my samples set.

Patch attached.

Comments

Anton Khirnov Oct. 24, 2023, 7:04 p.m. UTC | #1
Quoting Lynne (2023-10-24 06:37:03)
> Fixes several samples.
> 
> There may be issues with cropping, but so far, I have not found any
> in my samples set.

Frames ctx dimensions should be the allocated ones, cropping does not
enter into this.
Lynne Oct. 24, 2023, 11:38 p.m. UTC | #2
Oct 24, 2023, 21:05 by anton@khirnov.net:

> Quoting Lynne (2023-10-24 06:37:03)
>
>> Fixes several samples.
>>
>> There may be issues with cropping, but so far, I have not found any
>> in my samples set.
>>
>
> Frames ctx dimensions should be the allocated ones, cropping does not
> enter into this.
>

Correct, that's what I meant to say.

The sample in question is https://streams.videolan.org/issues/19938/20000_20180305-15.04.59.ts
Which is coded as 1920x1080, meant to be rendered at 1440x1080 with cropping,
or 1680x1080 before cropping. Currently, the created DPB is 1440x1080, which results
in the image being decoded incorrectly, as the decoder overwrites output memory.
This commit fixes this.

Added this to the commit description locally.
diff mbox series

Patch

From b928053158ec5f63d3c07a9daa9b802cb9229858 Mon Sep 17 00:00:00 2001
From: Lynne <dev@lynne.ee>
Date: Tue, 24 Oct 2023 06:33:07 +0200
Subject: [PATCH] vulkan_decode: use coded_width/height instead of the
 non-coded width and height

Fixes several samples.

There may be issues with cropping, but so far, I have not found any
in my samples set.
---
 libavcodec/vulkan_decode.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
index e6a0646139..3b9576c0a9 100644
--- a/libavcodec/vulkan_decode.c
+++ b/libavcodec/vulkan_decode.c
@@ -872,10 +872,10 @@  static int vulkan_decode_get_profile(AVCodecContext *avctx, AVBufferRef *frames_
                " separate_references" : "");
 
     /* Check if decoding is possible with the given parameters */
-    if (avctx->width  < caps->minCodedExtent.width   ||
-        avctx->height < caps->minCodedExtent.height  ||
-        avctx->width  > caps->maxCodedExtent.width   ||
-        avctx->height > caps->maxCodedExtent.height)
+    if (avctx->coded_width  < caps->minCodedExtent.width   ||
+        avctx->coded_height < caps->minCodedExtent.height  ||
+        avctx->coded_width  > caps->maxCodedExtent.width   ||
+        avctx->coded_height > caps->maxCodedExtent.height)
         return AVERROR(EINVAL);
 
     if (!(avctx->hwaccel_flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) &&
@@ -1027,8 +1027,8 @@  int ff_vk_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
     frames_ctx->user_opaque = prof;
     frames_ctx->free        = free_profile_data;
 
-    frames_ctx->width  = avctx->width;
-    frames_ctx->height = avctx->height;
+    frames_ctx->width  = avctx->coded_width;
+    frames_ctx->height = avctx->coded_height;
     frames_ctx->format = AV_PIX_FMT_VULKAN;
 
     hwfc->format[0]    = vkfmt;
@@ -1224,8 +1224,8 @@  int ff_vk_decode_init(AVCodecContext *avctx)
         dpb_frames = (AVHWFramesContext *)ctx->dpb_hwfc_ref->data;
         dpb_frames->format    = s->frames->format;
         dpb_frames->sw_format = s->frames->sw_format;
-        dpb_frames->width     = s->frames->width;
-        dpb_frames->height    = s->frames->height;
+        dpb_frames->width     = avctx->coded_width;
+        dpb_frames->height    = avctx->coded_height;
 
         dpb_hwfc = dpb_frames->hwctx;
         dpb_hwfc->create_pnext = (void *)ff_vk_find_struct(ctx->s.hwfc->create_pnext,
-- 
2.42.0