Re: [FFmpeg-devel] [PATCH] avfilter/vf_premultiply: add inplace mode

2017-08-07 Thread Nicolas George
Le septidi 17 thermidor, an CCXXV, Paul B Mahol a écrit :
> Hi,
> 
> patch attached.

> From f952d9a2c87f7c2387d509e986aee5adb424d9d2 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Fri, 4 Aug 2017 22:28:53 +0200
> Subject: [PATCH] avfilter/vf_premultiply: add inplace mode
> 
> ---
>  libavfilter/vf_premultiply.c | 195 
> +++
>  1 file changed, 142 insertions(+), 53 deletions(-)
> 
> diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c
> index 9ecafe4..2b5348b 100644
> --- a/libavfilter/vf_premultiply.c
> +++ b/libavfilter/vf_premultiply.c
> @@ -22,6 +22,7 @@
>  #include "libavutil/pixdesc.h"
>  #include "libavutil/opt.h"
>  #include "avfilter.h"
> +#include "filters.h"
>  #include "formats.h"
>  #include "framesync2.h"
>  #include "internal.h"
> @@ -34,6 +35,7 @@ typedef struct PreMultiplyContext {
>  int nb_planes;
>  int planes;
>  int inverse;
> +int inplace;
>  int half, depth, offset, max;
>  FFFrameSync fs;
>  
> @@ -50,6 +52,7 @@ typedef struct PreMultiplyContext {
>  
>  static const AVOption options[] = {
>  { "planes", "set planes", OFFSET(planes), AV_OPT_TYPE_INT, {.i64=0xF}, 
> 0, 0xF, FLAGS },
> +{ "inplace","enable inplace mode", OFFSET(inplace), AV_OPT_TYPE_BOOL, 
> {.i64=0}, 0, 1, FLAGS },
>  { NULL }
>  };
>  
> @@ -58,7 +61,9 @@ AVFILTER_DEFINE_CLASS(premultiply);
>  
>  static int query_formats(AVFilterContext *ctx)
>  {
> -static const enum AVPixelFormat pix_fmts[] = {
> +PreMultiplyContext *s = ctx->priv;
> +
> +static const enum AVPixelFormat no_alpha_pix_fmts[] = {
>  AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
>  AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
>  AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV444P14,
> @@ -69,7 +74,15 @@ static int query_formats(AVFilterContext *ctx)
>  AV_PIX_FMT_NONE
>  };
>  
> -return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
> +static const enum AVPixelFormat alpha_pix_fmts[] = {
> +AV_PIX_FMT_YUVA444P,
> +AV_PIX_FMT_YUVA444P9, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P16,
> +AV_PIX_FMT_GBRAP,
> +AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16,
> +AV_PIX_FMT_NONE
> +};
> +
> +return ff_set_common_formats(ctx, ff_make_format_list(s->inplace ? 
> alpha_pix_fmts : no_alpha_pix_fmts));
>  }
>  
>  static void premultiply8(const uint8_t *msrc, const uint8_t *asrc,
> @@ -348,29 +361,23 @@ static void unpremultiply16offset(const uint8_t *mmsrc, 
> const uint8_t *aasrc,
>  }
>  }
>  
> -static int process_frame(FFFrameSync *fs)
> +static int filter_frame(AVFilterContext *ctx,
> +AVFrame **out, AVFrame *base, AVFrame *alpha)
>  {
> -AVFilterContext *ctx = fs->parent;
> -PreMultiplyContext *s = fs->opaque;
> +PreMultiplyContext *s = ctx->priv;
>  AVFilterLink *outlink = ctx->outputs[0];
> -AVFrame *out, *base, *alpha;
> -int ret;
> -
> -if ((ret = ff_framesync2_get_frame(>fs, 0, ,  0)) < 0 ||
> -(ret = ff_framesync2_get_frame(>fs, 1, , 0)) < 0)
> -return ret;
>  
>  if (ctx->is_disabled) {
> -out = av_frame_clone(base);
> -if (!out)
> +*out = av_frame_clone(base);
> +if (!*out)
>  return AVERROR(ENOMEM);
>  } else {
>  int p, full, limited;
>  
> -out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> -if (!out)
> +*out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
> +if (!*out)
>  return AVERROR(ENOMEM);
> -av_frame_copy_props(out, base);
> +av_frame_copy_props(*out, base);
>  
>  full = base->color_range == AVCOL_RANGE_JPEG;
>  limited = base->color_range == AVCOL_RANGE_MPEG;
> @@ -378,6 +385,7 @@ static int process_frame(FFFrameSync *fs)
>  if (s->inverse) {
>  switch (outlink->format) {
>  case AV_PIX_FMT_YUV444P:
> +case AV_PIX_FMT_YUVA444P:
>  s->premultiply[0] = full ? unpremultiply8 : 
> unpremultiply8offset;
>  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
>  break;
> @@ -386,21 +394,28 @@ static int process_frame(FFFrameSync *fs)
>  s->premultiply[1] = s->premultiply[2] = unpremultiply8yuv;
>  break;
>  case AV_PIX_FMT_GBRP:
> +case AV_PIX_FMT_GBRAP:
>  s->premultiply[0] = s->premultiply[1] = s->premultiply[2] = 
> limited ? unpremultiply8offset : unpremultiply8;
>  break;
>  case AV_PIX_FMT_YUV444P9:
> +case AV_PIX_FMT_YUVA444P9:
>  case AV_PIX_FMT_YUV444P10:
> +case AV_PIX_FMT_YUVA444P10:
>  case AV_PIX_FMT_YUV444P12:
>  case AV_PIX_FMT_YUV444P14:
>  case AV_PIX_FMT_YUV444P16:
> +case AV_PIX_FMT_YUVA444P16:

Re: [FFmpeg-devel] [PATCH] avfilter/vf_premultiply: add inplace mode

2017-08-05 Thread Paul B Mahol
On 8/5/17, Nicolas George  wrote:
> Le septidi 17 thermidor, an CCXXV, Paul B Mahol a écrit :
>> From f952d9a2c87f7c2387d509e986aee5adb424d9d2 Mon Sep 17 00:00:00 2001
>> From: Paul B Mahol 
>> Date: Fri, 4 Aug 2017 22:28:53 +0200
>> Subject: [PATCH] avfilter/vf_premultiply: add inplace mode
>>
>> ---
>>  libavfilter/vf_premultiply.c | 195
>> +++
>>  1 file changed, 142 insertions(+), 53 deletions(-)
>
> But what does it do? How does it benefit the user?

I posted this mainly for comments on activate usage.

Basically with activated option it do not need two inputs but just
one, so now I need to know how to correctly use activate just to pass
what you get frames to next filter.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter/vf_premultiply: add inplace mode

2017-08-05 Thread Nicolas George
Le septidi 17 thermidor, an CCXXV, Paul B Mahol a écrit :
> From f952d9a2c87f7c2387d509e986aee5adb424d9d2 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol 
> Date: Fri, 4 Aug 2017 22:28:53 +0200
> Subject: [PATCH] avfilter/vf_premultiply: add inplace mode
> 
> ---
>  libavfilter/vf_premultiply.c | 195 
> +++
>  1 file changed, 142 insertions(+), 53 deletions(-)

But what does it do? How does it benefit the user?

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter/vf_premultiply: add inplace mode

2017-08-04 Thread Paul B Mahol
Hi,

patch attached.


0001-avfilter-vf_premultiply-add-inplace-mode.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel