X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=futatabi%2Fframe_on_disk.h;h=c8a74a758ffdc19e6fad72c34a9246408893971f;hb=refs%2Fheads%2Fmaster;hp=360bd23ce1222271cfef1f82df5006de0b141a60;hpb=e0cb348ca42ae7057f8f5acee92a23e7eb26075f;p=nageru diff --git a/futatabi/frame_on_disk.h b/futatabi/frame_on_disk.h index 360bd23..c8a74a7 100644 --- a/futatabi/frame_on_disk.h +++ b/futatabi/frame_on_disk.h @@ -46,7 +46,7 @@ public: std::string video; std::string audio; }; - Frame read_frame(FrameOnDisk frame, bool read_audio); + Frame read_frame(FrameOnDisk frame, bool read_video, bool read_audio); private: int fd = -1; @@ -61,6 +61,13 @@ find_last_frame_before(std::vector &frames, int64_t pts_origin) [](const FrameOnDisk &frame, int64_t pts) { return frame.pts < pts; }); } +inline std::vector::const_iterator +find_last_frame_before(const std::vector &frames, int64_t pts_origin) +{ + return std::lower_bound(frames.begin(), frames.end(), pts_origin, + [](const FrameOnDisk &frame, int64_t pts) { return frame.pts < pts; }); +} + inline std::vector::iterator find_first_frame_at_or_after(std::vector &frames, int64_t pts_origin) { @@ -68,4 +75,11 @@ find_first_frame_at_or_after(std::vector &frames, int64_t pts_origi [](int64_t pts, const FrameOnDisk &frame) { return pts < frame.pts; }); } +inline std::vector::const_iterator +find_first_frame_at_or_after(const std::vector &frames, int64_t pts_origin) +{ + return std::upper_bound(frames.begin(), frames.end(), pts_origin - 1, + [](int64_t pts, const FrameOnDisk &frame) { return pts < frame.pts; }); +} + #endif // !defined(_FRAME_ON_DISK_H)