vtl: more frame->sample renames and cleaning
This commit is contained in:
parent
96eee9e7a1
commit
74f2472c7d
|
@ -53,16 +53,6 @@ Editor::set_video_timeline_height (const int h)
|
|||
void
|
||||
Editor::update_video_timeline (bool flush)
|
||||
{
|
||||
#if DEBUG
|
||||
framepos_t rightmost_frame = leftmost_frame + current_page_samples();
|
||||
std::cout << "VIDEO SCROLL: " << leftmost_frame << " -- " << rightmost_frame << std::endl;
|
||||
std::cout << "SCROLL UNITS: " << sample_to_pixel(leftmost_frame) << " -- " << sample_to_pixel(rightmost_frame)
|
||||
<< " = " << sample_to_pixel(rightmost_frame) - sample_to_pixel(leftmost_frame)
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
// TODO later: make this a list for mult. video tracks
|
||||
// also modify ardour_ui_dialogs.cc : set_session()
|
||||
if (flush) {
|
||||
ARDOUR_UI::instance()->video_timeline->flush_local_cache();
|
||||
}
|
||||
|
|
|
@ -427,18 +427,18 @@ VideoMonitor::set_offset (ARDOUR::frameoffset_t offset)
|
|||
if (offset == NO_OFFSET ) { return; }
|
||||
|
||||
framecnt_t video_frame_offset;
|
||||
framecnt_t audio_frame_rate;
|
||||
framecnt_t audio_sample_rate;
|
||||
if (_session->config.get_videotimeline_pullup()) {
|
||||
audio_frame_rate = _session->frame_rate();
|
||||
audio_sample_rate = _session->frame_rate();
|
||||
} else {
|
||||
audio_frame_rate = _session->nominal_frame_rate();
|
||||
audio_sample_rate = _session->nominal_frame_rate();
|
||||
}
|
||||
|
||||
/* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */
|
||||
if (_session->config.get_use_video_file_fps()) {
|
||||
video_frame_offset = floor(offset * fps / audio_frame_rate);
|
||||
video_frame_offset = floor(offset * fps / audio_sample_rate);
|
||||
} else {
|
||||
video_frame_offset = floor(offset * _session->timecode_frames_per_second() / audio_frame_rate);
|
||||
video_frame_offset = floor(offset * _session->timecode_frames_per_second() / audio_sample_rate);
|
||||
}
|
||||
|
||||
// TODO remember if changed..
|
||||
|
@ -452,18 +452,18 @@ VideoMonitor::manual_seek (framepos_t when, bool /*force*/, ARDOUR::frameoffset_
|
|||
if (!is_started()) { return; }
|
||||
if (!_session) { return; }
|
||||
framecnt_t video_frame;
|
||||
framecnt_t audio_frame_rate;
|
||||
framecnt_t audio_sample_rate;
|
||||
if (_session->config.get_videotimeline_pullup()) {
|
||||
audio_frame_rate = _session->frame_rate();
|
||||
audio_sample_rate = _session->frame_rate();
|
||||
} else {
|
||||
audio_frame_rate = _session->nominal_frame_rate();
|
||||
audio_sample_rate = _session->nominal_frame_rate();
|
||||
}
|
||||
|
||||
/* Note: pull-up/down are applied here: frame_rate() vs. nominal_frame_rate() */
|
||||
if (_session->config.get_use_video_file_fps()) {
|
||||
video_frame = floor(when * fps / audio_frame_rate);
|
||||
video_frame = floor(when * fps / audio_sample_rate);
|
||||
} else {
|
||||
video_frame = floor(when * _session->timecode_frames_per_second() / audio_frame_rate);
|
||||
video_frame = floor(when * _session->timecode_frames_per_second() / audio_sample_rate);
|
||||
}
|
||||
if (video_frame < 0 ) video_frame = 0;
|
||||
|
||||
|
|
|
@ -269,7 +269,7 @@ float
|
|||
VideoTimeLine::get_apv()
|
||||
{
|
||||
// XXX: dup code - TODO use this fn in update_video_timeline()
|
||||
float apv = -1; /* audio frames per video frame; */
|
||||
float apv = -1; /* audio samples per video frame; */
|
||||
if (!_session) return apv;
|
||||
|
||||
if (_session->config.get_use_video_file_fps()) {
|
||||
|
@ -302,8 +302,8 @@ VideoTimeLine::update_video_timeline()
|
|||
if (_session->timecode_frames_per_second() == 0 ) return;
|
||||
}
|
||||
|
||||
double frames_per_unit = editor->get_current_zoom();
|
||||
framepos_t leftmost_frame = editor->leftmost_sample();
|
||||
const double samples_per_pixel = editor->get_current_zoom();
|
||||
const framepos_t leftmost_sample = editor->leftmost_sample();
|
||||
|
||||
/* Outline:
|
||||
* 1) calculate how many frames there should be in current zoom (plus 1 page on each side)
|
||||
|
@ -315,12 +315,12 @@ VideoTimeLine::update_video_timeline()
|
|||
|
||||
/* video-file and session properties */
|
||||
double display_vframe_width; /* unit: pixels ; width of one thumbnail in the timeline */
|
||||
float apv; /* audio frames per video frame; */
|
||||
float apv; /* audio samples per video frame; */
|
||||
framepos_t leftmost_video_frame; /* unit: video-frame number ; temporary var -> vtl_start */
|
||||
|
||||
/* variables needed to render videotimeline -- what needs to computed first */
|
||||
framepos_t vtl_start; /* unit: audio-frames ; first displayed video-frame */
|
||||
framepos_t vtl_dist; /* unit: audio-frames ; distance between displayed video-frames */
|
||||
framepos_t vtl_start; /* unit: audio-samples ; first displayed video-frame */
|
||||
framepos_t vtl_dist; /* unit: audio-samples ; distance between displayed video-frames */
|
||||
unsigned int visible_video_frames; /* number of frames that fit on current canvas */
|
||||
|
||||
if (_session->config.get_videotimeline_pullup()) {
|
||||
|
@ -336,12 +336,12 @@ VideoTimeLine::update_video_timeline()
|
|||
|
||||
display_vframe_width = bar_height * video_aspect_ratio;
|
||||
|
||||
if (apv > frames_per_unit * display_vframe_width) {
|
||||
if (apv > samples_per_pixel * display_vframe_width) {
|
||||
/* high-zoom: need space between successive video-frames */
|
||||
vtl_dist = rint(apv);
|
||||
} else {
|
||||
/* continous timeline: skip video-frames */
|
||||
vtl_dist = ceil(display_vframe_width * frames_per_unit / apv) * apv;
|
||||
vtl_dist = ceil(display_vframe_width * samples_per_pixel / apv) * apv;
|
||||
}
|
||||
|
||||
assert (vtl_dist > 0);
|
||||
|
@ -349,7 +349,7 @@ VideoTimeLine::update_video_timeline()
|
|||
|
||||
#define GOFFSET (video_offset)
|
||||
|
||||
leftmost_video_frame = floor (floor((leftmost_frame - video_start_offset - GOFFSET ) / vtl_dist) * vtl_dist / apv);
|
||||
leftmost_video_frame = floor (floor((leftmost_sample - video_start_offset - GOFFSET ) / vtl_dist) * vtl_dist / apv);
|
||||
|
||||
vtl_start = rint (GOFFSET + video_start_offset + leftmost_video_frame * apv);
|
||||
visible_video_frames = 2 + ceil(editor->current_page_samples() / vtl_dist); /* +2 left+right partial frames */
|
||||
|
@ -401,7 +401,7 @@ VideoTimeLine::update_video_timeline()
|
|||
#endif
|
||||
|
||||
for (unsigned int vfcount=0; vfcount < visible_video_frames; ++vfcount){
|
||||
framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
|
||||
framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-samples */
|
||||
framepos_t vframeno = rint ( (vfpos - GOFFSET) / apv); /* unit: video-frames */
|
||||
vfpos = (vframeno * apv ) + GOFFSET; /* audio-frame corresponding to /rounded/ video-frame */
|
||||
|
||||
|
@ -422,16 +422,15 @@ VideoTimeLine::update_video_timeline()
|
|||
for (VideoFrames::iterator i = outdated_video_frames.begin(); i != outdated_video_frames.end(); ++i ) {
|
||||
VideoImageFrame *frame = (*i);
|
||||
if (remaining.empty()) {
|
||||
frame->set_position(-2 * vtl_dist + leftmost_frame); /* move off screen */
|
||||
frame->set_position(-2 * vtl_dist + leftmost_sample); /* move off screen */
|
||||
} else {
|
||||
int vfcount=remaining.front();
|
||||
remaining.pop_front();
|
||||
framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-frames */
|
||||
framepos_t vfpos = vtl_start + vfcount * vtl_dist; /* unit: audio-samples */
|
||||
framepos_t vframeno = rint ((vfpos - GOFFSET) / apv); /* unit: video-frames */
|
||||
int rightend = -1; /* unit: pixels */
|
||||
if (vfpos + vtl_dist > video_start_offset + video_duration + GOFFSET) {
|
||||
rightend = display_vframe_width * (video_start_offset + video_duration + GOFFSET - vfpos) / vtl_dist;
|
||||
//printf("lf(n): %lu\n", vframeno); // XXX
|
||||
}
|
||||
frame->set_position(vfpos);
|
||||
frame->set_videoframe(vframeno, rightend);
|
||||
|
@ -500,7 +499,7 @@ VideoTimeLine::video_file_info (std::string filename, bool local)
|
|||
_session->config.set_timecode_format(timecode_60);
|
||||
break;
|
||||
default:
|
||||
warning << _("Failed to set session-framerate: ") << video_file_fps << _(" does not have a corresponding option setting in Ardour.") << endmsg; /* TODO: gettext arg */
|
||||
warning << _("Failed to set session-fps: ") << video_file_fps << _(" does not have a corresponding option setting in Ardour.") << endmsg; /* TODO: gettext arg */
|
||||
break;
|
||||
}
|
||||
_session->config.set_video_pullup(0); /* TODO only set if set_timecode_format() was successful ?!*/
|
||||
|
|
|
@ -92,7 +92,7 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p
|
|||
void save_session ();
|
||||
void close_session ();
|
||||
void sync_session_state (); /* video-monitor does not actively report window/pos changes, query it */
|
||||
float get_apv(); /* audio frames per video frame; */
|
||||
float get_apv(); /* audio samples per video frame; */
|
||||
ARDOUR::framecnt_t get_duration () { return video_duration;}
|
||||
ARDOUR::frameoffset_t get_offset () { return video_offset;}
|
||||
ARDOUR::frameoffset_t quantify_frames_to_apv (ARDOUR::frameoffset_t offset) { return floor(offset/get_apv())*get_apv(); }
|
||||
|
@ -108,10 +108,10 @@ class VideoTimeLine : public sigc::trackable, public ARDOUR::SessionHandlePtr, p
|
|||
void find_xjadeo ();
|
||||
|
||||
|
||||
ARDOUR::frameoffset_t video_start_offset; /**< unit: audio-frames - video-file */
|
||||
ARDOUR::frameoffset_t video_offset; /**< unit: audio-frames - session */
|
||||
ARDOUR::frameoffset_t video_start_offset; /**< unit: audio-samples - video-file */
|
||||
ARDOUR::frameoffset_t video_offset; /**< unit: audio-samples - session */
|
||||
ARDOUR::frameoffset_t video_offset_p; /**< used for undo from editor_drag.cc */
|
||||
framepos_t video_duration; /**< unit: audio-frames */
|
||||
framepos_t video_duration; /**< unit: audio-samples */
|
||||
std::string video_filename;
|
||||
bool local_file;
|
||||
double video_aspect_ratio;
|
||||
|
|
Loading…
Reference in New Issue