“This is the 27th day of my participation in the November Gwen Challenge. See details of the event: The Last Gwen Challenge 2021”.

The 44th article to participate in the event

The body of the

PF_InData

After Effects uses PF_InData to communicate with system, project, layer, and audio information. This structure is updated before each command selector is sent to the plug-in. Note that these fields are valid only for a specific PF_Cmds period. Also, don’t worry; Although PF_InData is large, you don’t have to remember what each member does; It’s just that certain fields are sometimes used.

PF_InData members

The field name describe
inter Used forThe user interaction.Add parameters.Check whether the user has interrupted the effect.Display progress barAnd in theGets the source frame and parameter values at a time other than the current render timeThe callback. This very useful feature suite is available in theInteractive callback functions”.
utils Graphical and mathematical callbacks. This pointer is inAt any timeI have to define.
effect_ref Must beOpaque data passed to most of the various callback routines. After Effects uses this to identify your plug-in.
quality Current quality Settings, i.ePF_Quality_HIPF_Quality_LO. The effect onLOIn should be faster than inHIIn should be more accurate. The graphics tool callback is inLOHIThe quality is executed differently from one quality to another. So should your effects! This field is defined in all frame and sequence selectors.
version Effect specification version, indicated inPF_Cmd_GLOBAL_SETUPRun the required version successfully during the.
serial_num The serial number of the calling application.
appl_id The identifier of the calling application. If your plug-in is running in After Effects, appl_id contains application creator code“FXTC”. If it were running in Premiere Pro, it would be“PrMr”. Use it to test whether you allow your plug-in to work with one application while also working with another.
num_params Input parameter count.
what_cpu Under macOS, it contains Gestalt values of CPU type (see Inside Macintosh, Volume 6).Not defined on Windows.
what_fpu Under macOS, it contains a Gestalt value of type FPU.Not defined on Windows.
current_time The render time of the current frame is inPF_Cmd_RENDERValid period. This is aThe layerThe current time in, not anysyntheticIn the. If the layer starts or stretches beyond time 0, the layer time and composition time willdifferent.The current frame numberiscurrent_timeDivided by thetime_step.The current timeIn seconds, yescurrent_timeDivided by thetime_scale. To handle time stretching, composite frame rate changes, and time remapping, After Effects may require the effect to be rendered at non-integer times (between two frames). Be prepared for it; Do not assume that you will only be asked to provide frames on frame boundaries. Note: fromCS3 (8.0)To start, it may need to be called when the time is negative.
time_step Duration of the current source frame being rendered. In aNested synthesisIn several cases, this source frame duration maydifferentThe time span between frames in this layer (local_time_step). You can divide bytime_scaleConvert this value to seconds. When calculating other source frame times (e.g., forPF_CHECKOUT_PARAM), please usetile_scaleDo not uselocal_time_step. If the layer is time reversed, it can be negative. If time remapping is applied to nested compositions, it may change from one frame to the next. When the source material is stretched or remapped in a nested composition, thelocal_time_stepIt might be different.For example,This can occur when an internal composition is nested within an external composition that has a different frame rate or when time remapping is applied to the external composition. If the value is in all framesNot a constantWhile the,PF_Cmd_SEQUENCE_SETUPThe value will be set to 0 during. Will be inPF_Cmd_FRAME_SETUPPF_Cmd_FRAME_SETDOWNSet correctly in the selector.warning: This can be zero, so check it before dividing.
total_time The duration of the layer. If the time stretch of the layer is greater than 100%, the value will be adjusted accordingly; However, this value will not be affected if the layer is stretched shorter over time. If time remapping is enabled, this value is the duration of composition. You can divide bytime_scaleConvert this value to seconds.
local_time_step The time difference between frames in the layer. Is affected by any stretch applied to the layer at any time. If the layer is time reversed, it can be negative. withtime_step different, which is constant from one frame to the next. You can divide bytime_scaleConvert this value to seconds. For constant step size values over the entire frame range of the layer, uselocal_time_stepIt is based on composite frame rates and layer stretching.
time_scale current_time.time_step.local_time_steptotal_timeUnits per second. iftime_scaleFor 30, thencurrent_time.time_step.local_time_steptotal_timeThe unit is 1/30 of a second. And then iftime_stepA value of 3 means that the sequence is actually rendered at 10 frames per second. iftotal_timeIs 105, indicating that the sequence is 3.5 seconds long.
field Only when thePF_Cmd_GLOBAL_SETUPDuring the period setPF_OutFlag_PIX_INDEPENDENTAvailable at the time. Check this field to see if you can only work with the fields above or below.
shutter_angle Motion blur shutter Angle. Values range from 0 to 1, representing 360 degrees. It will be zero unless motion blur is enabled and the target layer is checked.shutter_angle == 180saidcurrent_timecurrent_time + 1/2 time_stepThe time interval between. Only in thePF_Cmd_GLOBAL_SETUPDuring the period setPF_OutFlag_I_USE_SHUTTER_ANGLEAvailable at the time. For more information on how to achieve motion blur in effects, see”Motion blur”Section.
width height The dimensions of the source layer are not necessarily the same as the width and height fields in the input image parameters. Buffer resizing effects can cause this difference. Not affected by downsampling.
extent_hint The intersection of visible parts of the input and output layers; Contains composited rectangles converted to layer coordinates. Iterating over this rectangular pixel alone can speed things up significantly. See the notes later in this chapter for correct usage.
output_origin_x output_origin_y The origin of the output buffer in the input buffer. Non-zero only if the effect changes the origin.
downsample_x downsample_y The point control parameters and layer parameters are automatically resized to compensate for the user telling After Effects to render every n pixels. The effect requires a down-sampling factor to interpret scalar parameters (such as sliders) that represent pixel distances in the image. For example, a 4-pixel blur should be interpreted as a 2-pixel blur if the down-sampling factor in each direction is 1/2 (the down-sampling factor is expressed as a ratio)PF_Cmd_SEQUENCE_SETUP.PF_Cmd_SEQUENCE_RESETUP.PF_Cmd_FRAME_SETUP.PF_Cmd_FRAME_RENDER.
pixel_aspect_ratio Pixel aspect ratio (aspect ratio).
in_flags Temporarily useless
global_data sequence_data frame_data Data stored by the plug-in during other selectors. After Effects locks and unlocks the plug-in before and After it is called.
start_sampL Start sample number, relative to the start position of the audio layer.
dur_sampL The duration of the audio is represented by the number of samples. Audio specific.
total_sampL Samples in the audio layer; It’s equivalent to what’s represented in the sampletotal_time
src_snd PF_SoundWorldDescribes the input sound. Audio specific.
pica_basicP Point to thePICA BasicA pointer to a suite that is used to get other suites.
pre_effect_source_origin_x pre_effect_source_origin_y Enter the origin of the source image in the buffer. Valid only when sent with a frame selector. Non-zero only if one or more effects prior to this effect on the same level resize the output buffer and move the origin. Check resizing and new origin to determine the output region. This is useful for effects that have implicit spatial manipulations (except for dot controls), such as flipping files around the center of an image.Pay attention to: Checkout point parameter is specific to the current time (not checkout time)pre-effectThe origin is adjusted.
shutter_phase Offset from frame time to shutter opening time (expressed as a percentage of frame duration)

