Skip to content

Commit

Permalink
cufiltersの更新を反映。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Mar 5, 2024
1 parent 304c463 commit cd426ef
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 28 deletions.
93 changes: 93 additions & 0 deletions mppcore/rgy_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3217,6 +3217,71 @@ int parse_one_vpp_option(const TCHAR *option_name, const TCHAR *strInput[], int
vpp->overlay.push_back(overlay);
return 0;
}
if (IS_OPTION("vpp-fruc") && ENABLE_VPP_FILTER_FRUC) {
vpp->fruc.enable = true;
if (ENCODER_NVENC) {
vpp->fruc.mode = VppFrucMode::NVOFFRUCx2;
}
if (i + 1 >= nArgNum || strInput[i + 1][0] == _T('-')) {
return 0;
}
i++;

const auto paramList = std::vector<std::string>{ "fps" };

for (const auto& param : split(strInput[i], _T(","))) {
auto pos = param.find_first_of(_T("="));
if (pos != std::string::npos) {
auto param_arg = param.substr(0, pos);
auto param_val = param.substr(pos + 1);
param_arg = tolowercase(param_arg);
if (param_arg == _T("enable")) {
bool b = false;
if (!cmd_string_to_bool(&b, param_val)) {
vpp->fruc.enable = b;
} else {
print_cmd_error_invalid_value(tstring(option_name) + _T(" ") + param_arg + _T("="), param_val);
return 1;
}
continue;
}
if (param_arg == _T("fps")) {
int a[2] = { 0 };
if ( 2 == _stscanf_s(param_val.c_str(), _T("%d/%d"), &a[0], &a[1])
|| 2 == _stscanf_s(param_val.c_str(), _T("%d:%d"), &a[0], &a[1])
|| 2 == _stscanf_s(param_val.c_str(), _T("%d,%d"), &a[0], &a[1])) {
vpp->fruc.targetFps = rgy_rational<int>(a[0], a[1]);
vpp->fruc.mode = VppFrucMode::NVOFFRUCFps;
} else {
double d;
if (1 == _stscanf_s(param_val.c_str(), _T("%lf"), &d)) {
int rate = (int)(d * 1001.0 + 0.5);
if (rate % 1000 == 0) {
vpp->fruc.targetFps = rgy_rational<int>(rate, 1001);
} else {
vpp->fruc.targetFps = rgy_rational<int>((int)(d * 100000 + 0.5), 100000);
}
vpp->fruc.mode = VppFrucMode::NVOFFRUCFps;
} else {
print_cmd_error_invalid_value(option_name, strInput[i]);
return 1;
}
}
continue;
}
print_cmd_error_unknown_opt_param(option_name, param_arg, paramList);
return 1;
} else {
if (param == _T("double")) {
vpp->fruc.mode = VppFrucMode::NVOFFRUCx2;
continue;
}
print_cmd_error_unknown_opt_param(option_name, param, paramList);
return 1;
}
}
return 0;
}
if (IS_OPTION("vpp-perf-monitor")) {
vpp->checkPerformance = true;
return 0;
Expand Down Expand Up @@ -6375,6 +6440,26 @@ tstring gen_cmd(const RGYParamVpp *param, const RGYParamVpp *defaultPrm, bool sa
}
}
}
if (param->fruc != defaultPrm->fruc) {
tmp.str(tstring());
if (!param->fruc.enable && save_disabled_prm) {
tmp << _T(",enable=false");
}
if (param->fruc.enable || save_disabled_prm) {
if (param->fruc.mode == VppFrucMode::NVOFFRUCx2) {
tmp << _T(",double");
} else if (param->fruc.mode == VppFrucMode::NVOFFRUCFps) {
if (param->fruc.targetFps.is_valid()) {
tmp << _T(",fps=") << param->fruc.targetFps.printt();
}
}
}
if (!tmp.str().empty()) {
cmd << _T(" --vpp-fruc ") << tmp.str().substr(1);
} else if (param->fruc.enable) {
cmd << _T(" --vpp-fruc");
}
}
OPT_BOOL(_T("--vpp-perf-monitor"), _T("--no-vpp-perf-monitor"), checkPerformance);
return cmd.str();
}
Expand Down Expand Up @@ -7640,6 +7725,14 @@ tstring gen_cmd_help_vpp() {
_T(" lumakey_threshold=<float> set the range of softness for lumakey\n")
_T(" loop=<bool>\n")
);
#endif
#if ENABLE_VPP_FILTER_FRUC
str += strsprintf(_T("\n")
_T(" --vpp-fruc [<param1>=<value>][,<param2>=<value>][...]\n")
_T(" enable frame rate up conversion filter.\n")
_T(" params\n")
_T(" double double frame rate (fast)\n")
_T(" fps=<int>/<int> or <float> target frame rate\n"));
#endif
str += strsprintf(_T("\n")
_T(" --vpp-perf-monitor check vpp perfromance (for debug)\n")
Expand Down
19 changes: 19 additions & 0 deletions mppcore/rgy_err.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,25 @@ const TCHAR *get_err_mes(RGY_ERR sts) {
//CASE_ERR_NPP(NPP_MISALIGNED_DST_ROI_WARNING);
#undef CASE_ERR_NPP

#define CASE_ERR_NVOFFRUC(x) case RGY_ERR_NvOFFRUC_ ## x: return _T("NvOFFRUC_") _T(#x);
CASE_ERR_NVOFFRUC(NvOFFRUC_NOT_SUPPORTED);
CASE_ERR_NVOFFRUC(INVALID_PTR);
CASE_ERR_NVOFFRUC(INVALID_PARAM);
CASE_ERR_NVOFFRUC(INVALID_HANDLE);
CASE_ERR_NVOFFRUC(OUT_OF_SYSTEM_MEMORY);
CASE_ERR_NVOFFRUC(OUT_OF_VIDEO_MEMORY);
CASE_ERR_NVOFFRUC(OPENCV_NOT_AVAILABLE);
CASE_ERR_NVOFFRUC(UNIMPLEMENTED);
CASE_ERR_NVOFFRUC(OF_FAILURE);
CASE_ERR_NVOFFRUC(DUPLICATE_RESOURCE);
CASE_ERR_NVOFFRUC(UNREGISTERED_RESOURCE);
CASE_ERR_NVOFFRUC(INCORRECT_API_SEQUENCE);
CASE_ERR_NVOFFRUC(WRITE_TODISK_FAILED);
CASE_ERR_NVOFFRUC(PIPELINE_EXECUTION_FAILURE);
CASE_ERR_NVOFFRUC(SYNC_WRITE_FAILED);
CASE_ERR_NVOFFRUC(GENERIC);
#undef CASE_ERR_NVOFFRUC

#define CASE_ERR_MPP(x) case RGY_ERR_ ## x: return _T(#x);
CASE_ERR_MPP(MPP_ERR_UNKNOW);
CASE_ERR_MPP(MPP_ERR_NULL_PTR);
Expand Down
19 changes: 19 additions & 0 deletions mppcore/rgy_err.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,25 @@ enum RGY_ERR {
//RGY_ERR_NPP_WRONG_INTERSECTION_QUAD_WARNING = RGY_ERR_NPP_OFFSET 30,
//RGY_ERR_NPP_DOUBLE_SIZE_WARNING = RGY_ERR_NPP_OFFSET 35,
//RGY_ERR_NPP_MISALIGNED_DST_ROI_WARNING = RGY_ERR_NPP_OFFSET 10000,

//nvoffruc error
RGY_ERR_NvOFFRUC_OFFSET = -50000,
RGY_ERR_NvOFFRUC_NvOFFRUC_NOT_SUPPORTED = RGY_ERR_NvOFFRUC_OFFSET-1,
RGY_ERR_NvOFFRUC_INVALID_PTR = RGY_ERR_NvOFFRUC_OFFSET - 2,
RGY_ERR_NvOFFRUC_INVALID_PARAM = RGY_ERR_NvOFFRUC_OFFSET - 3,
RGY_ERR_NvOFFRUC_INVALID_HANDLE = RGY_ERR_NvOFFRUC_OFFSET - 4,
RGY_ERR_NvOFFRUC_OUT_OF_SYSTEM_MEMORY = RGY_ERR_NvOFFRUC_OFFSET - 5,
RGY_ERR_NvOFFRUC_OUT_OF_VIDEO_MEMORY = RGY_ERR_NvOFFRUC_OFFSET - 6,
RGY_ERR_NvOFFRUC_OPENCV_NOT_AVAILABLE = RGY_ERR_NvOFFRUC_OFFSET - 7,
RGY_ERR_NvOFFRUC_UNIMPLEMENTED = RGY_ERR_NvOFFRUC_OFFSET - 8,
RGY_ERR_NvOFFRUC_OF_FAILURE = RGY_ERR_NvOFFRUC_OFFSET - 9,
RGY_ERR_NvOFFRUC_DUPLICATE_RESOURCE = RGY_ERR_NvOFFRUC_OFFSET - 10,
RGY_ERR_NvOFFRUC_UNREGISTERED_RESOURCE = RGY_ERR_NvOFFRUC_OFFSET - 11,
RGY_ERR_NvOFFRUC_INCORRECT_API_SEQUENCE = RGY_ERR_NvOFFRUC_OFFSET - 12,
RGY_ERR_NvOFFRUC_WRITE_TODISK_FAILED = RGY_ERR_NvOFFRUC_OFFSET - 13,
RGY_ERR_NvOFFRUC_PIPELINE_EXECUTION_FAILURE = RGY_ERR_NvOFFRUC_OFFSET - 14,
RGY_ERR_NvOFFRUC_SYNC_WRITE_FAILED = RGY_ERR_NvOFFRUC_OFFSET - 15,
RGY_ERR_NvOFFRUC_GENERIC = RGY_ERR_NvOFFRUC_OFFSET - 16,
};

#if ENCODER_QSV
Expand Down
13 changes: 9 additions & 4 deletions mppcore/rgy_frame_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,20 @@ static bool cmpFrameInfoCspResolution(const RGYFrameInfo *pA, const RGYFrameInfo
|| pA->mem_type != pB->mem_type;
}

static void copyFrameProp(RGYFrameInfo *dst, const RGYFrameInfo *src) {
dst->width = src->width;
dst->height = src->height;
dst->csp = src->csp;
static void copyFramePropWithoutRes(RGYFrameInfo *dst, const RGYFrameInfo *src) {
dst->picstruct = src->picstruct;
dst->timestamp = src->timestamp;
dst->duration = src->duration;
dst->inputFrameId = src->inputFrameId;
dst->flags = src->flags;
dst->dataList = src->dataList;
}

static void copyFrameProp(RGYFrameInfo *dst, const RGYFrameInfo *src) {
copyFramePropWithoutRes(dst, src);
dst->width = src->width;
dst->height = src->height;
dst->csp = src->csp;
}

static int bytesPerPix(RGY_CSP csp) {
Expand Down
35 changes: 35 additions & 0 deletions mppcore/rgy_prm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ static const auto VPPTYPE_TO_STR = make_array<std::pair<VppType, tstring>>(
std::make_pair(VppType::MFX_PERC_ENC_PREFILTER, _T("mfx_perc_enc_prefilter")),
std::make_pair(VppType::MFX_COPY, _T("mfx_copy")),
#endif //#if ENCODER_QSV
#if ENCODER_NVENC || CLFILTERS_AUF
std::make_pair(VppType::NVVFX_DENOISE, _T("nvvfx_denoise")),
std::make_pair(VppType::NVVFX_ARTIFACT_REDUCTION, _T("nvvfx_artifact_reduction")),
#endif
#if ENCODER_VCEENC
std::make_pair(VppType::AMF_CONVERTER, _T("amf_perc_enc_prefilter")),
std::make_pair(VppType::AMF_PREPROCESS, _T("amf_preprocess")),
Expand Down Expand Up @@ -210,6 +214,10 @@ RGY_VPP_RESIZE_TYPE getVppResizeType(RGY_VPP_RESIZE_ALGO resize) {
} else if (resize < RGY_VPP_RESIZE_NPPI_MAX) {
return RGY_VPP_RESIZE_TYPE_NPPI;
#endif
#if ENCODER_NVENC && (!defined(_M_IX86) || FOR_AUO) || CUFILTERS || CLFILTERS_AUF
} else if (resize < RGY_VPP_RESIZE_NVVFX_MAX) {
return RGY_VPP_RESIZE_TYPE_NVVFX;
#endif
#if ENCODER_VCEENC
} else if (resize < RGY_VPP_RESIZE_AMF_MAX) {
return RGY_VPP_RESIZE_TYPE_AMF;
Expand Down Expand Up @@ -1407,6 +1415,32 @@ tstring VppDeband::print() const {
randEachFrame ? _T("yes") : _T("no"));
}

VppFruc::VppFruc() :
enable(false),
mode(VppFrucMode::Disabled),
targetFps() {

}

bool VppFruc::operator==(const VppFruc &x) const {
return enable == x.enable
&& mode == x.mode
&& targetFps == x.targetFps;
}
bool VppFruc::operator!=(const VppFruc &x) const {
return !(*this == x);
}

tstring VppFruc::print() const {
if (mode == VppFrucMode::NVOFFRUCx2) {
return _T("nvof-fruc: double frames");
} else if (mode == VppFrucMode::NVOFFRUCFps) {
return strsprintf(_T("nvof-fruc: %.3f(%d/%d) fps"), targetFps.qdouble(), targetFps.n(), targetFps.d());
} else {
return _T("Unknown");
}
}

RGYParamVpp::RGYParamVpp() :
filterOrder(),
resize_algo(RGY_VPP_RESIZE_AUTO),
Expand Down Expand Up @@ -1435,6 +1469,7 @@ RGYParamVpp::RGYParamVpp() :
transform(),
deband(),
overlay(),
fruc(),
checkPerformance(false) {

}
Expand Down

0 comments on commit cd426ef

Please sign in to comment.