@@ -103,13 +103,30 @@ static void ensure_color_properties(mlt_filter self, mlt_frame frame)
103103 mlt_colorspace colorspace = mlt_image_default_colorspace (format , height );
104104 mlt_properties_set_int (frame_properties , "colorspace" , colorspace );
105105 colorspace_str = mlt_properties_get (frame_properties , "colorspace" );
106+ } else {
107+ mlt_colorspace colorspace = mlt_image_colorspace_id (colorspace_str );
108+ if (format == mlt_image_rgb || format == mlt_image_rgba || format == mlt_image_rgba64 ) {
109+ // Correct the colorspace. For RGB, only support rgb.
110+ if (colorspace != mlt_colorspace_rgb ) {
111+ mlt_properties_set_int (frame_properties , "colorspace" , mlt_colorspace_rgb );
112+ colorspace_str = mlt_properties_get (frame_properties , "colorspace" );
113+ }
114+ }
106115 }
107116 mlt_colorspace colorspace = mlt_image_colorspace_id (colorspace_str );
108117
109118 const char * color_trc_str = mlt_properties_get (frame_properties , "color_trc" );
110119 if (!color_trc_str ) {
111120 mlt_color_trc color_trc = mlt_image_default_trc (colorspace );
112121 mlt_properties_set_int (frame_properties , "color_trc" , color_trc );
122+ } else {
123+ mlt_color_trc color_trc = mlt_image_color_trc_id (color_trc_str );
124+ if (format == mlt_image_rgb || format == mlt_image_rgba || format == mlt_image_rgba64 ) {
125+ // Correct the TRC. For RGB, only support linear or iec61966-2-1.
126+ if (color_trc != mlt_color_trc_linear && color_trc != mlt_color_trc_iec61966_2_1 ) {
127+ mlt_properties_set_int (frame_properties , "color_trc" , mlt_color_trc_iec61966_2_1 );
128+ }
129+ }
113130 }
114131
115132 const char * color_primaries_str = mlt_properties_get (frame_properties , "color_primaries" );
@@ -139,6 +156,14 @@ static void ensure_color_properties(mlt_filter self, mlt_frame frame)
139156 break ;
140157 }
141158 mlt_properties_set_int (frame_properties , "full_range" , full_range );
159+ } else {
160+ int full_range = mlt_properties_get_int (frame_properties , "full_range" );
161+ if (format == mlt_image_rgb || format == mlt_image_rgba || format == mlt_image_rgba64 ) {
162+ // Correct full range if it is set incorrectly for RGB
163+ if (!full_range ) {
164+ mlt_properties_set_int (frame_properties , "full_range" , 1 );
165+ }
166+ }
142167 }
143168}
144169
0 commit comments