[FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
Michael Niedermayer
michael at niedermayer.cc
Sun Aug 12 00:45:35 EEST 2018
On Sat, Aug 11, 2018 at 05:52:32PM +0300, Sergey Lavrushkin wrote:
> 2018-08-10 20:24 GMT+03:00 Michael Niedermayer <michael at niedermayer.cc>:
>
> > On Thu, Aug 09, 2018 at 08:15:16PM +0300, Sergey Lavrushkin wrote:
> > > Here are updated patches with fixes. I updated conversion functions, so
> > > they should
> > > properly work with format for different endianness.
> > [...]
> > > diff --git a/libswscale/input.c b/libswscale/input.c
> > > index 3fd3a5d81e..0e016d387f 100644
> > > --- a/libswscale/input.c
> > > +++ b/libswscale/input.c
> > > @@ -942,6 +942,30 @@ static av_always_inline void
> > planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
> > > }
> > > #undef rdpx
> > >
> > > +static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const
> > uint8_t *_src, const uint8_t *unused1,
> > > + const uint8_t *unused2, int
> > width, uint32_t *unused)
> > > +{
> > > + int i;
> > > + const float *src = (const float *)_src;
> > > + uint16_t *dst = (uint16_t *)_dst;
> > > +
> > > + for (i = 0; i < width; ++i){
> > > + dst[i] = lrintf(65535.0f * FFMIN(FFMAX(src[i], 0.0f), 1.0f));
> > > + }
> > > +}
> >
> > is it faster to clip the float before lrintf() than the integer afterwards
> > ?
> >
>
> Clipping integers is faster, switched to it.
>
>
> > [...]
> > > diff --git a/libswscale/output.c b/libswscale/output.c
> > > index 0af2fffea4..cd408fb285 100644
> > > --- a/libswscale/output.c
> > > +++ b/libswscale/output.c
> > > @@ -208,6 +208,121 @@ static void yuv2p016cX_c(SwsContext *c, const
> > int16_t *chrFilter, int chrFilterS
> > > }
> > > }
> > >
> > > +static av_always_inline void
> > > +yuv2plane1_float_c_template(const int32_t *src, float *dest, int dstW)
> > > +{
> > > +#if HAVE_BIGENDIAN
> > > + static const int big_endian = 1;
> > > +#else
> > > + static const int big_endian = 0;
> > > +#endif
> >
> > you can use HAVE_BIGENDIAN in place of big_endian
> > its either 0 or 1 already
> > or static const int big_endian = HAVE_BIGENDIAN
> >
>
> Ok.
>
> Here is updated patch.
> libswscale/input.c | 38 +++++++++++
> libswscale/output.c | 105 +++++++++++++++++++++++++++++++
> libswscale/ppc/swscale_altivec.c | 1
> libswscale/swscale_internal.h | 9 ++
> libswscale/swscale_unscaled.c | 54 +++++++++++++++
> libswscale/utils.c | 20 +++++
> libswscale/x86/swscale_template.c | 3
> tests/ref/fate/filter-pixdesc-grayf32be | 1
> tests/ref/fate/filter-pixdesc-grayf32le | 1
> tests/ref/fate/filter-pixfmts-copy | 2
> tests/ref/fate/filter-pixfmts-crop | 2
> tests/ref/fate/filter-pixfmts-field | 2
> tests/ref/fate/filter-pixfmts-fieldorder | 2
> tests/ref/fate/filter-pixfmts-hflip | 2
> tests/ref/fate/filter-pixfmts-il | 2
> tests/ref/fate/filter-pixfmts-null | 2
> tests/ref/fate/filter-pixfmts-scale | 2
> tests/ref/fate/filter-pixfmts-transpose | 2
> tests/ref/fate/filter-pixfmts-vflip | 2
> 19 files changed, 248 insertions(+), 4 deletions(-)
> db401051d0e42132f7ce76cb78de584951be704b 0005-libswscale-Adds-conversions-from-to-float-gray-forma.patch
> From cf523bcb50537abbf6daf0eb799341d8b706d366 Mon Sep 17 00:00:00 2001
> From: Sergey Lavrushkin <dualfal at gmail.com>
> Date: Fri, 3 Aug 2018 18:06:50 +0300
> Subject: [PATCH 5/9] libswscale: Adds conversions from/to float gray format.
>
> ---
> libswscale/input.c | 38 +++++++++++
> libswscale/output.c | 105 +++++++++++++++++++++++++++++++
> libswscale/ppc/swscale_altivec.c | 1 +
> libswscale/swscale_internal.h | 9 +++
> libswscale/swscale_unscaled.c | 54 +++++++++++++++-
> libswscale/utils.c | 20 +++++-
> libswscale/x86/swscale_template.c | 3 +-
> tests/ref/fate/filter-pixdesc-grayf32be | 1 +
> tests/ref/fate/filter-pixdesc-grayf32le | 1 +
> tests/ref/fate/filter-pixfmts-copy | 2 +
> tests/ref/fate/filter-pixfmts-crop | 2 +
> tests/ref/fate/filter-pixfmts-field | 2 +
> tests/ref/fate/filter-pixfmts-fieldorder | 2 +
> tests/ref/fate/filter-pixfmts-hflip | 2 +
> tests/ref/fate/filter-pixfmts-il | 2 +
> tests/ref/fate/filter-pixfmts-null | 2 +
> tests/ref/fate/filter-pixfmts-scale | 2 +
> tests/ref/fate/filter-pixfmts-transpose | 2 +
> tests/ref/fate/filter-pixfmts-vflip | 2 +
> 19 files changed, 248 insertions(+), 4 deletions(-)
> create mode 100644 tests/ref/fate/filter-pixdesc-grayf32be
> create mode 100644 tests/ref/fate/filter-pixdesc-grayf32le
>
> diff --git a/libswscale/input.c b/libswscale/input.c
> index 3fd3a5d81e..7e45df50ce 100644
> --- a/libswscale/input.c
> +++ b/libswscale/input.c
> @@ -942,6 +942,30 @@ static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
> }
> #undef rdpx
>
> +static av_always_inline void grayf32ToY16_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused1,
> + const uint8_t *unused2, int width, uint32_t *unused)
> +{
> + int i;
> + const float *src = (const float *)_src;
> + uint16_t *dst = (uint16_t *)_dst;
> +
> + for (i = 0; i < width; ++i){
> + dst[i] = FFMIN(FFMAX(lrintf(65535.0f * src[i]), 0), 65535);
this should use a intermediate variable as FFMIN/MAX are macros
so the compiler would have to recognize and eliminate alot of duplicate
expressions if the arguments to FFMIN/MAX are complicated
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180811/158a4139/attachment.sig>
More information about the ffmpeg-devel
mailing list