You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
First changes to use Settings instead of GetEnv
This commit is contained in:
@@ -79,6 +79,9 @@ namespace openshot {
|
||||
/// Use video card for faster video decoding (if supported)
|
||||
bool HARDWARE_DECODE = false;
|
||||
|
||||
/// Use video codec for faster video decoding (if supported)
|
||||
int HARDWARE_DECODER = 0;
|
||||
|
||||
/// Use video card for faster video encoding (if supported)
|
||||
bool HARDWARE_ENCODE = false;
|
||||
|
||||
@@ -94,6 +97,24 @@ namespace openshot {
|
||||
/// Wait for OpenMP task to finish before continuing (used to limit threads on slower systems)
|
||||
bool WAIT_FOR_VIDEO_PROCESSING_TASK = false;
|
||||
|
||||
/// Number of threads of OpenMP
|
||||
int OMP_THREADS = 6;//OPEN_MP_NUM_PROCESSORS
|
||||
|
||||
/// Number of threads that ffmpeg uses
|
||||
int FF_THREADS = 8;//FF_NUM_PROCESSORS
|
||||
|
||||
/// Maximum rows that hardware decode can handle
|
||||
int DE_LIMIT_HEIGHT_MAX = 1100;
|
||||
|
||||
/// Maximum columns that hardware decode can handle
|
||||
int DE_LIMIT_WIDTH_MAX = 1950;
|
||||
|
||||
/// Which GPU to use to decode (0 is the first)
|
||||
int HW_DE_DEVICE_SET = 0;
|
||||
|
||||
/// Which GPU to use to encode (0 is the first)
|
||||
int HW_EN_DEVICE_SET = 0;
|
||||
|
||||
/// Create or get an instance of this logger singleton (invoke the class with this method)
|
||||
static Settings * Instance();
|
||||
};
|
||||
|
||||
@@ -287,7 +287,7 @@ void FFmpegReader::Open()
|
||||
//hw_de_on = Settings::Instance()->HARDWARE_DECODE;
|
||||
|
||||
// New version turn hardware decode on
|
||||
{
|
||||
/* {
|
||||
char *decoder_hw = NULL;
|
||||
decoder_hw = getenv( "HW_DECODER" );
|
||||
if(decoder_hw != NULL) {
|
||||
@@ -299,7 +299,11 @@ void FFmpegReader::Open()
|
||||
} else {
|
||||
hw_de_on = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
// Newest versions
|
||||
{
|
||||
hw_de_on = (Settings::Instance()->HARDWARE_DECODER == 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
// Open video file
|
||||
if (avformat_open_input(&pFormatCtx, path.c_str(), NULL, NULL) != 0)
|
||||
@@ -366,7 +370,8 @@ void FFmpegReader::Open()
|
||||
// Open Hardware Acceleration
|
||||
// Use the hw device given in the environment variable HW_DE_DEVICE_SET or the default if not set
|
||||
char *dev_hw = NULL;
|
||||
char *decoder_hw = NULL;
|
||||
//char *decoder_hw = NULL;
|
||||
int i_decoder_hw = 0;
|
||||
char adapter[256];
|
||||
char *adapter_ptr = NULL;
|
||||
int adapter_num;
|
||||
@@ -380,60 +385,62 @@ void FFmpegReader::Open()
|
||||
#if defined(__linux__)
|
||||
snprintf(adapter,sizeof(adapter),"/dev/dri/renderD%d", adapter_num+128);
|
||||
adapter_ptr = adapter;
|
||||
decoder_hw = getenv( "HW_DECODER" );
|
||||
if(decoder_hw != NULL) {
|
||||
if (strncmp(decoder_hw,"0",4) == 0) { //Will never happen
|
||||
i_decoder_hw = Settings::Instance()->HARDWARE_DECODER;
|
||||
switch (i_decoder_hw) {
|
||||
case 0:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
|
||||
pCodecCtx->get_format = get_hw_dec_format_va;
|
||||
}
|
||||
if (strncmp(decoder_hw,"1",11) == 0) {
|
||||
break;
|
||||
case 1:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
|
||||
pCodecCtx->get_format = get_hw_dec_format_va;
|
||||
}
|
||||
if (strncmp(decoder_hw,"2",11) == 0) {
|
||||
break;
|
||||
case 2:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_CUDA;
|
||||
pCodecCtx->get_format = get_hw_dec_format_cu;
|
||||
}
|
||||
} else {
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
|
||||
pCodecCtx->get_format = get_hw_dec_format_va;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
|
||||
pCodecCtx->get_format = get_hw_dec_format_va;
|
||||
break;
|
||||
}
|
||||
|
||||
#elif defined(_WIN32)
|
||||
adapter_ptr = NULL;
|
||||
decoder_hw = getenv( "HW_DECODER" );
|
||||
if(decoder_hw != NULL) {
|
||||
if (strncmp(decoder_hw,"0",4) == 0) { //Will never happen
|
||||
i_decoder_hw = Settings::Instance()->HARDWARE_DECODER;
|
||||
switch (i_decoder_hw) {
|
||||
case 0:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
pCodecCtx->get_format = get_hw_dec_format_dx;
|
||||
}
|
||||
if (strncmp(decoder_hw,"3",19) == 0) {
|
||||
break;
|
||||
case 3:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
pCodecCtx->get_format = get_hw_dec_format_dx;
|
||||
}
|
||||
if (strncmp(decoder_hw,"4",19) == 0) {
|
||||
break;
|
||||
case 4:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_D3D11VA;
|
||||
pCodecCtx->get_format = get_hw_dec_format_d3;
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_DXVA2;
|
||||
pCodecCtx->get_format = get_hw_dec_format_dx;
|
||||
break;
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
adapter_ptr = NULL;
|
||||
decoder_hw = getenv( "HW_DECODER" );
|
||||
if(decoder_hw != NULL) {
|
||||
if (strncmp(decoder_hw,"0",4) == 0) { //Will never happen
|
||||
i_decoder_hw = Settings::Instance()->HARDWARE_DECODER;
|
||||
switch (i_decoder_hw) {
|
||||
case 0:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
|
||||
pCodecCtx->get_format = get_hw_dec_format_qs;
|
||||
}
|
||||
if (strncmp(decoder_hw,"5",11) == 0) {
|
||||
break;
|
||||
case 5:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
|
||||
pCodecCtx->get_format = get_hw_dec_format_qs;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
default:
|
||||
hw_de_av_device_type = AV_HWDEVICE_TYPE_QSV;
|
||||
pCodecCtx->get_format = get_hw_dec_format_qs;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -536,8 +543,10 @@ void FFmpegReader::Open()
|
||||
}
|
||||
else {
|
||||
int max_h, max_w;
|
||||
max_h = ((getenv( "LIMIT_HEIGHT_MAX" )==NULL) ? MAX_SUPPORTED_HEIGHT : atoi(getenv( "LIMIT_HEIGHT_MAX" )));
|
||||
max_w = ((getenv( "LIMIT_WIDTH_MAX" )==NULL) ? MAX_SUPPORTED_WIDTH : atoi(getenv( "LIMIT_WIDTH_MAX" )));
|
||||
//max_h = ((getenv( "LIMIT_HEIGHT_MAX" )==NULL) ? MAX_SUPPORTED_HEIGHT : atoi(getenv( "LIMIT_HEIGHT_MAX" )));
|
||||
max_h = Settings::Instance()->DE_LIMIT_HEIGHT_MAX;
|
||||
//max_w = ((getenv( "LIMIT_WIDTH_MAX" )==NULL) ? MAX_SUPPORTED_WIDTH : atoi(getenv( "LIMIT_WIDTH_MAX" )));
|
||||
max_w = Settings::Instance()->DE_LIMIT_WIDTH_MAX;
|
||||
ZmqLogger::Instance()->AppendDebugMethod("Constraints could not be found using default limit\n", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
|
||||
//cerr << "Constraints could not be found using default limit\n";
|
||||
if (pCodecCtx->coded_width < 0 ||
|
||||
|
||||
@@ -41,11 +41,19 @@ Settings *Settings::Instance()
|
||||
// Create the actual instance of logger only once
|
||||
m_pInstance = new Settings;
|
||||
m_pInstance->HARDWARE_DECODE = false;
|
||||
m_pInstance->HARDWARE_DECODER = 0;
|
||||
m_pInstance->HARDWARE_ENCODE = false;
|
||||
m_pInstance->HIGH_QUALITY_SCALING = false;
|
||||
m_pInstance->MAX_WIDTH = 0;
|
||||
m_pInstance->MAX_HEIGHT = 0;
|
||||
m_pInstance->WAIT_FOR_VIDEO_PROCESSING_TASK = false;
|
||||
m_pInstance->OMP_THREADS = 6;//OPEN_MP_NUM_PROCESSORS
|
||||
m_pInstance->FF_THREADS = 8;//FF_NUM_PROCESSORS
|
||||
m_pInstance->DE_LIMIT_HEIGHT_MAX = 1100;
|
||||
m_pInstance->DE_LIMIT_WIDTH_MAX = 1950;
|
||||
m_pInstance->HW_DE_DEVICE_SET = 0;
|
||||
m_pInstance->HW_EN_DEVICE_SET = 0;
|
||||
|
||||
}
|
||||
|
||||
return m_pInstance;
|
||||
|
||||
Reference in New Issue
Block a user