Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-06 Thread Lance Wang
OK,  I'll update the doc/filters.texi for the new option for the update
patch.  Thanks for the feedback.

On Thu, Jun 6, 2019 at 2:19 PM Liu Steven  wrote:

>
>
> > 在 2019年6月6日,下午2:06,Lance Wang  写道:
> >
> > On Sun, May 26, 2019 at 8:08 AM  wrote:
> >
> >> From: Limin Wang 
> >>
> >> The test ffmpeg command in iMAC system:
> >> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
> >> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
> >> Now I have tested with yuv420p10 overlay and check the result is OK,
> >> please help to test with your condition.
> >> ---
> >> libavfilter/vf_overlay.c | 42 +++-
> >> libavfilter/vf_overlay.h |  1 +
> >> 2 files changed, 42 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> >> index 2d06074f15..e708d525e5 100644
> >> --- a/libavfilter/vf_overlay.c
> >> +++ b/libavfilter/vf_overlay.c
> >> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx,
> const
> >> char *cmd, const char *ar
> >> }
> >>
> >> static const enum AVPixelFormat alpha_pix_fmts[] = {
> >> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
> >> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
> >> AV_PIX_FMT_YUVA444P,
> >> AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
> >> AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
> >> };
> >> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
> >> AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
> >> };
> >>
> >> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
> >> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
> >> +AV_PIX_FMT_NONE
> >> +};
> >> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
> >> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
> >> +};
> >> +
> >> static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
> >> AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
> >> AV_PIX_FMT_NONE
> >> };
> >> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
> >> goto fail;
> >> }
> >> break;
> >> +case OVERLAY_FORMAT_YUV420P10:
> >> +if (!(main_formats=
> >> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
> >> +!(overlay_formats =
> >> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
> >> +ret = AVERROR(ENOMEM);
> >> +goto fail;
> >> +}
> >> +break;
> >> case OVERLAY_FORMAT_YUV422:
> >> if (!(main_formats=
> >> ff_make_format_list(main_pix_fmts_yuv422)) ||
> >> !(overlay_formats =
> >> ff_make_format_list(overlay_pix_fmts_yuv422))) {
> >> @@ -565,6 +580,7 @@ static av_always_inline void
> >> blend_plane_##depth##_##nbits##bits(AVFilterContext
> >> }
> >>  \
> >> }
> >> DEFINE_BLEND_PLANE(8, 8);
> >> +DEFINE_BLEND_PLANE(16, 10);
> >>
> >> #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
> >> \
> >> static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
> >> *src, const AVFrame *dst, \
> >> @@ -616,6 +632,7 @@ static inline void
> >> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
> >> }
> >>  \
> >> }
> >> DEFINE_ALPHA_COMPOSITE(8, 8);
> >> +DEFINE_ALPHA_COMPOSITE(16, 10);
> >>
> >> #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
> >> \
> >> static av_always_inline void
> >> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
> >>   \
> >> @@ -646,6 +663,7 @@ static av_always_inline void
> >> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
> >> alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
> >> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
> >> }
> >> DEFINE_BLEND_SLICE_YUV(8, 8);
> >> +DEFINE_BLEND_SLICE_YUV(16, 10);
> >>
> >> static av_always_inline void blend_slice_planar_rgb(AVFilterContext
> *ctx,
> >> AVFrame *dst, const
> >> AVFrame *src,
> >> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext
> *ctx,
> >> void *arg, int jobnr, int n
> >> return 0;
> >> }
> >>
> >> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
> >> jobnr, int nb_jobs)
> >> +{
> >> +OverlayContext *s = ctx->priv;
> >> +ThreadData *td = arg;
> >> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x,
> s->y,
> >> 1, jobnr, nb_jobs);
> >> +return 0;
> >> +}
> >> +
> >> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
> >> jobnr, int nb_jobs)
> >> +{
> >> +OverlayContext *s = ctx->priv;
> >> +ThreadData *td = arg;
> >> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x,
> s->y,
> >> 1, jobnr, nb_jobs);
> 

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-06 Thread Liu Steven


