Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to pass data between CPU-side and GPU-side of an AE Transition Extension Plugin

Explorer ,
Mar 11, 2014 Mar 11, 2014

Hi,

I'm developing a Premiere Pro Transition Plugin using the GPU and AE Transition Extensions.

But right now I'm struggling to pass data between the CPU-side of the plugin to the GPU-side (e.g. data allocated and set during PF_Cmd_SEQUENCE_SETUP).

In the GPUFilter I tried to use GetProperty( kVideoSegmentProperty_Transition_TransitionOpaqueData ), but always received an suiteError_IDNotValid error.

I also tried to call

prSuiteError suiteError = mVideoSegmentSuite->GetNodeProperty(instanceID, kVideoSegmentProperty_Transition_TransitionOpaqueData, &buffer);

directly with instanceID == kVideoSegmentProperty_Transition_RuntimeInstanceID, but received the same error.

Then I tried to use the PrSDKOpaqueEffectDataSuite. A call to AcquireOpaqueEffectData() with instanceID seemed to work without error, but I always received a null pointer as the passed OpaqueEffectDataType.

I also tried to use an ArbitraryData parameter from the PF_Cmd_PARAMS_SETUP, but the memory pointer i received via GetParam() didn't seem to be valid anyhow.

Do you have any idea what I might be doing wrong, or what would be the correct way to pass data?

Regards,

Philipp Stelzer

TOPICS
SDK
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advisor , Mar 11, 2014 Mar 11, 2014

Hi Philipp,

If you're looking for something like sequence data, then the Opaque Effect Data suite is the right API mechanism to use for the plug-in type you're using.

I'd imagine AcquireOpaqueEffectData() would pass back a NULL pointer if you've never registered data to begin with.

Basically, an effect should call AcquireOpaqueEffectData / RegisterOpaqueEffectData on SEQUENCE_SETUP / RESETUP, and call ReleaseOpaqueEffectData on SEQUENCE_SETDOWN.  To elaborate:

When the effect is applied, in PF_Cmd_S

...
Translate
Advisor ,
Mar 11, 2014 Mar 11, 2014

Hi Philipp,

If you're looking for something like sequence data, then the Opaque Effect Data suite is the right API mechanism to use for the plug-in type you're using.

I'd imagine AcquireOpaqueEffectData() would pass back a NULL pointer if you've never registered data to begin with.

Basically, an effect should call AcquireOpaqueEffectData / RegisterOpaqueEffectData on SEQUENCE_SETUP / RESETUP, and call ReleaseOpaqueEffectData on SEQUENCE_SETDOWN.  To elaborate:

When the effect is applied, in PF_Cmd_SEQUENCE_SETUP, the effect plug-in allocates and initializes the sequence data in PF_OutData->out_data.  Then it calls AcquireOpaqueEffectData().  The opaque effect data does not yet exist, so the plug-in allocates it, and calls RegisterOpaqueEffectData, and then copies over the data from the sequence data.  So both sequence data and opaque effect data are allocated.

Then PF_Cmd_SEQUENCE_RESETUP is called (multiple times) for clones of the effect used for rendering.  The effect instance knows it’s a clone because the PF_InData->sequence_data is NULL (this is a special case if the effect has Opaque Effect Data – in this case, its render clones will receive PF_Cmd_SEQUENCE_RESETUP with a NULL sequence_data pointer).  The effect then calls AcquireOpaqueEffectData().  As a render clone, it relies on this opaque effect data, rather than sequence data, and does not try to copy the sequence data to opaque effect data.

When, on the other hand, SEQUENCE_RESETUP is called with valid sequence_data in PF_InData, this is not a render clone.  The plug-in unflattens this sequence data.  It then calls AcquireOpaqueEffectData(), and if the opaque effect data does not yet exist (i.e. when reopening a saved project), the plug-in allocates it, and calls RegisterOpaqueEffectData.  It then copies the sequence data to opaque effect data.

On SEQUENCE_FLATTEN, the plug-in takes the unflattened data, flattens it, and disposes of the un-flat data.

When SEQUENCE_SETDOWN is called (it may be called multiple times to dispose of render clones), ReleaseOpaqueEffectData() is called.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 11, 2014 Mar 11, 2014

Hi Zac,

thanks for your response.

I had read that paragraph about the Opaque Effect Data, but I found the description slightly confusing.

I already register some data during SEQUENCE_SETUP. But do I have to call AcquireOpaqueEffectData() in addition to that data allocation or is this handled by the effect internally?

If I have to call it manually, is it safe to call it from within an AE SDK based plugin? I mean, the AcquireOpaqueEffectData() is part of the PrSDKOpaqueEffectDataSuite, and I thought I read somewhere you can't call Premiere SDK suite functions from within AE based plugins (right now I can't find where exactly, though).

