Skip to content

Conversation

bmatherly
Copy link
Member

This filter can force the color TRC to whatever the consumer requests.

Posting this as a draft for conceptual review. The PR should not be pushed until it is tested with Shotcut.

This commit adds a new normalize filter that is added once by the loader on each clip, and then again by the consumer at the end of all the services. The first instance will set the TRC to be whatever is set by consumer.mlt_color_trc. The second will change the TRC to consumer.color_trc.

Example usage:
melt test.mp4 -consumer sdl2 mlt_color_trc=linear mlt_image_format=rgba64

@bmatherly bmatherly marked this pull request as draft September 29, 2025 03:20
@bmatherly bmatherly requested a review from Copilot September 29, 2025 03:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new colorspace normalize filter that automatically handles color transfer characteristic (TRC) conversions throughout the MLT pipeline. The filter addresses the need to normalize colorspace between different color TRCs as requested by consumers.

  • Adds a new colorspace filter that converts images to the TRC requested by consumers
  • Integrates the filter into the loader pipeline and consumer processing chain
  • Enhances AVFormat modules to properly set color properties on frames

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/modules/core/loader.ini Registers the colorspace filter in the loader pipeline
src/modules/core/filter_colorspace.yml Metadata definition for the new colorspace filter
src/modules/core/filter_colorspace.c Implementation of the colorspace conversion filter
src/modules/core/factory.c Registers the filter and its metadata in the core module
src/modules/core/CMakeLists.txt Adds the filter source file to the build
src/modules/avformat/link_avfilter.c Sets color properties from AVFrame to MLT frame properties
src/modules/avformat/filter_avfilter.c Sets color properties from AVFrame to MLT frame properties
src/modules/avformat/common.h Adds function declaration for color range conversion
src/modules/avformat/common.c Implements color range conversion from AV to MLT
src/framework/mlt_image.h Adds function declaration for default TRC lookup
src/framework/mlt_image.c Implements default TRC lookup based on colorspace
src/framework/mlt_consumer.c Integrates colorspace filter into consumer processing
src/framework/mlt.vers Exports the new default TRC function

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

This filter can force the color TRC to whatever the consumer
requests.
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +208 to +214
if (out_trc == mlt_color_trc_none || frame_trc == mlt_color_trc_none) {
mlt_log_info(MLT_FILTER_SERVICE(filter),
"Missing TRC - Frame: %s\tOut: %s\n",
mlt_image_color_trc_name(frame_trc),
mlt_image_color_trc_name(out_trc));
return 0;
}
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition checks for mlt_color_trc_none but doesn't handle other invalid TRC values like mlt_color_trc_invalid, mlt_color_trc_unspecified, or mlt_color_trc_reserved that are handled in av_trc_str function.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant