From: Nicolas George <george@nsup.org> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 01/12] avutil/frame: add AVFrame.alpha_mode Date: Fri, 28 Feb 2025 09:51:40 +0100 Message-ID: <Z8F5HHb6d6d0JV_o@phare.normalesup.org> (raw) In-Reply-To: <20250220122555.GB24779@haasn.xyz> Niklas Haas (HE12025-02-20): > This is true; I am thinking about adding negotiation to this in libavfilter > down the line as well, for the same reason. I just want to get the basic > infrastructure in place first. Ok, but... see later. > I don't see it as being worse than the status quo of silently doing the wrong > thing. The difference is the wrong thing is made official and can happen anywhere. > I think that the bigger issue is that some formats and sources can only deal > with premultiplied alpha. As a side note, something as simple as scaling an > image should only ever be done on premultiplied alpha - otherwise the > background fill color may leak into interpolated edge pixels. This statement is not true: take something that “must” be done in premuliplied and a normal input, convert the input to premultiplied, do the thing, convert back, and voilà. You can even factor the conversion formulas into the thing to have a more complex process that works directly on normal frames. The true statement is: some formats and source are more expensive in non-premultiplied format. Which… sure, but we can live with that, it is only a matter of compromise. > I think what bothers me about this approach is that it means we will need to > duplicate the options about whether the input is premultiplied or not for > every filter that can handle premul alpha. For example, vf_overlay, vf_scale, > vf_libplacebo. In the case of the latter, it's not even possible to handle > cleanly because the filter may have multiple inputs, some of which are premul > and others which are not. Just let the user insert the conversion filter. > IMO cleaner to have only a single frame flag and defer this to vf_setparams. > If you are concerned about API and memory bloat, a simpler option could be to > add a frame flag to AVFrame only, although that would prevent users from being > able to e.g. generate premultiplied JPEG-XL or TIFF files. (Both of those > formats, as far as I'm aware, suport tagging the alpha type) I am concerned about API bloat in the sense of adding yet another fscing thing the application programmer needs to think about. You do not address that concern. > I think we learned from YUVJ what a terrible idea this is in the long run. The YUVJ do not need a different treatment in the code. > > Last option, the worst one in my opinion: Like you did, but every > > component must explicitly declare if it supports premultiplied alpha; if > > a premultiplied frame arrives to a component that does not support them, > > return an error. The guiding principle is that it is better to fail than > > to silently propagate wrong output. > That is the idea here. If you insist on doing that way, then the guardrails must be there from the start: the commit that prevents a decoder or a filter from outputting a premultiplied frame if the receiver is not ready needs to be the very same commit that makes premultiplied frames official by adding a flag. Regards, -- Nicolas George _______________________________________________ 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:[~2025-02-28 8:51 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-02-19 20:45 Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 02/12] fftools/ffprobe: add support for AVFrame.alpha_mode Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 03/12] avfilter/vf_showinfo: print alpha mode when relevant Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 04/12] avcodec/avcodec: add AVCodecContext.alpha_mode Niklas Haas 2025-02-19 21:04 ` James Almer 2025-02-19 21:18 ` Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 05/12] avcodec/encode: enforce alpha mode compatibility at encode time Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 06/12] avcodec/png: set correct alpha mode Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 07/12] fftools/ffmpeg_enc: forward frame alpha mode to encoder Niklas Haas 2025-02-22 2:44 ` mypopy 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 08/12] avfilter/vf_premultiply: tag correct alpha mode on result Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 09/12] avfilter/vf_alphamerge: tag correct alpha mode Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 10/12] avfilter/vf_overlay: respect alpha mode tagging by default Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 11/12] avfilter/vf_setparams: add alpha_mode parameter Niklas Haas 2025-02-19 20:45 ` [FFmpeg-devel] [PATCH 12/12] avfilter/vf_libplacebo: add an alpha_mode setting Niklas Haas 2025-02-20 8:53 ` [FFmpeg-devel] [PATCH 01/12] avutil/frame: add AVFrame.alpha_mode Zhao Zhili 2025-02-20 9:39 ` Nicolas George 2025-02-20 11:25 ` Niklas Haas 2025-02-28 8:51 ` Nicolas George [this message] 2025-02-27 17:52 ` Niklas Haas 2025-02-28 8:53 ` Nicolas George
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=Z8F5HHb6d6d0JV_o@phare.normalesup.org \ --to=george@nsup.org \ --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