最近在更新公司一款Premiere Pro CC导入插件的时候,遇到了一个神奇的现象。具体的现象是这样的:我们的插件需要将一些私有的文件数据放到插件中,比如说当前活动的文件名。当插件中收到不同的selector时,我们能够随时获取到这些私有数据进行操作。具体来说,我们是在收到imGetPrefs8这个selector时,进行设置的。回调函数代码如下:

static prMALError
SDKGetPrefs8(
imStdParms *stdParms,
imFileAccessRec8 *fileInfo8,
imGetPrefsRec *prefsRec)
{
//-----------------
// The first time you are called (or if you've been Quieted or Closed)
// you will get asked for prefs data. First time called, return the
// size of the buffer you want Premiere to store prefs for your plug-in. // Note: if canOpen is not set to kPrTrue, I'm not getting this selector. Why?
// Answer: because this selector is associated directly with "hasSetup" if (prefsRec->prefsLength == 0) {
prefsRec->prefsLength = sizeof(MediaSettings);
}
else {
MediaSettings* settings = (MediaSettings*)prefsRec->prefs;
//do not show dialog for the first time.
if (fileInfo8->fileref != imInvalidHandleValue) {
auto ctx = (FileContext*)(fileInfo8->fileref);
if (!ctx || !ctx->media_source) {
return malNoError;
}
auto oldSettings = ctx->media_source->GetMediaSettings();
settings->layout = oldSettings.layout;
settings->lock_direction = oldSettings.lock_direction;
settings->use_flowstate = oldSettings.use_flowstate;
settings->media_case = oldSettings.media_case;
settings->need_update = !settings->need_update;
std::string currentFile = ctx->media_source->GetFilePath();
ctx->media_source->ShowSettingsDialog(settings, currentFile);
updateSettingFromFile(settings);
ctx->media_source->UpdateSettings(settings);
}
else {
//init settings
settings->use_flowstate = true;
}
}
return malNoError;
}

  根据Adobe官方提供的文档说明,imGetPrefs8这个selector在文件导入的时候会连续发送两次。第一次调用回调函数是为了获取用户私有数据缓存区的大小,Host程序会给我们分配这么大的一块缓冲区。第二次调用的时候,这块缓冲区已经分配好了。我们只要往这块内存写入私有用户数据就行了。按道理说,这个过程非常清晰明了,不应该出现什么问题。可是在我实际调试的时候,弹窗获取到用户输入后,并没有马上生效!那么,我是怎么判断用户输入之后没有生效呢?一般来说,如果用户更改了什么设置,那么需要插件立即去调用SDKGetSourceVideo()函数的。

static
prMALError
SDKGetSourceVideo(
imStdParms *stdparms,
imFileRef fileRef,
imSourceVideoRec *sourceVideoRec)
{
int ret; ImporterLocalRec8H ldataH = reinterpret_cast<ImporterLocalRec8H>(sourceVideoRec->inPrivateData);
ImporterLocalRec8Ptr localRecP = reinterpret_cast<ImporterLocalRec8Ptr>(*ldataH); // Get parameters for ReadFrameToBuffer()
imFrameFormat* frameFormat = &sourceVideoRec->inFrameFormats[];
prRect theRect;
if (frameFormat->inFrameWidth == && frameFormat->inFrameHeight == )
{
frameFormat->inFrameWidth = localRecP->theFile.width;
frameFormat->inFrameHeight = localRecP->theFile.height;
}
// Windows and MacOS have different definitions of Rects, so use the cross-platform prSetRect
prSetRect(&theRect, , , frameFormat->inFrameWidth, frameFormat->inFrameHeight);
localRecP->PPixCreatorSuite->CreatePPix(sourceVideoRec->outFrame, PrPPixBufferAccess_ReadWrite, frameFormat->inPixelFormat, &theRect);
csSDK_int32 theFrame = static_cast<csSDK_int32>(sourceVideoRec->inFrameTime / (*ldataH)->theFile.frameRate);
FileContext* ctx = (FileContext*)(localRecP)->fileRef;
if (ctx == nullptr) {
return imNoContent;
} ...
... return imNoErr;
}

这个函数负责根据当用的用户设置来重新生成一帧数据传递给Host程序渲染,这样用户才能实时看到设置生效了。问题是,我们的用户输入改变之后,SDKGetSourceVideo()这个方法并没有再次调用!那是什么原因导致的呢?难道是Premiere主程序有什么Bug?经过不断调试才发现,这个锅Premiere不能背啊!原因是,我在imGetPrefs8的回调函数中并没有修改私有数据。也就是说,在上面的SDKGetPrefs8()方法中,我通过prefsRec获取到用户私有数据缓冲区之后,如果没有修改过这块内存区的数据的话,Premiere会认为不需要重新渲染画面,也就不会再次调用SDKGetSourceVideo()方法了。

MediaSettings* settings = (MediaSettings*)prefsRec->prefs;

