Skip to main content
Known Participant
July 19, 2021
Answered

Importer + source settings effects SDK initial values

  • July 19, 2021
  • 1 reply
  • 690 views

We're struggling with how a source settings effect can initialise its values based on the properties of the media file in the importer.

 

To quote the SDK: (Page 13/14)

"For DPX, the initial parameters and default prefs are based on the bit depth of the video. These default prefs are passed back to the effect, which sets the initial param values and stashes a copy of them in sequence_data to use again for future calls to PF_Cmd_SEQUENCE_RESETUP."

 

How is it possible to set initial parameter values in an effect in this way? This contradicts the After Effects SDK which states that you cannot change parameter values anywhere except during PF_Cmd_USER_CHANGED_PARAM and during PF_Cmd_EVENT.

 

Parameters are created during PF_Cmd_PARAMS_SETUP which occurs only once when Premiere Pro is launched. By the time the importer plugin gets the opportunity to read a media file, the parameters are already created and their values can't be modified outside of a user initiated 'PF_Cmd_USER_CHANGED_PARAM'.

 

Can Adobe share a source code example showing how it is possible to apply initial values to the source effect from the importer?

 

Thanks

Russell

This topic has been closed for replies.
Correct answer Wil Renczes

Sure.  Verbatim from our DPX source settings plugin, here's the call to SequenceSetup() where we pull the source settings from the importer over into the source effect:

 

