bsd lang segv fix, enable bsd lv2, lv2 gui enable fix, proxy/ffmpeg toggle resize...
[goodguy/history.git] / cinelerra-5.1 / plugins / scaleratio / scaleratio.C
index c32e7f99c13cc6fc54708fb424acf0d3f2c8f6f4..e1ea68ccfa9a82232517cc0c032ebb3035c55489 100644 (file)
@@ -2,21 +2,21 @@
 /*
  * CINELERRA
  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- * 
+ *
  */
 
 #include "clip.h"
@@ -43,9 +43,9 @@ ScaleRatioConfig::ScaleRatioConfig()
 
 int ScaleRatioConfig::equivalent(ScaleRatioConfig &that)
 {
-       return EQUIV(src_x, that.src_x) && EQUIV(src_y, that.src_y) && 
+       return EQUIV(src_x, that.src_x) && EQUIV(src_y, that.src_y) &&
                EQUIV(src_w, that.src_w) && EQUIV(src_h, that.src_h) &&
-               EQUIV(dst_x, that.dst_x) && EQUIV(dst_y, that.dst_y) && 
+               EQUIV(dst_x, that.dst_x) && EQUIV(dst_y, that.dst_y) &&
                EQUIV(dst_w, that.dst_w) && EQUIV(dst_h, that.dst_h);
 }
 
@@ -59,7 +59,7 @@ void ScaleRatioConfig::copy_from(ScaleRatioConfig &that)
        dst_w = that.dst_w;  dst_h = that.dst_h;
 }
 
-void ScaleRatioConfig::interpolate(ScaleRatioConfig &prev, ScaleRatioConfig &next, 
+void ScaleRatioConfig::interpolate(ScaleRatioConfig &prev, ScaleRatioConfig &next,
        int64_t prev_frame, int64_t next_frame, int64_t current_frame)
 {
        double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
@@ -85,7 +85,7 @@ ScaleRatioMain::ScaleRatioMain(PluginServer *server)
 
 ScaleRatioMain::~ScaleRatioMain()
 {
-       
+
 
        if(temp_frame) delete temp_frame;
        temp_frame = 0;
@@ -93,7 +93,7 @@ ScaleRatioMain::~ScaleRatioMain()
        overlayer = 0;
 }
 
-const char* ScaleRatioMain::plugin_title() { return _("Scale Ratio"); }
+const char* ScaleRatioMain::plugin_title() { return N_("Scale Ratio"); }
 int ScaleRatioMain::is_realtime() { return 1; }
 
 
@@ -171,6 +171,8 @@ int ScaleRatioMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
 
        load_configuration();
 
+       if(get_use_opengl()) return run_opengl();
+
 //printf("ScaleRatioMain::process_realtime 1 %p\n", input);
        if( input->get_rows()[0] == output->get_rows()[0] ) {
                if( temp_frame && (
@@ -180,10 +182,9 @@ int ScaleRatioMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
                        delete temp_frame;
                        temp_frame = 0;
                }
-               if(!temp_frame) 
-                       temp_frame = new VFrame(0, -1,
-                               input_ptr->get_w(), input_ptr->get_h(),
-                               input->get_color_model(), -1);
+               if(!temp_frame)
+                       temp_frame = new VFrame(input_ptr->get_w(), input_ptr->get_h(),
+                               input->get_color_model(), 0);
                temp_frame->copy_from(input);
                input = temp_frame;
        }
@@ -231,3 +232,28 @@ void ScaleRatioMain::update_gui()
 }
 
 
+int ScaleRatioMain::handle_opengl()
+{
+#ifdef HAVE_GL
+       VFrame *input = get_input(), *output = get_output();
+       float ix1 = (input->get_w() - config.src_w)/2 + config.src_x;
+       float iy1 = (input->get_h() - config.src_h)/2 + config.src_y;
+       float ix2 = ix1 + config.src_w;
+       float iy2 = iy1 + config.src_h;
+       float ox1 = (output->get_w() - config.dst_w)/2 + config.dst_x;
+       float oy1 = (output->get_h() - config.dst_h)/2 + config.dst_y;
+       float ox2 = ox1 + config.dst_w;
+       float oy2 = oy1 + config.dst_h;
+
+       output->to_texture();
+       output->enable_opengl();
+       output->init_screen();
+       output->clear_pbuffer();
+       output->bind_texture(0);
+       output->draw_texture(ix1,iy1, ix2,iy2, ox1,oy1, ox2,oy2);
+       output->set_opengl_state(VFrame::SCREEN);
+#endif
+       return 0;
+}
+
+