Copy link to clipboard
Copied
I use PF_CHECKOUT_PARAM all the time now for reading from other layers. It's great because you can easily specify the frame / time you want to read from by modifying the in_data->current_time variable.
However, let's discuss a unique situation. I want to read a sequence from another layer and display a row of those on my effect layer... say 5. I want each of those instances to have a different animation offset.
To do this, I would have to checkout the layer inside a loop and from all my tests, it seems you cannot do that without a crash. You would need to do something like:
for (i=0;i<5;i++)
{
ERR(PF_CHECKOUT_PARAM( in_data,
LAYER_DISK_ID,
in_data->current_time+i,
in_data->time_step,
in_data->time_scale,
&checkout));
Do stuff...
ERR2(PF_CHECKIN_PARAM( in_data, &checkout));
}
So am I approaching this wrong? How would one be able to read sequences from another layer and offset them?
Thanks,
-Rich
1 Correct answer
Hi Richard, Hi Toby,
I remember checking out a single layer parameter at different times and having no crash...
Even without using a different 'checkout' variable. But in this case, I think the issue happens cos' the checkout variable is 'dirty'.
The code should look like this:
for (i=0;i<5;i++)
{
AEFX_CLR_STRUCT(checkout);//NEW line here
ERR(PF_CHECKOUT_PARAM( in_data,
LAYER_DISK_ID,
in_data->current_time+i,
in_data->time_step,
in_data->time_scale,
&checkout));
Do stuff...
ERR2(PF_CHECKIN_PARAM( in_data, &c
...
Copy link to clipboard
Copied
It is perfectly possible to check out multiple layers at once, then do your processing.
You should therefore investigate why a crash is happening. In your example you are re-using the "checkout" variable - it should be a separate one for each layer - maybe that causes a problem.

Copy link to clipboard
Copied
Also, you are always using LAYER_DISK_ID for each layer, also not a good idea .
Each layer you check out should have a corresponding parameter (it can be hidden).
Here is a simple setup (with LAYER_DISK_x being the 3 layer parameters):
ERR(PF_CHECKOUT_PARAM(in_data, LAYER_DISK_ID_0, in_data->current_time+0, in_data->time_step, in_data->time_scale, &checkout0));
ERR(PF_CHECKOUT_PARAM(in_data, LAYER_DISK_ID_1, in_data->current_time+1, in_data->time_step, in_data->time_scale, &checkout1));
ERR(PF_CHECKOUT_PARAM(in_data, LAYER_DISK_ID_2, in_data->current_time+2, in_data->time_step, in_data->time_scale, &checkout2));
// Do stuff...
ERR2(PF_CHECKIN_PARAM( in_data, &checkout0));
ERR2(PF_CHECKIN_PARAM( in_data, &checkout1));
ERR2(PF_CHECKIN_PARAM( in_data, &checkout2));
Copy link to clipboard
Copied
Hi Toby!
Thank you for your reply! Well, I may have been unclear.
I only want to checkout 1 layer, not multiple layers. That layer has an animation - say a circle moving from left to right.
To repeat that animation in my effect layer and offset it several times at once, I need to checkout that layer 5 times with a time offset in the checkout function. This needs to be done in a loop for x instances, each x offset. No need to checkout other layers (I already do that for other things).
So it goes back to the question of is it possible to checkout in a loop as per my example or is there a different approach?
Please let me know if perhaps I didn't explain it properly.
Thank you as always for your help,
-Rich

Copy link to clipboard
Copied
Even when checking out different time instances of the same layer, you should use a numbe rof different layer parameters to have them all available at the same time. In that regard, checking out the current layer at a different time isn't different to checking out a different layer alltogehter.
Possibly you could try to also check out and check in one after the other and save the pixel data inbetween in your own buffer, but even if that would work, it might be too much overhead, depending on your processing algorithm.
Copy link to clipboard
Copied
Hi Richard, Hi Toby,
I remember checking out a single layer parameter at different times and having no crash...
Even without using a different 'checkout' variable. But in this case, I think the issue happens cos' the checkout variable is 'dirty'.
The code should look like this:
for (i=0;i<5;i++)
{
AEFX_CLR_STRUCT(checkout);//NEW line here
ERR(PF_CHECKOUT_PARAM( in_data,
LAYER_DISK_ID,
in_data->current_time+i,
in_data->time_step,
in_data->time_scale,
&checkout));
Do stuff...
ERR2(PF_CHECKIN_PARAM( in_data, &checkout));
}
Hope it helps,
François

Copy link to clipboard
Copied
Yes, Francois, good hint and good practice to always clear structs/variable before re-using them!
I think Rich was aiming for having the pixel data from a layer at different points in time simultaneously available, so re-using the "checkout" variable (at least without buffering the results) would overwrite the previous result anyway.
Copy link to clipboard
Copied
I understood "Do stuff..." as filling the output with a part of the checked out layer.
If not, you're right, it will be overwritten every time.
Seems the answer lies inside the "do stuff" mystery 😉
Copy link to clipboard
Copied
Good afternoon Toby & Francoise!
This works and it is exactly what I was after. And not only that, it results in a very, very cool result! Thank you.
Yes, "Do stuff..." referred to using the checked layer's time instance in that loop instance and then discarding it for the next one.
Thank you to the both of you, as always, for taking the time to offer your guidance.
Cheers,
-Rich
Copy link to clipboard
Copied
Glad it works! 🙂

