Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Drew Dunne via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: "Ronald S. Bultje" <rsbultje@gmail.com>
Cc: FFmpeg development discussions and patches
	<ffmpeg-devel@ffmpeg.org>, Drew Dunne <asdunne@google.com>
Subject: [FFmpeg-devel] Re: [PATCH] vf_colorspace: Add an option to clamp trc LUT output
Date: Thu, 4 Sep 2025 13:07:10 -0400
Message-ID: <CAHHpSXZUjzp6UtgrDwadKVAxeHOAPmLq8cPGcDmCWce25XjGKQ@mail.gmail.com> (raw)
In-Reply-To: <CAEEMt2njHT+EeGdZ3zUAJXvKijYY+oPjE5a7=mv718gPOX=19g@mail.gmail.com>

Ronald,

Thanks! Created a PR at https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20438

- Drew

On Wed, Sep 3, 2025 at 8:31 AM Ronald S. Bultje <rsbultje@gmail.com> wrote:

> Hi Drew,
>
> I believe you create an account (if you don't already have one), fork the
> main FFmpeg repo (so you get a copy into your own personal account), push
> the patch into a branch on your personal repo, and submit a PR to merge
> that personal branch back into the main FFmpeg repo. It's similar to gitlab
> or github, if that helps. If emails feels a bit tardish, you can ask for
> help on IRC if you're not sure about any of these steps.
>
> Thanks!
> Ronald
>
> On Tue, Sep 2, 2025 at 3:49 PM Drew Dunne <asdunne@google.com> wrote:
>
>> Sure, I can submit it there. Is there documentation on how to submit a
>> patch there? Do I just submit it as a pull request?
>>
>> On Tue, Aug 26, 2025 at 2:33 PM Ronald S. Bultje <rsbultje@gmail.com>
>> wrote:
>>
>>> Hi Drew,
>>>
>>> Thanks for the bug report!
>>>
>>> On Mon, Aug 25, 2025 at 10:50 AM Drew Dunne via ffmpeg-devel <
>>> ffmpeg-devel@ffmpeg.org> wrote:
>>>
>>>> A solid color image of 8-bit YUV: Y=157, U=164, V=98.
>>>>
>>>> Specify the input as:
>>>>
>>>> Input range: MPEG
>>>> In color matrix: BT470BG
>>>> In color primaries: BT470M
>>>> In color transfer characteristics: Gamma 28
>>>>
>>>> Output as:
>>>> Out color range: JPEG
>>>> Out color matrix: BT.709
>>>> Out color primaries: BT.709
>>>> Out color transfer characteristics: BT.709
>>>>
>>>> During the calculation you get:
>>>>
>>>> Input YUV:                             y=157,      u=164,      v-98
>>>> Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152,
>>>> b=0.928606
>>>> Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494,
>>>> b=0.812709
>>>> Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626,
>>>> b=0.852400
>>>> Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932,
>>>> b=0.923793
>>>> Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25
>>>>
>>>> Where with this change, the delinear LUT output would be clamped to 0,
>>>> so the result would be:
>>>> r=0.000000, g=0.612390, b=0.918807 and a final output of
>>>> y=129, u=185, v=46
>>>
>>>
>>> So for those of us playing along, a repro looks like this:
>>>
>>> $ hexdump /tmp/in.yuv
>>> 0000000 9d9d 9d9d 62a4
>>> $ git diff
>>> diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
>>> index e1f4725f635..512eb620fcf 100644
>>> --- a/libavfilter/vf_colorspace.c
>>> +++ b/libavfilter/vf_colorspace.c
>>> @@ -348,11 +348,20 @@ static int convert(AVFilterContext *ctx, void
>>> *data, int job_nr, int n_jobs)
>>>           */
>>>          s->yuv2rgb(rgb, s->rgb_stride, in_data, td->in_linesize, w, h,
>>>                     s->yuv2rgb_coeffs, s->yuv_offset[0]);
>>> +        printf("post-yuv2rgb - R: %d, G: %d, B: %d\n",
>>> +               rgb[0][0], rgb[1][0], rgb[2][0]);
>>>          if (!s->rgb2rgb_passthrough) {
>>>              apply_lut(rgb, s->rgb_stride, w, h, s->lin_lut);
>>> -            if (!s->lrgb2lrgb_passthrough)
>>> +            printf("post-linearize - R: %d, G: %d, B: %d\n",
>>> +                   rgb[0][0], rgb[1][0], rgb[2][0]);
>>> +            if (!s->lrgb2lrgb_passthrough) {
>>>                  s->dsp.multiply3x3(rgb, s->rgb_stride, w, h,
>>> s->lrgb2lrgb_coeffs);
>>> +                printf("post-rgb2rgb - R: %d, G: %d, B: %d\n",
>>> +                       rgb[0][0], rgb[1][0], rgb[2][0]);
>>> +            }
>>>              apply_lut(rgb, s->rgb_stride, w, h, s->delin_lut);
>>> +            printf("post-delinearize - R: %d, G: %d, B: %d\n",
>>> +                   rgb[0][0], rgb[1][0], rgb[2][0]);
>>>          }
>>>          if (s->dither == DITHER_FSB) {
>>>              s->rgb2yuv_fsb(out_data, td->out_linesize, rgb,
>>> s->rgb_stride, w, h,
>>> $ make -j4 && ./ffmpeg -s 2x2 -pix_fmt yuv420p -f rawvideo -c:v rawvideo
>>> -i /tmp/in.yuv -vf
>>> colorspace=ispace=bt470bg:iprimaries=bt470m:itrc=gamma28:irange=mpeg:range=jpeg:all=bt709
>>> -y /tmp/out.yuv
>>> [..]
>>> post-yuv2rgb - R: 13076, G: 19616, B: 26625
>>> post-linearize - R: 3182, G: 9906, B: 23302
>>> post-rgb2rgb - R: -1193, G: 11028, B: 24440
>>> post-delinearize - R: -4697, G: 17660, B: 26487
>>>
>>> Patch looks OK. Drew, would it be possible to submit the patch at
>>> code.ffmpeg.org so I can merge it using our new system?
>>>
>>> Thanks,
>>> Ronald
>>>
>>
>>
>> --
>> Drew Dunne
>> asdunne@google.com
>>
>>

-- 
Drew Dunne
asdunne@google.com
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

      reply	other threads:[~2025-09-04 17:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <347789>
2025-08-18 15:55 ` [FFmpeg-devel] " Drew Dunne via ffmpeg-devel
2025-08-20 18:56   ` Ronald S. Bultje via ffmpeg-devel
2025-08-25 14:49     ` Drew Dunne via ffmpeg-devel
2025-08-26 18:33       ` [FFmpeg-devel] " Ronald S. Bultje via ffmpeg-devel
2025-09-02 19:48         ` Drew Dunne via ffmpeg-devel
2025-09-03 12:31           ` Ronald S. Bultje via ffmpeg-devel
2025-09-04 17:07             ` Drew Dunne via ffmpeg-devel [this message]

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=CAHHpSXZUjzp6UtgrDwadKVAxeHOAPmLq8cPGcDmCWce25XjGKQ@mail.gmail.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=asdunne@google.com \
    --cc=rsbultje@gmail.com \
    /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