> 在 2019年6月6日,下午2:06,Lance Wang  写道:
> 
> On Sun, May 26, 2019 at 8:08 AM  wrote:
> 
>> From: Limin Wang 
>> 
>> The test ffmpeg command in iMAC system:
>> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
>> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
>> Now I have tested with yuv420p10 overlay and check the result is OK,
>> please help to test with your condition.
>> ---
>> libavfilter/vf_overlay.c | 42 +++-
>> libavfilter/vf_overlay.h |  1 +
>> 2 files changed, 42 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
>> index 2d06074f15..e708d525e5 100644
>> --- a/libavfilter/vf_overlay.c
>> +++ b/libavfilter/vf_overlay.c
>> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx, const
>> char *cmd, const char *ar
>> }
>> 
>> static const enum AVPixelFormat alpha_pix_fmts[] = {
>> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
>> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
>> AV_PIX_FMT_YUVA444P,
>> AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
>> AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
>> };
>> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
>> AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
>> };
>> 
>> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
>> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
>> +AV_PIX_FMT_NONE
>> +};
>> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
>> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
>> +};
>> +
>> static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
>> AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
>> AV_PIX_FMT_NONE
>> };
>> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
>> goto fail;
>> }
>> break;
>> +case OVERLAY_FORMAT_YUV420P10:
>> +if (!(main_formats=
>> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
>> +!(overlay_formats =
>> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
>> +ret = AVERROR(ENOMEM);
>> +goto fail;
>> +}
>> +break;
>> case OVERLAY_FORMAT_YUV422:
>> if (!(main_formats=
>> ff_make_format_list(main_pix_fmts_yuv422)) ||
>> !(overlay_formats =
>> ff_make_format_list(overlay_pix_fmts_yuv422))) {
>> @@ -565,6 +580,7 @@ static av_always_inline void
>> blend_plane_##depth##_##nbits##bits(AVFilterContext
>> }
>>  \
>> }
>> DEFINE_BLEND_PLANE(8, 8);
>> +DEFINE_BLEND_PLANE(16, 10);
>> 
>> #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
>> \
>> static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
>> *src, const AVFrame *dst, \
>> @@ -616,6 +632,7 @@ static inline void
>> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
>> }
>>  \
>> }
>> DEFINE_ALPHA_COMPOSITE(8, 8);
>> +DEFINE_ALPHA_COMPOSITE(16, 10);
>> 
>> #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
>> \
>> static av_always_inline void
>> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
>>   \
>> @@ -646,6 +663,7 @@ static av_always_inline void
>> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
>> alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
>> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
>> }
>> DEFINE_BLEND_SLICE_YUV(8, 8);
>> +DEFINE_BLEND_SLICE_YUV(16, 10);
>> 
>> static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
>> AVFrame *dst, const
>> AVFrame *src,
>> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext *ctx,
>> void *arg, int jobnr, int n
>> return 0;
>> }
>> 
>> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
>> jobnr, int nb_jobs)
>> +{
>> +OverlayContext *s = ctx->priv;
>> +ThreadData *td = arg;
>> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y,
>> 1, jobnr, nb_jobs);
>> +return 0;
>> +}
>> +
>> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
>> jobnr, int nb_jobs)
>> +{
>> +OverlayContext *s = ctx->priv;
>> +ThreadData *td = arg;
>> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y,
>> 1, jobnr, nb_jobs);
>> +return 0;
>> +}
>> static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr,
>> int nb_jobs)
>> {
>> OverlayContext *s = ctx->priv;
>> @@ -855,6 +888,9 @@ static int config_input_main(AVFilterLink *inlink)
>> case OVERLAY_FORMAT_YUV420:
>> s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 :
>> blend_slice_yuv420;
>> break;
>> +case 

Re: [FFmpeg-devel] [PATCH 5/5] libavfilter/vf_overlay.c: add the yuv420p10 10bit support

2019-06-06 Thread Lance Wang
On Sun, May 26, 2019 at 8:08 AM  wrote:

> From: Limin Wang 
>
> The test ffmpeg command in iMAC system:
> ./ffmpeg -y  -i input.ts -i ./logo.png -filter_complex
> overlay=50:50:format=yuv420p10  -c:v hevc_videotoolbox ./test.ts
> Now I have tested with yuv420p10 overlay and check the result is OK,
> please help to test with your condition.
> ---
>  libavfilter/vf_overlay.c | 42 +++-
>  libavfilter/vf_overlay.h |  1 +
>  2 files changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> index 2d06074f15..e708d525e5 100644
> --- a/libavfilter/vf_overlay.c
> +++ b/libavfilter/vf_overlay.c
> @@ -153,7 +153,7 @@ static int process_command(AVFilterContext *ctx, const
> char *cmd, const char *ar
>  }
>
>  static const enum AVPixelFormat alpha_pix_fmts[] = {
> -AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P,
> +AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P,
> AV_PIX_FMT_YUVA444P,
>  AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA,
>  AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE
>  };
> @@ -172,6 +172,14 @@ static int query_formats(AVFilterContext *ctx)
>  AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE
>  };
>
> +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = {
> +AV_PIX_FMT_YUV420P10LE, AV_PIX_FMT_YUVA420P10LE,
> +AV_PIX_FMT_NONE
> +};
> +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = {
> +AV_PIX_FMT_YUVA420P10LE, AV_PIX_FMT_NONE
> +};
> +
>  static const enum AVPixelFormat main_pix_fmts_yuv422[] = {
>  AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P,
> AV_PIX_FMT_NONE
>  };
> @@ -217,6 +225,13 @@ static int query_formats(AVFilterContext *ctx)
>  goto fail;
>  }
>  break;
> +case OVERLAY_FORMAT_YUV420P10:
> +if (!(main_formats=
> ff_make_format_list(main_pix_fmts_yuv420p10)) ||
> +!(overlay_formats =
> ff_make_format_list(overlay_pix_fmts_yuv420p10))) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +break;
>  case OVERLAY_FORMAT_YUV422:
>  if (!(main_formats=
> ff_make_format_list(main_pix_fmts_yuv422)) ||
>  !(overlay_formats =
> ff_make_format_list(overlay_pix_fmts_yuv422))) {
> @@ -565,6 +580,7 @@ static av_always_inline void
> blend_plane_##depth##_##nbits##bits(AVFilterContext
>  }
>   \
>  }
>  DEFINE_BLEND_PLANE(8, 8);
> +DEFINE_BLEND_PLANE(16, 10);
>
>  #define DEFINE_ALPHA_COMPOSITE(depth, nbits)
>  \
>  static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame
> *src, const AVFrame *dst, \
> @@ -616,6 +632,7 @@ static inline void
> alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c
>  }
>   \
>  }
>  DEFINE_ALPHA_COMPOSITE(8, 8);
> +DEFINE_ALPHA_COMPOSITE(16, 10);
>
>  #define DEFINE_BLEND_SLICE_YUV(depth, nbits)
>  \
>  static av_always_inline void
> blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx,
>\
> @@ -646,6 +663,7 @@ static av_always_inline void
> blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon
>  alpha_composite_##depth##_##nbits##bits(src, dst, src_w, src_h,
> dst_w, dst_h, x, y, jobnr, nb_jobs);   \
>  }
>  DEFINE_BLEND_SLICE_YUV(8, 8);
> +DEFINE_BLEND_SLICE_YUV(16, 10);
>
>  static av_always_inline void blend_slice_planar_rgb(AVFilterContext *ctx,
>  AVFrame *dst, const
> AVFrame *src,
> @@ -692,6 +710,21 @@ static int blend_slice_yuva420(AVFilterContext *ctx,
> void *arg, int jobnr, int n
>  return 0;
>  }
>
> +static int blend_slice_yuv420p10(AVFilterContext *ctx, void *arg, int
> jobnr, int nb_jobs)
> +{
> +OverlayContext *s = ctx->priv;
> +ThreadData *td = arg;
> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 0, s->x, s->y,
> 1, jobnr, nb_jobs);
> +return 0;
> +}
> +
> +static int blend_slice_yuva420p10(AVFilterContext *ctx, void *arg, int
> jobnr, int nb_jobs)
> +{
> +OverlayContext *s = ctx->priv;
> +ThreadData *td = arg;
> +blend_slice_yuv_16_10bits(ctx, td->dst, td->src, 1, 1, 1, s->x, s->y,
> 1, jobnr, nb_jobs);
> +return 0;
> +}
>  static int blend_slice_yuv422(AVFilterContext *ctx, void *arg, int jobnr,
> int nb_jobs)
>  {
>  OverlayContext *s = ctx->priv;
> @@ -855,6 +888,9 @@ static int config_input_main(AVFilterLink *inlink)
>  case OVERLAY_FORMAT_YUV420:
>  s->blend_slice = s->main_has_alpha ? blend_slice_yuva420 :
> blend_slice_yuv420;
>  break;
> +case OVERLAY_FORMAT_YUV420P10:
> +s->blend_slice = s->main_has_alpha ? blend_slice_yuva420p10 :
> blend_slice_yuv420p10;
> +break;
>  case