The use of the extent_hint

Hint rectangles are more effective for SmartFX… It’s also more complicated…

Use extent_hint to handle only those pixels that need to be output; This is one of the simplest optimizations you can make. By setting PF_OutFlag_USE_OUTPUT_EXTENT in PF_OutData in PF_Cmd_GLOBAL_SETUP (and your PiPL), To tell After Effects that you use in_data> extent_hint.

Before testing the extent_hint code, disable caching from the preferences menu, so After Effects will render your effect whenever anything changes in composition. Otherwise, the caching mechanism will obfuscate the (possibly incorrect) output of your plug-in.

Move the layer in composition so that it can be cropped. Output >extent_hint is the part of the layer visible in the composition. Add a mask to your layer and move it around. This will change extent_HINT, which contains all non-zero alpha regions of the image.

In_data -> extent_hint is the intersection of these two rectangles (composition and mask) and changes whenever they change.

Before resizing and origin offset, the Extent Rectangles are calculated in the coordinate space of the original input layer to simplify the intersection of rectangles between the input and output ranges of the effect with PF_OutFlag_PIX_INDEPENDENT set. To get the output extent in the coordinate system of the output buffer, offset the extent_HINT with the PF_InData -> output_ORIGIN_X and Y fields.

Consider sampling when calculating output size; The user must be able to render at full resolution. If the output buffer exceeds 30,000 x 30,000, limit it to that size and consider displaying a warning dialog box.

After the code runs correctly, enable caching and see how long the effect takes to rerender. Consider a drop shadow; Users often apply static shadows to still images.

Output -> extent_hint if z is ignored, caching will be used more frequently.

To get buffer-expanding effects, intersect output> extent_hint with your plug-in’s Transformed bound and set the size accordingly during PF_Cmd_FRAME_SETUP.

Now there are 20% more pixels!

Starting with version 6.0, extent_hints were passed 20% larger than the layers themselves to help us make predictive rendering decisions. Many Effects extend the buffer by touch alone, and After Effects often uses prompt rectangles.

Point control and buffer extension

Extend the effect of the output buffer by setting set output_origin_X/Y in the PF_InData structure during PF_Cmd_FRAME_SETUP so that it is in the upper-left corner of the original layer. The effect of this offset on subsequent effects is reported in pre_effect_source_origin_X/y. Point parameters are automatically adjusted for this shift.

Before the effect takes effect, apply a buffer extender, such as the Gaussian blur or Resizer SDK example, and use a large resize value. If your effect does not handle pre_effect_source_origin_x/y correctly, turning blur on and off will change the position of the output.

All point parameter values (at all times) have offset values described by pre_effect_source_origin_X/Y. For most effects, this is transparent. However, if buffer expansion varies over time (as is the case with animation blur), the origin offset will move the non-animated point. Consider this when designing the effect of caching point parameter values between frames.