正文
错误
总是从 main() 返回一个 PF_Err。插件必须将所有错误传递回 After Effects 。
将任何错误(通过回调和 PICA 套件返回给你)传递给 After Effects 是非常重要的,除非你已经处理了它们。
注意返回正确的错误代码,并处理分配的所有内存。
错误码
| Error | Meaning |
|---|---|
PF_Err_NONE | 成功. |
PF_Err_OUT_OF_MEMORY | 内存分配失败。注意,RAM 预览将导致这种情况,因此 After Effects 将期望从您的插件接收这个错误。 |
PF_Err_INTERNAL_STRUCT_DAMAGED | 使用数据结构的问题。 |
PF_Err_INVALID_INDEX | 查找/使用数组成员的问题。 |
PF_Err_UNRECOGNIZED_PARAM_TYPE | 参数数据的问题。 |
PF_Err_INVALID_CALLBACK | 通过指针访问函数的问题。 |
PF_Err_BAD_CALLBACK_PARAM | 使用了 传递给回调的参数 的问题。 |
PF_Interrupt_CANCEL | 如果用户操作中止渲染,effect 和 AEGP (两种插件形式)回调都可以将此返回给 effects 。如果效果从回调中得到这个错误,它应该停止处理帧并将错误返回给主机。失败传递错误可能会导致错误渲染帧被缓存。 |
PF_Err_CANNOT_PARSE_KEYFRAME_TEXT | 当将剪贴板解析为关键帧数据出现问题时,从 PF_Arbitrary_SCAN_FUNC 返回此值。 |
错误报告策略
After Effects 有一个一致的错误处理策略; 遵守它。
如果在插件代码中遇到错误,请立即报告给用户,然后再从插件返回到 After Effects 。
After Effects 将插件执行过程中遇到的操作系统错误视为您的错误。
如果你从我们的回调函数中得到一个错误代码,将它传递回 After Effects ; 我们已经报告过了。
After Effects 不会报告内存不足的错误。错误报告总是抑制在 RAM 预览期间,当 After Effects 运行在 noui 模式。
要从插件内部报告错误,请设置 PF_OutFlag_DISPLAY_ERROR_MESSAGE ,并在 PF_OutData -> return_msg 中描述错误。
这样做将把您的错误输入到渲染日志中,并防止由渲染引擎或脚本驱动的渲染系统挂起。
深入
现在您已经对效果插件有了基本的了解,可以开始试验一些实际的代码了。开始吧!
在了解了插件设置的基础知识之后,您可能会对可重用代码、高级功能以及如何优化代码以提高运行速度有一些疑问。
为此,After Effects 通过功能套件公开了大量的内部功能。
通过依赖 After Effects 代码的工具函数,您应该能够让您的图像处理算法迅速实现。
这将在效果细节中讨论。
Errors
Always, always, always (always!) return a
PF_Errfrommain(). Plug-ins must pass all errors back to After Effects.It is vitally important that you pass any errors (returned to you by callbacks and PICA suites) to After Effects, unless you’ve handled them.
Be vigilant about returning the right error code, and disposing of any memory you’ve allocated.
Really. We’re serious.
Error Codes
Error Meaning PF_Err_NONESuccess. PF_Err_OUT_OF_MEMORYMemory allocation failed.Note that RAM preview will cause this condition, so After Effects will be expecting to receive this error from your plug-in. PF_Err_INTERNAL_STRUCT_DAMAGEDProblems using a data structure. PF_Err_INVALID_INDEXProblems finding/using array member. PF_Err_UNRECOGNIZED_PARAM_TYPEProblem with parameter data. PF_Err_INVALID_CALLBACKProblems accessing function through pointer. PF_Err_BAD_CALLBACK_PARAMProblems using a parameter passed to a callback. PF_Interrupt_CANCELBoth effect and AEGP callbacks can return this to effects, if a user action aborts a render.If the effect gets this error from a callback, it should stop processing the frame and return the error to the host.Failure to pass the error back may result in misrendered frames being cached. PF_Err_CANNOT_PARSE_KEYFRAME_TEXTReturn this from PF_Arbitrary_SCAN_FUNCwhen problems occur parsing the clipboard into keyframe data.
Error Reporting Policy
After Effects has a consistent policy for error handling; follow it.
If you encounter an error in your plug-in’s code, report it to the user immediately, before returning from your plug-in to After Effects.
After Effects considers errors from the operating system, encountered during your plug-in’s execution, to be yours.
If you get an error code back from one of our callback functions, pass it back to After Effects; we’ve already reported it.
Out-of-memory errors are never reported by After Effects. Error reporting is always suppressed during RAM preview, and when After Effects is running in - noui mode.
To report an error from within a plug-in, set
PF_OutFlag_DISPLAY_ERROR_MESSAGE, and describe the error in PF_OutData>return_msg.Doing so will enter your error into the render log, and prevent system hangs in renders driven by a render engine or scripting.
Dig In!
Now you have a basic understanding of effect plug-ins, and are ready to start experimenting with some real code. Go ahead and get started!
After getting the basics of your plug-in setup, you may have some questions about reuseable code, advanced functionality, and how to optimize your code to make it faster.
To this end, After Effects exposes a tremendous amount of its internal functionality via function suites.
By relying on After Effects code for utility functions, you should be able to get your image processing algorithms implemented quickly.
This will discussed in Effect Details.