[FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.

Song, Ruiling ruiling.song at intel.com
Tue May 22 05:11:27 EEST 2018



> -----Original Message-----
> From: mypopy at gmail.com [mailto:mypopy at gmail.com]
> Sent: Monday, May 21, 2018 3:23 PM
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Cc: sw at jkqxz.net; ffmpeg at haasn.xyz; Song, Ruiling <ruiling.song at intel.com>
> Subject: Re: [FFmpeg-devel] [PATCH] lavfi: add opencl tonemap filter.
> 
> 2018-05-21 14:50 GMT+08:00 Ruiling Song <ruiling.song at intel.com>:
> > 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>
> > ---
> >  configure                              |   1 +
> >  libavfilter/Makefile                   |   2 +
> >  libavfilter/allfilters.c               |   1 +
> >  libavfilter/colorspace_basic.c         |  89 ++++++
> >  libavfilter/colorspace_basic.h         |  40 +++
> >  libavfilter/opencl/colorspace_basic.cl | 179 +++++++++++
> >  libavfilter/opencl/tonemap.cl          | 258 +++++++++++++++
> >  libavfilter/opencl_source.h            |   2 +
> >  libavfilter/vf_tonemap_opencl.c        | 560
> +++++++++++++++++++++++++++++++++
> >  9 files changed, 1132 insertions(+)
> >  create mode 100644 libavfilter/colorspace_basic.c
> >  create mode 100644 libavfilter/colorspace_basic.h
> >  create mode 100644 libavfilter/opencl/colorspace_basic.cl
> >  create mode 100644 libavfilter/opencl/tonemap.cl
> >  create mode 100644 libavfilter/vf_tonemap_opencl.c
> >
> > diff --git a/libavfilter/opencl/colorspace_basic.cl
> b/libavfilter/opencl/colorspace_basic.cl
> > new file mode 100644
> > index 0000000..ffd98c2
> > --- /dev/null
> > +++ b/libavfilter/opencl/colorspace_basic.cl
> > @@ -0,0 +1,179 @@
> > +/*
> > + * 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
> > +constant const float ST2084_M1 = 0.1593017578125f;
> > +constant const float ST2084_M2 = 78.84375f;
> > +constant const float ST2084_C1 = 0.8359375f;
> > +constant const float ST2084_C2 = 18.8515625f;
> > +constant const float ST2084_C3 = 18.6875f;
> > +
> > +// TODO Move these colorspace matrix to .cpp files
> what's .cpp files? is it porting from some cpp file?
Sorry, this is a typo. It should be '.c'. It's better to move this matrix generation into .c file, so that it is easy to support more color spaces.
But currently, it is not so urgent as the tonemap only cares about bt709/bt2020 now.

Thanks!
Ruiling

> > +__constant float yuv2rgb_bt2020[] = {
> > +    1.0f, 0.0f, 1.4746f,
> > +    1.0f, -0.16455f, -0.57135f,
> > +    1.0f, 1.8814f, 0.0f
> > +};
> > +
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 
> 
> --
> =======================================
> Pixelworks
> Room 301-303 No. 88,Lane 887 Zuchongzhi Road, Zhangjiang Hi-tech Park,
> Shanghai 201203, China
> Best Regards,
> Jun zhao/赵军
> +++++++++++++++++++++++++++++++++++++++


More information about the ffmpeg-devel mailing list