static int flag =0;
FILE*fp;
static void dumpYuvPixelBuffer(CVPixelBufferRefpixelBuffer) {
if(flag<10) {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString*documentsDirectory = [pathsobjectAtIndex:0];
NSString*filePath = [documentsDirectorystringByAppendingPathComponent:@"/hdrinput.yuv"];
if(flag==0) {
fp=fopen([filePathUTF8String],"wb+");
}
CVPixelBufferLockBaseAddress(pixelBuffer, 0);
size_tcount =CVPixelBufferGetPlaneCount(pixelBuffer);
// NSMutableData *data = [NSMutableData data];
for(inti =0; i < count; i++) {
size_twidth =CVPixelBufferGetWidthOfPlane(pixelBuffer, i);
size_theight =CVPixelBufferGetHeightOfPlane(pixelBuffer, i);
size_tbytesPerRow =CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, i);
void* buf =CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, i);
// NSData *Data = [NSData dataWithBytes:buf length:bytesPerRow * height];
fwrite(buf,1, bytesPerRow * height,fp);
fflush(fp);
// [data appendData:Data];
}
// [data writeToFile:filePath atomically:YES];
CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
flag+=1;
}
}