[FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.

Sergey Lavrushkin dualfal at gmail.com
Sat Aug 11 17:52:32 EEST 2018


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-libswscale-Adds-conversions-from-to-float-gray-forma.patch
Type: text/x-patch
Size: 23426 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180811/8211031b/attachment.bin>


More information about the ffmpeg-devel mailing list