diff options
author | Robin Gareus <robin@gareus.org> | 2018-01-21 11:27:26 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2018-01-21 11:27:26 +0100 |
commit | 93625b108e9dd9b6bed4eebe9fe042222e558722 (patch) | |
tree | bdcc87de361b73942980cb3d66a50576bb877422 /gtk2_ardour/video_timeline.cc | |
parent | b88fd1e6ca4fec252ab6f8f2a57b61183111f8cc (diff) |
Use "frame" for video-frames, fixes video-monitor state.
revert/amend/undo 30b087ab for video-related units
Diffstat (limited to 'gtk2_ardour/video_timeline.cc')
-rw-r--r-- | gtk2_ardour/video_timeline.cc | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/gtk2_ardour/video_timeline.cc b/gtk2_ardour/video_timeline.cc index e336d59534..0c5b080124 100644 --- a/gtk2_ardour/video_timeline.cc +++ b/gtk2_ardour/video_timeline.cc @@ -48,8 +48,8 @@ using namespace VideoUtils; VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Container *vbg, int initial_height) : editor (ed) - , videotl_group(vbg) - , bar_height(initial_height) + , videotl_group(vbg) + , bar_height(initial_height) { video_start_offset = 0L; video_offset = 0L; @@ -62,7 +62,7 @@ VideoTimeLine::VideoTimeLine (PublicEditor *ed, ArdourCanvas::Container *vbg, in video_filename = ""; local_file = true; video_file_fps = 25.0; - flush_samples = false; + _flush_frames = false; vmonitor=0; reopen_vmonitor=false; find_xjadeo(); @@ -119,7 +119,7 @@ VideoTimeLine::close_session () sessionsave.disconnect(); close_video_monitor(); - remove_samples(); + remove_frames (); video_filename = ""; video_duration = 0; GuiUpdate("set-xjadeo-sensitive-off"); @@ -231,24 +231,24 @@ VideoTimeLine::get_state () } void -VideoTimeLine::remove_samples () +VideoTimeLine::remove_frames () { - for (VideoSamples::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) { - VideoImageFrame *sample = (*i); - delete sample; + for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i ) { + VideoImageFrame* frame = (*i); + delete frame; (*i) = 0; } video_frames.clear(); } -VideoImageFrame * +VideoImageFrame* VideoTimeLine::get_video_frame (samplepos_t vfn, int cut, int rightend) { if (vfn==0) cut=0; - for (VideoSamples::iterator i = video_frames.begin(); i != video_frames.end(); ++i) { - VideoImageFrame *sample = (*i); - if (abs(sample->get_video_frame_number()-vfn)<=cut - && sample->get_rightend() == rightend) { return sample; } + for (VideoFrames::iterator i = video_frames.begin(); i != video_frames.end(); ++i) { + VideoImageFrame* frame = (*i); + if (abs(frame->get_video_frame_number()-vfn)<=cut + && frame->get_rightend() == rightend) { return frame; } } return 0; } @@ -294,11 +294,11 @@ VideoTimeLine::update_video_timeline() const samplepos_t leftmost_sample = editor->leftmost_sample(); /* Outline: - * 1) calculate how many samples there should be in current zoom (plus 1 page on each side) - * 2) calculate first sample and distance between video-frames (according to zoom) - * 3) destroy/add samples - * 4) reposition existing samples - * 5) assign framenumber to samples -> request/decode video. + * 1) calculate how many frames there should be in current zoom (plus 1 page on each side) + * 2) calculate first frame and distance between video-frames (according to zoom) + * 3) destroy/add frames + * 4) reposition existing frames + * 5) assign framenumber to frames -> request/decode video. */ /* video-file and session properties */ @@ -309,7 +309,7 @@ VideoTimeLine::update_video_timeline() /* variables needed to render videotimeline -- what needs to computed first */ samplepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */ samplepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */ - unsigned int visible_video_frames; /* number of samples that fit on current canvas */ + unsigned int visible_video_frames; /* number of frames that fit on current canvas */ if (_session->config.get_videotimeline_pullup()) { apv = _session->sample_rate(); @@ -338,43 +338,43 @@ VideoTimeLine::update_video_timeline() leftmost_video_frame = floor (floor((long double)(leftmost_sample - video_start_offset - video_offset ) / vtl_dist) * vtl_dist / apv); vtl_start = rint (video_offset + video_start_offset + leftmost_video_frame * apv); - visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial samples */ + visible_video_frames = 2 + ceil((double)editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */ /* expand timeline (cache next/prev page images) */ vtl_start -= visible_video_frames * vtl_dist; visible_video_frames *=3; - /* don't request samples that are too far to the right */ + /* don't request frames that are too far to the right */ if (vtl_start < video_offset) { visible_video_frames = std::max((double)0.0, (double)visible_video_frames + ceil((double)(vtl_start - video_offset)/vtl_dist)); vtl_start = video_offset; } /* apply video-file constraints - * (first sample in video is at video_start_offset) */ + * (first frame in video is at video_start_offset) */ if (vtl_start > video_start_offset + video_duration + video_offset ) { visible_video_frames = 0; } /* trim end. - * end = position on timeline (video-offset) minus video-file's first sample position + * end = position on timeline (video-offset) minus video-file's first frame position * TODO optimize: compute rather than iterate */ while (visible_video_frames > 0 && vtl_start + (visible_video_frames-1) * vtl_dist >= video_start_offset + video_duration + video_offset) { --visible_video_frames; } - if (flush_samples) { - remove_samples(); - flush_samples=false; + if (_flush_frames) { + remove_frames (); + _flush_frames = false; } while (video_frames.size() < visible_video_frames) { - VideoImageFrame *sample; - sample = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename()); - sample->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context()); - video_frames.push_back(sample); + VideoImageFrame *frame; + frame = new VideoImageFrame(*editor, *videotl_group, display_vframe_width, bar_height, video_server_url, translated_filename()); + frame->ImgChanged.connect (*this, invalidator (*this), boost::bind (&PublicEditor::queue_visual_videotimeline_update, editor), gui_context()); + video_frames.push_back(frame); } - VideoSamples outdated_video_frames; + VideoFrames outdated_video_frames; std::list<int> remaining; outdated_video_frames = video_frames; @@ -400,21 +400,21 @@ VideoTimeLine::update_video_timeline() rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist; //printf("lf(e): %lu\n", vframeno); // XXX } - VideoImageFrame * sample = get_video_frame(vframeno, cut, rightend); - if (sample) { - sample->set_position(vfpos); - outdated_video_frames.remove(sample); + VideoImageFrame* frame = get_video_frame(vframeno, cut, rightend); + if (frame) { + frame->set_position(vfpos); + outdated_video_frames.remove (frame); } else { remaining.push_back(vfcount); } } - for (VideoSamples::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) { - VideoImageFrame *sample = (*i); + for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) { + VideoImageFrame* frame = (*i); if (remaining.empty()) { - sample->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */ + frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */ } else { - int vfcount=remaining.front(); + int vfcount = remaining.front(); remaining.pop_front(); samplepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-samples */ samplepos_t vframeno = rint ((vfpos - video_offset) / apv); /* unit: video-frames */ @@ -423,8 +423,8 @@ VideoTimeLine::update_video_timeline() rightend = display_vframe_width * (video_start_offset + video_duration + video_offset - vfpos) / vtl_dist; //printf("lf(n): %lu\n", vframeno); // XXX } - sample->set_position(vfpos); - sample->set_videoframe(vframeno, rightend); + frame->set_position(vfpos); + frame->set_videoframe(vframeno, rightend); } } } @@ -609,9 +609,9 @@ VideoTimeLine::gui_update(std::string const & t) { editor->toggle_xjadeo_viewoption(2, 1); } else if (t == "xjadeo-window-osd-timecode-off") { editor->toggle_xjadeo_viewoption(2, 0); - } else if (t == "xjadeo-window-osd-sample-on") { + } else if (t == "xjadeo-window-osd-frame-on") { editor->toggle_xjadeo_viewoption(3, 1); - } else if (t == "xjadeo-window-osd-sample-off") { + } else if (t == "xjadeo-window-osd-frame-off") { editor->toggle_xjadeo_viewoption(3, 0); } else if (t == "xjadeo-window-osd-box-on") { editor->toggle_xjadeo_viewoption(4, 1); @@ -650,7 +650,7 @@ VideoTimeLine::vmon_update () { void VideoTimeLine::flush_local_cache () { - flush_samples = true; + _flush_frames = true; vmon_update(); } |