From 14f4b2d42aa004cc3bed624da77b4276f8f85a9a Mon Sep 17 00:00:00 2001 From: rigaya Date: Thu, 6 Aug 2020 22:36:54 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=99=E3=82=8BAvisynth.dl?= =?UTF-8?q?l=E3=82=92=E6=8C=87=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=AA?= =?UTF-8?q?=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=80=82(=20--avsdll=20)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QSVEncC_Options.en.md | 3 +++ QSVEncC_Options.ja.md | 3 +++ QSVPipeline/rgy_cmd.cpp | 8 ++++++++ QSVPipeline/rgy_input.cpp | 1 + QSVPipeline/rgy_input_avs.cpp | 22 ++++++++++++++++------ QSVPipeline/rgy_input_avs.h | 3 ++- QSVPipeline/rgy_prm.cpp | 3 ++- QSVPipeline/rgy_prm.h | 1 + QSVPipeline/rgy_version.h | 6 +++--- 9 files changed, 39 insertions(+), 11 deletions(-) diff --git a/QSVEncC_Options.en.md b/QSVEncC_Options.en.md index 76e6641b..ec276589 100644 --- a/QSVEncC_Options.en.md +++ b/QSVEncC_Options.en.md @@ -1172,6 +1172,9 @@ Example: Limit maximum speed to 90 fps ### --lowlatency Tune for lower transcoding latency, but will hurt transcoding throughput. Not recommended in most cases. +### --avsdll +Specifies AviSynth DLL location to use. When unspecified, the DLL installed in the system32 will be used. + ### --perf-monitor [<string>][,<string>]... Outputs performance information. You can select the information name you want to output as a parameter from the following table. The default is all (all information). diff --git a/QSVEncC_Options.ja.md b/QSVEncC_Options.ja.md index f69691d6..c3684c40 100644 --- a/QSVEncC_Options.ja.md +++ b/QSVEncC_Options.ja.md @@ -1185,6 +1185,9 @@ avsw/avhw読み込み時のデバッグ情報出力。 ### --lowlatency エンコード遅延を低減するモード。最大エンコード速度(スループット)は低下するので、通常は不要。 +### --avsdll +使用するAvsiynth.dllを指定するオプション。特に指定しない場合、システムのAvisynth.dllが使用される。 + ### --perf-monitor [<string>][,<string>]... エンコーダのパフォーマンス情報を出力する。パラメータとして出力したい情報名を下記から選択できる。デフォルトはall (すべての情報)。 diff --git a/QSVPipeline/rgy_cmd.cpp b/QSVPipeline/rgy_cmd.cpp index 928526bd..dc878413 100644 --- a/QSVPipeline/rgy_cmd.cpp +++ b/QSVPipeline/rgy_cmd.cpp @@ -1819,6 +1819,11 @@ int parse_one_ctrl_option(const TCHAR *option_name, const TCHAR *strInput[], int } return 0; } + if (IS_OPTION("avsdll")) { + i++; + ctrl->avsdll = strInput[i]; + return 0; + } if (IS_OPTION("perf-monitor")) { if (strInput[i+1][0] == _T('-') || _tcslen(strInput[i+1]) == 0) { ctrl->perfMonitorSelect = (int)PERF_MONITOR_ALL; @@ -2295,6 +2300,7 @@ tstring gen_cmd(const RGYParamControl *param, const RGYParamControl *defaultPrm, OPT_LST(_T("--log-level"), loglevel, list_log_level); OPT_BOOL(_T("--log-framelist"), _T(""), logFramePosList); OPT_CHAR_PATH(_T("--log-mux-ts"), logMuxVidTsFile); + OPT_STR_PATH(_T("--avsdll"), avsdll); if (param->perfMonitorSelect != defaultPrm->perfMonitorSelect) { auto select = (int)param->perfMonitorSelect; std::basic_stringstream tmp; @@ -2584,6 +2590,8 @@ tstring gen_cmd_help_ctrl() { #endif //#if ENABLE_AVCODEC_AUDPROCESS_THREAD ); #endif //#if ENABLE_AVCODEC_OUT_THREAD + str += strsprintf(_T("\n") + _T(" --avsdll specifies AviSynth DLL location to use.\n")); str += strsprintf(_T("\n") _T(" --perf-monitor [][,]...\n") _T(" check performance info of encoder and output to log file\n") diff --git a/QSVPipeline/rgy_input.cpp b/QSVPipeline/rgy_input.cpp index 7f84ba36..26f0dfd1 100644 --- a/QSVPipeline/rgy_input.cpp +++ b/QSVPipeline/rgy_input.cpp @@ -408,6 +408,7 @@ RGY_ERR initReaders( #if ENABLE_AVISYNTH_READER case RGY_INPUT_FMT_AVS: inputPrmAvs.readAudio = common->nAudioSelectCount > 0; + inputPrmAvs.avsdll = ctrl->avsdll; pInputPrm = &inputPrmAvs; log->write(RGY_LOG_DEBUG, _T("avs reader selected.\n")); pFileReader.reset(new RGYInputAvs()); diff --git a/QSVPipeline/rgy_input_avs.cpp b/QSVPipeline/rgy_input_avs.cpp index a4b6f150..1593a9c1 100644 --- a/QSVPipeline/rgy_input_avs.cpp +++ b/QSVPipeline/rgy_input_avs.cpp @@ -55,7 +55,8 @@ const uint8_t* AVSC_CC rgy_avs_get_read_ptr_p(const AVS_VideoFrame * p, int plan RGYInputAvsPrm::RGYInputAvsPrm(RGYInputPrm base) : RGYInputPrm(base), - readAudio(false) { + readAudio(false), + avsdll() { } @@ -89,13 +90,22 @@ void RGYInputAvs::release_avisynth() { memset(&m_sAvisynth, 0, sizeof(m_sAvisynth)); } -RGY_ERR RGYInputAvs::load_avisynth() { +RGY_ERR RGYInputAvs::load_avisynth(const tstring &avsdll) { release_avisynth(); + const TCHAR *avs_dll_target = nullptr; + if (avsdll.length() > 0) { + avs_dll_target = avsdll.c_str(); + } + if (avs_dll_target == nullptr) { + avs_dll_target = avisynth_dll_name; + } + AddMessage(RGY_LOG_DEBUG, _T("Load Avisynth DLL \"%s\".\n"), avs_dll_target); + #if defined(_WIN32) || defined(_WIN64) - if (nullptr == (m_sAvisynth.h_avisynth = (HMODULE)LoadLibrary(avisynth_dll_name))) + if (nullptr == (m_sAvisynth.h_avisynth = (HMODULE)LoadLibrary(avs_dll_target))) #else - if (nullptr == (m_sAvisynth.h_avisynth = dlopen(avisynth_dll_name, RTLD_LAZY))) + if (nullptr == (m_sAvisynth.h_avisynth = dlopen(avs_dll_target, RTLD_LAZY))) #endif return RGY_ERR_INVALID_HANDLE; @@ -237,7 +247,8 @@ vector RGYInputAvs::GetStreamDataPackets(int inputFrame) { RGY_ERR RGYInputAvs::Init(const TCHAR *strFileName, VideoInfo *pInputInfo, const RGYInputPrm *prm) { m_inputVideoInfo = *pInputInfo; - if (load_avisynth() != RGY_ERR_NONE) { + auto avsPrm = reinterpret_cast(prm); + if (load_avisynth(avsPrm->avsdll) != RGY_ERR_NONE) { AddMessage(RGY_LOG_ERROR, _T("failed to load %s.\n"), avisynth_dll_name); return RGY_ERR_INVALID_HANDLE; } @@ -365,7 +376,6 @@ RGY_ERR RGYInputAvs::Init(const TCHAR *strFileName, VideoInfo *pInputInfo, const m_inputVideoInfo.frames = m_sAVSinfo->num_frames; rgy_reduce(m_inputVideoInfo.fpsN, m_inputVideoInfo.fpsD); - auto avsPrm = reinterpret_cast(prm); if (avsPrm != nullptr && avsPrm->readAudio) { if (!avs_has_audio(m_sAVSinfo)) { AddMessage(RGY_LOG_WARN, _T("avs has no audio.\n")); diff --git a/QSVPipeline/rgy_input_avs.h b/QSVPipeline/rgy_input_avs.h index 5e9580d6..feaf525b 100644 --- a/QSVPipeline/rgy_input_avs.h +++ b/QSVPipeline/rgy_input_avs.h @@ -100,6 +100,7 @@ struct avs_dll_t { class RGYInputAvsPrm : public RGYInputPrm { public: bool readAudio; + tstring avsdll; RGYInputAvsPrm(RGYInputPrm base); virtual ~RGYInputAvsPrm() {}; @@ -125,7 +126,7 @@ class RGYInputAvs : public RGYInput { protected: virtual RGY_ERR Init(const TCHAR *strFileName, VideoInfo *pInputInfo, const RGYInputPrm *prm) override; - RGY_ERR load_avisynth(); + RGY_ERR load_avisynth(const tstring& avsdll); void release_avisynth(); AVS_ScriptEnvironment *m_sAVSenv; diff --git a/QSVPipeline/rgy_prm.cpp b/QSVPipeline/rgy_prm.cpp index cc933f24..00d6b0e2 100644 --- a/QSVPipeline/rgy_prm.cpp +++ b/QSVPipeline/rgy_prm.cpp @@ -160,7 +160,8 @@ RGYParamControl::RGYParamControl() : perfMonitorInterval(RGY_DEFAULT_PERF_MONITOR_INTERVAL), parentProcessID(0), lowLatency(false), - gpuSelect() { + gpuSelect(), + avsdll() { } RGYParamControl::~RGYParamControl() {}; diff --git a/QSVPipeline/rgy_prm.h b/QSVPipeline/rgy_prm.h index ae071014..400d99b5 100644 --- a/QSVPipeline/rgy_prm.h +++ b/QSVPipeline/rgy_prm.h @@ -187,6 +187,7 @@ struct RGYParamControl { uint32_t parentProcessID; bool lowLatency; GPUAutoSelectMul gpuSelect; + tstring avsdll; RGYParamControl(); ~RGYParamControl(); diff --git a/QSVPipeline/rgy_version.h b/QSVPipeline/rgy_version.h index 936da8c9..ed5f9ea9 100644 --- a/QSVPipeline/rgy_version.h +++ b/QSVPipeline/rgy_version.h @@ -31,9 +31,9 @@ #include "rgy_rev.h" -#define VER_FILEVERSION 0,4,6,0 -#define VER_STR_FILEVERSION "4.06" -#define VER_STR_FILEVERSION_TCHAR _T("4.06") +#define VER_FILEVERSION 0,4,7,0 +#define VER_STR_FILEVERSION "4.07" +#define VER_STR_FILEVERSION_TCHAR _T("4.07") #ifdef _M_IX86 #define BUILD_ARCH_STR _T("x86")