[FFmpeg-devel] [PATCH v3 1/2] lavfi: add opencl tonemap filter.
Song, Ruiling
ruiling.song at intel.com
Thu Jun 7 18:16:56 EEST 2018
> -----Original Message-----
> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces at ffmpeg.org] On Behalf Of
> Michael Niedermayer
> Sent: Thursday, June 7, 2018 4:40 PM
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v3 1/2] lavfi: add opencl tonemap filter.
>
> On Wed, Jun 06, 2018 at 03:23:53PM +0800, Ruiling Song wrote:
> > This filter does HDR(HDR10/HLG) to SDR conversion with tone-mapping.
> >
> > An example command to use this filter with vaapi codecs:
> > FFMPEG -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
> > opencl=ocl at va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
> > vaapi -i INPUT -filter_hw_device ocl -filter_complex \
> > '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
> > [x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2
> OUTPUT
> >
> > Signed-off-by: Ruiling Song <ruiling.song at intel.com>
> > ---
> > this version mainly address Mark's comments on v2.
> >
> > Thanks!
> > Ruiling
> >
> > configure | 1 +
> > libavfilter/Makefile | 2 +
> > libavfilter/allfilters.c | 1 +
> > libavfilter/colorspace.c | 90 +++++
> > libavfilter/colorspace.h | 41 ++
> > libavfilter/opencl/colorspace_common.cl | 220 +++++++++++
> > libavfilter/opencl/tonemap.cl | 272 +++++++++++++
> > libavfilter/opencl_source.h | 2 +
> > libavfilter/vf_tonemap_opencl.c | 657
> ++++++++++++++++++++++++++++++++
> > 9 files changed, 1286 insertions(+)
> > create mode 100644 libavfilter/colorspace.c
> > create mode 100644 libavfilter/colorspace.h
> > create mode 100644 libavfilter/opencl/colorspace_common.cl
> > create mode 100644 libavfilter/opencl/tonemap.cl
> > create mode 100644 libavfilter/vf_tonemap_opencl.c
> >
> > --- /dev/null
> > +++ b/libavfilter/opencl/colorspace_common.cl
> > @@ -0,0 +1,220 @@
> > +/*
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
> > + */
> > +
> > +#define ST2084_MAX_LUMINANCE 10000.0f
> > +#define REFERENCE_WHITE 100.0f
> > +
>
> > +#if chroma_loc == 1
> > + #define chroma_sample(a,b,c,d) ((a + c) * 0.5f)
> > +#elif chroma_loc == 3
> > + #define chroma_sample(a,b,c,d) (a)
> > +#elif chroma_loc == 4
> > + #define chroma_sample(a,b,c,d) ((a + b) * 0.5f)
> > +#elif chroma_loc == 5
> > + #define chroma_sample(a,b,c,d) (c)
> > +#elif chroma_loc == 6
> > + #define chroma_sample(a,b,c,d) ((c + d) * 0.5f)
> > +#else
> > + #define chroma_sample(a,b,c,d) ((a + b + c + d) * 0.25f)
> > +#endif
>
> the arguments should be protected by () otherwise unexpected results can
> occur with some expressions
Yes, that's true, will fix it.
Ruiling
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Old school: Use the lowest level language in which you can solve the problem
> conveniently.
> New school: Use the highest level language in which the latest supercomputer
> can solve the problem without the user falling asleep waiting.
More information about the ffmpeg-devel
mailing list