avcapture: fix video resolutions mismatches
@@ -103,9 +103,10 @@ static void vidframe_set_pixbuf(struct vidframe *f, const CVImageBufferRef b)
struct vidsz sz;
NSString * const * preset;
} mapv[] = {
- {{ 192, 144}, &AVCaptureSessionPresetLow },
- {{ 480, 360}, &AVCaptureSessionPresetMedium },
- {{ 640, 480}, &AVCaptureSessionPresetHigh },
+ {{ 320 ,240}, &AVCaptureSessionPreset320x240 },
+ {{ 352, 288}, &AVCaptureSessionPreset352x288 },
+ {{ 640, 480}, &AVCaptureSessionPreset640x480 },
+ {{ 960, 540}, &AVCaptureSessionPreset960x540 },
{{1280, 720}, &AVCaptureSessionPreset1280x720}
};
int i, best = -1;
@@ -118,9 +119,8 @@ static void vidframe_set_pixbuf(struct vidframe *f, const CVImageBufferRef b)
![dev supportsAVCaptureSessionPreset:preset])
continue;
- if (mapv[i].sz.w >= sz->w && mapv[i].sz.h >= sz->h)
best = i;
- else
+ if (mapv[i].sz.w <= sz->w && mapv[i].sz.h <= sz->h)
break;
}
@@ -128,7 +128,7 @@ static void vidframe_set_pixbuf(struct vidframe *f, const CVImageBufferRef b)
return *mapv[best].preset;
else {
NSLog(@"no suitable preset found for %d x %d", sz->w, sz->h);
- return AVCaptureSessionPresetHigh;
+ return AVCaptureSessionPreset352x288;
}
}
