From: Dan Dennedy Date: Mon, 30 Dec 2013 07:47:53 +0000 (-0800) Subject: Convert sRGB to linear in movit.white_balance filter. X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=838c9f1e504e451c0a1ac7819bf916f43c26f930;p=mlt Convert sRGB to linear in movit.white_balance filter. Patch by Steinar Gunderson. --- diff --git a/src/modules/opengl/filter_white_balance.cpp b/src/modules/opengl/filter_white_balance.cpp index 1b458e7d..5080bcf4 100644 --- a/src/modules/opengl/filter_white_balance.cpp +++ b/src/modules/opengl/filter_white_balance.cpp @@ -19,11 +19,22 @@ #include #include +#include #include #include "glsl_manager.h" #include +static double srgb8_to_linear(int c) +{ + double x = c / 255.0f; + if (x < 0.04045f) { + return (1.0/12.92f) * x; + } else { + return pow((x + 0.055) * (1.0/1.055f), 2.4); + } +} + static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format, int *width, int *height, int writable ) { mlt_filter filter = (mlt_filter) mlt_frame_pop_service( frame ); @@ -35,9 +46,9 @@ static int get_image( mlt_frame frame, uint8_t **image, mlt_image_format *format mlt_position length = mlt_filter_get_length2( filter, frame ); int color_int = mlt_properties_anim_get_int( properties, "neutral_color", position, length ); RGBTriplet color( - float((color_int >> 24) & 0xff) / 255.0f, - float((color_int >> 16) & 0xff) / 255.0f, - float((color_int >> 8) & 0xff) / 255.0f + srgb8_to_linear((color_int >> 24) & 0xff), + srgb8_to_linear((color_int >> 16) & 0xff), + srgb8_to_linear((color_int >> 8) & 0xff) ); bool ok = effect->set_vec3( "neutral_color", (float*) &color ); ok |= effect->set_float( "output_color_temperature",