You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added a minimum # of packets to read in the FFmpegReader, which really helps utilize the multiple threads... and improved performance by 27% overall.
This commit is contained in:
@@ -266,10 +266,9 @@ Frame* FFmpegReader::GetFrame(int requested_frame)
|
||||
{
|
||||
// Check the cache for this frame
|
||||
if (final_cache.Exists(requested_frame))
|
||||
{
|
||||
// Return the cached frame
|
||||
return final_cache.GetFrame(requested_frame);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Frame is not in cache
|
||||
@@ -313,6 +312,10 @@ Frame* FFmpegReader::ReadStream(int requested_frame)
|
||||
bool frame_finished = false;
|
||||
int packet_error = -1;
|
||||
|
||||
// Minimum number of packets to process (for performance reasons)
|
||||
int packets_processed = 0;
|
||||
int minimum_packets = 12;
|
||||
|
||||
//omp_set_num_threads(1);
|
||||
#pragma omp parallel
|
||||
{
|
||||
@@ -384,6 +387,9 @@ Frame* FFmpegReader::ReadStream(int requested_frame)
|
||||
ProcessAudioPacket(requested_frame, location.frame, location.sample_start);
|
||||
}
|
||||
|
||||
// Count processed packets
|
||||
packets_processed++;
|
||||
|
||||
// Check if working frames are 'finished'
|
||||
bool is_cache_found = false;
|
||||
#pragma omp critical (openshot_cache)
|
||||
@@ -396,7 +402,7 @@ Frame* FFmpegReader::ReadStream(int requested_frame)
|
||||
}
|
||||
|
||||
// Break once the frame is found
|
||||
if (is_cache_found)
|
||||
if (is_cache_found && packets_processed >= minimum_packets)
|
||||
break;
|
||||
|
||||
} // end while
|
||||
|
||||
Reference in New Issue
Block a user