X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fplayer.cpp;h=684306f633181a50e87dda2b6ac3315763ae2516;hb=ce78eec4aa583bd2ef57a8e90d40e352c1803871;hp=918b61dbef6cf64ebede07abfd7502a63202425c;hpb=b563b8903fa84bb7fd62d7d0b84b70cb26843dbf;p=nageru diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 918b61d..684306f 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -1,14 +1,14 @@ #include "player.h" #include "clip_list.h" -#include "context.h" +#include "shared/context.h" #include "defs.h" #include "shared/ffmpeg_raii.h" #include "frame_on_disk.h" -#include "httpd.h" +#include "shared/httpd.h" #include "jpeg_frame_view.h" -#include "mux.h" -#include "timebase.h" +#include "shared/mux.h" +#include "shared/timebase.h" #include "video_stream.h" #include @@ -112,9 +112,10 @@ got_clip: double speed = 0.5; int64_t in_pts_start_next_clip = -1; + steady_clock::time_point next_frame_start; for (int frameno = 0; ; ++frameno) { // Ends when the clip ends. double out_pts = out_pts_origin + TIMEBASE * frameno / output_framerate; - steady_clock::time_point next_frame_start = + next_frame_start = origin + microseconds(lrint((out_pts - out_pts_origin) * 1e6 / TIMEBASE)); int64_t in_pts = lrint(in_pts_origin + TIMEBASE * frameno * speed / output_framerate); pts = lrint(out_pts); @@ -253,11 +254,9 @@ got_clip: // (ie., move less than 1% of an _output_ frame), do so. // TODO: Snap secondary (fade-to) clips in the same fashion. bool snapped = false; - for (int64_t snap_pts : { frame_lower.pts, frame_upper.pts }) { - double snap_pts_as_frameno = (snap_pts - in_pts_origin) * output_framerate / TIMEBASE / speed; + for (FrameOnDisk snap_frame : { frame_lower, frame_upper }) { + double snap_pts_as_frameno = (snap_frame.pts - in_pts_origin) * output_framerate / TIMEBASE / speed; if (fabs(snap_pts_as_frameno - frameno) < 0.01) { - FrameOnDisk snap_frame = frame_lower; - snap_frame.pts = snap_pts; auto display_func = [this, primary_stream_idx, snap_frame, secondary_frame, fade_alpha]{ destination->setFrame(primary_stream_idx, snap_frame, secondary_frame, fade_alpha); }; @@ -275,7 +274,7 @@ got_clip: snap_frame, secondary_frame, fade_alpha); } } - in_pts_origin += snap_pts - in_pts; + in_pts_origin += snap_frame.pts - in_pts; snapped = true; break; } @@ -329,7 +328,7 @@ got_clip: got_next_clip = false; // Start the next clip from the point where the fade went out. - origin = steady_clock::now(); + origin = next_frame_start; in_pts_origin = in_pts_start_next_clip; goto got_clip; }