这么看来,Premiere的这个机制还是有道理的。如果用户私有数据没有更改,很大可能是不需要重新渲染画面的。这在某些计算频繁的场景下可能能够提供一定的性能提升。但是在文档里面并没有注明这一点。所以实际上,这个现象看起来像是一个锅实际上并不是一个锅……

Adobe Premiere Pro导入插件开发遇到的一个问题的更多相关文章

  1. Adobe Premiere Pro CS6 下载安装包成功

    Adobe Premiere Pro CS6 https://pan.baidu.com/s/1miBq59e 下载地址 安装方式 断网(必须):安装官方原版程序: 一.安装前先运行程序包的“必先运行 ...

  2. 【强大的视频编辑工具】Adobe Premiere Pro CC 2019 for Mac

    [简介] PR CC是视频编辑爱好者和专业人士必不可少的视频编辑工具.它可以提升您的创作能力和创作自由度,它是易学.高效.精确的视频剪辑软件.PR CC提供了采集.剪辑.调色.美化音频.字幕添加.输出 ...

  3. adobe premiere pro cc2015.0已停止工作 解决办法

    adobe premiere pro cc2015.0已停止工作 一直报错 解决办法就是: 删除我的电脑  我的饿文档下的 Adobe下的Premiere Pro文件夹 现象就是怎么重新安装都不管用P ...

  4. AviSynth AVS Importer Plugin for Adobe Premiere Pro CC 2015 x64

    Premiere CS AVS Importer x64.prm copy to Adobe\Adobe Premiere Pro CC 2015\Plug-Ins\Common\ VSFilterM ...

  5. 一、Adobe Premiere Pro CC概述

    一.Adobe Premiere Pro CC概述 使用建议 一.开始 二.在Adobe Premiere Pro CC执行非线性编辑 1.标准的视频剪辑工作流 2.使用Premiere增强工作流 p ...

  6. Adobe Premiere Pro生成峰值文件假死

    一.正文 使用Adobe的Premiere Pro CC进行视频剪辑制作的时候,有的时候在右下角总会出现一个“自动生成峰值文件”的提示符,并跟随一个进度条: 大部分时候,这并不会引起什么问题.虽然我也 ...

  7. 探究:Adobe Premiere Pro CC 2018 导入SRT字幕显示不全问题

    问题:如果使用PR,大概率会遇到导入SRT格式的字幕文件后,PR里面显示的字幕不完整,字幕丢失的问题. 探究:字幕文件的内容正常,导入PR后字幕出现丢失. 查看字幕文件,并测试,发现如下图,如果出现字 ...

  8. Adobe Premiere Pro 2020破解教程

    首先官网下载Adobe Creative Cloud,安装完之后使用它继续安装Pr.注意在安装之前,点击文件→首选项,先设置一下你的安装路径,没有设置则默认安装在C盘. 接着下载网上良心博主推荐的破解 ...

  9. Adobe Premiere Pro CC ------ 快捷键

    ctrl + ~:全屏 Esc:退出全屏

随机推荐

  1. #include <> 和 #inlude ""的区别

    #include < >引用的是编译器的类库路径里面的头文件#include  " "引用的是你程序目录的相对路径中的头文件,在程序目录的相对路径中找不到该头文件时会继 ...

  2. Workrave怎么用 Workrave使用方法, Workrave 健康计时器,预防电脑长期操作的职业病伤害

    下载绿色版: https://portableapps.com/apps/utilities/workrave_portable 选择阅读模式: 中文: 可以只选择启动休息的计时器,这样其他2个就不用 ...

  3. 如何用纯 CSS 创作一个均衡器 loader 动画

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/oybWBy 可交互视频教 ...

  4. 利用js实现图片展开与收缩

    1.元素居中放大: 1>除了要改变元素的宽高以外,还要改变元素的定位(left,top),如果图片放大一倍,那么位移放大宽高的一半. 2>元素必须是定位的.所以,在css中设置为浮动布局, ...

  5. 第一章 pyhton基础

    一 .pyhton2与python3的区别 在pyhton2中,其中编码默认使用的是ascii编码,输出格式为print"xxx",输入为raw_input(“请输入”),在整型中 ...

  6. day12-图

  7. JAVA连接MYSQL8.0问题

    title: java连接mysql8.0问题 date: 2018-07-08 19:27:38 updated: tags: description: keywords: comments: im ...

  8. Knockout v3.4.0 中文版教程-12-控制文本内容和外观-html绑定

    3. html绑定 目的 html绑定会使关联的DOM元素显示你参数指定的html内容. 当你的视图模型里面的值是HTML标记字符串,而你想要呈现它,这时候用html绑定特别合适. 例子 <di ...

  9. Convolution Fundamental I

    Convolution Fundamental I Foundations of CNNs Learning to implement the foundational layers of CNN's ...

  10. Leetcode 385.字典序排序

    字典序排序 给定一个整数 n, 返回从 1 到 n 的字典顺序. 例如, 给定 n =1 3,返回 [1,10,11,12,13,2,3,4,5,6,7,8,9] . 请尽可能的优化算法的时间复杂度和 ...