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 8B65344ABE for ; Wed, 2 Nov 2022 21:46:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C33C68BEC6; Wed, 2 Nov 2022 23:46:38 +0200 (EET) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FE4B68BD94 for ; Wed, 2 Nov 2022 23:46:31 +0200 (EET) Received: by mail-lj1-f173.google.com with SMTP id s24so26692360ljs.11 for ; Wed, 02 Nov 2022 14:46:31 -0700 (PDT) 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=fzkQ9rn0ATb4UFDEM1YgKgWqk4F3YDpmHRBuA3ExkKk=; b=j43p+vPmVowog6HFhuq2WF+3xzF6c5UfNHne1dNNOEvO7BOggp5dr0nfkhbyeGu0Mk 3FLAL7W4Cn/kt7rZpqVpoE0f/OtGLE5bebAxnErtzDJXRgMlwHY0qWs+dtISjJI4hmFI M3hnPFGWz2/fo8Pm62xtLPUCXXmRwUyWk/b4SNAU4Ll94bxx7TFwt7hZCZc6JH2UCMax bBJaOU6zCeVuxLfvSdhaeC3HBntgUEYAZyKJbK9+wXDfoTRv7TgVJF2/XoFnFyLrh9dz y0zIoGh9VALWno8KpNo9fNmLg8iTDytImcmAj9oDZ6duaKU9ePYQdie3weC/Oc9nhVAD c9Dg== 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=fzkQ9rn0ATb4UFDEM1YgKgWqk4F3YDpmHRBuA3ExkKk=; b=1A/RcHTyge9Y66uSihaV1sDd5n29Eywfo3sOgGdlNCsi01jcg4Cd0pKAKsBBu0xMgW lkajsy64LwlQK2TKII6lGZdrZGM3o21zJJkbBchsL9ZOf2q1HJ8KV10V5QSa0slvQOvs P9u8Z+qkQIlUh0BwM1loTHEmGSoqCa2d5MJH0x/8NxXca/D+J6QH2nz89fPQWyHp3Np8 Ly1PiIlDb8tddpatULsyIRrBxoZqHMNQuu6odXDDjodzxu/vE34RO48OT2mDAsNMlWGo QflXU1y7z2q2k2oj8zgA4x5F7V/ejTZh5xDtQxfqx7IQwzCeTFwQUbNMfkP+gUR4ZNzB 2fWA== X-Gm-Message-State: ACrzQf0dwIjvKBB93heO+hJyM3lQE/QtlgLNxlup3GUXfyAYbo55XORM o3Ba/LeZLL2GSjF//0eJ0hHBm8b4Y4nIlFSR10n2oJAK1wg= X-Google-Smtp-Source: AMsMyM4UQpzAs2q7lIWIh5VbQerSHdBAbJm2aFKK4z1B0a6VCr1LXePKxGfV8GyGdNPziUGgrFM+FEXBxNJqIk3o3fM= X-Received: by 2002:a2e:a786:0:b0:277:5302:905 with SMTP id c6-20020a2ea786000000b0027753020905mr7296188ljf.499.1667425589495; Wed, 02 Nov 2022 14:46:29 -0700 (PDT) MIME-Version: 1.0 References: <20221031003235.348-1-mindmark@gmail.com> <20221031003235.348-5-mindmark@gmail.com> <20221102210401.GH1814017@pb2> In-Reply-To: <20221102210401.GH1814017@pb2> From: Mark Reid Date: Wed, 2 Nov 2022 14:46:16 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [FFmpeg-devel] [PATCH v2 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 Wed, Nov 2, 2022 at 2:04 PM Michael Niedermayer wrote: > On Sun, Oct 30, 2022 at 05:32:35PM -0700, 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 0e1c1225a0..e2ec9cbdf5 100644 > > --- a/libswscale/output.c > > +++ b/libswscale/output.c > > @@ -2474,6 +2474,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; > > + 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, 30); > > + G = av_clip_uintp2(Y + G, 30); > > + B = av_clip_uintp2(Y + B, 30); > > these additions can overflow i think given sufficiently "bad" input > especially with the bt2020 matrix > ive posted a proposed solution for the rgba64 / gbrp16/32f cases > something similar can be done here > > thx > > Make sense. I'll take a look and submit a new version with the fix. I also have some yuv to float16 patches coming that I will incorporate the fix into too! > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Opposition brings concord. Out of discord comes the fairest harmony. > -- Heraclitus > _______________________________________________ > 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".