Skip to content

Commit

Permalink
使用するAvisynth.dllを指定するオプションを追加。( --avsdll )
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Aug 6, 2020
1 parent d253435 commit 14f4b2d
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 11 deletions.
3 changes: 3 additions & 0 deletions QSVEncC_Options.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
3 changes: 3 additions & 0 deletions QSVEncC_Options.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -1185,6 +1185,9 @@ avsw/avhw読み込み時のデバッグ情報出力。
### --lowlatency
エンコード遅延を低減するモード。最大エンコード速度(スループット)は低下するので、通常は不要。

### --avsdll
使用するAvsiynth.dllを指定するオプション。特に指定しない場合、システムのAvisynth.dllが使用される。

### --perf-monitor [<string>][,<string>]...
エンコーダのパフォーマンス情報を出力する。パラメータとして出力したい情報名を下記から選択できる。デフォルトはall (すべての情報)。

Expand Down
8 changes: 8 additions & 0 deletions QSVPipeline/rgy_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<TCHAR> tmp;
Expand Down Expand Up @@ -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 <string> specifies AviSynth DLL location to use.\n"));
str += strsprintf(_T("\n")
_T(" --perf-monitor [<string>][,<string>]...\n")
_T(" check performance info of encoder and output to log file\n")
Expand Down
1 change: 1 addition & 0 deletions QSVPipeline/rgy_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
22 changes: 16 additions & 6 deletions QSVPipeline/rgy_input_avs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

}

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -237,7 +247,8 @@ vector<AVPacket> 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<const RGYInputAvsPrm *>(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;
}
Expand Down Expand Up @@ -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<const RGYInputAvsPrm *>(prm);
if (avsPrm != nullptr && avsPrm->readAudio) {
if (!avs_has_audio(m_sAVSinfo)) {
AddMessage(RGY_LOG_WARN, _T("avs has no audio.\n"));
Expand Down
3 changes: 2 additions & 1 deletion QSVPipeline/rgy_input_avs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct avs_dll_t {
class RGYInputAvsPrm : public RGYInputPrm {
public:
bool readAudio;
tstring avsdll;
RGYInputAvsPrm(RGYInputPrm base);

virtual ~RGYInputAvsPrm() {};
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion QSVPipeline/rgy_prm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ RGYParamControl::RGYParamControl() :
perfMonitorInterval(RGY_DEFAULT_PERF_MONITOR_INTERVAL),
parentProcessID(0),
lowLatency(false),
gpuSelect() {
gpuSelect(),
avsdll() {

}
RGYParamControl::~RGYParamControl() {};
Expand Down
1 change: 1 addition & 0 deletions QSVPipeline/rgy_prm.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct RGYParamControl {
uint32_t parentProcessID;
bool lowLatency;
GPUAutoSelectMul gpuSelect;
tstring avsdll;

RGYParamControl();
~RGYParamControl();
Expand Down
6 changes: 3 additions & 3 deletions QSVPipeline/rgy_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 14f4b2d

Please sign in to comment.