From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D6374428E7 for ; Mon, 5 Dec 2022 05:39:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E4C5C68BC39; Mon, 5 Dec 2022 07:39:28 +0200 (EET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96F8868BC0E for ; Mon, 5 Dec 2022 07:39:22 +0200 (EET) Received: by mail-pj1-f46.google.com with SMTP id u5so808221pjy.5 for ; Sun, 04 Dec 2022 21:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=SPBNEbh29uLLhLGdCMvlD2R/Lfb0afvqJ9WUp1gW37M=; b=PwWDzX4Ia68m1Hrk2DGeSp1RHkgCgcCpmcWPDeTN2EkU6JzRq1QosANYsPLinPeeaU BBDXA6llMm+3jFgKvCMP46PLR/V6FxAA+PBaTtT9waF3znRzplM/5tjwmfw9OQuCpckp tyDoNKAJh4fuMp0jJfkDCyBSfO26Xfxz8J0+CtMmeYrHShv7c9UG9DllhAMOjwL8v54P 8U3CSOVvIJPfrjGLaCmxT1V1/nVQMzBh2CqwZjlQn+qNwGuuDw16sa7p0lxCWFXdfFe3 XlxI4yP4LcscdJnI75jGUUWSrZ2Mskl0FyP1ZmxIVunf/dAohD0RmbtUMYBWRZfpGFkE 9JVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SPBNEbh29uLLhLGdCMvlD2R/Lfb0afvqJ9WUp1gW37M=; b=m7cxjVosMF+bDl5SehyjVEuJ9bENRNRjvY/zT/+/K38KhxOBgcApKmDItWYrExXXjK fw+vJUpAKSKeQPfVP4DJzlyv/kgkFRCV/iijuKIQyyhMCU87HVuuBojxKMtzuTu3gLqW jwqvcmA88kIauO/ZkWoILu6k9j3HnnRWE09zNHA6Ypj7PDgr7ODClVwDebpAc856AFg6 ftwB2SLPlju5YoKBJ6kgArGGEt3CuVbK3CJ2VIHFm6UVwuHrsAR2L/JUFviO99lk3d5B CUULMSA9+48xF2272ksY+rj13Hug4FYE6xbSo2gSRnybi4z2rprgWSX0zUCbMOybfAl3 VwLg== X-Gm-Message-State: ANoB5pmrvROupjl/1SaHgq0t426s3V62RCEHJxXoLrjFtA0bMHW3MAZF VaeGVtmc7nLGXTE2tQAGbvyjQxZANPWKa5oSkvNswlG28SE= X-Google-Smtp-Source: AA0mqf67tuUl96VJD+MLvu+QmVZfTfGeRatA2kI1+luVEUBHSRvt7Wu7iRuFu/6GJpet+cyufhC1DAoDOL7h+8AZ9YU= X-Received: by 2002:a17:90a:2ec2:b0:219:d1eb:b8a1 with SMTP id h2-20020a17090a2ec200b00219d1ebb8a1mr3829553pjs.174.1670218760404; Sun, 04 Dec 2022 21:39:20 -0800 (PST) MIME-Version: 1.0 References: <20221123193540.741-1-mindmark@gmail.com> <20221123193540.741-5-mindmark@gmail.com> <20221205000523.GX3806951@pb2> In-Reply-To: <20221205000523.GX3806951@pb2> From: Mark Reid Date: Sun, 4 Dec 2022 21:39:08 -0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH v5 4/4] swscale/output: add rgbaf32 output support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, Dec 4, 2022 at 4:05 PM Michael Niedermayer wrote: > On Wed, Nov 23, 2022 at 11:35:40AM -0800, mindmark@gmail.com wrote: > > From: Mark Reid > > > > --- > > libswscale/output.c | 92 ++++++++++++++++++++++++ > > libswscale/swscale_unscaled.c | 4 +- > > libswscale/tests/floatimg_cmp.c | 4 +- > > libswscale/utils.c | 16 +++-- > > libswscale/yuv2rgb.c | 2 + > > tests/ref/fate/filter-pixdesc-rgbaf32be | 1 + > > tests/ref/fate/filter-pixdesc-rgbaf32le | 1 + > > tests/ref/fate/filter-pixdesc-rgbf32be | 1 + > > tests/ref/fate/filter-pixdesc-rgbf32le | 1 + > > tests/ref/fate/filter-pixfmts-copy | 4 ++ > > tests/ref/fate/filter-pixfmts-crop | 4 ++ > > tests/ref/fate/filter-pixfmts-field | 4 ++ > > tests/ref/fate/filter-pixfmts-fieldorder | 4 ++ > > tests/ref/fate/filter-pixfmts-hflip | 4 ++ > > tests/ref/fate/filter-pixfmts-il | 4 ++ > > tests/ref/fate/filter-pixfmts-null | 4 ++ > > tests/ref/fate/filter-pixfmts-scale | 4 ++ > > tests/ref/fate/filter-pixfmts-transpose | 4 ++ > > tests/ref/fate/filter-pixfmts-vflip | 4 ++ > > tests/ref/fate/sws-floatimg-cmp | 16 +++++ > > 20 files changed, 170 insertions(+), 8 deletions(-) > > create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32be > > create mode 100644 tests/ref/fate/filter-pixdesc-rgbaf32le > > create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32be > > create mode 100644 tests/ref/fate/filter-pixdesc-rgbf32le > > > > diff --git a/libswscale/output.c b/libswscale/output.c > > index 5c85bff971..1d86a244f9 100644 > > --- a/libswscale/output.c > > +++ b/libswscale/output.c > > @@ -2471,6 +2471,92 @@ yuv2gbrpf32_full_X_c(SwsContext *c, const int16_t > *lumFilter, > > } > > } > > > > +static void > > +yuv2rgbaf32_full_X_c(SwsContext *c, const int16_t *lumFilter, > > + const int16_t **lumSrcx, int lumFilterSize, > > + const int16_t *chrFilter, const int16_t **chrUSrcx, > > + const int16_t **chrVSrcx, int chrFilterSize, > > + const int16_t **alpSrcx, uint8_t *dest, > > + int dstW, int y) > > +{ > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->dstFormat); > > + int i; > > + int alpha = desc->flags & AV_PIX_FMT_FLAG_ALPHA; > > + int hasAlpha = alpha && alpSrcx; > > + int pixelStep = alpha ? 4 : 3; > > + uint32_t *dest32 = (uint32_t*)dest; > > + const int32_t **lumSrc = (const int32_t**)lumSrcx; > > + const int32_t **chrUSrc = (const int32_t**)chrUSrcx; > > + const int32_t **chrVSrc = (const int32_t**)chrVSrcx; > > + const int32_t **alpSrc = (const int32_t**)alpSrcx; > > + static const float float_mult = 1.0f / 65535.0f; > > + uint32_t a = av_float2int(1.0f); > > + > > + for (i = 0; i < dstW; i++) { > > + int j; > > + int Y = -0x40000000; > > + int U = -(128 << 23); > > + int V = -(128 << 23); > > + int R, G, B, A; > > + > > + for (j = 0; j < lumFilterSize; j++) > > + Y += lumSrc[j][i] * (unsigned)lumFilter[j]; > > + > > + for (j = 0; j < chrFilterSize; j++) { > > + U += chrUSrc[j][i] * (unsigned)chrFilter[j]; > > + V += chrVSrc[j][i] * (unsigned)chrFilter[j]; > > + } > > + > > + Y >>= 14; > > + Y += 0x10000; > > + U >>= 14; > > + V >>= 14; > > + > > + if (hasAlpha) { > > + A = -0x40000000; > > + > > + for (j = 0; j < lumFilterSize; j++) > > + A += alpSrc[j][i] * (unsigned)lumFilter[j]; > > + > > + A >>= 1; > > + A += 0x20002000; > > + a = av_float2int(float_mult * (float)(av_clip_uintp2(A, 30) > >> 14)); > > + } > > + > > + Y -= c->yuv2rgb_y_offset; > > + Y *= c->yuv2rgb_y_coeff; > > + Y += (1 << 13) - (1 << 29); > > + R = V * c->yuv2rgb_v2r_coeff; > > + G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff; > > + B = U * c->yuv2rgb_u2b_coeff; > > + > > + R = av_clip_uintp2(((Y + R) >> 14) + (1<<15), 16); > > + G = av_clip_uintp2(((Y + G) >> 14) + (1<<15), 16); > > + B = av_clip_uintp2(((Y + B) >> 14) + (1<<15), 16); > > + > > + dest32[0] = av_float2int(float_mult * (float)R); > > + dest32[1] = av_float2int(float_mult * (float)G); > > + dest32[2] = av_float2int(float_mult * (float)B); > > + if (alpha) > > + dest32[3] = a; > > why is this using uint32_t with av_float2int() and not floats straight ? > > It's this way because it is matching the planar f32 version, I will change both. > > > > + > > + dest32 += pixelStep; > > + } > > + if ((!isBE(c->dstFormat)) != (!HAVE_BIGENDIAN)) { > > + dest32 = (uint32_t*)dest; > > + for (i = 0; i < dstW; i++) { > > + dest32[0] = av_bswap32(dest32[0]); > > + dest32[1] = av_bswap32(dest32[1]); > > + dest32[2] = av_bswap32(dest32[2]); > > + if (alpha) > > + dest32[3] = av_bswap32(dest32[3]); > > + > > + dest32 += pixelStep; > > + } > > + } > > teh code in bswapdsp seems more efficient, that should be shared and > used ideally > I just sent a patch moving the bswapdsp code from avcodec to avutil > > thx > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. > User > questions about the command line tools should be sent to the ffmpeg-user > ML. > And questions about how to use libav* should be sent to the libav-user ML. > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".