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

Michael Niedermayer michael at niedermayer.cc
Fri Aug 10 20:24:41 EEST 2018


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 ?


[...]
> 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

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- 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/20180810/672ac042/attachment.sig>


More information about the ffmpeg-devel mailing list