Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light
@ 2023-08-16  5:20 Leo Izen
  2023-08-16 10:48 ` Paul B Mahol
  2023-08-17 12:59 ` Tomas Härdin
  0 siblings, 2 replies; 5+ messages in thread
From: Leo Izen @ 2023-08-16  5:20 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Leo Izen

By default the OpenEXR decoder outputs linear light pixel data by
applying a gamma=1.0 transfer (i.e. a no-op). When it does so, it
should tag the data as linear so color-managed filters or other tools
can work with it correctly.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
 libavcodec/exr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index fae1d08ab0..518066facf 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -2088,6 +2088,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *picture,
 
     if (s->apply_trc_type != AVCOL_TRC_UNSPECIFIED)
         avctx->color_trc = s->apply_trc_type;
+    else if (s->gamma > 0.9999f && s->gamma < 1.0001f)
+        avctx->color_trc = AVCOL_TRC_LINEAR;
 
     switch (s->compression) {
     case EXR_RAW:
-- 
2.41.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light
  2023-08-16  5:20 [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light Leo Izen
@ 2023-08-16 10:48 ` Paul B Mahol
  2023-08-17 12:59 ` Tomas Härdin
  1 sibling, 0 replies; 5+ messages in thread
From: Paul B Mahol @ 2023-08-16 10:48 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Leo Izen

LGTM
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light
  2023-08-16  5:20 [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light Leo Izen
  2023-08-16 10:48 ` Paul B Mahol
@ 2023-08-17 12:59 ` Tomas Härdin
  2023-08-17 18:04   ` Leo Izen
  1 sibling, 1 reply; 5+ messages in thread
From: Tomas Härdin @ 2023-08-17 12:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

ons 2023-08-16 klockan 01:20 -0400 skrev Leo Izen:
> By default the OpenEXR decoder outputs linear light pixel data by
> applying a gamma=1.0 transfer (i.e. a no-op). When it does so, it
> should tag the data as linear so color-managed filters or other tools
> can work with it correctly.
> 
> Signed-off-by: Leo Izen <leo.izen@gmail.com>
> ---
>  libavcodec/exr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> index fae1d08ab0..518066facf 100644
> --- a/libavcodec/exr.c
> +++ b/libavcodec/exr.c
> @@ -2088,6 +2088,8 @@ static int decode_frame(AVCodecContext *avctx,
> AVFrame *picture,
>  
>      if (s->apply_trc_type != AVCOL_TRC_UNSPECIFIED)
>          avctx->color_trc = s->apply_trc_type;
> +    else if (s->gamma > 0.9999f && s->gamma < 1.0001f)
> +        avctx->color_trc = AVCOL_TRC_LINEAR;

I'm going to be difficult here and point out that gamma=0.99991 is not
linear. It's probably linear *enough* most of the time, but also 1.0
can be exactly represented by float so an equality check seems
appropriate

/Tomas

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light
  2023-08-17 12:59 ` Tomas Härdin
@ 2023-08-17 18:04   ` Leo Izen
  2023-08-20 13:00     ` Tomas Härdin
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Izen @ 2023-08-17 18:04 UTC (permalink / raw)
  To: ffmpeg-devel

On 8/17/23 08:59, Tomas Härdin wrote:
> ons 2023-08-16 klockan 01:20 -0400 skrev Leo Izen:
>> By default the OpenEXR decoder outputs linear light pixel data by
>> applying a gamma=1.0 transfer (i.e. a no-op). When it does so, it
>> should tag the data as linear so color-managed filters or other tools
>> can work with it correctly.
>>
>> Signed-off-by: Leo Izen <leo.izen@gmail.com>
>> ---
>>   libavcodec/exr.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/libavcodec/exr.c b/libavcodec/exr.c
>> index fae1d08ab0..518066facf 100644
>> --- a/libavcodec/exr.c
>> +++ b/libavcodec/exr.c
>> @@ -2088,6 +2088,8 @@ static int decode_frame(AVCodecContext *avctx,
>> AVFrame *picture,
>>   
>>       if (s->apply_trc_type != AVCOL_TRC_UNSPECIFIED)
>>           avctx->color_trc = s->apply_trc_type;
>> +    else if (s->gamma > 0.9999f && s->gamma < 1.0001f)
>> +        avctx->color_trc = AVCOL_TRC_LINEAR;
> 
> I'm going to be difficult here and point out that gamma=0.99991 is not
> linear. It's probably linear *enough* most of the time, but also 1.0
> can be exactly represented by float so an equality check seems
> appropriate.

This exact check exists elsewhere in the source file. There's a branch 
where it sets up a LUT if gamma is not between those values, and has a 
no-op track otherwise - so in the event you request 0.99995 or something 
of that form, the code that does the color conversion treats it as 1.0f.

- Leo Izen


_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light
  2023-08-17 18:04   ` Leo Izen
@ 2023-08-20 13:00     ` Tomas Härdin
  0 siblings, 0 replies; 5+ messages in thread
From: Tomas Härdin @ 2023-08-20 13:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

tor 2023-08-17 klockan 14:04 -0400 skrev Leo Izen:
> On 8/17/23 08:59, Tomas Härdin wrote:
> > ons 2023-08-16 klockan 01:20 -0400 skrev Leo Izen:
> > > By default the OpenEXR decoder outputs linear light pixel data by
> > > applying a gamma=1.0 transfer (i.e. a no-op). When it does so, it
> > > should tag the data as linear so color-managed filters or other
> > > tools
> > > can work with it correctly.
> > > 
> > > Signed-off-by: Leo Izen <leo.izen@gmail.com>
> > > ---
> > >   libavcodec/exr.c | 2 ++
> > >   1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/libavcodec/exr.c b/libavcodec/exr.c
> > > index fae1d08ab0..518066facf 100644
> > > --- a/libavcodec/exr.c
> > > +++ b/libavcodec/exr.c
> > > @@ -2088,6 +2088,8 @@ static int decode_frame(AVCodecContext
> > > *avctx,
> > > AVFrame *picture,
> > >   
> > >       if (s->apply_trc_type != AVCOL_TRC_UNSPECIFIED)
> > >           avctx->color_trc = s->apply_trc_type;
> > > +    else if (s->gamma > 0.9999f && s->gamma < 1.0001f)
> > > +        avctx->color_trc = AVCOL_TRC_LINEAR;
> > 
> > I'm going to be difficult here and point out that gamma=0.99991 is
> > not
> > linear. It's probably linear *enough* most of the time, but also
> > 1.0
> > can be exactly represented by float so an equality check seems
> > appropriate.
> 
> This exact check exists elsewhere in the source file. There's a
> branch 
> where it sets up a LUT if gamma is not between those values, and has
> a 
> no-op track otherwise - so in the event you request 0.99995 or
> something 
> of that form, the code that does the color conversion treats it as
> 1.0f.

Alright. I just find myself wondering how gamma could ever become some
value that is close to 1.0 but not quite equal.

/Tomas
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-20 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-16  5:20 [FFmpeg-devel] [PATCH] avcodec/exr: tag gamma=1.0 output as linear light Leo Izen
2023-08-16 10:48 ` Paul B Mahol
2023-08-17 12:59 ` Tomas Härdin
2023-08-17 18:04   ` Leo Izen
2023-08-20 13:00     ` Tomas Härdin

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