* [FFmpeg-devel] [PATCH] avcodec/libjxlenc: avoid hard failure with unspecified primaries
@ 2022-07-07 18:32 Leo Izen
2022-07-14 19:06 ` Leo Izen
0 siblings, 1 reply; 2+ messages in thread
From: Leo Izen @ 2022-07-07 18:32 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Leo Izen
This patch prevents the libjxl encoder wrapper from failing to
encode images when the input video has untagged primaries. It will
instead assume BT.709/sRGB primaries and print a warning.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
libavcodec/libjxlenc.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 6a948cc3ae..d6d25fe970 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -343,8 +343,11 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra
ret = libjxl_populate_primaries(&jxl_color,
frame->color_primaries && frame->color_primaries != AVCOL_PRI_UNSPECIFIED
? frame->color_primaries : avctx->color_primaries);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ av_log(avctx, AV_LOG_WARNING, "Unknown primaries, assuming BT.709/sRGB. Colors may be wrong.\n");
+ jxl_color.primaries = JXL_PRIMARIES_SRGB;
+ jxl_color.white_point = JXL_WHITE_POINT_D65;
+ }
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE);
if (sd && sd->size && JxlEncoderSetICCProfile(ctx->encoder, sd->data, sd->size) != JXL_ENC_SUCCESS)
--
2.37.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] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/libjxlenc: avoid hard failure with unspecified primaries
2022-07-07 18:32 [FFmpeg-devel] [PATCH] avcodec/libjxlenc: avoid hard failure with unspecified primaries Leo Izen
@ 2022-07-14 19:06 ` Leo Izen
0 siblings, 0 replies; 2+ messages in thread
From: Leo Izen @ 2022-07-14 19:06 UTC (permalink / raw)
To: FFmpeg Development
On 7/7/22 14:32, Leo Izen wrote:
> This patch prevents the libjxl encoder wrapper from failing to
> encode images when the input video has untagged primaries. It will
> instead assume BT.709/sRGB primaries and print a warning.
>
> Signed-off-by: Leo Izen <leo.izen@gmail.com>
> ---
> libavcodec/libjxlenc.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
> index 6a948cc3ae..d6d25fe970 100644
> --- a/libavcodec/libjxlenc.c
> +++ b/libavcodec/libjxlenc.c
> @@ -343,8 +343,11 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra
> ret = libjxl_populate_primaries(&jxl_color,
> frame->color_primaries && frame->color_primaries != AVCOL_PRI_UNSPECIFIED
> ? frame->color_primaries : avctx->color_primaries);
> - if (ret < 0)
> - return ret;
> + if (ret < 0) {
> + av_log(avctx, AV_LOG_WARNING, "Unknown primaries, assuming BT.709/sRGB. Colors may be wrong.\n");
> + jxl_color.primaries = JXL_PRIMARIES_SRGB;
> + jxl_color.white_point = JXL_WHITE_POINT_D65;
> + }
>
> sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE);
> if (sd && sd->size && JxlEncoderSetICCProfile(ctx->encoder, sd->data, sd->size) != JXL_ENC_SUCCESS)
Bumping for review.
- Leo Izen (thebombzen)
_______________________________________________
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] 2+ messages in thread
end of thread, other threads:[~2022-07-14 19:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07 18:32 [FFmpeg-devel] [PATCH] avcodec/libjxlenc: avoid hard failure with unspecified primaries Leo Izen
2022-07-14 19:06 ` Leo Izen
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