Re: [FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-12 Thread Jun Zhao


On 2016/9/12 1:37, Moritz Barsnick wrote:
> On Fri, Sep 09, 2016 at 11:31:22 +0800, Jun Zhao wrote:
>> v4 : - fix sharpless typo(sharpless -> sharpness)
> [...]
> 
>> Date: Tue, 30 Aug 2016 14:36:00 +0800
>> Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.
>>
>> add denoise/sharpless support, used scope [-1, 100] as the input
>> scope.
> 
> Well, the commit message still contains the typo, twice. 
> 
> Also, please drop the space character before the colon. The top line of
> the commit message should probably read:
> lavfi/scale_vaapi: add denoise/sharpless support

Thanks for you correct me, will re-submit the patch with correct prefix as your 
comments.

> 
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-12 Thread Jun Zhao


On 2016/9/10 3:29, Mark Thompson wrote:
> On 09/09/16 04:31, Jun Zhao wrote:
>> v4 : - fix sharpless typo(sharpless -> sharpness)
>>  - when don't support denoise/sharpness, report the error and return
>>  - fix denoise/sharpness params buffer leak in error handle
>> v3 : fix sharpless mapping issue
>> v2 : fix filter support flag check logic issue
>>
>> From d1f0b556bdd6be4dffcd3b1b93cba5cd1098908a Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Tue, 30 Aug 2016 14:36:00 +0800
>> Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.
> 
> I think libavfilter is generally "lavfi" ("lavf" is libavformat).

Thanks for you correct me, will re-submit the patch with correct prefix "lavfi"

> 
>> add denoise/sharpless support, used scope [-1, 100] as the input
>> scope.
>>
>> Signed-off-by: Jun Zhao 
>> ---
>>  libavfilter/vf_scale_vaapi.c | 112 
>> +++
>>  1 file changed, 112 insertions(+)
>>
>> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
>> index 8dd5acf..e48e201 100644
>> --- a/libavfilter/vf_scale_vaapi.c
>> +++ b/libavfilter/vf_scale_vaapi.c
>> @@ -53,6 +53,14 @@ typedef struct ScaleVAAPIContext {
>>  int output_width;
>>  int output_height;
>>
>> +VAProcFilterCap denoise_caps;
>> +int denoise; // enable denoise algo. level is the optional
>> + // value from the interval [-1, 100], -1 means 
>> disabled
>> +
>> +VAProcFilterCap sharpness_caps;
>> +int sharpness;   // enable sharpness. level is the optional value
>> + // from the interval [-1, 100], -1 means disabled
>> +
>>  } ScaleVAAPIContext;
>>
>>
>> @@ -117,6 +125,8 @@ static int scale_vaapi_config_output(AVFilterLink 
>> *outlink)
>>  AVVAAPIFramesContext *va_frames;
>>  VAStatus vas;
>>  int err, i;
>> +unsigned int num_denoise_caps = 1;
>> +unsigned int num_sharpness_caps = 1;
>>
>>  scale_vaapi_pipeline_uninit(ctx);
>>
>> @@ -225,6 +235,28 @@ static int scale_vaapi_config_output(AVFilterLink 
>> *outlink)
>>  goto fail;
>>  }
>>
>> +if (ctx->denoise != -1) {
>> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
>> ctx->va_context,
>> + VAProcFilterNoiseReduction,
>> + >denoise_caps, 
>> _denoise_caps);
>> +if (vas != VA_STATUS_SUCCESS) {
>> +av_log(ctx, AV_LOG_ERROR, "Failed to query denoise caps "
>> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
>> +return AVERROR(EIO);
>> +}
>> +}
>> +
>> +if (ctx->sharpness != -1) {
>> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
>> ctx->va_context,
>> + VAProcFilterSharpening,
>> + >sharpness_caps, 
>> _sharpness_caps);
>> +if (vas != VA_STATUS_SUCCESS) {
>> +av_log(ctx, AV_LOG_ERROR, "Failed to query sharpness caps "
>> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
>> +return AVERROR(EIO);
>> +}
>> +}
>> +
>>  av_freep();
>>  av_hwframe_constraints_free();
>>  return 0;
>> @@ -250,6 +282,14 @@ static int vaapi_proc_colour_standard(enum AVColorSpace 
>> av_cs)
>>  }
>>  }
>>
>> +static float map_to_range(
>> +int input, int in_min, int in_max,
>> +float out_min, float out_max)
>> +{
>> +return (input - in_min) * (out_max - out_min) / (in_max - in_min) + 
>> out_min;
>> +}
>> +
>> +
>>  static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame 
>> *input_frame)
>>  {
>>  AVFilterContext *avctx = inlink->dst;
>> @@ -259,6 +299,10 @@ static int scale_vaapi_filter_frame(AVFilterLink 
>> *inlink, AVFrame *input_frame)
>>  VASurfaceID input_surface, output_surface;
>>  VAProcPipelineParameterBuffer params;
>>  VABufferID params_id;
>> +VABufferID denoise_id;
>> +VABufferID sharpness_id;
>> +VABufferID filter_bufs[8];
> 
> VAProcFilterCount might be a better number than 8 as an upper bound on the 
> number of filters which could ever be added to this.

agree

> 
>> +int num_filter_bufs = 0;
>>  VAStatus vas;
>>  int err;
>>
>> @@ -290,6 +334,43 @@ static int scale_vaapi_filter_frame(AVFilterLink 
>> *inlink, AVFrame *input_frame)
>>  av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n",
>> output_surface);
>>
>> +if (ctx->denoise != -1) {
>> +VAProcFilterParameterBuffer denoise;
>> +denoise.type  = VAProcFilterNoiseReduction;
>> +denoise.value =  map_to_range(ctx->denoise, 0, 100,
>> +  ctx->denoise_caps.range.min_value,
>> +  ctx->denoise_caps.range.max_value);
>> +vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
>> +  

Re: [FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-11 Thread Moritz Barsnick
On Fri, Sep 09, 2016 at 11:31:22 +0800, Jun Zhao wrote:
> v4 : - fix sharpless typo(sharpless -> sharpness)
[...]

> Date: Tue, 30 Aug 2016 14:36:00 +0800
> Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.
> 
> add denoise/sharpless support, used scope [-1, 100] as the input
> scope.

Well, the commit message still contains the typo, twice. 

Also, please drop the space character before the colon. The top line of
the commit message should probably read:
lavfi/scale_vaapi: add denoise/sharpless support

Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-09 Thread Mark Thompson
On 09/09/16 04:31, Jun Zhao wrote:
> v4 : - fix sharpless typo(sharpless -> sharpness)
>  - when don't support denoise/sharpness, report the error and return
>  - fix denoise/sharpness params buffer leak in error handle
> v3 : fix sharpless mapping issue
> v2 : fix filter support flag check logic issue
> 
> From d1f0b556bdd6be4dffcd3b1b93cba5cd1098908a Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Tue, 30 Aug 2016 14:36:00 +0800
> Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.

I think libavfilter is generally "lavfi" ("lavf" is libavformat).

> add denoise/sharpless support, used scope [-1, 100] as the input
> scope.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_scale_vaapi.c | 112 
> +++
>  1 file changed, 112 insertions(+)
>
> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
> index 8dd5acf..e48e201 100644
> --- a/libavfilter/vf_scale_vaapi.c
> +++ b/libavfilter/vf_scale_vaapi.c
> @@ -53,6 +53,14 @@ typedef struct ScaleVAAPIContext {
>  int output_width;
>  int output_height;
>
> +VAProcFilterCap denoise_caps;
> +int denoise; // enable denoise algo. level is the optional
> + // value from the interval [-1, 100], -1 means 
> disabled
> +
> +VAProcFilterCap sharpness_caps;
> +int sharpness;   // enable sharpness. level is the optional value
> + // from the interval [-1, 100], -1 means disabled
> +
>  } ScaleVAAPIContext;
>
>
> @@ -117,6 +125,8 @@ static int scale_vaapi_config_output(AVFilterLink 
> *outlink)
>  AVVAAPIFramesContext *va_frames;
>  VAStatus vas;
>  int err, i;
> +unsigned int num_denoise_caps = 1;
> +unsigned int num_sharpness_caps = 1;
>
>  scale_vaapi_pipeline_uninit(ctx);
>
> @@ -225,6 +235,28 @@ static int scale_vaapi_config_output(AVFilterLink 
> *outlink)
>  goto fail;
>  }
>
> +if (ctx->denoise != -1) {
> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
> ctx->va_context,
> + VAProcFilterNoiseReduction,
> + >denoise_caps, 
> _denoise_caps);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to query denoise caps "
> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +}
> +
> +if (ctx->sharpness != -1) {
> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
> ctx->va_context,
> + VAProcFilterSharpening,
> + >sharpness_caps, 
> _sharpness_caps);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to query sharpness caps "
> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +}
> +
>  av_freep();
>  av_hwframe_constraints_free();
>  return 0;
> @@ -250,6 +282,14 @@ static int vaapi_proc_colour_standard(enum AVColorSpace 
> av_cs)
>  }
>  }
>
> +static float map_to_range(
> +int input, int in_min, int in_max,
> +float out_min, float out_max)
> +{
> +return (input - in_min) * (out_max - out_min) / (in_max - in_min) + 
> out_min;
> +}
> +
> +
>  static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame 
> *input_frame)
>  {
>  AVFilterContext *avctx = inlink->dst;
> @@ -259,6 +299,10 @@ static int scale_vaapi_filter_frame(AVFilterLink 
> *inlink, AVFrame *input_frame)
>  VASurfaceID input_surface, output_surface;
>  VAProcPipelineParameterBuffer params;
>  VABufferID params_id;
> +VABufferID denoise_id;
> +VABufferID sharpness_id;
> +VABufferID filter_bufs[8];

VAProcFilterCount might be a better number than 8 as an upper bound on the 
number of filters which could ever be added to this.

> +int num_filter_bufs = 0;
>  VAStatus vas;
>  int err;
>
> @@ -290,6 +334,43 @@ static int scale_vaapi_filter_frame(AVFilterLink 
> *inlink, AVFrame *input_frame)
>  av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n",
> output_surface);
>
> +if (ctx->denoise != -1) {
> +VAProcFilterParameterBuffer denoise;
> +denoise.type  = VAProcFilterNoiseReduction;
> +denoise.value =  map_to_range(ctx->denoise, 0, 100,
> +  ctx->denoise_caps.range.min_value,
> +  ctx->denoise_caps.range.max_value);
> +vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
> +   VAProcFilterParameterBufferType, sizeof(denoise), 1,
> +   , _id);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR,  "Failed to create denoise parameter 
> buffer: "
> +   "%d 

[FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-08 Thread Jun Zhao
v4 : - fix sharpless typo(sharpless -> sharpness)
 - when don't support denoise/sharpness, report the error and return
 - fix denoise/sharpness params buffer leak in error handle
v3 : fix sharpless mapping issue
v2 : fix filter support flag check logic issue
From d1f0b556bdd6be4dffcd3b1b93cba5cd1098908a Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Tue, 30 Aug 2016 14:36:00 +0800
Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.

add denoise/sharpless support, used scope [-1, 100] as the input
scope.

Signed-off-by: Jun Zhao 
---
 libavfilter/vf_scale_vaapi.c | 112 +++
 1 file changed, 112 insertions(+)

diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 8dd5acf..e48e201 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -53,6 +53,14 @@ typedef struct ScaleVAAPIContext {
 int output_width;
 int output_height;
 
+VAProcFilterCap denoise_caps;
+int denoise; // enable denoise algo. level is the optional
+ // value from the interval [-1, 100], -1 means 
disabled
+
+VAProcFilterCap sharpness_caps;
+int sharpness;   // enable sharpness. level is the optional value
+ // from the interval [-1, 100], -1 means disabled
+
 } ScaleVAAPIContext;
 
 
@@ -117,6 +125,8 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
 AVVAAPIFramesContext *va_frames;
 VAStatus vas;
 int err, i;
+unsigned int num_denoise_caps = 1;
+unsigned int num_sharpness_caps = 1;
 
 scale_vaapi_pipeline_uninit(ctx);
 
@@ -225,6 +235,28 @@ static int scale_vaapi_config_output(AVFilterLink *outlink)
 goto fail;
 }
 
