mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 16:06:59 +00:00
Camera and editor improvements
This commit is contained in:
parent
e9228cb9fa
commit
59467108e1
@ -76,10 +76,11 @@ private final class CameraContext {
|
||||
self.output.configureVideoStabilization()
|
||||
}
|
||||
|
||||
self.output.processSampleBuffer = { [weak self] pixelBuffer, connection in
|
||||
self.output.processSampleBuffer = { [weak self] sampleBuffer, pixelBuffer, connection in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
self.previewNode?.enqueue(sampleBuffer)
|
||||
|
||||
let timestamp = CACurrentMediaTime()
|
||||
if timestamp > self.lastSnapshotTimestamp + 2.5 {
|
||||
|
@ -61,7 +61,7 @@ final class CameraOutput: NSObject {
|
||||
var activeFilter: CameraFilter?
|
||||
var faceLandmarks: Bool = false
|
||||
|
||||
var processSampleBuffer: ((CVImageBuffer, AVCaptureConnection) -> Void)?
|
||||
var processSampleBuffer: ((CMSampleBuffer, CVImageBuffer, AVCaptureConnection) -> Void)?
|
||||
var processCodes: (([CameraCode]) -> Void)?
|
||||
var processFaceLandmarks: (([VNFaceObservation]) -> Void)?
|
||||
|
||||
@ -233,7 +233,7 @@ extension CameraOutput: AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureA
|
||||
}
|
||||
|
||||
if let videoPixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) {
|
||||
self.processSampleBuffer?(videoPixelBuffer, connection)
|
||||
self.processSampleBuffer?(sampleBuffer, videoPixelBuffer, connection)
|
||||
}
|
||||
|
||||
// let finalSampleBuffer: CMSampleBuffer = sampleBuffer
|
||||
|
@ -505,7 +505,7 @@ public final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelega
|
||||
|
||||
if strongSelf.shouldAnimateDisappearance {
|
||||
let displayNode = topTransition.previous.value.displayNode
|
||||
displayNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, completion: { [weak displayNode] _ in
|
||||
displayNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak displayNode] _ in
|
||||
displayNode?.removeFromSupernode()
|
||||
})
|
||||
} else {
|
||||
|
@ -513,7 +513,7 @@ private final class QrCodeScanScreenNode: ViewControllerTracingNode, UIScrollVie
|
||||
self.errorTextNode.textAlignment = .center
|
||||
self.errorTextNode.isHidden = true
|
||||
|
||||
self.camera = Camera(configuration: .init(preset: .hd1920x1080, position: .back, audio: false, photo: true, metadata: false, preferredFps: 60))
|
||||
self.camera = Camera(configuration: .init(preset: .hd1920x1080, position: .back, audio: false, photo: true, metadata: true, preferredFps: 60))
|
||||
|
||||
super.init()
|
||||
|
||||
|
@ -4,31 +4,27 @@
|
||||
|
||||
using namespace metal;
|
||||
|
||||
static inline
|
||||
float sRGB_nonLinearNormToLinear(float normV)
|
||||
{
|
||||
if (normV <= 0.04045f) {
|
||||
normV *= (1.0f / 12.92f);
|
||||
} else {
|
||||
const float a = 0.055f;
|
||||
const float gamma = 2.4f;
|
||||
//const float gamma = 1.0f / (1.0f / 2.4f);
|
||||
normV = (normV + a) * (1.0f / (1.0f + a));
|
||||
normV = pow(normV, gamma);
|
||||
}
|
||||
|
||||
return normV;
|
||||
static inline float sRGBnonLinearNormToLinear(float normV) {
|
||||
if (normV <= 0.04045f) {
|
||||
normV *= (1.0f / 12.92f);
|
||||
} else {
|
||||
const float a = 0.055f;
|
||||
const float gamma = 2.4f;
|
||||
normV = (normV + a) * (1.0f / (1.0f + a));
|
||||
normV = pow(normV, gamma);
|
||||
}
|
||||
return normV;
|
||||
}
|
||||
|
||||
static inline
|
||||
float4 sRGB_gamma_decode(const float4 rgba) {
|
||||
rgba.r = sRGB_nonLinearNormToLinear(rgba.r);
|
||||
rgba.g = sRGB_nonLinearNormToLinear(rgba.g);
|
||||
rgba.b = sRGB_nonLinearNormToLinear(rgba.b);
|
||||
return rgba;
|
||||
static inline float4 sRGBGammaDecode(const float4 rgba) {
|
||||
float4 result = rgba;
|
||||
result.r = sRGBnonLinearNormToLinear(rgba.r);
|
||||
result.g = sRGBnonLinearNormToLinear(rgba.g);
|
||||
result.b = sRGBnonLinearNormToLinear(rgba.b);
|
||||
return rgba;
|
||||
}
|
||||
|
||||
static inline float4 BT709_decode(const float Y, const float Cb, const float Cr) {
|
||||
static inline float4 BT709Decode(const float Y, const float Cb, const float Cr) {
|
||||
float Yn = Y;
|
||||
|
||||
float Cbn = (Cb - (128.0f/255.0f));
|
||||
@ -60,8 +56,8 @@ fragment float4 bt709ToRGBFragmentShader(RasterizerData in [[stage_in]],
|
||||
float Cb = float(uvSamples[0]);
|
||||
float Cr = float(uvSamples[1]);
|
||||
|
||||
float4 pixel = BT709_decode(Y, Cb, Cr);
|
||||
pixel = sRGB_gamma_decode(pixel);
|
||||
float4 pixel = BT709Decode(Y, Cb, Cr);
|
||||
pixel = sRGBGammaDecode(pixel);
|
||||
pixel.rgb = pow(pixel.rgb, 1.0 / 2.2);
|
||||
return pixel;
|
||||
}
|
||||
|
@ -1704,6 +1704,7 @@ public final class MediaEditorScreen: ViewController {
|
||||
}
|
||||
self.isDismissed = true
|
||||
controller.statusBar.statusBarStyle = .Ignore
|
||||
self.isUserInteractionEnabled = false
|
||||
|
||||
let previousDimAlpha = self.backgroundDimView.alpha
|
||||
self.backgroundDimView.alpha = 0.0
|
||||
|
12
submodules/TelegramUI/Images.xcassets/Camera/DualIcon.imageset/Contents.json
vendored
Normal file
12
submodules/TelegramUI/Images.xcassets/Camera/DualIcon.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"filename" : "Frame 122.pdf",
|
||||
"idiom" : "universal"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
271
submodules/TelegramUI/Images.xcassets/Camera/DualIcon.imageset/Frame 122.pdf
vendored
Normal file
271
submodules/TelegramUI/Images.xcassets/Camera/DualIcon.imageset/Frame 122.pdf
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
%PDF-1.7
|
||||
|
||||
1 0 obj
|
||||
<< /Type /XObject
|
||||
/Length 2 0 R
|
||||
/Group << /Type /Group
|
||||
/S /Transparency
|
||||
>>
|
||||
/Subtype /Form
|
||||
/Resources << >>
|
||||
/BBox [ 0.000000 0.000000 40.000000 40.000000 ]
|
||||
>>
|
||||
stream
|
||||
/DeviceRGB CS
|
||||
/DeviceRGB cs
|
||||
q
|
||||
1.000000 0.000000 -0.000000 1.000000 13.998047 10.339355 cm
|
||||
1.000000 1.000000 1.000000 scn
|
||||
11.170002 10.660645 m
|
||||
11.170002 10.202249 11.541606 9.830645 12.000002 9.830645 c
|
||||
12.458398 9.830645 12.830002 10.202249 12.830002 10.660645 c
|
||||
11.170002 10.660645 l
|
||||
h
|
||||
3.001953 0.830645 m
|
||||
3.460350 0.830645 3.831953 1.202248 3.831953 1.660645 c
|
||||
3.831953 2.119041 3.460350 2.490644 3.001953 2.490644 c
|
||||
3.001953 0.830645 l
|
||||
h
|
||||
2.998467 1.660645 m
|
||||
2.998891 2.490644 l
|
||||
2.998467 1.660645 l
|
||||
h
|
||||
10.361974 19.333664 m
|
||||
10.738786 20.073200 l
|
||||
10.361974 19.333664 l
|
||||
h
|
||||
11.673021 18.022615 m
|
||||
12.412557 18.399427 l
|
||||
12.412557 18.399427 l
|
||||
11.673021 18.022615 l
|
||||
h
|
||||
4.800001 18.830645 m
|
||||
7.200001 18.830645 l
|
||||
7.200001 20.490644 l
|
||||
4.800001 20.490644 l
|
||||
4.800001 18.830645 l
|
||||
h
|
||||
0.830000 4.662598 m
|
||||
0.830000 14.860643 l
|
||||
-0.830000 14.860643 l
|
||||
-0.830000 4.662598 l
|
||||
0.830000 4.662598 l
|
||||
h
|
||||
11.170002 14.860643 m
|
||||
11.170002 10.660645 l
|
||||
12.830002 10.660645 l
|
||||
12.830002 14.860643 l
|
||||
11.170002 14.860643 l
|
||||
h
|
||||
-0.830000 4.662598 m
|
||||
-0.830000 4.660887 -0.830000 4.659719 -0.830000 4.658687 c
|
||||
0.830000 4.659535 l
|
||||
0.830000 4.660037 0.830000 4.660682 0.830000 4.662598 c
|
||||
-0.830000 4.662598 l
|
||||
h
|
||||
3.001953 2.490644 m
|
||||
3.000037 2.490644 2.999392 2.490644 2.998891 2.490644 c
|
||||
2.998042 0.830645 l
|
||||
2.999075 0.830645 3.000243 0.830645 3.001953 0.830645 c
|
||||
3.001953 2.490644 l
|
||||
h
|
||||
-0.830000 4.658687 m
|
||||
-0.828919 2.544966 0.884321 0.831726 2.998042 0.830645 c
|
||||
2.998891 2.490644 l
|
||||
1.801299 2.491257 0.830612 3.461945 0.830000 4.659535 c
|
||||
-0.830000 4.658687 l
|
||||
h
|
||||
7.200001 18.830645 m
|
||||
8.053776 18.830645 8.644189 18.830000 9.102807 18.792528 c
|
||||
9.551736 18.755850 9.800802 18.688065 9.985161 18.594128 c
|
||||
10.738786 20.073200 l
|
||||
10.281409 20.306244 9.789569 20.401949 9.237984 20.447016 c
|
||||
8.696089 20.491289 8.026384 20.490644 7.200001 20.490644 c
|
||||
7.200001 18.830645 l
|
||||
h
|
||||
12.830002 14.860643 m
|
||||
12.830002 15.687027 12.830647 16.356731 12.786373 16.898626 c
|
||||
12.741306 17.450211 12.645601 17.942053 12.412557 18.399427 c
|
||||
10.933486 17.645803 l
|
||||
11.027422 17.461445 11.095207 17.212378 11.131886 16.763451 c
|
||||
11.169356 16.304832 11.170002 15.714418 11.170002 14.860643 c
|
||||
12.830002 14.860643 l
|
||||
h
|
||||
9.985161 18.594128 m
|
||||
10.393473 18.386084 10.725441 18.054115 10.933486 17.645803 c
|
||||
12.412557 18.399427 l
|
||||
12.045362 19.120089 11.459446 19.706005 10.738786 20.073200 c
|
||||
9.985161 18.594128 l
|
||||
h
|
||||
4.800001 20.490644 m
|
||||
3.973618 20.490644 3.303913 20.491289 2.762018 20.447016 c
|
||||
2.210433 20.401949 1.718593 20.306244 1.261216 20.073200 c
|
||||
2.014841 18.594128 l
|
||||
2.199200 18.688065 2.448266 18.755850 2.897195 18.792528 c
|
||||
3.355813 18.830000 3.946226 18.830645 4.800001 18.830645 c
|
||||
4.800001 20.490644 l
|
||||
h
|
||||
0.830000 14.860643 m
|
||||
0.830000 15.714418 0.830646 16.304832 0.868116 16.763451 c
|
||||
0.904795 17.212378 0.972580 17.461445 1.066516 17.645803 c
|
||||
-0.412555 18.399427 l
|
||||
-0.645600 17.942053 -0.741305 17.450211 -0.786371 16.898626 c
|
||||
-0.830646 16.356731 -0.830000 15.687027 -0.830000 14.860643 c
|
||||
0.830000 14.860643 l
|
||||
h
|
||||
1.261216 20.073200 m
|
||||
0.540556 19.706005 -0.045360 19.120089 -0.412555 18.399427 c
|
||||
1.066516 17.645803 l
|
||||
1.274561 18.054115 1.606529 18.386084 2.014841 18.594128 c
|
||||
1.261216 20.073200 l
|
||||
h
|
||||
f
|
||||
n
|
||||
Q
|
||||
q
|
||||
1.000000 0.000000 -0.000000 1.000000 20.000000 8.340000 cm
|
||||
1.000000 1.000000 1.000000 scn
|
||||
7.170000 5.660000 m
|
||||
7.170000 3.909257 5.750742 2.490000 4.000000 2.490000 c
|
||||
4.000000 0.830000 l
|
||||
6.667535 0.830000 8.830000 2.992465 8.830000 5.660000 c
|
||||
7.170000 5.660000 l
|
||||
h
|
||||
4.000000 2.490000 m
|
||||
2.249257 2.490000 0.830000 3.909257 0.830000 5.660000 c
|
||||
-0.830000 5.660000 l
|
||||
-0.830000 2.992465 1.332465 0.830000 4.000000 0.830000 c
|
||||
4.000000 2.490000 l
|
||||
h
|
||||
0.830000 5.660000 m
|
||||
0.830000 7.410743 2.249257 8.830000 4.000000 8.830000 c
|
||||
4.000000 10.490000 l
|
||||
1.332465 10.490000 -0.830000 8.327536 -0.830000 5.660000 c
|
||||
0.830000 5.660000 l
|
||||
h
|
||||
4.000000 8.830000 m
|
||||
5.750742 8.830000 7.170000 7.410743 7.170000 5.660000 c
|
||||
8.830000 5.660000 l
|
||||
8.830000 8.327536 6.667535 10.490000 4.000000 10.490000 c
|
||||
4.000000 8.830000 l
|
||||
h
|
||||
f
|
||||
n
|
||||
Q
|
||||
|
||||
endstream
|
||||
endobj
|
||||
|
||||
2 0 obj
|
||||
3928
|
||||
endobj
|
||||
|
||||
3 0 obj
|
||||
<< /Type /XObject
|
||||
/Length 4 0 R
|
||||
/Group << /Type /Group
|
||||
/S /Transparency
|
||||
>>
|
||||
/Subtype /Form
|
||||
/Resources << >>
|
||||
/BBox [ 0.000000 0.000000 40.000000 40.000000 ]
|
||||
>>
|
||||
stream
|
||||
/DeviceRGB CS
|
||||
/DeviceRGB cs
|
||||
q
|
||||
1.000000 0.000000 -0.000000 1.000000 4.000000 5.000000 cm
|
||||
0.000000 0.000000 0.000000 scn
|
||||
0.000000 16.000000 m
|
||||
0.000000 24.836555 7.163444 32.000000 16.000000 32.000000 c
|
||||
16.000000 32.000000 l
|
||||
24.836555 32.000000 32.000000 24.836555 32.000000 16.000000 c
|
||||
32.000000 16.000000 l
|
||||
32.000000 7.163445 24.836555 0.000000 16.000000 0.000000 c
|
||||
16.000000 0.000000 l
|
||||
7.163444 0.000000 0.000000 7.163445 0.000000 16.000000 c
|
||||
0.000000 16.000000 l
|
||||
h
|
||||
f
|
||||
n
|
||||
Q
|
||||
|
||||
endstream
|
||||
endobj
|
||||
|
||||
4 0 obj
|
||||
472
|
||||
endobj
|
||||
|
||||
5 0 obj
|
||||
<< /XObject << /X1 1 0 R >>
|
||||
/ExtGState << /E1 << /SMask << /Type /Mask
|
||||
/G 3 0 R
|
||||
/S /Alpha
|
||||
>>
|
||||
/Type /ExtGState
|
||||
>> >>
|
||||
>>
|
||||
endobj
|
||||
|
||||
6 0 obj
|
||||
<< /Length 7 0 R >>
|
||||
stream
|
||||
/DeviceRGB CS
|
||||
/DeviceRGB cs
|
||||
q
|
||||
/E1 gs
|
||||
/X1 Do
|
||||
Q
|
||||
|
||||
endstream
|
||||
endobj
|
||||
|
||||
7 0 obj
|
||||
46
|
||||
endobj
|
||||
|
||||
8 0 obj
|
||||
<< /Annots []
|
||||
/Type /Page
|
||||
/MediaBox [ 0.000000 0.000000 40.000000 40.000000 ]
|
||||
/Resources 5 0 R
|
||||
/Contents 6 0 R
|
||||
/Parent 9 0 R
|
||||
>>
|
||||
endobj
|
||||
|
||||
9 0 obj
|
||||
<< /Kids [ 8 0 R ]
|
||||
/Count 1
|
||||
/Type /Pages
|
||||
>>
|
||||
endobj
|
||||
|
||||
10 0 obj
|
||||
<< /Pages 9 0 R
|
||||
/Type /Catalog
|
||||
>>
|
||||
endobj
|
||||
|
||||
xref
|
||||
0 11
|
||||
0000000000 65535 f
|
||||
0000000010 00000 n
|
||||
0000004186 00000 n
|
||||
0000004209 00000 n
|
||||
0000004929 00000 n
|
||||
0000004951 00000 n
|
||||
0000005249 00000 n
|
||||
0000005351 00000 n
|
||||
0000005372 00000 n
|
||||
0000005545 00000 n
|
||||
0000005619 00000 n
|
||||
trailer
|
||||
<< /ID [ (some) (id) ]
|
||||
/Root 10 0 R
|
||||
/Size 11
|
||||
>>
|
||||
startxref
|
||||
5679
|
||||
%%EOF
|
Loading…
x
Reference in New Issue
Block a user