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: Thu, 20 Feb 2025 10:39:56 +0100
Message-ID: <Z7b4bLJP0edBTmqn@phare.normalesup.org> (raw)
In-Reply-To: <20250219204550.2826561-1-ffmpeg@haasn.xyz>
Niklas Haas (HE12025-02-19):
> FFmpeg currently handles alpha in a quasi-arbitrary way. Some filters/codecs
> assume alpha is premultiplied, others assume it is independent. If there is
> to be any hope for order in this chaos, we need to start by defining an enum
> for the possible range of values.
Please, not like that.
To start with: in libavfilter, if a filter expects full range and
receives premultiplied, then automatic conversion needs to happen. That
means integrating the new flag into the negotiation process. And given
how fragile and uncovered by FATE the negotiation process is, good luck
with that without breaking anything.¹
But more importantly: “We have a bug that makes your output subtly wrong
in some corner cases. To fix that, we introduce this new flag. You have
to take it into account because otherwise any of your output might be
wrong.” This is a terrible API change for applications.
IIRC, we use full range alpha everywhere except in a few specialized
filters. I remember thinking adding these specialized filters was a
terrible idea at the time. It is possible that more such cases have been
added while I was not paying attention.
So my main suggestion is to keep it that way: decide that FFmpeg uses
full range alpha, period. Make it clear in the documentation that the
few filters that use premultiplied are a specialized case for experts
only, with the responsibility of checking the format and converting
resting squarely on the shoulders of these expert users.
Another option would be to treat premultiplied alpha as different pixels
formats: we have YUVA420P for full range alpha, add YUVM420P for
premultiplied alpha.
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.
1: On the other hand, if you have energy to spare, adding FATE coverage
to the libavfilter negotiation process would be immensely useful. You
can see an attempt there:
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2022-August/299593.html
It requires a detailed graph output option, which you are working on, so
that is good.
The process to develop these tests is: find a line in the code that
looks like it needs coverage; understand what it does; conceive a filter
graph where it has a consequence and add it as a test; disable that line
and check the test fails.
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-20 9:40 UTC|newest]
Thread overview: 18+ 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 [this message]
2025-02-20 11:25 ` Niklas Haas
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=Z7b4bLJP0edBTmqn@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