+if (ctx->denoise != -1) {
+vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, ctx->va_context,
+ VAProcFilterNoiseReduction,
+ >denoise_caps, 
_denoise_caps);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed to query denoise caps "
+   "context: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+}
+
+if (ctx->sharpness != -1) {
+vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, ctx->va_context,
+ VAProcFilterSharpening,
+ >sharpness_caps, 
_sharpness_caps);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR, "Failed to query sharpness caps "
+   "context: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+}
+
 av_freep();
 av_hwframe_constraints_free();
 return 0;
@@ -250,6 +282,14 @@ static int vaapi_proc_colour_standard(enum AVColorSpace 
av_cs)
 }
 }
 
+static float map_to_range(
+int input, int in_min, int in_max,
+float out_min, float out_max)
+{
+return (input - in_min) * (out_max - out_min) / (in_max - in_min) + 
out_min;
+}
+
+
 static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
 {
 AVFilterContext *avctx = inlink->dst;
@@ -259,6 +299,10 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 VASurfaceID input_surface, output_surface;
 VAProcPipelineParameterBuffer params;
 VABufferID params_id;
+VABufferID denoise_id;
+VABufferID sharpness_id;
+VABufferID filter_bufs[8];
+int num_filter_bufs = 0;
 VAStatus vas;
 int err;
 
@@ -290,6 +334,43 @@ static int scale_vaapi_filter_frame(AVFilterLink *inlink, 
AVFrame *input_frame)
 av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n",
output_surface);
 
+if (ctx->denoise != -1) {
+VAProcFilterParameterBuffer denoise;
+denoise.type  = VAProcFilterNoiseReduction;
+denoise.value =  map_to_range(ctx->denoise, 0, 100,
+  ctx->denoise_caps.range.min_value,
+  ctx->denoise_caps.range.max_value);
+vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
+   VAProcFilterParameterBufferType, sizeof(denoise), 1,
+   , _id);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(ctx, AV_LOG_ERROR,  "Failed to create denoise parameter 
buffer: "
+   "%d (%s).\n", vas, vaErrorStr(vas));
+err = AVERROR(EIO);
+goto fail;
+}
+filter_bufs[num_filter_bufs++] = denoise_id;
+}
+
+if (ctx->sharpness != -1) {
+VAProcFilterParameterBuffer sharpness;
+sharpness.type  = VAProcFilterSharpening;
+sharpness.value = map_to_range(ctx->sharpness,
+   0, 100,
+   ctx->sharpness_caps.range.min_value,
+