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/libjxldec: fix gamma22 and gamma28 recognization
@ 2023-01-18 14:24 Leo Izen
  2023-01-20 22:15 ` Jan Ekström
  0 siblings, 1 reply; 3+ messages in thread
From: Leo Izen @ 2023-01-18 14:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Leo Izen

Gamma 2.2 and Gamma 2.8 are tagged in the file as 0.45455 and 0.35714,
respectively (i.e. 1/2.2 and 1/2.8). Trying to identify them as 2.2 and
2.8 instead of these values will cause the transfer function to not
properly be recognized. This patch fixes this.
---
 libavcodec/libjxldec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 55c7366f61..0009af9615 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -167,9 +167,9 @@ static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlC
     case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428;
     case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67;
     case JXL_TRANSFER_FUNCTION_GAMMA:
-        if (jxl_color->gamma > 2.199 && jxl_color->gamma < 2.201)
+        if (jxl_color->gamma > 0.45355 && jxl_color->gamma < 0.45555)
             return AVCOL_TRC_GAMMA22;
-        else if (jxl_color->gamma > 2.799 && jxl_color->gamma < 2.801)
+        else if (jxl_color->gamma > 0.35614 && jxl_color->gamma < 0.35814)
             return AVCOL_TRC_GAMMA28;
         else
             av_log(avctx, AV_LOG_WARNING, "Unsupported gamma transfer: %f\n", jxl_color->gamma);
-- 
2.39.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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/libjxldec: fix gamma22 and gamma28 recognization
  2023-01-18 14:24 [FFmpeg-devel] [PATCH] avcodec/libjxldec: fix gamma22 and gamma28 recognization Leo Izen
@ 2023-01-20 22:15 ` Jan Ekström
  2023-01-22 15:20   ` Jan Ekström
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Ekström @ 2023-01-20 22:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Wed, Jan 18, 2023 at 4:24 PM Leo Izen <leo.izen@gmail.com> wrote:
>
> Gamma 2.2 and Gamma 2.8 are tagged in the file as 0.45455 and 0.35714,
> respectively (i.e. 1/2.2 and 1/2.8). Trying to identify them as 2.2 and
> 2.8 instead of these values will cause the transfer function to not
> properly be recognized. This patch fixes this.

Agreed upon reading the spec, which notes that the value is saved as
an unsigned 24bit integer consisting of the numerator part of a
rational number, with a 10^7 denumerator and a valid range of (0, 1].

Only nit: recognization -> recognition

> ---
>  libavcodec/libjxldec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
> index 55c7366f61..0009af9615 100644
> --- a/libavcodec/libjxldec.c
> +++ b/libavcodec/libjxldec.c
> @@ -167,9 +167,9 @@ static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlC
>      case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428;
>      case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67;
>      case JXL_TRANSFER_FUNCTION_GAMMA:
> -        if (jxl_color->gamma > 2.199 && jxl_color->gamma < 2.201)
> +        if (jxl_color->gamma > 0.45355 && jxl_color->gamma < 0.45555)
>              return AVCOL_TRC_GAMMA22;
> -        else if (jxl_color->gamma > 2.799 && jxl_color->gamma < 2.801)
> +        else if (jxl_color->gamma > 0.35614 && jxl_color->gamma < 0.35814)

These values leave ~0.001 of leeway which seems like it was before.

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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avcodec/libjxldec: fix gamma22 and gamma28 recognization
  2023-01-20 22:15 ` Jan Ekström
@ 2023-01-22 15:20   ` Jan Ekström
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Ekström @ 2023-01-22 15:20 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Sat, Jan 21, 2023 at 12:15 AM Jan Ekström <jeebjp@gmail.com> wrote:
>
> On Wed, Jan 18, 2023 at 4:24 PM Leo Izen <leo.izen@gmail.com> wrote:
> >
> > Gamma 2.2 and Gamma 2.8 are tagged in the file as 0.45455 and 0.35714,
> > respectively (i.e. 1/2.2 and 1/2.8). Trying to identify them as 2.2 and
> > 2.8 instead of these values will cause the transfer function to not
> > properly be recognized. This patch fixes this.
>
> Agreed upon reading the spec, which notes that the value is saved as
> an unsigned 24bit integer consisting of the numerator part of a
> rational number, with a 10^7 denumerator and a valid range of (0, 1].
>
> Only nit: recognization -> recognition
>
> > ---
> >  libavcodec/libjxldec.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
> > index 55c7366f61..0009af9615 100644
> > --- a/libavcodec/libjxldec.c
> > +++ b/libavcodec/libjxldec.c
> > @@ -167,9 +167,9 @@ static enum AVColorTransferCharacteristic libjxl_get_trc(void *avctx, const JxlC
> >      case JXL_TRANSFER_FUNCTION_DCI: return AVCOL_TRC_SMPTE428;
> >      case JXL_TRANSFER_FUNCTION_HLG: return AVCOL_TRC_ARIB_STD_B67;
> >      case JXL_TRANSFER_FUNCTION_GAMMA:
> > -        if (jxl_color->gamma > 2.199 && jxl_color->gamma < 2.201)
> > +        if (jxl_color->gamma > 0.45355 && jxl_color->gamma < 0.45555)
> >              return AVCOL_TRC_GAMMA22;
> > -        else if (jxl_color->gamma > 2.799 && jxl_color->gamma < 2.801)
> > +        else if (jxl_color->gamma > 0.35614 && jxl_color->gamma < 0.35814)
>
> These values leave ~0.001 of leeway which seems like it was before.
>
> LGTM

Applied to master as 9d5e66942c5bae578926e29efebec348199798df with the
typo fix, as well as back-ported to release/5.1.

Jan
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2023-01-22 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-18 14:24 [FFmpeg-devel] [PATCH] avcodec/libjxldec: fix gamma22 and gamma28 recognization Leo Izen
2023-01-20 22:15 ` Jan Ekström
2023-01-22 15:20   ` Jan Ekström

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