diff --git a/include/FrameMapper.h b/include/FrameMapper.h index 0c68b038..19b4ca4f 100644 --- a/include/FrameMapper.h +++ b/include/FrameMapper.h @@ -183,47 +183,6 @@ namespace openshot /// Set the source framerate void SourceFPS(Framerate new_fps) { original = new_fps; }; - /** - * @brief Re-map time to slow down, speed up, or reverse a clip based on a Keyframe. - * - * This method re-maps the time of a clip, or in other words, changes the sequence and/or - * duration of frames in a clip. Because this method accepts a Keyframe, the time, sequence, - * and direction of frames can be based on LINEAR, BEZIER, or CONSTANT values. - * - * The X axis of the Keyframe represents the time (in frames) of this clip. If you make the - * X axis longer than the number of frames in the clip, if will slow down your clip. If the - * X axis is shorter than your clip, it will speed up your clip. The Y axis determines which - * original frame from the media file will be played. For example, if you clip has 100 frames, - * and your Keyframe goes from (1,1) to (100,100), the clip will playback in the original sequence, - * and at the original speed. If your Keyframe goes from (1,100) to (100,1), it will playback in the - * reverse direction, and at normal speed. If your Keyframe goes from (1,100) to (500,1), - * it will play in reverse at 1/5 the original speed. - * - * Please see the following Example Code: - * \code - * // Create a mapping between 24 fps and 24 fps (a mapping is required for time-remapping) - * FrameMapper mapping(100, Framerate(24, 1), Framerate(24, 1), PULLDOWN_NONE); - * - * // Print the mapping (before it's been time-mapped) - * mapping.PrintMapping(); - * cout << "-----------------------" << endl; - * - * // Create a Keyframe to re-map time (forward, reverse, and then forward again) - * Keyframe kf; - * kf.AddPoint(Point(Coordinate(1, 1), LINEAR)); - * kf.AddPoint(Point(Coordinate(40, 40), LINEAR)); - * kf.AddPoint(Point(Coordinate(60, 20), LINEAR)); // Reverse for 20 frames - * kf.AddPoint(Point(Coordinate(100, 100), LINEAR)); // Play to end (in fast forward) - * - * // Use the Keyframe to remap the time of this clip - * mapping.MapTime(kf); - * - * // Print the mapping again (to see the time remapping) - * mapping.PrintMapping(); - * \endcode - */ - void MapTime(Keyframe new_time) throw(OutOfBoundsFrame); - /// Open the internal reader void Open() throw(InvalidFile); diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp index f90c13de..8444a20e 100644 --- a/src/FrameMapper.cpp +++ b/src/FrameMapper.cpp @@ -279,10 +279,13 @@ void FrameMapper::Init() MappedFrame FrameMapper::GetMappedFrame(int TargetFrameNumber) throw(OutOfBoundsFrame) { // Check if frame number is valid - if(TargetFrameNumber < 1 || TargetFrameNumber > frames.size()) - { + if(TargetFrameNumber < 1) + // frame too small, return error throw OutOfBoundsFrame("An invalid frame was requested.", TargetFrameNumber, frames.size()); - } + + else if (TargetFrameNumber > frames.size()) + // frame too large, set to end frame + TargetFrameNumber = frames.size(); // Return frame return frames[TargetFrameNumber - 1]; @@ -371,41 +374,6 @@ tr1::shared_ptr FrameMapper::GetFrame(int requested_frame) throw(ReaderCl return final_cache.GetFrame(frame->number); } -void FrameMapper::MapTime(Keyframe new_time) throw(OutOfBoundsFrame) -{ - // New time-mapped frames vector - vector time_mapped_frames; - - // Loop through each coordinate of the Keyframe - for (int keyframe_number = 1; keyframe_number < new_time.Values.size(); keyframe_number++) { - // Get the current coordinate from the Keyframe - Coordinate c = new_time.Values[keyframe_number]; - - // Get the requested time-mapped frame number... and make it zero based, to match - // the existing frame mapper vector. - int requested_frame = round(c.Y) - 1; - - // Check if frame number is valid - if(requested_frame < 0 || requested_frame >= frames.size()) - { - throw OutOfBoundsFrame("An invalid frame was requested.", requested_frame + 1, frames.size()); - } - - // Add the Keyframe requested frame to the new "time-mapped" frames vector - time_mapped_frames.push_back(frames[requested_frame]); - } - - // Now that we have a new vector of frames that match the Keyframe, we need - // to replace the internal frames vector with this new one. - frames.clear(); - for (int new_frame = 0; new_frame < time_mapped_frames.size(); new_frame++) - { - // Add new frames to this frame mapper instance - frames.push_back(time_mapped_frames[new_frame]); - } - -} - // Calculate the # of samples per video frame (for a specific frame number) int FrameMapper::GetSamplesPerFrame(int frame_number, Fraction rate) {