Lines Matching refs:ctx

96     LibJxlEncodeContext *ctx = avctx->priv_data;
99 JxlEncoderReset(ctx->encoder);
101 ctx->options = JxlEncoderFrameSettingsCreate(ctx->encoder, NULL);
102 if (!ctx->options) {
108 if (JxlEncoderSetParallelRunner(ctx->encoder, JxlThreadParallelRunner, ctx->runner)
115 if (JxlEncoderFrameSettingsSetOption(ctx->options, JXL_ENC_FRAME_SETTING_EFFORT, ctx->effort)
117 av_log(avctx, AV_LOG_ERROR, "Failed to set effort to: %d\n", ctx->effort);
122 if (ctx->distance < 0.0) {
125 ctx->distance = quality_to_distance((float)avctx->global_quality / FF_QP2LAMBDA);
128 ctx->distance = 1.0;
135 if (ctx->distance > 0.0 && ctx->distance < 0.01)
136 ctx->distance = 0.01;
137 if (JxlEncoderSetFrameDistance(ctx->options, ctx->distance) != JXL_ENC_SUCCESS) {
138 av_log(avctx, AV_LOG_ERROR, "Failed to set distance: %f\n", ctx->distance);
147 if (JxlEncoderFrameSettingsSetOption(ctx->options, JXL_ENC_FRAME_SETTING_MODULAR,
148 ctx->modular || ctx->distance <= 0.0 ? 1 : -1) != JXL_ENC_SUCCESS) {
162 LibJxlEncodeContext *ctx = avctx->priv_data;
166 ctx->encoder = JxlEncoderCreate(&manager);
167 if (!ctx->encoder) {
172 ctx->runner = JxlThreadParallelRunnerCreate(&manager, ff_libjxl_get_threadcount(avctx->thread_count));
173 if (!ctx->runner) {
178 ctx->buffer_size = 4096;
179 ctx->buffer = av_realloc(NULL, ctx->buffer_size);
181 if (!ctx->buffer) {
247 LibJxlEncodeContext *ctx = avctx->priv_data;
255 size_t available = ctx->buffer_size;
257 uint8_t *next_out = ctx->buffer;
292 info.uses_original_profile = ctx->distance == 0.0;
294 if (JxlEncoderSetBasicInfo(ctx->encoder, &info) != JXL_ENC_SUCCESS) {
355 if (sd && sd->size && JxlEncoderSetICCProfile(ctx->encoder, sd->data, sd->size) != JXL_ENC_SUCCESS)
357 if (JxlEncoderSetColorEncoding(ctx->encoder, &jxl_color) != JXL_ENC_SUCCESS)
362 if (JxlEncoderGetRequiredCodestreamLevel(ctx->encoder) > 5) {
363 if (JxlEncoderSetCodestreamLevel(ctx->encoder, 10) != JXL_ENC_SUCCESS)
370 if (JxlEncoderAddImageFrame(ctx->options, &jxl_fmt, frame->data[0], jxl_fmt.align * info.ysize) != JXL_ENC_SUCCESS) {
379 JxlEncoderCloseInput(ctx->encoder);
382 jret = JxlEncoderProcessOutput(ctx->encoder, &next_out, &available);
387 bytes_written = ctx->buffer_size - available;
398 size_t new_size = ctx->buffer_size * 2;
399 temp = av_realloc(ctx->buffer, new_size);
402 ctx->buffer = temp;
403 ctx->buffer_size = new_size;
404 next_out = ctx->buffer + bytes_written;
416 memcpy(pkt->data, ctx->buffer, bytes_written);
424 LibJxlEncodeContext *ctx = avctx->priv_data;
426 if (ctx->runner)
427 JxlThreadParallelRunnerDestroy(ctx->runner);
428 ctx->runner = NULL;
432 * ctx->options so we don't need to
434 if (ctx->encoder)
435 JxlEncoderDestroy(ctx->encoder);
436 ctx->encoder = NULL;
438 av_freep(&ctx->buffer);