You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Removed Framerate class, since its functionality is already represented in the Fraction class. Also, corrected a few unittests, and updated some documentation.
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
#include "Color.h"
|
||||
#include "Enums.h"
|
||||
#include "FFmpegReader.h"
|
||||
#include "FrameRate.h"
|
||||
#include "Fraction.h"
|
||||
#include "FrameMapper.h"
|
||||
#include "ImageReader.h"
|
||||
#include "TextReader.h"
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "Magick++.h"
|
||||
#include "Cache.h"
|
||||
#include "Exceptions.h"
|
||||
#include "FrameRate.h"
|
||||
#include "Fraction.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace openshot
|
||||
{
|
||||
private:
|
||||
tr1::shared_ptr<Frame> image_frame;
|
||||
Framerate fps;
|
||||
Fraction fps;
|
||||
float duration;
|
||||
int sample_rate;
|
||||
int width;
|
||||
@@ -69,7 +69,7 @@ namespace openshot
|
||||
DummyReader();
|
||||
|
||||
/// Constructor for DummyReader.
|
||||
DummyReader(Framerate fps, int width, int height, int sample_rate, int channels, float duration);
|
||||
DummyReader(Fraction fps, int width, int height, int sample_rate, int channels, float duration);
|
||||
|
||||
/// Close File
|
||||
void Close();
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#ifndef OPENSHOT_FRACTION_H
|
||||
#define OPENSHOT_FRACTION_H
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace openshot {
|
||||
|
||||
/**
|
||||
@@ -59,6 +61,9 @@ namespace openshot {
|
||||
/// Return this fraction as a double (i.e. 1/2 = 0.5)
|
||||
double ToDouble();
|
||||
|
||||
/// Return a rounded integer of the fraction (for example 30000/1001 returns 30)
|
||||
int ToInt();
|
||||
|
||||
/// Return the reciprocal as a Fraction
|
||||
Fraction Reciprocal();
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "../include/Cache.h"
|
||||
#include "../include/ReaderBase.h"
|
||||
#include "../include/Frame.h"
|
||||
#include "../include/FrameRate.h"
|
||||
#include "../include/Fraction.h"
|
||||
#include "../include/Exceptions.h"
|
||||
#include "../include/KeyFrame.h"
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace openshot
|
||||
* Please see the following <b>Example Code</b>:
|
||||
* \code
|
||||
* // Create a frame mapper for a clip with 100 frames, and convert the frame rate (from 24 fps to 29.97 fps)
|
||||
* FrameMapper mapping(100, Framerate(24, 1), Framerate(30000, 1001), PULLDOWN_CLASSIC);
|
||||
* FrameMapper mapping(100, Fraction(24, 1), Fraction(30000, 1001), PULLDOWN_CLASSIC);
|
||||
* Frame frame2 = mapping.GetFrame(2);
|
||||
* assert(frame2.Odd.Frame == 2);
|
||||
* \endcode
|
||||
@@ -131,8 +131,8 @@ namespace openshot
|
||||
private:
|
||||
bool is_open;
|
||||
bool field_toggle; // Internal odd / even toggle (used when building the mapping)
|
||||
Framerate original; // The original frame rate
|
||||
Framerate target; // The target frame rate
|
||||
Fraction original; // The original frame rate
|
||||
Fraction target; // The target frame rate
|
||||
PulldownType pulldown; // The pull-down technique
|
||||
ReaderBase *reader; // The source video reader
|
||||
Cache final_cache; // Cache of actual Frame objects
|
||||
@@ -156,7 +156,7 @@ namespace openshot
|
||||
vector<MappedFrame> frames; // List of all frames
|
||||
|
||||
/// Default constructor for FrameMapper class
|
||||
FrameMapper(ReaderBase *reader, Framerate target, PulldownType pulldown);
|
||||
FrameMapper(ReaderBase *reader, Fraction target, PulldownType pulldown);
|
||||
|
||||
/// Close the internal reader
|
||||
void Close();
|
||||
@@ -182,16 +182,16 @@ namespace openshot
|
||||
void SetJsonValue(Json::Value root) throw(InvalidFile); ///< Load Json::JsonValue into this object
|
||||
|
||||
/// Get the target framerate
|
||||
Framerate TargetFPS() { return target; };
|
||||
Fraction TargetFPS() { return target; };
|
||||
|
||||
/// Get the source framerate
|
||||
Framerate SourceFPS() { return original; };
|
||||
Fraction SourceFPS() { return original; };
|
||||
|
||||
/// Set the target framerate
|
||||
void TargetFPS(Framerate new_fps) { target = new_fps; };
|
||||
void TargetFPS(Fraction new_fps) { target = new_fps; };
|
||||
|
||||
/// Set the source framerate
|
||||
void SourceFPS(Framerate new_fps) { original = new_fps; };
|
||||
void SourceFPS(Fraction new_fps) { original = new_fps; };
|
||||
|
||||
/// Open the internal reader
|
||||
void Open() throw(InvalidFile);
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Header file for the FrameRate class
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
||||
* (http://www.openshotstudios.com). This file is part of
|
||||
* OpenShot Library (http://www.openshot.org), an open-source project
|
||||
* dedicated to delivering high quality video editing and animation solutions
|
||||
* to the world.
|
||||
*
|
||||
* OpenShot Library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPENSHOT_FRAMERATE_H
|
||||
#define OPENSHOT_FRAMERATE_H
|
||||
|
||||
#include <math.h>
|
||||
#include "Fraction.h"
|
||||
|
||||
namespace openshot
|
||||
{
|
||||
/**
|
||||
* @brief This class represents a frame rate (otherwise known as frames per second).
|
||||
*
|
||||
* Frame rates are stored as a fraction, such as 24/1, 25/1 and 30000/1001 (29.97).
|
||||
*
|
||||
* Please see the following <b>Example Code</b>:
|
||||
* \code
|
||||
* Framerate rate(25, 1);
|
||||
* assert(rate.GetRoundedFPS() == 25);
|
||||
*
|
||||
* Framerate rate(30000, 1001);
|
||||
* assert(rate.GetRoundedFPS() == 30);
|
||||
* \endcode
|
||||
*/
|
||||
class Framerate {
|
||||
private:
|
||||
int m_numerator;
|
||||
int m_denominator;
|
||||
|
||||
public:
|
||||
|
||||
/// Default constructor (24/1 FPS)
|
||||
Framerate();
|
||||
|
||||
/// Constructor which lets you set the frame rate (as a fraction)
|
||||
Framerate(int numerator, int denominator);
|
||||
|
||||
/// Return a rounded integer of the frame rate (for example 30000/1001 returns 30 fps)
|
||||
int GetRoundedFPS();
|
||||
|
||||
/// Return a float of the frame rate (for example 30000/1001 returns 29.97...)
|
||||
float GetFPS();
|
||||
|
||||
/// Return a Fraction of the framerate
|
||||
Fraction GetFraction();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -115,7 +115,6 @@
|
||||
#include "Fraction.h"
|
||||
#include "Frame.h"
|
||||
#include "FrameMapper.h"
|
||||
#include "FrameRate.h"
|
||||
#include "ImageReader.h"
|
||||
#include "KeyFrame.h"
|
||||
#include "PlayerBase.h"
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include "ReaderBase.h"
|
||||
#include "Fraction.h"
|
||||
#include "Frame.h"
|
||||
#include "FrameRate.h"
|
||||
#include "KeyFrame.h"
|
||||
|
||||
#include "effects/ChromaKey.h"
|
||||
@@ -98,7 +97,7 @@ namespace openshot {
|
||||
* // Create a Timeline
|
||||
* Timeline t(1280, // width
|
||||
* 720, // height
|
||||
* Framerate(25,1), // framerate
|
||||
* Fraction(25,1), // framerate
|
||||
* 44100, // sample rate
|
||||
* 2 // channels
|
||||
* );
|
||||
|
||||
@@ -155,7 +155,6 @@ SET ( OPENSHOT_SOURCE_FILES
|
||||
Fraction.cpp
|
||||
Frame.cpp
|
||||
FrameMapper.cpp
|
||||
FrameRate.cpp
|
||||
KeyFrame.cpp
|
||||
ImageReader.cpp
|
||||
PlayerBase.cpp
|
||||
|
||||
@@ -122,7 +122,7 @@ Clip::Clip(string path)
|
||||
{
|
||||
// Open common video format
|
||||
reader = new FFmpegReader(path);
|
||||
cout << "READER FOUND: FFmpegReader" << endl;
|
||||
|
||||
} catch(...) { }
|
||||
}
|
||||
|
||||
@@ -133,18 +133,15 @@ Clip::Clip(string path)
|
||||
{
|
||||
// Try an image reader
|
||||
reader = new ImageReader(path);
|
||||
cout << "READER FOUND: ImageReader" << endl;
|
||||
|
||||
} catch(...) {
|
||||
try
|
||||
{
|
||||
// Try a video reader
|
||||
reader = new FFmpegReader(path);
|
||||
cout << "READER FOUND: FFmpegReader" << endl;
|
||||
|
||||
} catch(BaseException ex) {
|
||||
// No Reader Found, Throw an exception
|
||||
cout << "READER NOT FOUND" << endl;
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@
|
||||
using namespace openshot;
|
||||
|
||||
// Blank constructor for DummyReader, with default settings.
|
||||
DummyReader::DummyReader() : fps(Framerate(24,1)), width(1280), height(720),
|
||||
DummyReader::DummyReader() : fps(Fraction(24,1)), width(1280), height(720),
|
||||
sample_rate(44100), channels(2), duration(30.0) {
|
||||
|
||||
}
|
||||
|
||||
// Constructor for DummyReader. Pass a framerate and samplerate.
|
||||
DummyReader::DummyReader(Framerate fps, int width, int height, int sample_rate, int channels, float duration) :
|
||||
DummyReader::DummyReader(Fraction fps, int width, int height, int sample_rate, int channels, float duration) :
|
||||
fps(fps), width(width), height(height), sample_rate(sample_rate), channels(channels), duration(duration)
|
||||
{
|
||||
// Init FileInfo struct (clear all values)
|
||||
@@ -69,10 +69,10 @@ void DummyReader::Open() throw(InvalidFile)
|
||||
info.pixel_ratio.num = 1;
|
||||
info.pixel_ratio.den = 1;
|
||||
info.duration = duration;
|
||||
info.fps.num = fps.GetFraction().num;
|
||||
info.fps.den = fps.GetFraction().den;
|
||||
info.video_timebase.num = fps.GetFraction().den;
|
||||
info.video_timebase.den = fps.GetFraction().num;
|
||||
info.fps.num = fps.num;
|
||||
info.fps.den = fps.den;
|
||||
info.video_timebase.num = fps.den;
|
||||
info.video_timebase.den = fps.num;
|
||||
info.video_length = round(info.duration * info.fps.ToDouble());
|
||||
info.acodec = "raw";
|
||||
info.channels = channels;
|
||||
|
||||
@@ -47,6 +47,12 @@ double Fraction::ToDouble() {
|
||||
return double(num) / double(den);
|
||||
}
|
||||
|
||||
// Return a rounded integer of the frame rate (for example 30000/1001 returns 30 fps)
|
||||
int Fraction::ToInt() {
|
||||
return round((float) num / den);
|
||||
}
|
||||
|
||||
// Calculate the greatest common denominator
|
||||
int Fraction::GreatestCommonDenominator() {
|
||||
int first = num;
|
||||
int second = den;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
FrameMapper::FrameMapper(ReaderBase *reader, Framerate target, PulldownType pulldown) :
|
||||
FrameMapper::FrameMapper(ReaderBase *reader, Fraction target, PulldownType pulldown) :
|
||||
reader(reader), target(target), pulldown(pulldown), final_cache(820 * 1024)
|
||||
{
|
||||
|
||||
@@ -38,14 +38,14 @@ FrameMapper::FrameMapper(ReaderBase *reader, Framerate target, PulldownType pull
|
||||
InitFileInfo();
|
||||
|
||||
// Set the original frame rate from the reader
|
||||
original = Framerate(reader->info.fps.num, reader->info.fps.den);
|
||||
original = Fraction(reader->info.fps.num, reader->info.fps.den);
|
||||
|
||||
// Set all info struct members equal to the internal reader
|
||||
info = reader->info;
|
||||
info.fps.num = target.GetFraction().num;
|
||||
info.fps.den = target.GetFraction().den;
|
||||
info.video_timebase.num = target.GetFraction().den;
|
||||
info.video_timebase.den = target.GetFraction().num;
|
||||
info.fps.num = target.num;
|
||||
info.fps.den = target.den;
|
||||
info.video_timebase.num = target.den;
|
||||
info.video_timebase.den = target.num;
|
||||
info.video_length = round(info.duration * info.fps.ToDouble());
|
||||
info.sample_rate = reader->info.sample_rate;
|
||||
info.channels = reader->info.channels;
|
||||
@@ -86,11 +86,11 @@ void FrameMapper::Init()
|
||||
|
||||
// Some framerates are handled special, and some use a generic Keyframe curve to
|
||||
// map the framerates. These are the special framerates:
|
||||
if ((original.GetRoundedFPS() == 24 || original.GetRoundedFPS() == 25 || original.GetRoundedFPS() == 30) &&
|
||||
(target.GetRoundedFPS() == 24 || target.GetRoundedFPS() == 25 || target.GetRoundedFPS() == 30)) {
|
||||
if ((original.ToInt() == 24 || original.ToInt() == 25 || original.ToInt() == 30) &&
|
||||
(target.ToInt() == 24 || target.ToInt() == 25 || target.ToInt() == 30)) {
|
||||
|
||||
// Get the difference (in frames) between the original and target frame rates
|
||||
float difference = target.GetRoundedFPS() - original.GetRoundedFPS();
|
||||
float difference = target.ToInt() - original.ToInt();
|
||||
|
||||
// Find the number (i.e. interval) of fields that need to be skipped or repeated
|
||||
int field_interval = 0;
|
||||
@@ -98,7 +98,7 @@ void FrameMapper::Init()
|
||||
|
||||
if (difference != 0)
|
||||
{
|
||||
field_interval = round(fabs(original.GetRoundedFPS() / difference));
|
||||
field_interval = round(fabs(original.ToInt() / difference));
|
||||
|
||||
// Get frame interval (2 fields per frame)
|
||||
frame_interval = field_interval * 2.0f;
|
||||
@@ -177,7 +177,7 @@ void FrameMapper::Init()
|
||||
} else {
|
||||
// Map the remaining framerates using a simple Keyframe curve
|
||||
// Calculate the difference (to be used as a multiplier)
|
||||
float rate_diff = target.GetFPS() / original.GetFPS();
|
||||
float rate_diff = target.ToFloat() / original.ToFloat();
|
||||
int new_length = reader->info.video_length * rate_diff;
|
||||
|
||||
// Build curve for framerate mapping
|
||||
@@ -222,12 +222,12 @@ void FrameMapper::Init()
|
||||
// Determine the range of samples (from the original rate, to the new rate)
|
||||
int end_samples_frame = start_samples_frame;
|
||||
int end_samples_position = start_samples_position;
|
||||
int remaining_samples = GetSamplesPerFrame(frame_number, target.GetFraction());
|
||||
int remaining_samples = GetSamplesPerFrame(frame_number, target);
|
||||
|
||||
while (remaining_samples > 0)
|
||||
{
|
||||
// get original samples
|
||||
int original_samples = GetSamplesPerFrame(end_samples_frame, original.GetFraction()) - end_samples_position;
|
||||
int original_samples = GetSamplesPerFrame(end_samples_frame, original) - end_samples_position;
|
||||
|
||||
// Enough samples
|
||||
if (original_samples >= remaining_samples)
|
||||
@@ -247,12 +247,12 @@ void FrameMapper::Init()
|
||||
|
||||
|
||||
// Create the sample mapping struct
|
||||
SampleRange Samples = {start_samples_frame, start_samples_position, end_samples_frame, end_samples_position, GetSamplesPerFrame(frame_number, target.GetFraction())};
|
||||
SampleRange Samples = {start_samples_frame, start_samples_position, end_samples_frame, end_samples_position, GetSamplesPerFrame(frame_number, target)};
|
||||
|
||||
// Reset the audio variables
|
||||
start_samples_frame = end_samples_frame;
|
||||
start_samples_position = end_samples_position + 1;
|
||||
if (start_samples_position >= GetSamplesPerFrame(start_samples_frame, original.GetFraction()))
|
||||
if (start_samples_position >= GetSamplesPerFrame(start_samples_frame, original))
|
||||
{
|
||||
start_samples_frame += 1; // increment the frame (since we need to wrap onto the next one)
|
||||
start_samples_position = 0; // reset to 0, since we wrapped
|
||||
@@ -302,7 +302,7 @@ tr1::shared_ptr<Frame> FrameMapper::GetFrame(int requested_frame) throw(ReaderCl
|
||||
MappedFrame mapped = GetMappedFrame(requested_frame);
|
||||
|
||||
// Init some basic properties about this frame
|
||||
int samples_in_frame = GetSamplesPerFrame(requested_frame, target.GetFraction());
|
||||
int samples_in_frame = GetSamplesPerFrame(requested_frame, target);
|
||||
|
||||
// Create a new frame
|
||||
tr1::shared_ptr<Frame> frame(new Frame(requested_frame, 1, 1, "#000000", samples_in_frame, info.channels));
|
||||
@@ -391,7 +391,7 @@ int FrameMapper::GetSamplesPerFrame(int frame_number, Fraction rate)
|
||||
void FrameMapper::PrintMapping()
|
||||
{
|
||||
// Get the difference (in frames) between the original and target frame rates
|
||||
float difference = target.GetRoundedFPS() - original.GetRoundedFPS();
|
||||
float difference = target.ToInt() - original.ToInt();
|
||||
|
||||
int field_interval = 0;
|
||||
int frame_interval = 0;
|
||||
@@ -399,14 +399,14 @@ void FrameMapper::PrintMapping()
|
||||
if (difference != 0)
|
||||
{
|
||||
// Find the number (i.e. interval) of fields that need to be skipped or repeated
|
||||
field_interval = round(fabs(original.GetRoundedFPS() / difference));
|
||||
field_interval = round(fabs(original.ToInt() / difference));
|
||||
|
||||
// Get frame interval (2 fields per frame)
|
||||
frame_interval = field_interval * 2.0f;
|
||||
}
|
||||
|
||||
// print header
|
||||
cout << "Convert " << original.GetRoundedFPS() << " fps to " << target.GetRoundedFPS() << " fps" << endl;
|
||||
cout << "Convert " << original.ToInt() << " fps to " << target.ToInt() << " fps" << endl;
|
||||
cout << "Difference of " << difference << " frames per second" << endl;
|
||||
cout << "Field Interval: " << field_interval << "th field" << endl;
|
||||
cout << "Frame Interval: " << frame_interval << "th field" << endl << endl;
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Source file for the FrameRate class
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
||||
* (http://www.openshotstudios.com). This file is part of
|
||||
* OpenShot Library (http://www.openshot.org), an open-source project
|
||||
* dedicated to delivering high quality video editing and animation solutions
|
||||
* to the world.
|
||||
*
|
||||
* OpenShot Library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../include/FrameRate.h"
|
||||
|
||||
using namespace openshot;
|
||||
|
||||
Framerate::Framerate(int numerator, int denominator) {
|
||||
m_numerator = numerator;
|
||||
m_denominator = denominator;
|
||||
}
|
||||
|
||||
Framerate::Framerate() {
|
||||
m_numerator = 24;
|
||||
m_denominator = 1;
|
||||
}
|
||||
|
||||
// Return a rounded integer of the frame rate (for example 30000/1001 returns 30 fps)
|
||||
int Framerate::GetRoundedFPS() {
|
||||
return round((float) m_numerator / m_denominator);
|
||||
}
|
||||
|
||||
// Return a float of the frame rate (for example 30000/1001 returns 29.97...)
|
||||
float Framerate::GetFPS() {
|
||||
return (float) m_numerator / m_denominator;
|
||||
}
|
||||
|
||||
// Return a Fraction of the framerate
|
||||
Fraction Framerate::GetFraction()
|
||||
{
|
||||
return Fraction(m_numerator, m_denominator);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ int main(int argc, char* argv[])
|
||||
// ir.Open();
|
||||
//
|
||||
// // FrameMapper to de-interlace frame
|
||||
// //FrameMapper fm(&ir, Framerate(24,1), PULLDOWN_NONE);
|
||||
// //FrameMapper fm(&ir, Fraction(24,1), PULLDOWN_NONE);
|
||||
// //fm.DeInterlaceFrame(ir.GetFrame(1), true)->Display();
|
||||
// Deinterlace de(false);
|
||||
// de.GetFrame(ir.GetFrame(1), 1)->Display();
|
||||
@@ -80,7 +80,7 @@ int main(int argc, char* argv[])
|
||||
r1.Open();
|
||||
|
||||
// FrameMapper
|
||||
FrameMapper r(&r1, Framerate(24,1), PULLDOWN_ADVANCED);
|
||||
FrameMapper r(&r1, Fraction(24,1), PULLDOWN_ADVANCED);
|
||||
r.PrintMapping();
|
||||
|
||||
/* WRITER ---------------- */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import openshot
|
||||
|
||||
# Create a empty clip
|
||||
t = openshot.Timeline(720, 480, openshot.Framerate(24,1), 44100, 2)
|
||||
t = openshot.Timeline(720, 480, openshot.Fraction(24,1), 44100, 2)
|
||||
|
||||
# lower layer
|
||||
lower = openshot.ImageReader("/home/jonathan/apps/libopenshot/src/examples/back.png")
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
#include "../include/Fraction.h"
|
||||
#include "../include/Frame.h"
|
||||
#include "../include/FrameMapper.h"
|
||||
#include "../include/FrameRate.h"
|
||||
#include "../include/ImageReader.h"
|
||||
#include "../include/PlayerBase.h"
|
||||
#include "../include/Point.h"
|
||||
@@ -109,7 +108,6 @@
|
||||
%include "../include/Fraction.h"
|
||||
%include "../include/Frame.h"
|
||||
%include "../include/FrameMapper.h"
|
||||
%include "../include/FrameRate.h"
|
||||
%include "../include/ImageReader.h"
|
||||
%include "../include/PlayerBase.h"
|
||||
%include "../include/Point.h"
|
||||
|
||||
@@ -124,7 +124,6 @@ add_executable(tester
|
||||
FFmpegReader_Tests.cpp
|
||||
Fraction_Tests.cpp
|
||||
FrameMapper_Tests.cpp
|
||||
FrameRate_Tests.cpp
|
||||
KeyFrame_Tests.cpp
|
||||
Point_Tests.cpp
|
||||
Timeline_Tests.cpp)
|
||||
|
||||
@@ -60,15 +60,15 @@ TEST(FFmpegReader_Check_Audio_File)
|
||||
|
||||
// Check audio properties
|
||||
CHECK_EQUAL(2, f->GetAudioChannelsCount());
|
||||
CHECK_EQUAL(267, f->GetAudioSamplesCount());
|
||||
CHECK_EQUAL(333, f->GetAudioSamplesCount());
|
||||
|
||||
// Check actual sample values (to be sure the waveform is correct)
|
||||
CHECK_CLOSE(0.0f, samples[0], 0.00001);
|
||||
CHECK_CLOSE(0.0f, samples[50], 0.00001);
|
||||
CHECK_CLOSE(0.0f, samples[100], 0.00001);
|
||||
CHECK_CLOSE(0.0f, samples[200], 0.00001);
|
||||
CHECK_CLOSE(0.164062f, samples[230], 0.00001);
|
||||
CHECK_CLOSE(-0.164062f, samples[266], 0.00001);
|
||||
CHECK_CLOSE(0.160781, samples[230], 0.00001);
|
||||
CHECK_CLOSE(-0.06125f, samples[300], 0.00001);
|
||||
|
||||
// Close reader
|
||||
r.Close();
|
||||
|
||||
@@ -34,10 +34,10 @@ using namespace openshot;
|
||||
TEST(FrameMapper_Get_Valid_Frame)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(24,1), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping between 24 fps and 29.97 fps using classic pulldown
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_CLASSIC);
|
||||
FrameMapper mapping(&r, Fraction(30000, 1001), PULLDOWN_CLASSIC);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -55,35 +55,23 @@ TEST(FrameMapper_Get_Valid_Frame)
|
||||
TEST(FrameMapper_Invalid_Frame_Too_Small)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(24,1), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping 24 fps and 29.97 fps
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_CLASSIC);
|
||||
FrameMapper mapping(&r, Fraction(30000, 1001), PULLDOWN_CLASSIC);
|
||||
|
||||
// Check invalid frame number
|
||||
CHECK_THROW(mapping.GetMappedFrame(0), OutOfBoundsFrame);
|
||||
|
||||
}
|
||||
|
||||
TEST(FrameMapper_Invalid_Frame_Too_Large)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 4.0);
|
||||
|
||||
// Create mapping 24 fps and 29.97 fps
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_CLASSIC);
|
||||
|
||||
// Check invalid frame number
|
||||
CHECK_THROW(mapping.GetMappedFrame(151), OutOfBoundsFrame);
|
||||
}
|
||||
|
||||
TEST(FrameMapper_24_fps_to_30_fps_Pulldown_Classic)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(24,1), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping 24 fps and 29.97 fps
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_CLASSIC);
|
||||
FrameMapper mapping(&r, Fraction(30000, 1001), PULLDOWN_CLASSIC);
|
||||
MappedFrame frame2 = mapping.GetMappedFrame(2);
|
||||
MappedFrame frame3 = mapping.GetMappedFrame(3);
|
||||
|
||||
@@ -97,10 +85,10 @@ TEST(FrameMapper_24_fps_to_30_fps_Pulldown_Classic)
|
||||
TEST(FrameMapper_24_fps_to_30_fps_Pulldown_Advanced)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(24,1), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping 24 fps and 29.97 fps
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_ADVANCED);
|
||||
FrameMapper mapping(&r, Fraction(30000, 1001), PULLDOWN_ADVANCED);
|
||||
MappedFrame frame2 = mapping.GetMappedFrame(2);
|
||||
MappedFrame frame3 = mapping.GetMappedFrame(3);
|
||||
MappedFrame frame4 = mapping.GetMappedFrame(4);
|
||||
@@ -117,10 +105,10 @@ TEST(FrameMapper_24_fps_to_30_fps_Pulldown_Advanced)
|
||||
TEST(FrameMapper_24_fps_to_30_fps_Pulldown_None)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(24,1), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(24,1), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping 24 fps and 29.97 fps
|
||||
FrameMapper mapping(&r, Framerate(30000, 1001), PULLDOWN_NONE);
|
||||
FrameMapper mapping(&r, Fraction(30000, 1001), PULLDOWN_NONE);
|
||||
MappedFrame frame4 = mapping.GetMappedFrame(4);
|
||||
MappedFrame frame5 = mapping.GetMappedFrame(5);
|
||||
|
||||
@@ -134,10 +122,10 @@ TEST(FrameMapper_24_fps_to_30_fps_Pulldown_None)
|
||||
TEST(FrameMapper_30_fps_to_24_fps_Pulldown_Classic)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping between 29.97 fps and 24 fps
|
||||
FrameMapper mapping(&r, Framerate(24, 1), PULLDOWN_CLASSIC);
|
||||
FrameMapper mapping(&r, Fraction(24, 1), PULLDOWN_CLASSIC);
|
||||
MappedFrame frame3 = mapping.GetMappedFrame(3);
|
||||
MappedFrame frame4 = mapping.GetMappedFrame(4);
|
||||
MappedFrame frame5 = mapping.GetMappedFrame(5);
|
||||
@@ -154,10 +142,10 @@ TEST(FrameMapper_30_fps_to_24_fps_Pulldown_Classic)
|
||||
TEST(FrameMapper_30_fps_to_24_fps_Pulldown_Advanced)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping between 29.97 fps and 24 fps
|
||||
FrameMapper mapping(&r, Framerate(24, 1), PULLDOWN_ADVANCED);
|
||||
FrameMapper mapping(&r, Fraction(24, 1), PULLDOWN_ADVANCED);
|
||||
MappedFrame frame2 = mapping.GetMappedFrame(2);
|
||||
MappedFrame frame3 = mapping.GetMappedFrame(3);
|
||||
MappedFrame frame4 = mapping.GetMappedFrame(4);
|
||||
@@ -174,10 +162,10 @@ TEST(FrameMapper_30_fps_to_24_fps_Pulldown_Advanced)
|
||||
TEST(FrameMapper_30_fps_to_24_fps_Pulldown_None)
|
||||
{
|
||||
// Create a reader
|
||||
DummyReader r(Framerate(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
DummyReader r(Fraction(30000, 1001), 720, 480, 22000, 2, 5.0);
|
||||
|
||||
// Create mapping between 29.97 fps and 24 fps
|
||||
FrameMapper mapping(&r, Framerate(24, 1), PULLDOWN_NONE);
|
||||
FrameMapper mapping(&r, Fraction(24, 1), PULLDOWN_NONE);
|
||||
MappedFrame frame4 = mapping.GetMappedFrame(4);
|
||||
MappedFrame frame5 = mapping.GetMappedFrame(5);
|
||||
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Unit tests for openshot::Framerate
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2013 OpenShot Studios, LLC
|
||||
* (http://www.openshotstudios.com). This file is part of
|
||||
* OpenShot Library (http://www.openshot.org), an open-source project
|
||||
* dedicated to delivering high quality video editing and animation solutions
|
||||
* to the world.
|
||||
*
|
||||
* OpenShot Library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* OpenShot Library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "UnitTest++.h"
|
||||
#include "../include/OpenShot.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace openshot;
|
||||
|
||||
TEST(FrameRate_Check_Rounded_24_FPS)
|
||||
{
|
||||
// Create framerate for 24 fps
|
||||
Framerate rate(24, 1);
|
||||
|
||||
CHECK_EQUAL(24, rate.GetRoundedFPS());
|
||||
}
|
||||
|
||||
TEST(FrameRate_Check_Rounded_25_FPS)
|
||||
{
|
||||
// Create framerate for 25 fps
|
||||
Framerate rate(25, 1);
|
||||
|
||||
CHECK_EQUAL(25, rate.GetRoundedFPS());
|
||||
}
|
||||
|
||||
TEST(FrameRate_Check_Rounded_29_97_FPS)
|
||||
{
|
||||
// Create framerate for 29.97 fps
|
||||
Framerate rate(30000, 1001);
|
||||
|
||||
CHECK_EQUAL(30, rate.GetRoundedFPS());
|
||||
}
|
||||
|
||||
TEST(FrameRate_Check_Decimal_24_FPS)
|
||||
{
|
||||
// Create framerate for 24 fps
|
||||
Framerate rate(24, 1);
|
||||
|
||||
CHECK_CLOSE(24.0f, rate.GetFPS(), 0.0001);
|
||||
}
|
||||
|
||||
TEST(FrameRate_Check_Decimal_25_FPS)
|
||||
{
|
||||
// Create framerate for 24 fps
|
||||
Framerate rate(25, 1);
|
||||
|
||||
CHECK_CLOSE(25.0f, rate.GetFPS(), 0.0001);
|
||||
}
|
||||
|
||||
TEST(FrameRate_Check_Decimal_29_97_FPS)
|
||||
{
|
||||
// Create framerate for 29.97 fps
|
||||
Framerate rate(30000, 1001);
|
||||
|
||||
CHECK_CLOSE(29.97f, rate.GetFPS(), 0.0001);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user