Or is there an equivalent function in an AE suite?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Mar 11, 2014 Mar 11, 2014

Hi Philipp,

Yes you would need to make the calls manually.  This is safe for an AE plug-in running in PPro.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 11, 2014 Mar 11, 2014

Perfect! It looks like it works correctly.

Thanks a lot, Zac.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 13, 2019 Jul 13, 2019

Sorry for opening an old thread but I have an issue with OpaqueDataSuite.

Every time I call ReleaseOpaqueEffectData in SequenceSetdown I get error 516 which is  PF_Err_BAD_CALLBACK_PARAM. Any ideas why?

If I call Acquire* and Release* in Render function it's OK. The problem only happens on Release* call in SequenceSetdown.

Any help would be greatly appreciated!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 20, 2020 Nov 20, 2020

Hello,

thanks to this thread i came a little closer to my desired task sharing my instance data between cpu and gpu. What i am not getting right is the correct setup/resetup on cpu and the acquiring on the gpu. I will provide example code. Hopefully you could help me with this issue. Is my code correct? What data do i need to set as parameter of the register funtion? on GPU side the acquired data is NULL.


CPU Side setup:

static PF_Err SequenceSetup(PF_InData* in_data,PF_OutData* out_data, PF_ParamDef* params[]){
/* 
*
* some other code
*
*/

out_data->sequence_data = instanceUnflatH;


AEFX_SuiteScoper<PF_UtilitySuite4> utilitySuite(in_data, kPFUtilitySuite, kPFUtilitySuiteVersion4, out_data);
AEFX_SuiteScoper<PrSDKOpaqueEffectDataSuite> opaqueEffectDataSuite(in_data, kPrSDKOpaqueEffectDataSuite, kPrSDKOpaqueEffectDataSuiteVersion, out_data);

A_long instanceID;

err = utilitySuite->GetFilterInstanceID(in_data->effect_ref, &instanceID);
assert(err == PF_Err_NONE);

OpaqueEffectDataType* pData = 0;
err = opaqueEffectDataSuite->AcquireOpaqueEffectData(instanceID, &pData);

if (pData == 0)
{
	err = opaqueEffectDataSuite->RegisterOpaqueEffectData(instanceID,&whatData);
	assert(err == PF_Err_NONE);
}

}

 


GPU Side Render

prSuiteError Render(const PrGPUFilterRenderParams* inRenderParams,const PPixHand* inFrames,csSDK_size_t inFrameCount,PPixHand* outFrame){

csSDK_uint32 instanceID;
GetProperty(kVideoSegmentProperty_Effect_RuntimeInstanceID,instanceID);

PrMemoryPtr data;
OpaqueEffectDataType* dataO;
mOpaqueEffectSuite->AcquireOpaqueEffectData(instanceID,&dataO);
mVideoSegmentSuite->GetNodeProperty(instanceID,kVideoSegmentProperty_Effect_FilterOpaqueData, &data);

}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 29, 2023 Sep 29, 2023

Just to answer the above in case someone is searching for this

 

 if(RunningPremiere()) 
{
   AEFX_SuiteScoper<PF_UtilitySuite4> utilitySuite(in_data, kPFUtilitySuite, kPFUtilitySuiteVersion4, out_data);
   AEFX_SuiteScoper<PrSDKOpaqueEffectDataSuite> opaqueEffectDataSuite(in_data, kPrSDKOpaqueEffectDataSuite, kPrSDKOpaqueEffectDataSuiteVersion, out_data);

   A_long instanceID;

   auto err = utilitySuite->GetFilterInstanceID(in_data->effect_ref, &instanceID);
   if(err != PF_Err_NONE) {
      return err;
   }

   OpaqueEffectDataType* pData = 0;
   err = opaqueEffectDataSuite->AcquireOpaqueEffectData(instanceID, &pData);
   if (err != PF_Err_NONE) {
      return err;
   }

   if (pData == 0)
   {
      // Just have to 'reinterpret_cast' your actual unflat structure pointer to
      // the `OpaqueEffectDataType` one, since it just like a void*.
      pData = (OpaqueEffectDataType*)(unflatP);
      err = opaqueEffectDataSuite->RegisterOpaqueEffectData(instanceID, &pData);
      if (err != PF_Err_NONE) {
         return err;
      }
   }
}

 And for GPU, you just have to `reinterpret_cast` back to the unflatten structure when Acquiring the data.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 24, 2023 Nov 24, 2023
LATEST

I found an error with the above.

You need to allocate any sort of memory as raw ptr, then you need to just delete that memory during SequenceSetDown as mentioned in the comment.

Note the Register dont seems to perform any Refcount incrementation, so don't Release during SequenceSetup/Resetup.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines