Adobe Premiere Pro导入插件开发遇到的一个问题
最近在更新公司一款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导入插件开发遇到的一个问题的更多相关文章
- Adobe Premiere Pro CS6 下载安装包成功
Adobe Premiere Pro CS6 https://pan.baidu.com/s/1miBq59e 下载地址 安装方式 断网(必须):安装官方原版程序: 一.安装前先运行程序包的“必先运行 ...
- 【强大的视频编辑工具】Adobe Premiere Pro CC 2019 for Mac
[简介] PR CC是视频编辑爱好者和专业人士必不可少的视频编辑工具.它可以提升您的创作能力和创作自由度,它是易学.高效.精确的视频剪辑软件.PR CC提供了采集.剪辑.调色.美化音频.字幕添加.输出 ...
- adobe premiere pro cc2015.0已停止工作 解决办法
adobe premiere pro cc2015.0已停止工作 一直报错 解决办法就是: 删除我的电脑 我的饿文档下的 Adobe下的Premiere Pro文件夹 现象就是怎么重新安装都不管用P ...
- 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 ...
- 一、Adobe Premiere Pro CC概述
一.Adobe Premiere Pro CC概述 使用建议 一.开始 二.在Adobe Premiere Pro CC执行非线性编辑 1.标准的视频剪辑工作流 2.使用Premiere增强工作流 p ...
- Adobe Premiere Pro生成峰值文件假死
一.正文 使用Adobe的Premiere Pro CC进行视频剪辑制作的时候,有的时候在右下角总会出现一个“自动生成峰值文件”的提示符,并跟随一个进度条: 大部分时候,这并不会引起什么问题.虽然我也 ...
- 探究:Adobe Premiere Pro CC 2018 导入SRT字幕显示不全问题
问题:如果使用PR,大概率会遇到导入SRT格式的字幕文件后,PR里面显示的字幕不完整,字幕丢失的问题. 探究:字幕文件的内容正常,导入PR后字幕出现丢失. 查看字幕文件,并测试,发现如下图,如果出现字 ...
- Adobe Premiere Pro 2020破解教程
首先官网下载Adobe Creative Cloud,安装完之后使用它继续安装Pr.注意在安装之前,点击文件→首选项,先设置一下你的安装路径,没有设置则默认安装在C盘. 接着下载网上良心博主推荐的破解 ...
- Adobe Premiere Pro CC ------ 快捷键
ctrl + ~:全屏 Esc:退出全屏
随机推荐
- Multi Paxos
Multi Paxos [2] 通过basic paxos 以上步骤分布式系统已经能确定一个值,“只确定一个值有什么用?这可解决不了我面临的问题.” 你心中可能有这样的疑问. 原simple paxo ...
- 同时使用多个UITableView
1.xib\storyboard中给2个tableView设置constraints(等宽) 方法 : ①设置mainTableView的上\下\左\三部分的约束为0:subTableView上\下\ ...
- 【实用工具】Teleport Pro爬取整个网站镜像到本地
1. 使用Teleport Pro可以完全或部分下载一个网站上的内容,在硬盘上创建一个与原网站完全相同的镜象,使用户能够离线浏览 Teleport Pro的安装以及基本使用 在菜单栏Project下得 ...
- 蓝牙学习(2)USB Adapter
主要分析一下蓝牙USB Adapter使用USB接口传输HCI包的实现及过程. 参照上面的Bluetooth core system architecture图, 蓝牙USB Adapter作为Blu ...
- Flux reference
https://facebook.github.io/flux/docs/dispatcher.html#content 首先安装 npm install --save flux Dispatcher ...
- 王小胖之 Base64编码/解码
使用场景:编码网址作为URL参数,简单编码或加密数据,下载地址生成或解析. 实现功能:BASE64在线编码和解码. 数据实例:王小胖好啊,王小胖顶呱呱!! ~~ english 123 !@#$%^& ...
- java获取时间格式
文章来源:https://www.cnblogs.com/hello-tl/p/9263602.html package com.util; import java.text.SimpleDateFo ...
- Python把类当做字典来访问
定义一个类将它实例化,我们可以通过obj.属性来访问类的属性,如果想获取类的所有实例变量,我们可以使用obj.__dict__来访问,如下: class A: def __init__(self): ...
- 面试准备——springboot相关
https://www.jianshu.com/p/63ad69c480fe https://blog.csdn.net/u013605060/article/details/80255192 htt ...
- Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 继续跪一把
这次的前三题挺简单的,可是我做的不快也不对. A. Bank Robbery time limit per test 2 seconds memory limit per test 256 megab ...