In case this is useful to know, and if you're up for checking it out, this is how I am creating the full frame from the two temporal samples.
static FxBitmap* makeFull( FxBitmap *lower, FxBitmap *upper ) { FxBitmap *pNewImage; FxImageInfo outImageInfo = [lower imageInfo]; outImageInfo.height *= 2;
pNewImage = [[FxBitmap alloc] initWithInfo:(FxImageInfo)outImageInfo];
if( lower == 0 && upper == 0 ) return pNewImage;
int row = 0; int col = 0;
unsigned char *iBasePtr = (unsigned char *)[lower dataPtr]; int in_rowbytes = [lower rowBytes]; int iWidth = [lower width]; int iHeight = [lower height]; int iNumBytesPerPixel = [lower bytes] * 4;
unsigned char *oBasePtr = (unsigned char *)[pNewImage dataPtr]; int out_rowbytes = [pNewImage rowBytes]; int oWidth = [pNewImage width]; int oHeight = [pNewImage height]; int bytes] * 4; int numBytes = MIN(iWidth*iNumBytesPerPixel, oWidth*oNumBytesPerPixel);
// lower first int outY = 1; for (int y = 0; y < iHeight; ++y, outY+=2) { unsigned char *iT = iBasePtr + y*in_rowbytes; unsigned char *oT = oBasePtr + outY*out_rowbytes; memcpy(oT, iT, numBytes); }
iBasePtr = (unsigned char *)[upper dataPtr]; in_rowbytes = [upper rowBytes]; iWidth = [upper width]; iHeight = [upper height]; iNumBytesPerPixel = [upper bytes] * 4;
// upper next outY = 0; for (int y = 0; y < iHeight; ++y, outY+=2) { unsigned char *iT = iBasePtr + y*in_rowbytes; unsigned char *oT = oBasePtr + outY*out_rowbytes; memcpy(oT, iT, numBytes); }
return pNewImage; }
Thanks,
Micah
On Nov 29, 2007, at 10:20 AM, Darrin Cardani wrote: Micah, What you have below looks correct to me. When you say that you are "seeing some results that somewhere my fields are slightly off," in what way are they off? Just curious - what do you see when running it in Motion?
Darrin On Nov 28, 2007, at 4:56 PM, Micah Sharp wrote: Hey guys, I know we talked at one point about a technique that could be used with temporal bitmaps to create our own interlaced frames. I am doing this but seeing some results that somewhere my fields are slightly off. Could you confirm if this code makes sense? I am getting the previous frame, the current frame, and the next frame. I am using it in an NTSC sequence, so assuming lower field dominance in some places for now, but I'm quite sure the renderInfo.fieldOrder is indeed lower field dominant.
The "makeFull()" function creates a new double height bitmap and takes the first bitmap and copies it into every other line starting at 1, where then 2nd bitmap is copied into every other line starting at line 0 (thus the lower field assumption).
id temporalAPI; temporalAPI = [_apiManager apiForProtocol:@protocol(FxTemporalImageAPI)];
///////////////////////////////////////
double before = (long)(renderInfo.frame-1); double after = (long)(renderInfo.frame+1); double current = (long)(renderInfo.frame);
FxBitmap *prev1 = NULL; FxBitmap *prev2 = NULL; FxBitmap *now1 = NULL; FxBitmap *now2 = NULL; FxBitmap *next1 = NULL; FxBitmap *next2 = NULL;
[temporalAPI getInputBitmap:(FxBitmap **)&prev1 withInfo: renderInfo atTime:before];
[temporalAPI getInputBitmap:(FxBitmap **)&prev2 withInfo: renderInfo atTime:before+.5];
[temporalAPI getInputBitmap:(FxBitmap **)&now1 withInfo: renderInfo atTime:current];
[temporalAPI getInputBitmap:(FxBitmap **)&now2 withInfo: renderInfo atTime:current+.5];
[temporalAPI getInputBitmap:(FxBitmap **)&next1 withInfo: renderInfo atTime:after];
[temporalAPI getInputBitmap:(FxBitmap **)&next2 withInfo: renderInfo atTime:after+.5];
FxBitmap *prevFull = makeFull( prev1, prev2 ); // lower first FxBitmap *nowFull = makeFull( now1, now2 ); // lower first FxBitmap *nextFull = makeFull( next1, next2 ); // lower first
///////////////////////////////////////
Any help is appreciated. Thanks,
|