diff mbox series

[FFmpeg-devel] avutils/vulkan: hwmap, respect src frame resolution

Message ID 20210121043513.1961168-1-guangxin.xu@intel.com
State Accepted
Headers show
Series [FFmpeg-devel] avutils/vulkan: hwmap, respect src frame resolution
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Xu, Guangxin Jan. 21, 2021, 4:35 a.m. UTC
fixes http://trac.ffmpeg.org/ticket/9055

The hw decoder may allocate a large frame from AVHWFramesContext, and adjust width and height based on bitstream.
We need to use resolution from src frame instead of AVHWFramesContext.

test command:
ffmpeg -loglevel debug -hide_banner -hwaccel vaapi -init_hw_device vaapi=va:/dev/dri/renderD128 -hwaccel_device va -hwaccel_output_format vaapi -init_hw_device vulkan=vulk -filter_hw_device vulk -i 1920x1080.264 -c:v libx264 -r:v 30 -profile:v high -preset veryfast -vf "hwmap,chromaber_vulkan=0:0,hwdownload,format=nv12" -map 0 -y vaapiouts.mkv

expected:
No green bar at bottom.
---
 libavutil/hwcontext_vulkan.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Lynne Jan. 22, 2021, 3:37 a.m. UTC | #1
Jan 21, 2021, 05:35 by guangxin.xu@intel.com:

