[FFmpeg-devel] [PATCH v4 1/4] swscale/input: add rgbaf32 input support
Michael Niedermayer
michael at niedermayer.cc
Tue Nov 22 21:42:47 EET 2022
On Mon, Nov 21, 2022 at 02:11:43PM -0800, mindmark at gmail.com wrote:
> From: Mark Reid <mindmark at gmail.com>
>
> ---
> libswscale/input.c | 120 +++++++++++++++++++++++++++++++++++++++++++++
> libswscale/utils.c | 6 +++
> 2 files changed, 126 insertions(+)
>
> diff --git a/libswscale/input.c b/libswscale/input.c
> index d5676062a2..a305be5ac2 100644
> --- a/libswscale/input.c
> +++ b/libswscale/input.c
> @@ -1284,6 +1284,96 @@ static void rgbaf16##endian_name##ToA_c(uint8_t *_dst, const uint8_t *_src, cons
> rgbaf16_funcs_endian(le, 0)
> rgbaf16_funcs_endian(be, 1)
>
> +#define rdpx(src) (is_be ? av_int2float(AV_RB32(&src)): av_int2float(AV_RL32(&src)))
> +
> +static av_always_inline void rgbaf32ToUV_endian(uint16_t *dstU, uint16_t *dstV, int is_be,
> + const float *src, int width,
> + int32_t *rgb2yuv, int comp)
> +{
> + int32_t ru = rgb2yuv[RU_IDX], gu = rgb2yuv[GU_IDX], bu = rgb2yuv[BU_IDX];
> + int32_t rv = rgb2yuv[RV_IDX], gv = rgb2yuv[GV_IDX], bv = rgb2yuv[BV_IDX];
> + int i;
> + for (i = 0; i < width; i++) {
> + int r = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, 65535.0f));
> + int g = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, 65535.0f));
> + int b = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, 65535.0f));
> +
> + dstU[i] = (ru*r + gu*g + bu*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> + dstV[i] = (rv*r + gv*g + bv*b + (0x10001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> + }
> +}
> +
> +static av_always_inline void rgbaf32ToY_endian(uint16_t *dst, const float *src, int is_be,
> + int width, int32_t *rgb2yuv, int comp)
> +{
> + int32_t ry = rgb2yuv[RY_IDX], gy = rgb2yuv[GY_IDX], by = rgb2yuv[BY_IDX];
> + int i;
> + for (i = 0; i < width; i++) {
> + int r = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+0]), 0.0f, 65535.0f));
> + int g = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+1]), 0.0f, 65535.0f));
> + int b = lrintf(av_clipf(65535.0f * rdpx(src[i*comp+2]), 0.0f, 65535.0f));
> +
> + dst[i] = (ry*r + gy*g + by*b + (0x2001<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT;
> + }
> +}
I thought you would post a patchset that in the end has 1 lrintf/av_clipf
for a function like this not 3
Just asking as you arent saying this is temporary in this set nor why its
left liek this nor does it include the factorization of these operations
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20221122/7123dfd8/attachment.sig>
More information about the ffmpeg-devel
mailing list