dynamic keyframes, textbox rework, andrea ffmpeg.opts, perpetual chkpt undo, lv2...
[goodguy/history.git] / cinelerra-5.1 / plugins / scaleratio / scaleratio.C
index 52073c10c7ebdf19e987d1ee42d6818596f359b5..40856cce4511783231b30085754115e79d5943ad 100644 (file)
@@ -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; }
 
 
@@ -105,7 +105,7 @@ void ScaleRatioMain::save_data(KeyFrame *keyframe)
        FileXML output;
 
 // cause data to be stored directly in text
-       output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
+       output.set_shared_output(keyframe->xbuf);
 
 // Store data
        output.tag.set_title("SCALERATIO");
@@ -136,7 +136,7 @@ void ScaleRatioMain::read_data(KeyFrame *keyframe)
 {
        FileXML input;
 
-       input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+       input.set_shared_input(keyframe->xbuf);
 
        int result = 0;
 
@@ -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 && (
@@ -230,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;
+}
+
+