static PF_Err SequenceSetup(
    PF_InData *in_data,
    PF_OutData *out_data,
    PF_ParamDef	*params[],
    PF_LayerDef	*output )
{
	out_data->sequence_data = PF_NEW_HANDLE(sizeof(SequenceData));
	if (!out_data->sequence_data)
	{
		return PF_Err_INTERNAL_STRUCT_DAMAGED;
	}

	PF_SourceSettingsSuite* sourceSettingsSuite = NULL;

	AEFX_AcquireSuite(
		in_data,
		out_data,
		kPFSourceSettingsSuite,
		kPFSourceSettingsSuiteVersion,
		NULL,
		(const void**)&sourceSettingsSuite);

	DPX::CineonPrefs data;
	sourceSettingsSuite->PerformSourceSettingsCommand(in_data->effect_ref, (void*)&data, sizeof(data));

 

The code then goes on to apply that data to the controls.  It's heavily macro'ed, so I don't think it's as useful to post, but basically we use the checkout_param / checkin_param calls to get access to various controls (see the description in AE_Effect.h).

Basically, for each control you want to update, call checkout_param, then use the PF_UpdateParamUI() callback to update its value, then checkin_param once you're done.

 

Just to be complete, note that I showed SequenceSetup() here.  That will be called for newly applied effects.  But, if you then save your project, then relaunch at some future time, you won't get a call for SequenceSetup() when you reopen that saved project;  instead you'll get called by SequenceResetup().  But the same logic for applying the source data from the importer applies here, ie make sure you put do the same initial value population in both calls.

 

Cheers

1 reply

Wil Renczes
Adobe Employee
Wil RenczesCorrect answer
Adobe Employee
July 19, 2021

Sure.  Verbatim from our DPX source settings plugin, here's the call to SequenceSetup() where we pull the source settings from the importer over into the source effect:

 

static PF_Err SequenceSetup(
    PF_InData *in_data,
    PF_OutData *out_data,
    PF_ParamDef	*params[],
    PF_LayerDef	*output )
{
	out_data->sequence_data = PF_NEW_HANDLE(sizeof(SequenceData));
	if (!out_data->sequence_data)
	{
		return PF_Err_INTERNAL_STRUCT_DAMAGED;
	}

	PF_SourceSettingsSuite* sourceSettingsSuite = NULL;

	AEFX_AcquireSuite(
		in_data,
		out_data,
		kPFSourceSettingsSuite,
		kPFSourceSettingsSuiteVersion,
		NULL,
		(const void**)&sourceSettingsSuite);

	DPX::CineonPrefs data;
	sourceSettingsSuite->PerformSourceSettingsCommand(in_data->effect_ref, (void*)&data, sizeof(data));

 

The code then goes on to apply that data to the controls.  It's heavily macro'ed, so I don't think it's as useful to post, but basically we use the checkout_param / checkin_param calls to get access to various controls (see the description in AE_Effect.h).

Basically, for each control you want to update, call checkout_param, then use the PF_UpdateParamUI() callback to update its value, then checkin_param once you're done.

 

Just to be complete, note that I showed SequenceSetup() here.  That will be called for newly applied effects.  But, if you then save your project, then relaunch at some future time, you won't get a call for SequenceSetup() when you reopen that saved project;  instead you'll get called by SequenceResetup().  But the same logic for applying the source data from the importer applies here, ie make sure you put do the same initial value population in both calls.

 

Cheers

Known Participant
July 20, 2021

Hi,

Thanks for the quick response. I have tried to implemented it but unfortunately its still not updating the parameters in the effect controls UI.

 

This is my code:

PF_Err PluginSourceSettings::SequenceSetup(PF_InData * in_data, PF_OutData * out_data, PF_ParamDef * params[], PF_LayerDef * output)
{
	OutputDebugString("PluginSourceSettings::SequenceSetup");

	// Allocate sequence data to store the UAD file's 'As Shot' RAW parameters
	out_data->sequence_data = PF_NEW_HANDLE(sizeof(Decode::sRAWProcessParams));
	if (!out_data->sequence_data)
		return PF_Err_INTERNAL_STRUCT_DAMAGED;
	
	// Get the initial settings from the importer
	AEFX_SuiteScoper<PF_SourceSettingsSuite2> sourceSettingsSuite(in_data, kPFSourceSettingsSuite, kPFSourceSettingsSuiteVersion2, out_data);
	Decode::sRAWProcessParams ImporterRawParams;
	sourceSettingsSuite->PerformSourceSettingsCommand(in_data->effect_ref, &ImporterRawParams, sizeof(Decode::sRAWProcessParams));

	// Apply the initial settings to the parameter controls
	AEParamUIBuilder::SetSliderValue((int)eUIElementId::WhiteBalanceTemperature, in_data, out_data, 1234);

	// Save 'As Shot' into the sequence data
	Decode::sRAWProcessParams* pParamsLocal = *(Decode::sRAWProcessParams**)out_data->sequence_data;
	*pParamsLocal = ImporterRawParams;

	return PF_Err_NONE;
}

bool AEParamUIBuilder::SetSliderValue(int ParamId, PF_InData* in_data, PF_OutData* out_data, double Value, std::optional<double> Default)
{
	PF_Err err = PF_Err_NONE;
	PF_Err err2 = PF_Err_NONE;

	PF_ParamDef Param;
	AEFX_CLR_STRUCT(Param);

	ERR(PF_CHECKOUT_PARAM(in_data,
		ParamId, in_data->current_time,
		in_data->time_step,
		in_data->time_scale,
		&Param));

	if (!err) {
		switch (Param.param_type) {
		case PF_Param_FLOAT_SLIDER:
			Param.u.fs_d.value = (PF_FpLong)Value;
			if (Default.has_value())
				Param.u.fs_d.dephault = (PF_FpLong)*Default;
			break;
		case PF_Param_SLIDER:
			Param.u.sd.value = (PF_ParamValue)Value;
			if (Default.has_value())
				Param.u.sd.dephault = (PF_ParamValue)*Default;
			break;
		default:
			break;
		}
	}

	Param.uu.change_flags = PF_ChangeFlag_CHANGED_VALUE;
	AEFX_SuiteScoper<PF_ParamUtilsSuite3> paramUtilsSuite(in_data, kPFParamUtilsSuite, kPFParamUtilsSuiteVersion3, out_data);
	paramUtilsSuite->PF_UpdateParamUI(in_data->effect_ref, ParamId, &Param);
	ERR2(PF_CHECKIN_PARAM(in_data, &Param));

	return err != PF_Err_NONE;
}

 

I've attached the debugger and I can confirm all the calls are being run. I'm testing with a new project dragging new media in. 'SequenceSetup' is fired and SetSliderValue is called by it returning no error.

Wil Renczes
Adobe Employee
Adobe Employee
July 20, 2021

Hmm, the only thing that I can think of immediately is to try setting the slider_max / valid_max ranges on your slider controls here.  Beyond that, if you can throw a plugin at us, I could try to debug what's happening when you call PF_UpdateParamUI().