Merge branch 'develop' into hardware-support

This commit is contained in:
eisneinechse
2019-01-18 16:42:46 -08:00
23 changed files with 394 additions and 636 deletions

View File

@@ -88,7 +88,7 @@ FFmpegReader::FFmpegReader(string path)
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0),
current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0),
packet(NULL), use_omp_threads(true) {
packet(NULL) {
// Initialize FFMpeg, and register all formats and codecs
AV_REGISTER_ALL
@@ -110,7 +110,7 @@ FFmpegReader::FFmpegReader(string path, bool inspect_reader)
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0),
current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0),
packet(NULL), use_omp_threads(true) {
packet(NULL) {
// Initialize FFMpeg, and register all formats and codecs
AV_REGISTER_ALL
@@ -633,9 +633,6 @@ void FFmpegReader::Open()
missing_frames.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels);
final_cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels);
// Initialize OMP threading support
use_omp_threads = openshot::IsOMPEnabled();
// Mark as "open"
is_open = true;
}
@@ -1025,7 +1022,7 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame)
// Process Video Packet
ProcessVideoPacket(requested_frame);
if (!use_omp_threads) {
if (openshot::Settings::Instance()->WAIT_FOR_VIDEO_PROCESSING_TASK) {
// Wait on each OMP task to complete before moving on to the next one. This slows
// down processing considerably, but might be more stable on some systems.
#pragma omp taskwait
@@ -1040,16 +1037,16 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame)
num_packets_since_video_frame++;
// Check the status of a seek (if any)
if (is_seeking)
#pragma omp critical (openshot_seek)
check_seek = CheckSeek(false);
else
check_seek = false;
if (is_seeking)
#pragma omp critical (openshot_seek)
check_seek = CheckSeek(false);
else
check_seek = false;
if (check_seek) {
// Jump to the next iteration of this loop
continue;
}
if (check_seek) {
// Jump to the next iteration of this loop
continue;
}
// Update PTS / Frame Offset (if any)
UpdatePTSOffset(false);
@@ -1371,8 +1368,12 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame)
// Copy picture data from one AVFrame (or AVPicture) to another one.
AV_COPY_PICTURE_DATA(pFrameRGB, buffer, PIX_FMT_RGBA, width, height);
int scale_mode = SWS_FAST_BILINEAR;
if (openshot::Settings::Instance()->HIGH_QUALITY_SCALING) {
scale_mode = SWS_LANCZOS;
}
SwsContext *img_convert_ctx = sws_getContext(info.width, info.height, AV_GET_CODEC_PIXEL_FORMAT(pStream, pCodecCtx), width,
height, PIX_FMT_RGBA, SWS_LANCZOS, NULL, NULL, NULL);
height, PIX_FMT_RGBA, scale_mode, NULL, NULL, NULL);
// Resize / Convert to RGB
sws_scale(img_convert_ctx, my_frame->data, my_frame->linesize, 0,
@@ -2426,7 +2427,7 @@ void FFmpegReader::RemoveAVFrame(AVFrame* remove_frame)
{
// Free memory
av_freep(&remove_frame->data[0]);
AV_FREE_FRAME(&remove_frame);
AV_FREE_FRAME(&remove_frame);
}
}