X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fthreshold%2Fthreshold.C;h=09a3680b58a9b501c73458455e55f9da1888f7ad;hb=af44bff549c39ac8bb6e42a791e7a211e1013526;hp=052ba25257c28a53b7e65214653acdb32db4729a;hpb=9d832a1fff11b11aaa1108c460690ed05e2bdc05;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/threshold/threshold.C b/cinelerra-5.1/plugins/threshold/threshold.C index 052ba252..09a3680b 100644 --- a/cinelerra-5.1/plugins/threshold/threshold.C +++ b/cinelerra-5.1/plugins/threshold/threshold.C @@ -22,17 +22,17 @@ #include #include +#include "threshold.h" +#include "bccolors.h" #include "clip.h" #include "bchash.h" #include "filexml.h" #include "histogramengine.h" #include "language.h" -#include "bccolors.h" -#include "threshold.h" +#include "playback3d.h" #include "thresholdwindow.h" #include "vframe.h" -; using ::std::string; @@ -259,10 +259,12 @@ int ThresholdMain::handle_opengl() "uniform vec4 low_color;\n" "uniform vec4 mid_color;\n" "uniform vec4 high_color;\n" + "uniform mat3 rgb_to_yuv_matrix;\n" + "uniform float yminf;\n" "void main()\n" "{\n" " vec4 pixel = texture2D(tex, gl_TexCoord[0].st);\n" - " float v = dot(pixel.rgb, vec3(0.299, 0.587, 0.114));\n" + " float v = dot(pixel.rgb, rgb_to_yuv_matrix[0]) + yminf;\n" " if(v < min)\n" " pixel = low_color;\n" " else if(v < max)\n" @@ -294,78 +296,67 @@ int ThresholdMain::handle_opengl() get_output()->to_texture(); get_output()->enable_opengl(); - unsigned int shader = 0; int color_model = get_output()->get_color_model(); bool is_yuv = BC_CModels::is_yuv(color_model); bool has_alpha = BC_CModels::has_alpha(color_model); - if(is_yuv) - shader = VFrame::make_shader(0, yuv_shader, 0); - else - shader = VFrame::make_shader(0, rgb_shader, 0); - - if(shader > 0) - { + unsigned int shader = VFrame::make_shader(0, is_yuv ? yuv_shader : rgb_shader, 0); + if( shader > 0 ) { glUseProgram(shader); glUniform1i(glGetUniformLocation(shader, "tex"), 0); glUniform1f(glGetUniformLocation(shader, "min"), config.min); glUniform1f(glGetUniformLocation(shader, "max"), config.max); - if (is_yuv) - { + if (is_yuv) { float y_low, u_low, v_low; float y_mid, u_mid, v_mid; float y_high, u_high, v_high; - YUV::rgb_to_yuv_f((float)config.low_color.r / 0xff, - (float)config.low_color.g / 0xff, - (float)config.low_color.b / 0xff, - y_low, - u_low, - v_low); - u_low += 0.5; - v_low += 0.5; - YUV::rgb_to_yuv_f((float)config.mid_color.r / 0xff, - (float)config.mid_color.g / 0xff, - (float)config.mid_color.b / 0xff, - y_mid, - u_mid, - v_mid); - u_mid += 0.5; - v_mid += 0.5; - YUV::rgb_to_yuv_f((float)config.high_color.r / 0xff, - (float)config.high_color.g / 0xff, - (float)config.high_color.b / 0xff, - y_high, - u_high, - v_high); - u_high += 0.5; - v_high += 0.5; + YUV::yuv.rgb_to_yuv_f( + (float)config.low_color.r / 0xff, + (float)config.low_color.g / 0xff, + (float)config.low_color.b / 0xff, + y_low, u_low, v_low); + u_low += 0.5; v_low += 0.5; + YUV::yuv.rgb_to_yuv_f( + (float)config.mid_color.r / 0xff, + (float)config.mid_color.g / 0xff, + (float)config.mid_color.b / 0xff, + y_mid, u_mid, v_mid); + u_mid += 0.5; v_mid += 0.5; + YUV::yuv.rgb_to_yuv_f( + (float)config.high_color.r / 0xff, + (float)config.high_color.g / 0xff, + (float)config.high_color.b / 0xff, + y_high, u_high, v_high); + u_high += 0.5; v_high += 0.5; glUniform4f(glGetUniformLocation(shader, "low_color"), - y_low, u_low, v_low, - has_alpha ? (float)config.low_color.a / 0xff : 1.0); + y_low, u_low, v_low, + has_alpha ? (float)config.low_color.a / 0xff : 1.0); glUniform4f(glGetUniformLocation(shader, "mid_color"), - y_mid, u_mid, v_mid, - has_alpha ? (float)config.mid_color.a / 0xff : 1.0); + y_mid, u_mid, v_mid, + has_alpha ? (float)config.mid_color.a / 0xff : 1.0); glUniform4f(glGetUniformLocation(shader, "high_color"), - y_high, u_high, v_high, - has_alpha ? (float)config.high_color.a / 0xff : 1.0); - } else { + y_high, u_high, v_high, + has_alpha ? (float)config.high_color.a / 0xff : 1.0); + } + else { glUniform4f(glGetUniformLocation(shader, "low_color"), - (float)config.low_color.r / 0xff, - (float)config.low_color.g / 0xff, - (float)config.low_color.b / 0xff, - has_alpha ? (float)config.low_color.a / 0xff : 1.0); + (float)config.low_color.r / 0xff, + (float)config.low_color.g / 0xff, + (float)config.low_color.b / 0xff, + has_alpha ? (float)config.low_color.a / 0xff : 1.0); glUniform4f(glGetUniformLocation(shader, "mid_color"), - (float)config.mid_color.r / 0xff, - (float)config.mid_color.g / 0xff, - (float)config.mid_color.b / 0xff, - has_alpha ? (float)config.mid_color.a / 0xff : 1.0); + (float)config.mid_color.r / 0xff, + (float)config.mid_color.g / 0xff, + (float)config.mid_color.b / 0xff, + has_alpha ? (float)config.mid_color.a / 0xff : 1.0); glUniform4f(glGetUniformLocation(shader, "high_color"), - (float)config.high_color.r / 0xff, - (float)config.high_color.g / 0xff, - (float)config.high_color.b / 0xff, - has_alpha ? (float)config.high_color.a / 0xff : 1.0); + (float)config.high_color.r / 0xff, + (float)config.high_color.g / 0xff, + (float)config.high_color.b / 0xff, + has_alpha ? (float)config.high_color.a / 0xff : 1.0); + BC_GL_RGB_TO_YUV(shader); } } @@ -456,25 +447,22 @@ inline uint16_t scale_to_range(int v) return v << 8 | v; } -static inline void rgb_to_yuv(YUV & yuv, - unsigned char r, unsigned char g, unsigned char b, +static inline void rgb_to_yuv(unsigned char r, unsigned char g, unsigned char b, unsigned char & y, unsigned char & u, unsigned char & v) { - yuv.rgb_to_yuv_8(r, g, b, y, u, v); + YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v); } -static inline void rgb_to_yuv(YUV & yuv, - float r, float g, float b, +static inline void rgb_to_yuv(float r, float g, float b, float & y, float & u, float & v) { - yuv.rgb_to_yuv_f(r, g, b, y, u, v); + YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); } -static inline void rgb_to_yuv(YUV & yuv, - uint16_t r, uint16_t g, uint16_t b, +static inline void rgb_to_yuv(uint16_t r, uint16_t g, uint16_t b, uint16_t & y, uint16_t & u, uint16_t & v) { - yuv.rgb_to_yuv_16(r, g, b, y, u, v); + YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); } template @@ -509,9 +497,9 @@ void ThresholdUnit::render_data(LoadPackage *package) if (USE_YUV) { - rgb_to_yuv(*server->yuv, r_low, g_low, b_low, y_low, u_low, v_low); - rgb_to_yuv(*server->yuv, r_mid, g_mid, b_mid, y_mid, u_mid, v_mid); - rgb_to_yuv(*server->yuv, r_high, g_high, b_high, y_high, u_high, v_high); + rgb_to_yuv(r_low, g_low, b_low, y_low, u_low, v_low); + rgb_to_yuv(r_mid, g_mid, b_mid, y_mid, u_mid, v_mid); + rgb_to_yuv(r_high, g_high, b_high, y_high, u_high, v_high); } for(int i = pkg->start; i < pkg->end; i++) @@ -631,12 +619,10 @@ ThresholdEngine::ThresholdEngine(ThresholdMain *plugin) plugin->get_project_smp() + 1) { this->plugin = plugin; - yuv = new YUV; } ThresholdEngine::~ThresholdEngine() { - delete yuv; } void ThresholdEngine::process_packages(VFrame *data)