so im exporting an image sequence as a quicktime clip and it begins to work fine.
so i think... ok let's scale this up to the whole clip!
i decide i'll use an array to act as a buffer... the array stores a number of image sequences before writing them to disk (as i'm still under the impression that this is what the code is doing)
it get's through the first couple of images fine and then it suddenly stops does nothing but it DOES tell me something that isn't the GDB disclaimer message (shock horror it the program said something useful
)
i don't understand why memory is still being taken up once the j loop is done as if the images from the previous burst still exist.
if you need to know my getCurrentFrame method is the same as the third snipet from here:
http://snipt.net/Alexander_Smirnov
with a few changed before the return statement
apologies for all the side scrolling you would have to do to give me an idea of what i'm doing wrong.
if this code that i've stated is correct and there is no reason for it to continuously take up memory when it shouldn't be then the problem must be somewhere else
please tell me what i've done is wrong
so i think... ok let's scale this up to the whole clip!
i decide i'll use an array to act as a buffer... the array stores a number of image sequences before writing them to disk (as i'm still under the impression that this is what the code is doing)
it get's through the first couple of images fine and then it suddenly stops does nothing but it DOES tell me something that isn't the GDB disclaimer message (shock horror it the program said something useful
so i set a break point in the method where i figure it's going wrong, and i get there and it just stops... does nothing elseMyProgram(1942,0xa0565720) malloc: *** mmap(size=2097152) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
Code:
int numberOfBursts = 50; // render the sequence in 50 parts
int bufferFrames = 90; // each part is 90 frames long
int i = 0;
for(i = 0; i < numberOfBursts; i++) {
// for each part...
// create a mutable array to hold all the images
NSMutableArray* imageSeq = [[NSMutableArray alloc] initWithCapacity: bufferFrames];
int j = 0;
for( j = 0; j < bufferFrames; j++) {
// for each frame that's meant to exist grab it from the current conetext
[imageSeq addObject: [self getCurrentFrame]];
<---- step forward a frame and render it to screen so then glReadPixels has something to read ------>
}
int k = 0;
for( k = 0; k < bufferFrames; k++) {
// for each image gathered..
// make a QTTime and hope like hell this is correct... because it probably isn't, even using the QTTime from existing QT files makes this cry and do something different
QTTime timeInt = QTMakeTime(1, 30);
// grab the image from the array
NSImage *img = [imageSeq objectAtIndex: k];
// add the image for (what we hope is) 1/30 of a second encoded as a png because i don't know how to change that
[mQTMovieExport addImage:img forDuration:timeInt withAttributes:attrs];
//[img release]; put this here and it will crash on the 2nd burst, it'll read from the array an NSImage but then suddenly say it's not
}
k = 0;
// release each image from memory outside that last loop because for some f***** up reason if i put in [img release] at the end of the loop above it treats future images in future bursts as something other than an image and starts to cry...
for(k = 0; k < bufferFrames; k++) {
[[imageSeq objectAtIndex: k] release];
}
// release the array
[imageSeq release];
// update the movie
[mQTMovieExport updateMovieFile];
}
i don't understand why memory is still being taken up once the j loop is done as if the images from the previous burst still exist.
if you need to know my getCurrentFrame method is the same as the third snipet from here:
http://snipt.net/Alexander_Smirnov
with a few changed before the return statement
Code:
CGImageRef imageRef = CGImageCreate(width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
NSImage* img = [[NSImage alloc] initWithData: [[[NSBitmapImageRep alloc] initWithCGImage: imageRef] TIFFRepresentation]];
free(buffer);
free(buffer2);
CFRelease(imageRef);
CFRelease(colorSpaceRef);
apologies for all the side scrolling you would have to do to give me an idea of what i'm doing wrong.
if this code that i've stated is correct and there is no reason for it to continuously take up memory when it shouldn't be then the problem must be somewhere else
please tell me what i've done is wrong