예제 #1
0
void	Convert::fill_conv_step_with_gcor (ConvStep &step, const ::VSMap &in, ::VSMap &out, const char arg_0 [])
{
	double         gcor = get_arg_flt (in, out, arg_0, -1);
	if (gcor <= 0)
	{
		gcor = -1;
	}
	step._gammac = gcor;
}
예제 #2
0
Convert::Convert (const ::VSMap &in, ::VSMap &out, void *user_data_ptr, ::VSCore &core, const ::VSAPI &vsapi)
:	vsutl::FilterBase (vsapi, "convert", ::fmParallel, 0)
,	_clip_src_sptr (vsapi.propGetNode (&in, "clip", 0, 0), vsapi)
,	_vi_in (*_vsapi.getVideoInfo (_clip_src_sptr.get ()))
,	_vi_out (_vi_in)
,	_fmtc (*(vsapi.getPluginById (fmtc_PLUGIN_NAME, &core)))
,	_step_list ()
,	_col_fam (-1)
,	_mats (fmtcl::ColorSpaceH265_UNSPECIFIED)
,	_matd (fmtcl::ColorSpaceH265_UNSPECIFIED)
,	_cplaces (fmtcl::ChromaPlacement_UNDEF)
,	_cplaced (fmtcl::ChromaPlacement_UNDEF)
,	_fulls (ConvStep::Range_UNDEF)
,	_fulld (ConvStep::Range_UNDEF)
,	_transs (fmtcl::TransCurve_UNDEF)
,	_transd (fmtcl::TransCurve_UNDEF)
,	_gcors (get_arg_flt (in, out, "gcors", 1))
,	_gcord (get_arg_flt (in, out, "gcord", 1))
{
	const ::VSFormat &   fmt_src = *(_vi_in.format);
	retrieve_output_colorspace (in, out, core, fmt_src);
	const ::VSFormat &   fmt_dst = *(_vi_out.format);

	// Range
	_fulls = retrieve_range (fmt_src, in, out, "fulls");
	_fulld = retrieve_range (fmt_dst, in, out, "fulld");

	// Chroma placement
	const std::string cplace_str = get_arg_str (in, out, "cplace", "mpeg2");
	if (vsutl::has_chroma (fmt_src))
	{
		const std::string cplacex_str =
			get_arg_str (in, out, "cplaces", cplace_str);
		_cplaces = Resample::conv_str_to_chroma_placement (*this, cplacex_str);
	}
	if (vsutl::has_chroma (fmt_dst))
	{
		const std::string cplacex_str =
			get_arg_str (in, out, "cplaced", cplace_str);
		_cplaced = Resample::conv_str_to_chroma_placement (*this, cplacex_str);
	}

	// Matrix presets
	std::string    mat (get_arg_str (in, out, "mat", ""));
	std::string    mats ((   fmt_src.colorFamily == ::cmYUV ) ? mat : "");
	std::string    matd ((   fmt_dst.colorFamily == ::cmYUV
	                      || fmt_dst.colorFamily == ::cmGray) ? mat : "");
	mats = get_arg_str (in, out, "mats", mats);
	matd = get_arg_str (in, out, "matd", matd);
	if (! mats.empty () || ! matd.empty ())
	{
		fstb::conv_to_lower_case (mats);
		fstb::conv_to_lower_case (matd);
		Matrix::select_def_mat (mats, fmt_src);
		Matrix::select_def_mat (matd, fmt_dst);
		_mats = Matrix::find_cs_from_mat_str (*this, mats, true);
		_matd = Matrix::find_cs_from_mat_str (*this, matd, true);
	}

	// Transfer curve
	_transs = retrieve_tcurve (fmt_src, in, out, "transs", "");
	_transd = retrieve_tcurve (fmt_dst, in, out, "transd", "");



	/*** To do ***/

	find_conversion_steps (in, out);

	/*** To do ***/

}
예제 #3
0
Transfer::Transfer (const ::VSMap &in, ::VSMap &out, void * /*user_data_ptr*/, ::VSCore &core, const ::VSAPI &vsapi)
:	vsutl::FilterBase (vsapi, "transfer", ::fmParallel, 0)
,	_clip_src_sptr (vsapi.propGetNode (&in, "clip", 0, 0), vsapi)
,	_vi_in (*_vsapi.getVideoInfo (_clip_src_sptr.get ()))
,	_vi_out (_vi_in)
,	_sse2_flag (false)
,	_avx2_flag (false)
,	_transs (get_arg_str (in, out, "transs", ""))
,	_transd (get_arg_str (in, out, "transd", ""))
,	_contrast (get_arg_flt (in, out, "cont", 1))
,	_gcor (get_arg_flt (in, out, "gcor", 1))
,	_lvl_black (get_arg_flt (in, out, "blacklvl", 0))
,	_full_range_src_flag (get_arg_int (in, out, "fulls", 1) != 0)
,	_full_range_dst_flag (get_arg_int (in, out, "fulld", 1) != 0)
,	_curve_s (fmtcl::TransCurve_UNDEF)
,	_curve_d (fmtcl::TransCurve_UNDEF)
,	_loglut_flag (false)
,	_plane_processor (vsapi, *this, "transfer", true)
,	_lut_uptr ()
{
	assert (&in != 0);
	assert (&out != 0);
	assert (&core != 0);
	assert (&vsapi != 0);

	fstb::conv_to_lower_case (_transs);
	fstb::conv_to_lower_case (_transd);

	vsutl::CpuOpt  cpu_opt (*this, in, out);
	_sse2_flag = cpu_opt.has_sse2 ();
	_avx2_flag = cpu_opt.has_avx2 ();

	// Checks the input clip
	if (_vi_in.format == 0)
	{
		throw_inval_arg ("only constant pixel formats are supported.");
	}

	const ::VSFormat &   fmt_src = *_vi_in.format;

	if (   fmt_src.colorFamily != ::cmGray
	    && fmt_src.colorFamily != ::cmRGB)
	{
		throw_inval_arg ("unsupported color family.");
	}
	if (   (   fmt_src.sampleType == ::stInteger
	        && (   fmt_src.bitsPerSample <  8
	            || fmt_src.bitsPerSample > 16))
	    || (   fmt_src.sampleType == ::stFloat
	        && fmt_src.bitsPerSample != 32))
	{
		throw_inval_arg ("pixel bitdepth not supported.");
	}

	// Destination colorspace
	const ::VSFormat& fmt_dst =
		get_output_colorspace (in, out, core, fmt_src);

	if (   (   fmt_dst.sampleType == ::stInteger
	        && fmt_dst.bitsPerSample != 16)
	    || (   fmt_dst.sampleType == ::stFloat
	        && fmt_dst.bitsPerSample != 32))
	{
		throw_inval_arg ("output bitdepth not supported.");
	}

	// Output format is validated.
	_vi_out.format = &fmt_dst;

	init_table ();
}