> fixes http://trac.ffmpeg.org/ticket/9055
>
> The hw decoder may allocate a large frame from AVHWFramesContext, and adjust width and height based on bitstream.
> We need to use resolution from src frame instead of AVHWFramesContext.
>
> test command:
> ffmpeg -loglevel debug -hide_banner -hwaccel vaapi -init_hw_device vaapi=va:/dev/dri/renderD128 -hwaccel_device va -hwaccel_output_format vaapi -init_hw_device vulkan=vulk -filter_hw_device vulk -i 1920x1080.264 -c:v libx264 -r:v 30 -profile:v high -preset veryfast -vf "hwmap,chromaber_vulkan=0:0,hwdownload,format=nv12" -map 0 -y vaapiouts.mkv
>
> expected:
> No green bar at bottom.
> ---
>  libavutil/hwcontext_vulkan.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
> index d4ff4ae307..f6d0cae8ae 100644
> --- a/libavutil/hwcontext_vulkan.c
> +++ b/libavutil/hwcontext_vulkan.c
> @@ -2009,7 +2009,7 @@ static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc)
>  }
>  
>  static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **frame,
> -                                          AVDRMFrameDescriptor *desc)
> +                                          const AVFrame *src, AVDRMFrameDescriptor *desc)
>  {
>  int err = 0;
>  VkResult ret;
> @@ -2085,7 +2085,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
>  };
>  
>  get_plane_wh(&create_info.extent.width, &create_info.extent.height,
> -                     hwfc->sw_format, hwfc->width, hwfc->height, i);
> +                     hwfc->sw_format, src->width, src->height, i);
>  
>  for (int j = 0; j < planes; j++) {
>  plane_data[j].offset     = desc->layers[i].planes[j].offset;
> @@ -2246,7 +2246,7 @@ static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
>  AVVkFrame *f;
>  VulkanMapping *map = NULL;
>  
> -    err = vulkan_map_from_drm_frame_desc(hwfc, &f,
> +    err = vulkan_map_from_drm_frame_desc(hwfc, &f, src,
>  (AVDRMFrameDescriptor *)src->data[0]);
>  if (err)
>  return err;
>

Thanks, pushed with a small style nit.
Xu, Guangxin Jan. 22, 2021, 4:14 a.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Lynne
> Sent: Friday, January 22, 2021 11:37 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avutils/vulkan: hwmap, respect src
> frame resolution
> 
> Jan 21, 2021, 05:35 by guangxin.xu@intel.com:
> 
> > fixes http://trac.ffmpeg.org/ticket/9055
> >
> > The hw decoder may allocate a large frame from AVHWFramesContext,
> and adjust width and height based on bitstream.
> > We need to use resolution from src frame instead of AVHWFramesContext.
> >
> > test command:
> > ffmpeg -loglevel debug -hide_banner -hwaccel vaapi -init_hw_device
> > vaapi=va:/dev/dri/renderD128 -hwaccel_device va -
> hwaccel_output_format
> > vaapi -init_hw_device vulkan=vulk -filter_hw_device vulk -i
> > 1920x1080.264 -c:v libx264 -r:v 30 -profile:v high -preset veryfast
> > -vf "hwmap,chromaber_vulkan=0:0,hwdownload,format=nv12" -map 0 -y
> > vaapiouts.mkv
> >
> > expected:
> > No green bar at bottom.
> > ---
> >  libavutil/hwcontext_vulkan.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavutil/hwcontext_vulkan.c
> > b/libavutil/hwcontext_vulkan.c index d4ff4ae307..f6d0cae8ae 100644
> > --- a/libavutil/hwcontext_vulkan.c
> > +++ b/libavutil/hwcontext_vulkan.c
> > @@ -2009,7 +2009,7 @@ static inline VkFormat
> > drm_to_vulkan_fmt(uint32_t drm_fourcc)  }
> >
> >  static int vulkan_map_from_drm_frame_desc(AVHWFramesContext
> *hwfc, AVVkFrame **frame,
> > -                                          AVDRMFrameDescriptor *desc)
> > +                                          const AVFrame *src,
> > + AVDRMFrameDescriptor *desc)
> >  {
> >  int err = 0;
> >  VkResult ret;
> > @@ -2085,7 +2085,7 @@ static int
> > vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc,
> AVVkFrame **f
> > };
> >
> >  get_plane_wh(&create_info.extent.width, &create_info.extent.height,
> > -                     hwfc->sw_format, hwfc->width, hwfc->height, i);
> > +                     hwfc->sw_format, src->width, src->height, i);
> >
> >  for (int j = 0; j < planes; j++) {
> >  plane_data[j].offset     = desc->layers[i].planes[j].offset;
> > @@ -2246,7 +2246,7 @@ static int
> vulkan_map_from_drm(AVHWFramesContext
> > *hwfc, AVFrame *dst,  AVVkFrame *f;  VulkanMapping *map = NULL;
> >
> > -    err = vulkan_map_from_drm_frame_desc(hwfc, &f,
> > +    err = vulkan_map_from_drm_frame_desc(hwfc, &f, src,
> >  (AVDRMFrameDescriptor *)src->data[0]);  if (err)  return err;
> >
> 
> Thanks, pushed with a small style nit.
Great! thanks.
> _______________________________________________
> 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".
diff mbox series

Patch

diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index d4ff4ae307..f6d0cae8ae 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2009,7 +2009,7 @@  static inline VkFormat drm_to_vulkan_fmt(uint32_t drm_fourcc)
 }
 
 static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **frame,
-                                          AVDRMFrameDescriptor *desc)
+                                          const AVFrame *src, AVDRMFrameDescriptor *desc)
 {
     int err = 0;
     VkResult ret;
@@ -2085,7 +2085,7 @@  static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
         };
 
         get_plane_wh(&create_info.extent.width, &create_info.extent.height,
-                     hwfc->sw_format, hwfc->width, hwfc->height, i);
+                     hwfc->sw_format, src->width, src->height, i);
 
         for (int j = 0; j < planes; j++) {
             plane_data[j].offset     = desc->layers[i].planes[j].offset;
@@ -2246,7 +2246,7 @@  static int vulkan_map_from_drm(AVHWFramesContext *hwfc, AVFrame *dst,
     AVVkFrame *f;
     VulkanMapping *map = NULL;
 
-    err = vulkan_map_from_drm_frame_desc(hwfc, &f,
+    err = vulkan_map_from_drm_frame_desc(hwfc, &f, src,
                                          (AVDRMFrameDescriptor *)src->data[0]);
     if (err)
         return err;