Merge pull request #530 from ferdnyc/omp-and-ffmpeg-classes

Move off deprecated OpenMP API, fix FFmpeg code paths
This commit is contained in:
Jonathan Thomas
2020-10-16 14:45:20 -05:00
committed by GitHub
7 changed files with 58 additions and 58 deletions

View File

@@ -85,7 +85,7 @@ static int set_hwframe_ctx(AVCodecContext *ctx, AVBufferRef *hw_device_ctx, int6
}
#endif // HAVE_HW_ACCEL
FFmpegWriter::FFmpegWriter(std::string path) :
FFmpegWriter::FFmpegWriter(const std::string& path) :
path(path), fmt(NULL), oc(NULL), audio_st(NULL), video_st(NULL), samples(NULL),
audio_outbuf(NULL), audio_outbuf_size(0), audio_input_frame_size(0), audio_input_position(0),
initial_audio_input_frame_size(0), img_convert_ctx(NULL), cache_size(8), num_of_rescalers(32),
@@ -97,6 +97,12 @@ FFmpegWriter::FFmpegWriter(std::string path) :
info.has_audio = false;
info.has_video = false;
// Configure OpenMP parallelism
// Default number of threads per block
omp_set_num_threads(OPEN_MP_NUM_PROCESSORS);
// Allow nested parallel sections as deeply as supported
omp_set_max_active_levels(OPEN_MP_MAX_ACTIVE);
// Initialize FFMpeg, and register all formats and codecs
AV_REGISTER_ALL
@@ -718,11 +724,6 @@ void FFmpegWriter::write_queued_frames() {
spooled_video_frames.clear();
spooled_audio_frames.clear();
// Set the number of threads in OpenMP
omp_set_num_threads(OPEN_MP_NUM_PROCESSORS);
// Allow nested OpenMP sections
omp_set_nested(true);
// Create blank exception
bool has_error_encoding_video = false;