Re: FxPlug using CIImage with CIFilter behave differently between Motion and Final Cut
site_archiver@lists.apple.com Delivered-To: pro-apps-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=PAAK3vC5Lr4uW/OJfJU6jXuGbVxAX6zyKfaZ673KjbE=; b=I5p4XHvAIR3zMBkvWwFCMUd5KnzNtOrk4eJob3IHRRrBTJV/cIrc2RmwM322tApcCl Y6oeR8EnOSqoWcR8Ih7iTmOUIBNkJK2S2S0PA+07bKWgAiRltWw+pLLBprxhvyUCKba9 fee7IN5Q8YHjjnyh9DJNXy7fNKmh6xCqcYzHI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=CABDHLQjUBNEweqRAlkf8dB08s5kDMfZj+S2WWF/zaSFKqw7kV3gpOgwnK7itkTL+r orKm7mCiJKsmmoGLIlEUKoiHENKbdKlmWAdZMdtTKQ/AeaEzk1xAEhZxZqwL20P7YyLn 0F+5dwXj5UZquXFcV7pnIdkwOL4yMpZzse024= good thinking, I did a print of the texture ID. In Motion it is always the same, but in final cut it is always different. I am not releasing the texture within the loop. doing so actually causes a crash. does anyone have any ideas what to do to ensure that new textures get allocated each iteration? On a related note, is there anyway that i can cache these frames into some sort of LRU expulsion cache. Most of the time, especially during render, each frame of out put uses almost the same frames of input but I am not storing them locally at all. If i could store them and reduce the number of calls to temporalImageAPI perhaps that would help performance? Thanks! On Thu, Oct 2, 2008 at 1:28 AM, Darrin Cardani <dcardani@apple.com> wrote:
On Oct 1, 2008, at 12:22 AM, Jim George wrote:
I've run into a discrepancy between the behavior of using Core Image filters between Final Cut and Motion in an FxPlug and wonder if anyone would have any insight into the problem. I have a filter that takes a number of contiguous frames and runs some processing over them. I am using the temporalImageAPI to get the frames as FxTextures. In Final Cut the filter comes out correctly, but in Motion only the *last* frame gets drawn. I'm thinking somehow that Motion uses a shared context or texture where final cut allocates new ones, but my understanding of these under the hood is a bit of guesswork.
Jim, Yes there are cases where Motion reuses textures. You could check whether we're giving you the same texture by printing out the texture ID in the loop. I would think that since you aren't releasing the textures (at least in the code below) that we wouldn't be reusing the texture ID. If this is a cut-down version of the code and you actually are releasing the textures after each loop iteration, that may be the issue. Try not releasing them until after the draw command. Remember that CI filters don't actually execute until you call the drawImage: command because they can concatenate for improved speed, so if you're releasing them in the loop, they might not be there when the drawing happens.
Below is the basics of what I'm doing in the Render method for FxPlug.
glPushAttrib(GL_CURRENT_BIT); CIContext *ciContext = [CIContext contextWithCGLContext:CGLGetCurrentContext()
pixelFormat:CGLGetPixelFormat(CGLGetCurrentContext()) options:NULL]; CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB(); FxTexture* inputTex; [temporalImageAPI getInputTexture:&inputTex withInfo: renderInfo atTime: renderInfo.frame - width/2]; CIImage* imageBase = [CIImage imageWithTexture:[inputTex textureId] size:CGSizeMake([inputTex width],[inputTex height]) flipped:NO colorSpace:cspace]; UInt32 frameStep = 0; double i; for(i = renderInfo.frame - width/2; i <= renderInfo.frame + width/2; i++){ [_filter setValue:imageBase forKey: @"inputBase"]; [temporalImageAPI getInputTexture:&inputTex withInfo: renderInfo atTime:i]; CIImage* inputImage = [CIImage imageWithTexture:[inputTex textureId] size:CGSizeMake([inputTex width],[inputTex height]) flipped:NO colorSpace:cspace]; [_filter setValue:inputImage forKey:@"inputImage"]; imageBase = [_filter valueForKey:@"outputImage"]; } [ciContext drawImage:imageBase inRect:CGRectMake(left,bottom,right-left,top-bottom) fromRect:CGRectMake(tLeft,tBottom,tRight-tLeft,tTop-tBottom)]; glPopAttrib();
Darrin -- Darrin Cardani dcardani@apple.com
-- - Jim www.INTelegance.net _______________________________________________ Do not post admin requests to the list. They will be ignored. Pro-apps-dev mailing list (Pro-apps-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/pro-apps-dev/site_archiver%40lists.ap... This email sent to site_archiver@lists.apple.com
participants (1)
-
Jim George