From: Mark Reid <mindmark@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH v2 4/4] swscale/output: add rgbaf32 output support Date: Wed, 2 Nov 2022 14:46:16 -0700 Message-ID: <CA+anCRnOErFMmLMYv0nATsNGKAXXHcB-+_b5pL=c1BLHWoy-Rw@mail.gmail.com> (raw) In-Reply-To: <20221102210401.GH1814017@pb2> On Wed, Nov 2, 2022 at 2:04 PM Michael Niedermayer <michael@niedermayer.cc> wrote: > On Sun, Oct 30, 2022 at 05:32:35PM -0700, mindmark@gmail.com wrote: > > From: Mark Reid <mindmark@gmail.com> > > > > --- > > 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".
next prev parent reply other threads:[~2022-11-02 21:46 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-31 0:32 [FFmpeg-devel] [PATCH v2 0/4] swscale rgbaf32 input/output support mindmark 2022-10-31 0:32 ` [FFmpeg-devel] [PATCH v2 1/4] swscale/input: add rgbaf32 input support mindmark 2022-10-31 0:32 ` [FFmpeg-devel] [PATCH v2 2/4] avfilter/vf_hflip: add support for packed rgb float formats mindmark 2022-10-31 0:32 ` [FFmpeg-devel] [PATCH v2 3/4] avfilter/vf_transpose: " mindmark 2022-10-31 0:32 ` [FFmpeg-devel] [PATCH v2 4/4] swscale/output: add rgbaf32 output support mindmark 2022-11-02 21:04 ` Michael Niedermayer 2022-11-02 21:46 ` Mark Reid [this message] 2022-10-31 8:42 ` [FFmpeg-devel] [PATCH v2 0/4] swscale rgbaf32 input/output support Diederick C. Niehorster
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CA+anCRnOErFMmLMYv0nATsNGKAXXHcB-+_b5pL=c1BLHWoy-Rw@mail.gmail.com' \ --to=mindmark@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git