You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Splitting FF_NUM_PROCESSORS into a VIDEO and AUDIO constant. Also limiting VIDEO encoders to 16 threads and audio encoders to 2 threads.
This commit is contained in:
@@ -278,7 +278,7 @@ void FFmpegReader::Open() {
|
||||
retry_decode_open = 0;
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
pCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
pCodecCtx->thread_count = std::min(FF_VIDEO_NUM_PROCESSORS, 16);
|
||||
|
||||
if (pCodec == NULL) {
|
||||
throw InvalidCodec("A valid video codec could not be found for this file.", path);
|
||||
@@ -524,8 +524,8 @@ void FFmpegReader::Open() {
|
||||
const AVCodec *aCodec = avcodec_find_decoder(codecId);
|
||||
aCodecCtx = AV_GET_CODEC_CONTEXT(aStream, aCodec);
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
aCodecCtx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
// Audio encoding does not typically use more than 2 threads (most codecs use 1 thread)
|
||||
aCodecCtx->thread_count = std::min(FF_AUDIO_NUM_PROCESSORS, 2);
|
||||
|
||||
if (aCodec == NULL) {
|
||||
throw InvalidCodec("A valid audio codec could not be found for this file.", path);
|
||||
|
||||
@@ -1334,8 +1334,9 @@ void FFmpegWriter::open_audio(AVFormatContext *oc, AVStream *st) {
|
||||
const AVCodec *codec;
|
||||
AV_GET_CODEC_FROM_STREAM(st, audio_codec_ctx)
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
audio_codec_ctx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
// Audio encoding does not typically use more than 2 threads (most codecs use 1 thread)
|
||||
audio_codec_ctx->thread_count = std::min(FF_AUDIO_NUM_PROCESSORS, 2);
|
||||
std::cout << "FFmpegWriter audio thread_count: " << audio_codec_ctx->thread_count << std::endl;
|
||||
|
||||
// Find the audio encoder
|
||||
codec = avcodec_find_encoder_by_name(info.acodec.c_str());
|
||||
@@ -1409,8 +1410,8 @@ void FFmpegWriter::open_video(AVFormatContext *oc, AVStream *st) {
|
||||
const AVCodec *codec;
|
||||
AV_GET_CODEC_FROM_STREAM(st, video_codec_ctx)
|
||||
|
||||
// Set number of threads equal to number of processors (not to exceed 16)
|
||||
video_codec_ctx->thread_count = std::min(FF_NUM_PROCESSORS, 16);
|
||||
// Set number of threads equal to number of processors (not to exceed 16, FFmpeg doesn't recommend more than 16)
|
||||
video_codec_ctx->thread_count = std::min(FF_VIDEO_NUM_PROCESSORS, 16);
|
||||
|
||||
#if USE_HW_ACCEL
|
||||
if (hw_en_on && hw_en_supported) {
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
#include "Settings.h"
|
||||
|
||||
// Calculate the # of OpenMP Threads to allow
|
||||
#define OPEN_MP_NUM_PROCESSORS (std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->OMP_THREADS) ))
|
||||
#define FF_NUM_PROCESSORS (std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->FF_THREADS) ))
|
||||
#define OPEN_MP_NUM_PROCESSORS std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->OMP_THREADS))
|
||||
#define FF_VIDEO_NUM_PROCESSORS std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->FF_THREADS))
|
||||
#define FF_AUDIO_NUM_PROCESSORS std::min(omp_get_num_procs(), std::max(2, openshot::Settings::Instance()->FF_THREADS))
|
||||
|
||||
// Set max-active-levels to the max supported, if possible
|
||||
// (supported_active_levels is OpenMP 5.0 (November 2018) or later, only.)
|
||||
|
||||
Reference in New Issue
Block a user