1
0
Fork 0

avcodec/libjxlenc: add option to disable xyb encoding

Add an AVOption to the libjxl encoder wrapper, which exposes the flag
uses_original_profile in libjxl. For highly unusual ICC profiles where
the target needs to stay in the original space, this can be useful.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
This commit is contained in:
Leo Izen 2024-02-11 12:03:19 -05:00
parent c9eb36e0a0
commit a356815a31
No known key found for this signature in database
GPG Key ID: 764E48EA48221833
2 changed files with 5 additions and 2 deletions

View File

@ -52,6 +52,7 @@ typedef struct LibJxlEncodeContext {
int effort;
float distance;
int modular;
int xyb;
uint8_t *buffer;
size_t buffer_size;
} LibJxlEncodeContext;
@ -303,7 +304,7 @@ static int libjxl_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFra
av_log(avctx, AV_LOG_WARNING, "Unknown color range, assuming full (pc)\n");
/* bitexact lossless requires there to be no XYB transform */
info.uses_original_profile = ctx->distance == 0.0;
info.uses_original_profile = ctx->distance == 0.0 || !ctx->xyb;
info.orientation = frame->linesize[0] >= 0 ? JXL_ORIENT_IDENTITY : JXL_ORIENT_FLIP_VERTICAL;
if (JxlEncoderSetBasicInfo(ctx->encoder, &info) != JXL_ENC_SUCCESS) {
@ -474,6 +475,8 @@ static const AVOption libjxl_encode_options[] = {
{ "distance", "Maximum Butteraugli distance (quality setting, "
"lower = better, zero = lossless, default 1.0)", OFFSET(distance), AV_OPT_TYPE_FLOAT, { .dbl = -1.0 }, -1.0, 15.0, VE },
{ "modular", "Force modular mode", OFFSET(modular), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "xyb", "Use XYB-encoding for lossy images", OFFSET(xyb),
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, VE },
{ NULL },
};

View File

@ -30,7 +30,7 @@
#include "version_major.h"
#define LIBAVCODEC_VERSION_MINOR 1
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \