Retrieve current frame as float data within UserChangedParam()
Hi Community,
I posted almost the same question in the Premiere Pro discussions and after no activity there, I thought I should post it here as this might be a better place for questions concerning the AE Plugin SDK.
I'm creating a video effect for Premiere Pro using the AE Plugin SDK and I'd like to analyse the current frame when the user pushes a button and then set some parameters based on the analysis.
Firstly, I managed to retrieve the current frame using PF_CHECKOUT_PARAM from within UserChangedParam() and set other parameters from the analysis however the returned layer is formatted as PrPixelFormat_ARGB_4444_8u and I need higher precision than 8-bit for the type of analysis being done, simply converting to float won't do it as I'm working from 10-to-16 bit log and linear footage.
Secondly, when I add the effect to an adjustment layer which does not begin at start of the timeline, the returned frame is not the frame under the cursor, since inData->current_time is apparently the current time relative to the beginning of the adjustment layer but param.u.ld holds data to the frame at inData->current_time relative to the beginning of the timeline.
I'm setting the following flags in GlobalSetup():
out_data->out_flags = PF_OutFlag_DEEP_COLOR_AWARE | PF_OutFlag_KEEP_RESOURCE_OPEN | PF_OutFlag_WIDE_TIME_INPUT;
out_data->out_flags2 = PF_OutFlag2_FLOAT_COLOR_AWARE | PF_OutFlag2_SUPPORTS_THREADED_RENDERING;
if (in_data->appl_id == 'PrMr') {
auto pixelFormatSuite = AEFX_SuiteScoper<PF_PixelFormatSuite1>(in_data, kPFPixelFormatSuite, kPFPixelFormatSuiteVersion1, out_data);
(*pixelFormatSuite->ClearSupportedPixelFormats)(in_data->effect_ref);
(*pixelFormatSuite->AddSupportedPixelFormat)(in_data->effect_ref, PrPixelFormat_BGRA_4444_32f);
}
And this is a code snippet from UserChangedParam():
PF_ParamDef param;
auto err = PF_CHECKOUT_PARAM(inData, ParamIndex::kInput, inData->current_time, inData->time_step, inData->time_scale, ¶m);
...
auto layer = ¶m.u.ld;
...
AEFX_SuiteScoper<PF_PixelFormatSuite1> pixelFormatSuite(inData, kPFPixelFormatSuite, kPFPixelFormatSuiteVersion1, outData);
PrPixelFormat format = PrPixelFormat_Invalid;
pixelFormatSuite->GetPixelFormat(layer, &format);
...
if (format == PrPixelFormat_ARGB_4444_8u) {
cv::Mat src(layer->height, layer->width, CV_8UC4, layer->data, layer->rowbytes);
...
}
PF_CHECKIN_PARAM(inData, ¶m);
Any hints as to how to obtain the current frame with float precision on a button press or how to deal with the time offset of the adjustment layer would be appreciated!
