[FFmpeg-devel] [PATCH] avfilter: add inverse tone mapping

Niklas Haas ffmpeg at haasn.xyz
Wed Jul 23 12:41:32 EEST 2025


On Wed, 23 Jul 2025 05:30:57 +0000 Sarthak Indurkhya via ffmpeg-devel <ffmpeg-devel at ffmpeg.org> wrote:
> Thank you for the thoughtful feedback.
>
> Advantages over vf_libplacebo’s inverse tone mapping:
>
>   1.  Algorithmic Differentiation:
> My filter is based on a novel local adaptation + inverse tone mapping strategy specifically tailored to enhance perceptual brightness while preserving spatial detail.
>
>        My implementation uses:
>
>      *   Local bilateral filtering over luminance for content-adaptive scaling.
>      *   Dynamic inverse tone mapping via (R / (1 - R))^1/n style reparameterization.
>      *   Chromatic scaling to preserve original hues during dynamic range expansion.
>   1.  Color Fidelity & HDR Metadata:
>      *   The filter performs color space conversion from BT.709 to BT.2020 explicitly and integrates PQ transfer function encoding with full support for mastering metadata (mastering_display_primaries, content_light_level, etc.).
>      *   It incorporates localized tone curve shaping, white balance, and chroma boosting that target HDR presentation aesthetics more directly.
>   2.  Customizability:
>      *   Parameters like sigma_spatial, sigma_range, n, and hdr_max allow users to tailor the HDR expansion according to scene content or output requirements.

None of that sounds different from what vf_libplacebo is doing. Do you have
an example output somewhere that we could compare?

>
> I agree that a GPU-based real-time implementation would be valuable. The algorithm I've used is highly parallelizable and very well-suited for implementation as a GPU shader
>
>
> Get Outlook for Mac <https://aka.ms/GetOutlookForMac>
>
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of Kacper Michajlow <kasper93 at gmail.com>
> Date: Saturday, 19 July 2025 at 8:18 PM
> To: FFmpeg development discussions and patches <ffmpeg-devel at ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] avfilter: add inverse tone mapping
> EXTERNAL: Use caution when clicking on links or opening attachments.
>
>
> On Sat, 19 Jul 2025 at 16:13, Sarthak Indurkhya via ffmpeg-devel <
> ffmpeg-devel at ffmpeg.org> wrote:
>
> > Hello FFmpeg developers,
> > This patch introduces a new video filter called inversetonemap for FFmpeg.
> > The filter performs SDR to HDR conversion by mapping SDR BT.709 video to
> > HDR BT.2020 PQ, using local adaptation and inverse tone mapping. The goal
> > is to provide a simple, flexible tool for upconverting SDR content for HDR
> > displays, with local adaptation, tone curve sensitivity, and chroma
> > processing.
> >
> > Please review.
> > Thanks,
> > Sarthak
> >
> >
> >
> Interesting. Could you describe what are the advantages of the new filter,
> compared to existing solutions like vf_libplacebo inverse tone mapping?
> Additionally if there is a big gap in libplacebo's inverse tone mapping
> quality would you be interested in improving the libplacebo implementation
> in addition to this filter? I think there would be a gain in having real
> time gpu implementation too.
>
> - Kacper
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel&data=05%7C02%7Csindurkhya%40adobe.com%7Cae51c0c89a19441126c408ddc6d348ef%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C638885332956664603%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=c7Ot4ow8uXKRfk%2F05O9B5bCkxjynTUwg90S%2Bf5uJeYU%3D&reserved=0<https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list