-
Notifications
You must be signed in to change notification settings - Fork 350
Add colorspace normalize filter #1159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
54f8b64
to
123c3ac
Compare
There was a problem hiding this 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.
There was a problem hiding this 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.
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; | ||
} |
Copilot
AI
Oct 12, 2025
There was a problem hiding this comment.
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.
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