Skip to content

Commit 63dea13

Browse files
committed
Switch to hardware zoom
1 parent 25229bb commit 63dea13

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

videocore/api/iOS/VCSimpleSession.mm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,12 @@ - (void) setVideoZoomFactor:(float)videoZoomFactor
289289
{
290290
_videoZoomFactor = videoZoomFactor;
291291
if(m_positionTransform) {
292-
// We could use AVCaptureConnection's zoom factor, but in reality it's
293-
// doing the exact same thing as this (in terms of the algorithm used),
294-
// but it is not clear how CoreVideo accomplishes it.
295-
// In this case this is just modifying the matrix
296-
// multiplication that is already happening once per frame.
297-
m_positionTransform->setSize(self.videoSize.width * videoZoomFactor,
298-
self.videoSize.height * videoZoomFactor);
292+
// Switched to Hardware zoom to better support iPhone 7 Plus
293+
m_cameraSource->setVideoZoomFactor(MAX(1.0, MIN(videoZoomFactor, 6.4)));
294+
295+
// Original VideoCore code:
296+
//m_positionTransform->setSize(self.videoSize.width * videoZoomFactor,
297+
// self.videoSize.height * videoZoomFactor);
299298
}
300299
}
301300
- (void) setAudioChannelCount:(int)channelCount

videocore/sources/iOS/CameraSource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ namespace videocore { namespace iOS {
114114

115115
bool setContinuousExposure(bool wantsContinuous);
116116

117+
bool setVideoZoomFactor(float zoomFactor);
117118

118119
public:
119120
/*! Used by Objective-C Capture Session */

videocore/sources/iOS/CameraSource.mm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,5 +503,17 @@ - (void) orientationChanged: (NSNotification*) notification
503503
return ret;
504504
}
505505

506+
bool
507+
CameraSource::setVideoZoomFactor(float zoomFactor) {
508+
AVCaptureDevice* device = (AVCaptureDevice*)m_captureDevice;
509+
NSError* err = nil;
510+
if([device lockForConfiguration:&err]) {
511+
device.videoZoomFactor = zoomFactor;
512+
return YES;
513+
} else {
514+
return NO;
515+
}
516+
}
517+
506518
}
507519
}

0 commit comments

Comments
 (0)