diff --git a/include/DummyReader.h b/include/DummyReader.h
index 57e3bbf9..1a676d8d 100644
--- a/include/DummyReader.h
+++ b/include/DummyReader.h
@@ -55,12 +55,6 @@ namespace openshot
{
private:
tr1::shared_ptr image_frame;
- Fraction fps;
- float duration;
- int sample_rate;
- int width;
- int height;
- int channels;
bool is_open;
public:
diff --git a/src/DummyReader.cpp b/src/DummyReader.cpp
index 68b6d45f..827aafbe 100644
--- a/src/DummyReader.cpp
+++ b/src/DummyReader.cpp
@@ -30,18 +30,45 @@
using namespace openshot;
// Blank constructor for DummyReader, with default settings.
-DummyReader::DummyReader() : fps(Fraction(24,1)), width(1280), height(720),
- sample_rate(44100), channels(2), duration(30.0) {
+DummyReader::DummyReader() {
+ // Call actual constructor with default values
+ DummyReader(Fraction(24,1), 1280, 768, 44100, 2, 30.0);
}
// Constructor for DummyReader. Pass a framerate and samplerate.
-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)
-{
+DummyReader::DummyReader(Fraction fps, int width, int height, int sample_rate, int channels, float duration) {
+
// Init FileInfo struct (clear all values)
InitFileInfo();
+ // Set key info settings
+ info.has_audio = false;
+ info.has_video = true;
+ info.file_size = width * height * sizeof(int);
+ info.vcodec = "raw";
+ info.fps = fps;
+ info.width = width;
+ info.height = height;
+ info.sample_rate = sample_rate;
+ info.channels = channels;
+ info.duration = duration;
+ info.video_length = duration * fps.ToFloat();
+ info.pixel_ratio.num = 1;
+ info.pixel_ratio.den = 1;
+ info.video_timebase = fps.Reciprocal();
+ info.acodec = "raw";
+
+ // Calculate the DAR (display aspect ratio)
+ Fraction size(info.width * info.pixel_ratio.num, info.height * info.pixel_ratio.den);
+
+ // Reduce size fraction
+ size.Reduce();
+
+ // Set the ratio based on the reduced fraction
+ info.display_ratio.num = size.num;
+ info.display_ratio.den = size.den;
+
// Open and Close the reader, to populate it's attributes (such as height, width, etc...)
Open();
Close();
@@ -54,39 +81,10 @@ void DummyReader::Open() throw(InvalidFile)
if (!is_open)
{
// Create or get frame object
- image_frame = tr1::shared_ptr(new Frame(1, width, height, "#000000", sample_rate, channels));
+ image_frame = tr1::shared_ptr(new Frame(1, info.width, info.height, "#000000", info.sample_rate, info.channels));
// Add Image data to frame
- image_frame->AddImage(tr1::shared_ptr(new Magick::Image(Magick::Geometry(width, height), Magick::Color("#000000"))));
-
- // Update image properties
- info.has_audio = false;
- info.has_video = true;
- info.file_size = width * height * sizeof(int);
- info.vcodec = "raw";
- info.width = width;
- info.height = height;
- info.pixel_ratio.num = 1;
- info.pixel_ratio.den = 1;
- info.duration = duration;
- 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;
- info.sample_rate = sample_rate;
-
- // Calculate the DAR (display aspect ratio)
- Fraction size(info.width * info.pixel_ratio.num, info.height * info.pixel_ratio.den);
-
- // Reduce size fraction
- size.Reduce();
-
- // Set the ratio based on the reduced fraction
- info.display_ratio.num = size.num;
- info.display_ratio.den = size.den;
+ image_frame->AddImage(tr1::shared_ptr(new Magick::Image(Magick::Geometry(info.width, info.height), Magick::Color("#000000"))));
// Mark as "open"
is_open = true;
diff --git a/src/FrameMapper.cpp b/src/FrameMapper.cpp
index 6f5ca128..6c4c2251 100644
--- a/src/FrameMapper.cpp
+++ b/src/FrameMapper.cpp
@@ -279,7 +279,7 @@ void FrameMapper::Init()
MappedFrame FrameMapper::GetMappedFrame(int TargetFrameNumber) throw(OutOfBoundsFrame)
{
// Check if frame number is valid
- if(TargetFrameNumber < 1)
+ if(TargetFrameNumber < 1 || frames.size() == 0)
// frame too small, return error
throw OutOfBoundsFrame("An invalid frame was requested.", TargetFrameNumber, frames.size());
@@ -415,8 +415,8 @@ void FrameMapper::PrintMapping()
for (float map = 1; map <= frames.size(); map++)
{
MappedFrame frame = frames[map - 1];
- cout << "Target frame #: " << map << " mapped to original frame #:\t(" << frame.Odd.Frame << " odd, " << frame.Even.Frame << " even)" << endl;
- cout << " - Audio samples mapped to frame " << frame.Samples.frame_start << ":" << frame.Samples.sample_start << " to frame " << frame.Samples.frame_end << ":" << frame.Samples.sample_end << endl;
+ //cout << "Target frame #: " << map << " mapped to original frame #:\t(" << frame.Odd.Frame << " odd, " << frame.Even.Frame << " even)" << endl;
+ //cout << " - Audio samples mapped to frame " << frame.Samples.frame_start << ":" << frame.Samples.sample_start << " to frame " << frame.Samples.frame_end << ":" << frame.Samples.sample_end << endl;
}
}