Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v1 1/3] lavfi/vaapi: Add function to get surface ID from AVFrame
@ 2023-05-30  0:29 Fei Wang
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 2/3] lavfi/vaapi: Add some debug message Fei Wang
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode Fei Wang
  0 siblings, 2 replies; 7+ messages in thread
From: Fei Wang @ 2023-05-30  0:29 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavfilter/vaapi_vpp.c | 10 ++--------
 libavfilter/vaapi_vpp.h |  5 +++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index a323dab8b8..10d31977c6 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -518,7 +518,6 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
                              AVFrame *output_frame)
 {
     VAAPIVPPContext *ctx = avctx->priv;
-    VASurfaceID input_surface;
     int err;
 
     ctx->input_region = (VARectangle) {
@@ -534,10 +533,8 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
     output_frame->crop_left   = 0;
     output_frame->crop_right  = 0;
 
-    input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3],
-
     *params = (VAProcPipelineParameterBuffer) {
-        .surface                 = input_surface,
+        .surface                 = ff_vaapi_vpp_get_surface_id(input_frame),
         .surface_region          = &ctx->input_region,
         .output_region           = NULL,
         .output_background_color = VAAPI_VPP_BACKGROUND_BLACK,
@@ -623,7 +620,6 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
                                  AVFrame *output_frame)
 {
     VAAPIVPPContext *ctx = avctx->priv;
-    VASurfaceID output_surface;
     VABufferID *params_ids;
     VAStatus vas;
     int err;
@@ -635,10 +631,8 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
     for (int i = 0; i < cout; i++)
         params_ids[i] = VA_INVALID_ID;
 
-    output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
-
     vas = vaBeginPicture(ctx->hwctx->display,
-                         ctx->va_context, output_surface);
+                         ctx->va_context, ff_vaapi_vpp_get_surface_id(output_frame));
     if (vas != VA_STATUS_SUCCESS) {
         av_log(avctx, AV_LOG_ERROR, "Failed to attach new picture: "
                "%d (%s).\n", vas, vaErrorStr(vas));
diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
index ead07036dc..cc845b854c 100644
--- a/libavfilter/vaapi_vpp.h
+++ b/libavfilter/vaapi_vpp.h
@@ -27,6 +27,11 @@
 
 #include "avfilter.h"
 
+static inline VASurfaceID ff_vaapi_vpp_get_surface_id(const AVFrame *frame)
+{
+    return (uintptr_t)frame->data[3];
+}
+
 // ARGB black, for VAProcPipelineParameterBuffer.output_background_color.
 #define VAAPI_VPP_BACKGROUND_BLACK 0xff000000
 
-- 
2.25.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH v1 2/3] lavfi/vaapi: Add some debug message
  2023-05-30  0:29 [FFmpeg-devel] [PATCH v1 1/3] lavfi/vaapi: Add function to get surface ID from AVFrame Fei Wang
@ 2023-05-30  0:29 ` Fei Wang
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode Fei Wang
  1 sibling, 0 replies; 7+ messages in thread
From: Fei Wang @ 2023-05-30  0:29 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavfilter/vaapi_vpp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 10d31977c6..4de19564e9 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -554,6 +554,10 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
     if (err < 0)
         return err;
 
+    av_log(avctx, AV_LOG_DEBUG, "Filter frame from surface %#x to %#x.\n",
+           ff_vaapi_vpp_get_surface_id(input_frame),
+           ff_vaapi_vpp_get_surface_id(output_frame));
+
     return 0;
 }
 
-- 
2.25.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [FFmpeg-devel] [PATCH v1 3/3]  lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode
  2023-05-30  0:29 [FFmpeg-devel] [PATCH v1 1/3] lavfi/vaapi: Add function to get surface ID from AVFrame Fei Wang
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 2/3] lavfi/vaapi: Add some debug message Fei Wang
@ 2023-05-30  0:29 ` Fei Wang
  2023-06-12  7:25   ` Xiang, Haihao
  2023-06-13 16:17   ` Eoff, Ullysses A
  1 sibling, 2 replies; 7+ messages in thread
From: Fei Wang @ 2023-05-30  0:29 UTC (permalink / raw)
  To: ffmpeg-devel

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavfilter/vaapi_vpp.c        | 15 ++++++++++++---
 libavfilter/vaapi_vpp.h        |  2 ++
 libavfilter/vf_misc_vaapi.c    |  9 +++++++++
 libavfilter/vf_procamp_vaapi.c | 10 ++++++++++
 libavfilter/vf_scale_vaapi.c   |  9 +++++++++
 5 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index 4de19564e9..cf2592e068 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -95,6 +95,7 @@ int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
 int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
 {
     AVFilterContext *avctx = outlink->src;
+    AVFilterLink   *inlink = avctx->inputs[0];
     VAAPIVPPContext *ctx   = avctx->priv;
     AVVAAPIHWConfig *hwconfig = NULL;
     AVHWFramesConstraints *constraints = NULL;
@@ -111,6 +112,17 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
     if (!ctx->output_height)
         ctx->output_height = avctx->inputs[0]->h;
 
+    outlink->w = ctx->output_width;
+    outlink->h = ctx->output_height;
+
+    if (ctx->passthrough) {
+        if (inlink->hw_frames_ctx)
+            outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+        av_log(ctx, AV_LOG_VERBOSE, "Using VAAPI filter passthrough mode.\n");
+
+        return 0;
+    }
+
     av_assert0(ctx->input_frames);
     ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
     if (!ctx->device_ref) {
@@ -214,9 +226,6 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
         return AVERROR(EIO);
     }
 
-    outlink->w = ctx->output_width;
-    outlink->h = ctx->output_height;
-
     if (ctx->build_filter_params) {
         err = ctx->build_filter_params(avctx);
         if (err < 0)
diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
index cc845b854c..6764ab0c39 100644
--- a/libavfilter/vaapi_vpp.h
+++ b/libavfilter/vaapi_vpp.h
@@ -56,6 +56,8 @@ typedef struct VAAPIVPPContext {
     VABufferID         filter_buffers[VAProcFilterCount];
     int                nb_filter_buffers;
 
+    int passthrough;
+
     int (*build_filter_params)(AVFilterContext *avctx);
 
     void (*pipeline_uninit)(AVFilterContext *avctx);
diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
index db3e69679a..0a4c174ab9 100644
--- a/libavfilter/vf_misc_vaapi.c
+++ b/libavfilter/vf_misc_vaapi.c
@@ -131,6 +131,9 @@ static int misc_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
            av_get_pix_fmt_name(input_frame->format),
            input_frame->width, input_frame->height, input_frame->pts);
 
+    if (vpp_ctx->passthrough)
+        return ff_filter_frame(outlink, input_frame);
+
     if (vpp_ctx->va_context == VA_INVALID_ID)
         return AVERROR(EINVAL);
 
@@ -176,11 +179,14 @@ fail:
 static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
 {
     VAAPIVPPContext *vpp_ctx = avctx->priv;
+    DenoiseVAAPIContext *ctx = avctx->priv;
 
     ff_vaapi_vpp_ctx_init(avctx);
     vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
     vpp_ctx->build_filter_params = denoise_vaapi_build_filter_params;
     vpp_ctx->output_format       = AV_PIX_FMT_NONE;
+    if (!ctx->denoise)
+        vpp_ctx->passthrough = 1;
 
     return 0;
 }
@@ -188,11 +194,14 @@ static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
 static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
 {
     VAAPIVPPContext *vpp_ctx = avctx->priv;
+    SharpnessVAAPIContext *ctx = avctx->priv;
 
     ff_vaapi_vpp_ctx_init(avctx);
     vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
     vpp_ctx->build_filter_params = sharpness_vaapi_build_filter_params;
     vpp_ctx->output_format       = AV_PIX_FMT_NONE;
+    if (!ctx->sharpness)
+        vpp_ctx->passthrough = 1;
 
     return 0;
 }
diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
index 4a3b9d0766..82c446dc76 100644
--- a/libavfilter/vf_procamp_vaapi.c
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -136,6 +136,9 @@ static int procamp_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame
            av_get_pix_fmt_name(input_frame->format),
            input_frame->width, input_frame->height, input_frame->pts);
 
+    if (vpp_ctx->passthrough)
+        return ff_filter_frame(outlink, input_frame);
+
     if (vpp_ctx->va_context == VA_INVALID_ID)
         return AVERROR(EINVAL);
 
@@ -179,11 +182,18 @@ fail:
 static av_cold int procamp_vaapi_init(AVFilterContext *avctx)
 {
     VAAPIVPPContext *vpp_ctx = avctx->priv;
+    ProcampVAAPIContext *ctx = avctx->priv;
+    float eps = 0.0001;
 
     ff_vaapi_vpp_ctx_init(avctx);
     vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
     vpp_ctx->build_filter_params = procamp_vaapi_build_filter_params;
     vpp_ctx->output_format       = AV_PIX_FMT_NONE;
+    if (fabs(ctx->saturation - SATURATION_DEFAULT) < eps &&
+        fabs(ctx->bright - BRIGHTNESS_DEFAULT) < eps &&
+        fabs(ctx->contrast - CONTRAST_DEFAULT) < eps &&
+        fabs(ctx->hue - HUE_DEFAULT) < eps)
+        vpp_ctx->passthrough = 1;
 
     return 0;
 }
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index a371077ee0..aa18891c56 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -85,6 +85,15 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
     ff_scale_adjust_dimensions(inlink, &vpp_ctx->output_width, &vpp_ctx->output_height,
                                ctx->force_original_aspect_ratio, ctx->force_divisible_by);
 
+    if (inlink->w == outlink->w && inlink->h == outlink->w &&
+        vpp_ctx->input_frames->sw_format == vpp_ctx->output_format &&
+        ctx->colour_primaries == AVCOL_PRI_UNSPECIFIED &&
+        ctx->colour_transfer == AVCOL_TRC_UNSPECIFIED &&
+        ctx->colour_matrix == AVCOL_SPC_UNSPECIFIED &&
+        ctx->colour_range == AVCOL_RANGE_UNSPECIFIED &&
+        ctx->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
+        vpp_ctx->passthrough = 1;
+
     err = ff_vaapi_vpp_config_output(outlink);
     if (err < 0)
         return err;
-- 
2.25.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1 3/3]  lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode Fei Wang
@ 2023-06-12  7:25   ` Xiang, Haihao
  2023-06-14  2:58     ` Wang, Fei W
  2023-06-13 16:17   ` Eoff, Ullysses A
  1 sibling, 1 reply; 7+ messages in thread
From: Xiang, Haihao @ 2023-06-12  7:25 UTC (permalink / raw)
  To: ffmpeg-devel

On Di, 2023-05-30 at 08:29 +0800, Fei Wang wrote:
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavfilter/vaapi_vpp.c        | 15 ++++++++++++---
>  libavfilter/vaapi_vpp.h        |  2 ++
>  libavfilter/vf_misc_vaapi.c    |  9 +++++++++
>  libavfilter/vf_procamp_vaapi.c | 10 ++++++++++
>  libavfilter/vf_scale_vaapi.c   |  9 +++++++++
>  5 files changed, 42 insertions(+), 3 deletions(-)
> 
> diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> index 4de19564e9..cf2592e068 100644
> --- a/libavfilter/vaapi_vpp.c
> +++ b/libavfilter/vaapi_vpp.c
> @@ -95,6 +95,7 @@ int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
>  int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
>  {
>      AVFilterContext *avctx = outlink->src;
> +    AVFilterLink   *inlink = avctx->inputs[0];
>      VAAPIVPPContext *ctx   = avctx->priv;
>      AVVAAPIHWConfig *hwconfig = NULL;
>      AVHWFramesConstraints *constraints = NULL;
> @@ -111,6 +112,17 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
>      if (!ctx->output_height)
>          ctx->output_height = avctx->inputs[0]->h;
>  
> +    outlink->w = ctx->output_width;
> +    outlink->h = ctx->output_height;
> +
> +    if (ctx->passthrough) {
> +        if (inlink->hw_frames_ctx)
> +            outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
> +        av_log(ctx, AV_LOG_VERBOSE, "Using VAAPI filter passthrough
> mode.\n");
> +
> +        return 0;
> +    }
> +
>      av_assert0(ctx->input_frames);
>      ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
>      if (!ctx->device_ref) {
> @@ -214,9 +226,6 @@ int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
>          return AVERROR(EIO);
>      }
>  
> -    outlink->w = ctx->output_width;
> -    outlink->h = ctx->output_height;
> -
>      if (ctx->build_filter_params) {
>          err = ctx->build_filter_params(avctx);
>          if (err < 0)
> diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
> index cc845b854c..6764ab0c39 100644
> --- a/libavfilter/vaapi_vpp.h
> +++ b/libavfilter/vaapi_vpp.h
> @@ -56,6 +56,8 @@ typedef struct VAAPIVPPContext {
>      VABufferID         filter_buffers[VAProcFilterCount];
>      int                nb_filter_buffers;
>  
> +    int passthrough;
> +
>      int (*build_filter_params)(AVFilterContext *avctx);
>  
>      void (*pipeline_uninit)(AVFilterContext *avctx);
> diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
> index db3e69679a..0a4c174ab9 100644
> --- a/libavfilter/vf_misc_vaapi.c
> +++ b/libavfilter/vf_misc_vaapi.c
> @@ -131,6 +131,9 @@ static int misc_vaapi_filter_frame(AVFilterLink *inlink,
> AVFrame *input_frame)
>             av_get_pix_fmt_name(input_frame->format),
>             input_frame->width, input_frame->height, input_frame->pts);
>  
> +    if (vpp_ctx->passthrough)
> +        return ff_filter_frame(outlink, input_frame);
> +
>      if (vpp_ctx->va_context == VA_INVALID_ID)
>          return AVERROR(EINVAL);
>  
> @@ -176,11 +179,14 @@ fail:
>  static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
>  {
>      VAAPIVPPContext *vpp_ctx = avctx->priv;
> +    DenoiseVAAPIContext *ctx = avctx->priv;
>  
>      ff_vaapi_vpp_ctx_init(avctx);
>      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
>      vpp_ctx->build_filter_params = denoise_vaapi_build_filter_params;
>      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> +    if (!ctx->denoise)
> +        vpp_ctx->passthrough = 1;
>  
>      return 0;
>  }
> @@ -188,11 +194,14 @@ static av_cold int denoise_vaapi_init(AVFilterContext
> *avctx)
>  static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
>  {
>      VAAPIVPPContext *vpp_ctx = avctx->priv;
> +    SharpnessVAAPIContext *ctx = avctx->priv;
>  
>      ff_vaapi_vpp_ctx_init(avctx);
>      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
>      vpp_ctx->build_filter_params = sharpness_vaapi_build_filter_params;
>      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> +    if (!ctx->sharpness)
> +        vpp_ctx->passthrough = 1;
>  
>      return 0;
>  }
> diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
> index 4a3b9d0766..82c446dc76 100644
> --- a/libavfilter/vf_procamp_vaapi.c
> +++ b/libavfilter/vf_procamp_vaapi.c
> @@ -136,6 +136,9 @@ static int procamp_vaapi_filter_frame(AVFilterLink
> *inlink, AVFrame *input_frame
>             av_get_pix_fmt_name(input_frame->format),
>             input_frame->width, input_frame->height, input_frame->pts);
>  
> +    if (vpp_ctx->passthrough)
> +        return ff_filter_frame(outlink, input_frame);
> +
>      if (vpp_ctx->va_context == VA_INVALID_ID)
>          return AVERROR(EINVAL);
>  
> @@ -179,11 +182,18 @@ fail:
>  static av_cold int procamp_vaapi_init(AVFilterContext *avctx)
>  {
>      VAAPIVPPContext *vpp_ctx = avctx->priv;
> +    ProcampVAAPIContext *ctx = avctx->priv;
> +    float eps = 0.0001;

Use a smaller eps, e.g. 1.0e-10f ? 

>  
>      ff_vaapi_vpp_ctx_init(avctx);
>      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
>      vpp_ctx->build_filter_params = procamp_vaapi_build_filter_params;
>      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> +    if (fabs(ctx->saturation - SATURATION_DEFAULT) < eps &&
> +        fabs(ctx->bright - BRIGHTNESS_DEFAULT) < eps &&
> +        fabs(ctx->contrast - CONTRAST_DEFAULT) < eps &&
> +        fabs(ctx->hue - HUE_DEFAULT) < eps)
> +        vpp_ctx->passthrough = 1;
>  
>      return 0;
>  }
> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
> index a371077ee0..aa18891c56 100644
> --- a/libavfilter/vf_scale_vaapi.c
> +++ b/libavfilter/vf_scale_vaapi.c
> @@ -85,6 +85,15 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
>      ff_scale_adjust_dimensions(inlink, &vpp_ctx->output_width, &vpp_ctx-
> >output_height,
>                                 ctx->force_original_aspect_ratio, ctx-
> >force_divisible_by);
>  
> +    if (inlink->w == outlink->w && inlink->h == outlink->w &&

'inlink->h == outlink->w' should be typo of
'inlink->h == outlink->h'

BTW outlink->w and outlink-h are set in ff_vaapi_vpp_config_output, here both
outlink->w and outlink->h are 0. 

> +        vpp_ctx->input_frames->sw_format == vpp_ctx->output_format &&
> +        ctx->colour_primaries == AVCOL_PRI_UNSPECIFIED &&
> +        ctx->colour_transfer == AVCOL_TRC_UNSPECIFIED &&
> +        ctx->colour_matrix == AVCOL_SPC_UNSPECIFIED &&
> +        ctx->colour_range == AVCOL_RANGE_UNSPECIFIED &&
> +        ctx->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
> +        vpp_ctx->passthrough = 1;
> +

May we enable passthrough when ctx->mode is not 0 ? 

Thanks
Haihao

>      err = ff_vaapi_vpp_config_output(outlink);
>      if (err < 0)
>          return err;

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1 3/3]  lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode
  2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode Fei Wang
  2023-06-12  7:25   ` Xiang, Haihao
@ 2023-06-13 16:17   ` Eoff, Ullysses A
  2023-06-14  2:59     ` Wang, Fei W
  1 sibling, 1 reply; 7+ messages in thread
From: Eoff, Ullysses A @ 2023-06-13 16:17 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Fei Wang
> Sent: Monday, May 29, 2023 8:30 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode

> @@ -188,11 +194,14 @@ static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
>  static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
>  {
>      VAAPIVPPContext *vpp_ctx = avctx->priv;
> +    SharpnessVAAPIContext *ctx = avctx->priv;
> 
>      ff_vaapi_vpp_ctx_init(avctx);
>      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
>      vpp_ctx->build_filter_params = sharpness_vaapi_build_filter_params;
>      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> +    if (!ctx->sharpness)
> +        vpp_ctx->passthrough = 1;

[UAE] It should be passthrough for the default value.  SHARPNESS_DEFAULT = 44 

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1 3/3]  lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode
  2023-06-12  7:25   ` Xiang, Haihao
@ 2023-06-14  2:58     ` Wang, Fei W
  0 siblings, 0 replies; 7+ messages in thread
From: Wang, Fei W @ 2023-06-14  2:58 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2023-06-12 at 07:25 +0000, Xiang, Haihao wrote:
> On Di, 2023-05-30 at 08:29 +0800, Fei Wang wrote:
> > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > ---
> >  libavfilter/vaapi_vpp.c        | 15 ++++++++++++---
> >  libavfilter/vaapi_vpp.h        |  2 ++
> >  libavfilter/vf_misc_vaapi.c    |  9 +++++++++
> >  libavfilter/vf_procamp_vaapi.c | 10 ++++++++++
> >  libavfilter/vf_scale_vaapi.c   |  9 +++++++++
> >  5 files changed, 42 insertions(+), 3 deletions(-)
> > 
> > diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
> > index 4de19564e9..cf2592e068 100644
> > --- a/libavfilter/vaapi_vpp.c
> > +++ b/libavfilter/vaapi_vpp.c
> > @@ -95,6 +95,7 @@ int ff_vaapi_vpp_config_input(AVFilterLink
> > *inlink)
> >  int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
> >  {
> >      AVFilterContext *avctx = outlink->src;
> > +    AVFilterLink   *inlink = avctx->inputs[0];
> >      VAAPIVPPContext *ctx   = avctx->priv;
> >      AVVAAPIHWConfig *hwconfig = NULL;
> >      AVHWFramesConstraints *constraints = NULL;
> > @@ -111,6 +112,17 @@ int ff_vaapi_vpp_config_output(AVFilterLink
> > *outlink)
> >      if (!ctx->output_height)
> >          ctx->output_height = avctx->inputs[0]->h;
> >  
> > +    outlink->w = ctx->output_width;
> > +    outlink->h = ctx->output_height;
> > +
> > +    if (ctx->passthrough) {
> > +        if (inlink->hw_frames_ctx)
> > +            outlink->hw_frames_ctx = av_buffer_ref(inlink-
> > >hw_frames_ctx);
> > +        av_log(ctx, AV_LOG_VERBOSE, "Using VAAPI filter
> > passthrough
> > mode.\n");
> > +
> > +        return 0;
> > +    }
> > +
> >      av_assert0(ctx->input_frames);
> >      ctx->device_ref = av_buffer_ref(ctx->input_frames-
> > >device_ref);
> >      if (!ctx->device_ref) {
> > @@ -214,9 +226,6 @@ int ff_vaapi_vpp_config_output(AVFilterLink
> > *outlink)
> >          return AVERROR(EIO);
> >      }
> >  
> > -    outlink->w = ctx->output_width;
> > -    outlink->h = ctx->output_height;
> > -
> >      if (ctx->build_filter_params) {
> >          err = ctx->build_filter_params(avctx);
> >          if (err < 0)
> > diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
> > index cc845b854c..6764ab0c39 100644
> > --- a/libavfilter/vaapi_vpp.h
> > +++ b/libavfilter/vaapi_vpp.h
> > @@ -56,6 +56,8 @@ typedef struct VAAPIVPPContext {
> >      VABufferID         filter_buffers[VAProcFilterCount];
> >      int                nb_filter_buffers;
> >  
> > +    int passthrough;
> > +
> >      int (*build_filter_params)(AVFilterContext *avctx);
> >  
> >      void (*pipeline_uninit)(AVFilterContext *avctx);
> > diff --git a/libavfilter/vf_misc_vaapi.c
> > b/libavfilter/vf_misc_vaapi.c
> > index db3e69679a..0a4c174ab9 100644
> > --- a/libavfilter/vf_misc_vaapi.c
> > +++ b/libavfilter/vf_misc_vaapi.c
> > @@ -131,6 +131,9 @@ static int misc_vaapi_filter_frame(AVFilterLink
> > *inlink,
> > AVFrame *input_frame)
> >             av_get_pix_fmt_name(input_frame->format),
> >             input_frame->width, input_frame->height, input_frame-
> > >pts);
> >  
> > +    if (vpp_ctx->passthrough)
> > +        return ff_filter_frame(outlink, input_frame);
> > +
> >      if (vpp_ctx->va_context == VA_INVALID_ID)
> >          return AVERROR(EINVAL);
> >  
> > @@ -176,11 +179,14 @@ fail:
> >  static av_cold int denoise_vaapi_init(AVFilterContext *avctx)
> >  {
> >      VAAPIVPPContext *vpp_ctx = avctx->priv;
> > +    DenoiseVAAPIContext *ctx = avctx->priv;
> >  
> >      ff_vaapi_vpp_ctx_init(avctx);
> >      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
> >      vpp_ctx->build_filter_params =
> > denoise_vaapi_build_filter_params;
> >      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> > +    if (!ctx->denoise)
> > +        vpp_ctx->passthrough = 1;
> >  
> >      return 0;
> >  }
> > @@ -188,11 +194,14 @@ static av_cold int
> > denoise_vaapi_init(AVFilterContext
> > *avctx)
> >  static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
> >  {
> >      VAAPIVPPContext *vpp_ctx = avctx->priv;
> > +    SharpnessVAAPIContext *ctx = avctx->priv;
> >  
> >      ff_vaapi_vpp_ctx_init(avctx);
> >      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
> >      vpp_ctx->build_filter_params =
> > sharpness_vaapi_build_filter_params;
> >      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> > +    if (!ctx->sharpness)
> > +        vpp_ctx->passthrough = 1;
> >  
> >      return 0;
> >  }
> > diff --git a/libavfilter/vf_procamp_vaapi.c
> > b/libavfilter/vf_procamp_vaapi.c
> > index 4a3b9d0766..82c446dc76 100644
> > --- a/libavfilter/vf_procamp_vaapi.c
> > +++ b/libavfilter/vf_procamp_vaapi.c
> > @@ -136,6 +136,9 @@ static int
> > procamp_vaapi_filter_frame(AVFilterLink
> > *inlink, AVFrame *input_frame
> >             av_get_pix_fmt_name(input_frame->format),
> >             input_frame->width, input_frame->height, input_frame-
> > >pts);
> >  
> > +    if (vpp_ctx->passthrough)
> > +        return ff_filter_frame(outlink, input_frame);
> > +
> >      if (vpp_ctx->va_context == VA_INVALID_ID)
> >          return AVERROR(EINVAL);
> >  
> > @@ -179,11 +182,18 @@ fail:
> >  static av_cold int procamp_vaapi_init(AVFilterContext *avctx)
> >  {
> >      VAAPIVPPContext *vpp_ctx = avctx->priv;
> > +    ProcampVAAPIContext *ctx = avctx->priv;
> > +    float eps = 0.0001;
> 
> Use a smaller eps, e.g. 1.0e-10f ? 

Will fix in V2.

> 
> >  
> >      ff_vaapi_vpp_ctx_init(avctx);
> >      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
> >      vpp_ctx->build_filter_params =
> > procamp_vaapi_build_filter_params;
> >      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> > +    if (fabs(ctx->saturation - SATURATION_DEFAULT) < eps &&
> > +        fabs(ctx->bright - BRIGHTNESS_DEFAULT) < eps &&
> > +        fabs(ctx->contrast - CONTRAST_DEFAULT) < eps &&
> > +        fabs(ctx->hue - HUE_DEFAULT) < eps)
> > +        vpp_ctx->passthrough = 1;
> >  
> >      return 0;
> >  }
> > diff --git a/libavfilter/vf_scale_vaapi.c
> > b/libavfilter/vf_scale_vaapi.c
> > index a371077ee0..aa18891c56 100644
> > --- a/libavfilter/vf_scale_vaapi.c
> > +++ b/libavfilter/vf_scale_vaapi.c
> > @@ -85,6 +85,15 @@ static int
> > scale_vaapi_config_output(AVFilterLink *outlink)
> >      ff_scale_adjust_dimensions(inlink, &vpp_ctx->output_width,
> > &vpp_ctx-
> > > output_height,
> >                                 ctx->force_original_aspect_ratio,
> > ctx-
> > > force_divisible_by);
> >  
> > +    if (inlink->w == outlink->w && inlink->h == outlink->w &&
> 
> 'inlink->h == outlink->w' should be typo of
> 'inlink->h == outlink->h'
> 
> BTW outlink->w and outlink-h are set in ff_vaapi_vpp_config_output,
> here both
> outlink->w and outlink->h are 0. 

Will fix in V2.

> 
> > +        vpp_ctx->input_frames->sw_format == vpp_ctx->output_format 
> > &&
> > +        ctx->colour_primaries == AVCOL_PRI_UNSPECIFIED &&
> > +        ctx->colour_transfer == AVCOL_TRC_UNSPECIFIED &&
> > +        ctx->colour_matrix == AVCOL_SPC_UNSPECIFIED &&
> > +        ctx->colour_range == AVCOL_RANGE_UNSPECIFIED &&
> > +        ctx->chroma_location == AVCHROMA_LOC_UNSPECIFIED)
> > +        vpp_ctx->passthrough = 1;
> > +
> 
> May we enable passthrough when ctx->mode is not 0 ? 

The default of ctx->mode is HQ(512), scale vaapi filter should use
passthrough mode if there is no option specificed. 

Thanks
Fei
> 
> Thanks
> Haihao
> 
> >      err = ff_vaapi_vpp_config_output(outlink);
> >      if (err < 0)
> >          return err;
> 
> _______________________________________________
> 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".
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [FFmpeg-devel] [PATCH v1 3/3]  lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode
  2023-06-13 16:17   ` Eoff, Ullysses A
@ 2023-06-14  2:59     ` Wang, Fei W
  0 siblings, 0 replies; 7+ messages in thread
From: Wang, Fei W @ 2023-06-14  2:59 UTC (permalink / raw)
  To: ffmpeg-devel

On Tue, 2023-06-13 at 16:17 +0000, Eoff, Ullysses A wrote:
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Fei Wang
> > Sent: Monday, May 29, 2023 8:30 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp,
> > scale, sharpness}_vaapi: Add passthrough mode
> > @@ -188,11 +194,14 @@ static av_cold int
> > denoise_vaapi_init(AVFilterContext *avctx)
> >  static av_cold int sharpness_vaapi_init(AVFilterContext *avctx)
> >  {
> >      VAAPIVPPContext *vpp_ctx = avctx->priv;
> > +    SharpnessVAAPIContext *ctx = avctx->priv;
> > 
> >      ff_vaapi_vpp_ctx_init(avctx);
> >      vpp_ctx->pipeline_uninit     = ff_vaapi_vpp_pipeline_uninit;
> >      vpp_ctx->build_filter_params =
> > sharpness_vaapi_build_filter_params;
> >      vpp_ctx->output_format       = AV_PIX_FMT_NONE;
> > +    if (!ctx->sharpness)
> > +        vpp_ctx->passthrough = 1;
> 
> [UAE] It should be passthrough for the default
> value.  SHARPNESS_DEFAULT = 44 

Will fix in V2.

Thanks
Fei

> 
> _______________________________________________
> 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".
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-14  2:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-30  0:29 [FFmpeg-devel] [PATCH v1 1/3] lavfi/vaapi: Add function to get surface ID from AVFrame Fei Wang
2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 2/3] lavfi/vaapi: Add some debug message Fei Wang
2023-05-30  0:29 ` [FFmpeg-devel] [PATCH v1 3/3] lavfi/{denoise, procamp, scale, sharpness}_vaapi: Add passthrough mode Fei Wang
2023-06-12  7:25   ` Xiang, Haihao
2023-06-14  2:58     ` Wang, Fei W
2023-06-13 16:17   ` Eoff, Ullysses A
2023-06-14  2:59     ` Wang, Fei W

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