You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Replaced ImagMagick with QImage on almost all key methods and classes. Reprogrammed all effects and the entire rendering pipeline to use QImage and QTransforms, primarily for increases in speed and stability. libopenshot is more than 10X faster on many of the most CPU heavy tasks. This was a huge change, and still has a few minor issues relating to BlackMagick Decklink and Text rendering.... which should be resolved very soon.
Also, much work has been done on memory management / leak detection, and optimizations with multi-threading... including a new thread cacher class used by the video playback (which is smoother than ever).
This commit is contained in:
100
src/Qt/VideoCacheThread.cpp
Normal file
100
src/Qt/VideoCacheThread.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Source file for VideoCacheThread class
|
||||
* @author Jonathan Thomas <jonathan@openshot.org>
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
||||
* <http://www.openshotstudios.com/>. This file is part of
|
||||
* OpenShot Library (libopenshot), an open-source project dedicated to
|
||||
* delivering high quality video editing and animation solutions to the
|
||||
* world. For more information visit <http://www.openshot.org/>.
|
||||
*
|
||||
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU Lesser 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 (libopenshot) 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../include/Qt/VideoCacheThread.h"
|
||||
|
||||
namespace openshot
|
||||
{
|
||||
// Constructor
|
||||
VideoCacheThread::VideoCacheThread()
|
||||
: Thread("video-cache"), speed(1), is_playing(false), position(1)
|
||||
, reader(NULL), max_frames(OPEN_MP_NUM_PROCESSORS * 2), current_display_frame(1)
|
||||
{
|
||||
}
|
||||
|
||||
// Destructor
|
||||
VideoCacheThread::~VideoCacheThread()
|
||||
{
|
||||
}
|
||||
|
||||
// Get the currently playing frame number (if any)
|
||||
int VideoCacheThread::getCurrentFramePosition()
|
||||
{
|
||||
if (frame)
|
||||
return frame->number;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set the currently playing frame number (if any)
|
||||
void VideoCacheThread::setCurrentFramePosition(int current_frame_number)
|
||||
{
|
||||
current_display_frame = current_frame_number;
|
||||
}
|
||||
|
||||
// Seek the audio thread
|
||||
void VideoCacheThread::Seek(int new_position)
|
||||
{
|
||||
position = new_position;
|
||||
}
|
||||
|
||||
// Play the audio
|
||||
void VideoCacheThread::Play() {
|
||||
// Start playing
|
||||
is_playing = true;
|
||||
}
|
||||
|
||||
// Stop the audio
|
||||
void VideoCacheThread::Stop() {
|
||||
// Stop playing
|
||||
is_playing = false;
|
||||
}
|
||||
|
||||
// Start the thread
|
||||
void VideoCacheThread::run()
|
||||
{
|
||||
while (!threadShouldExit()) {
|
||||
|
||||
// Calculate sleep time for frame rate
|
||||
double frame_time = (1000.0 / reader->info.fps.ToDouble());
|
||||
|
||||
// Cache frames before the other threads need them
|
||||
// Cache frames up to the max frames
|
||||
while ((position - current_display_frame) < max_frames)
|
||||
{
|
||||
// Only cache up till the max_frames amount... then sleep
|
||||
if (reader)
|
||||
reader->GetFrame(position);
|
||||
|
||||
// Increment frame number
|
||||
position++;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user