Fixed a small audio buffer issue, and removed more debug code.

This commit is contained in:
Jonathan Thomas
2012-07-04 04:01:59 -05:00
parent 34a07b8d82
commit 53e16efd63
4 changed files with 14 additions and 14 deletions

View File

@@ -27,6 +27,7 @@ namespace openshot {
int max_frames; ///< This is the max number of frames to cache
map<int, Frame> frames; ///< This map holds the frame number and Frame objects
deque<int> frame_numbers; ///< This queue holds a sequential list of cached Frame numbers
int current_frame; ///< This is the last requested frame (used to dynamically adjust the max_frames)
/// Clean up cached frames that exceed the number in our max_frames variable
void CleanUp();
@@ -41,7 +42,7 @@ namespace openshot {
/// Add a Frame to the cache
void Add(int frame_number, Frame frame);
/// Check for the existance of a frame in the cache
/// Check for the existence of a frame in the cache
bool Exists(int frame_number);
/// Get a frame from the cache
@@ -68,6 +69,9 @@ namespace openshot {
/// Set maximum frames to a different amount
void SetMaxFrames(int max_frames) { max_frames = max_frames; };
/// Gets the maximum frames value
int GetMaxFrames() { return max_frames; };
};
}

View File

@@ -52,6 +52,9 @@ Frame Cache::GetFrame(int frame_number)
// Does frame exists in cache?
if (Exists(frame_number))
{
// Set current frame
current_frame = frame_number;
// return the Frame object
return frames[frame_number];
}

View File

@@ -4,7 +4,7 @@ using namespace openshot;
FFmpegReader::FFmpegReader(string path) throw(InvalidFile, NoStreamsFound, InvalidCodec)
: last_video_frame(0), last_audio_frame(0), is_seeking(0), seeking_pts(0), seeking_frame(0),
audio_pts_offset(99999), video_pts_offset(99999), working_cache(30), final_cache(30), path(path),
audio_pts_offset(99999), video_pts_offset(99999), working_cache(130), final_cache(130), path(path),
is_video_seek(true), check_interlace(false), check_fps(false), init_settings(false),
enable_seek(true) { // , resampleCtx(NULL)
@@ -737,8 +737,8 @@ void FFmpegReader::ProcessAudioPacket(int requested_frame, int target_frame, int
// Decrement remaining samples
remaining_samples -= samples;
// Update working cache
if (remaining_samples > 0)
// Update working cache (if audio is completed for this frame + channel)
if (remaining_samples > 0 || start + samples >= samples_per_frame)
// If more samples remain, this frame must all it's audio data now
f.SetAudioComplete(channel_filter);
@@ -1033,13 +1033,6 @@ void FFmpegReader::CheckWorkingFrames(bool end_of_stream)
Frame f = working_cache.GetSmallestFrame();
bool is_ready = f.IsReady(info.has_video, info.has_audio);
if (f.number == 300)
{
cout << "CheckWorkingFrames: frame: " << f.number << endl;
cout << "f.IsReady(): " << f.IsReady(info.has_video, info.has_audio) << endl;
cout << "f.IsAudioReady(): " << f.IsAudioReady(info.has_audio) << endl;
}
// Check if working frame is final
if (is_ready || end_of_stream)
{

View File

@@ -17,11 +17,11 @@ int main()
// openshot::FFmpegReader r("/home/jonathan/apps/libopenshot/src/examples/test.mp4");
// openshot::FFmpegReader r("/home/jonathan/apps/libopenshot/src/examples/test1.mp4");
// openshot::FFmpegReader r("/home/jonathan/apps/libopenshot/src/examples/piano.wav");
openshot::FFmpegReader r("/home/jonathan/Videos/sintel-1024-stereo.mp4");
// openshot::FFmpegReader r("/home/jonathan/Videos/sintel-1024-stereo.mp4");
// openshot::FFmpegReader r("/home/jonathan/Videos/00001.mts");
// openshot::FFmpegReader r("/home/jonathan/Videos/sintel_trailer-720p.mp4");
// openshot::FFmpegReader r("/home/jonathan/Aptana Studio Workspace/OpenShotLibrary/src/examples/piano.wav");
// openshot::FFmpegReader r("/home/jonathan/Music/Army of Lovers/Crucified/Army of Lovers - Crucified [Single Version].mp3");
openshot::FFmpegReader r("/home/jonathan/Music/Army of Lovers/Crucified/Army of Lovers - Crucified [Single Version].mp3");
// openshot::FFmpegReader r("/home/jonathan/Documents/OpenShot Art/test.jpeg");
// openshot::FFmpegReader r("/home/jonathan/Videos/60fps.mp4");
// openshot::FFmpegReader r("/home/jonathan/Aptana Studio Workspace/OpenShotLibrary/src/examples/asdf.wdf");
@@ -37,7 +37,7 @@ int main()
Frame f = r.GetFrame(frame);
//f.Play();
//f.Display();
//f.DisplayWaveform(false);
f.DisplayWaveform(false);
}
// Seek to frame 1