4 // repeat last output frame on read_frame error
5 // uses vframe.status as read status
7 REGISTER_PLUGIN(LofEffect)
16 void LofConfig::copy_from(LofConfig &src)
23 int LofConfig::equivalent(LofConfig &src)
25 if( errs != src.errs ) return 0;
26 if( miss != src.miss ) return 0;
27 if( mark != src.mark ) return 0;
31 void LofConfig::interpolate(LofConfig &prev, LofConfig &next,
32 long prev_frame, long next_frame, long current_frame)
37 LofEffect::LofEffect(PluginServer *server)
38 : PluginVClient(server)
42 LofEffect::~LofEffect()
47 const char* LofEffect::plugin_title() { return _("Last Frame"); }
48 int LofEffect::is_realtime() { return 1; }
50 NEW_WINDOW_MACRO(LofEffect, LofWindow)
51 LOAD_CONFIGURATION_MACRO(LofEffect, LofConfig)
53 void LofEffect::update_gui()
56 thread->window->lock_window();
58 ((LofWindow*)thread->window)->update();
59 thread->window->unlock_window();
64 void LofEffect::save_data(KeyFrame *keyframe)
67 output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
68 output.tag.set_title("LOF");
69 output.tag.set_property("ERRS", config.errs);
70 output.tag.set_property("MISS", config.miss);
71 output.tag.set_property("MARK", config.mark);
73 output.terminate_string();
76 void LofEffect::read_data(KeyFrame *keyframe)
79 input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
80 while(!input.read_tag()) {
81 if(input.tag.title_is("LOF")) {
82 config.errs = input.tag.get_property("ERRS", config.errs);
83 config.miss = input.tag.get_property("MISS", config.miss);
84 config.mark = input.tag.get_property("MARK", config.mark);
90 int LofEffect::process_buffer(VFrame *frame, int64_t start_position, double frame_rate)
93 int w = frame->get_w(), h = frame->get_h();
94 int colormodel = frame->get_color_model();
95 if( frm && (frm->get_w() != w || frm->get_h() != h ||
96 frm->get_color_model() != colormodel ) ) {
99 int ret = read_frame(frame, 0, start_position, frame_rate, get_use_opengl());
100 if( ret >= 0 ) ret = frame->get_status();
103 frm = new VFrame(w, h, colormodel, -1);
104 frm->copy_from(frame);
107 frame->clear_frame();
108 else if( (ret < 0 && config.errs) || (!ret && config.miss) ) {
109 frame->copy_from(frm);
111 VFrame dot(1, 1, BC_RGBA8888, -1);
112 *(uint32_t*)dot.get_rows()[0] = 0xff0000ff;
113 int scl = 48, sz = 3, ww = w/scl, hh = h/scl;
114 if( ww < sz ) ww = w > sz ? sz : w;
115 if( hh < sz ) hh = h > sz ? sz : h;
116 BC_CModels::transfer(
117 frame->get_rows(), dot.get_rows(),
118 frame->get_y(), frame->get_u(), frame->get_v(),
119 dot.get_y(), dot.get_u(), dot.get_v(),
120 0, 0, 1, 1, 0, 0, ww, hh,
121 dot.get_color_model(), frame->get_color_model(),
122 0, dot.get_w(), frame->get_w());