mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
commit
f55410d4d3
@ -115,7 +115,7 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func decode(frame: MediaTrackDecodableFrame, ptsOffset: CMTime?) -> MediaTrackFrame? {
|
public func decode(frame: MediaTrackDecodableFrame, ptsOffset: CMTime?, forceARGB: Bool = false) -> MediaTrackFrame? {
|
||||||
let status = frame.packet.send(toDecoder: self.codecContext)
|
let status = frame.packet.send(toDecoder: self.codecContext)
|
||||||
if status == 0 {
|
if status == 0 {
|
||||||
self.defaultDuration = frame.duration
|
self.defaultDuration = frame.duration
|
||||||
@ -126,7 +126,7 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
if let ptsOffset = ptsOffset {
|
if let ptsOffset = ptsOffset {
|
||||||
pts = CMTimeAdd(pts, ptsOffset)
|
pts = CMTimeAdd(pts, ptsOffset)
|
||||||
}
|
}
|
||||||
return convertVideoFrame(self.videoFrame, pts: pts, dts: pts, duration: frame.duration)
|
return convertVideoFrame(self.videoFrame, pts: pts, dts: pts, duration: frame.duration, forceARGB: forceARGB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
return UIImage(cgImage: image, scale: 1.0, orientation: .up)
|
return UIImage(cgImage: image, scale: 1.0, orientation: .up)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func convertVideoFrame(_ frame: FFMpegAVFrame, pts: CMTime, dts: CMTime, duration: CMTime) -> MediaTrackFrame? {
|
private func convertVideoFrame(_ frame: FFMpegAVFrame, pts: CMTime, dts: CMTime, duration: CMTime, forceARGB: Bool = false) -> MediaTrackFrame? {
|
||||||
if frame.data[0] == nil {
|
if frame.data[0] == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -247,14 +247,27 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
var pixelBufferRef: CVPixelBuffer?
|
var pixelBufferRef: CVPixelBuffer?
|
||||||
|
|
||||||
let pixelFormat: OSType
|
let pixelFormat: OSType
|
||||||
|
var hasAlpha = false
|
||||||
|
if forceARGB {
|
||||||
|
pixelFormat = kCVPixelFormatType_32ARGB
|
||||||
|
switch frame.pixelFormat {
|
||||||
|
case .YUV:
|
||||||
|
hasAlpha = false
|
||||||
|
case .YUVA:
|
||||||
|
hasAlpha = true
|
||||||
|
default:
|
||||||
|
hasAlpha = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
switch frame.pixelFormat {
|
switch frame.pixelFormat {
|
||||||
case .YUV:
|
case .YUV:
|
||||||
pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
|
pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
|
||||||
case .YUVA:
|
case .YUVA:
|
||||||
pixelFormat = kCVPixelFormatType_32ARGB
|
pixelFormat = kCVPixelFormatType_420YpCbCr8VideoRange_8A_TriPlanar
|
||||||
default:
|
default:
|
||||||
pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
|
pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let pixelBufferPool = self.pixelBufferPool {
|
if let pixelBufferPool = self.pixelBufferPool {
|
||||||
let auxAttributes: [String: Any] = [kCVPixelBufferPoolAllocationThresholdKey as String: bufferCount as NSNumber];
|
let auxAttributes: [String: Any] = [kCVPixelBufferPoolAllocationThresholdKey as String: bufferCount as NSNumber];
|
||||||
@ -290,7 +303,7 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
var base: UnsafeMutableRawPointer
|
var base: UnsafeMutableRawPointer
|
||||||
if pixelFormat == kCVPixelFormatType_32ARGB {
|
if pixelFormat == kCVPixelFormatType_32ARGB {
|
||||||
let bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer)
|
let bytesPerRow = CVPixelBufferGetBytesPerRow(pixelBuffer)
|
||||||
decodeYUVAPlanesToRGBA(frame.data[0], Int32(frame.lineSize[0]), frame.data[1], Int32(frame.lineSize[1]), frame.data[2], Int32(frame.lineSize[2]), frame.data[3], CVPixelBufferGetBaseAddress(pixelBuffer)?.assumingMemoryBound(to: UInt8.self), Int32(frame.width), Int32(frame.height), Int32(bytesPerRow))
|
decodeYUVAPlanesToRGBA(frame.data[0], Int32(frame.lineSize[0]), frame.data[1], Int32(frame.lineSize[1]), frame.data[2], Int32(frame.lineSize[2]), hasAlpha, frame.data[3], CVPixelBufferGetBaseAddress(pixelBuffer)?.assumingMemoryBound(to: UInt8.self), Int32(frame.width), Int32(frame.height), Int32(bytesPerRow))
|
||||||
} else {
|
} else {
|
||||||
let srcPlaneSize = Int(frame.lineSize[1]) * Int(frame.height / 2)
|
let srcPlaneSize = Int(frame.lineSize[1]) * Int(frame.height / 2)
|
||||||
let uvPlaneSize = srcPlaneSize * 2
|
let uvPlaneSize = srcPlaneSize * 2
|
||||||
|
|||||||
@ -58,12 +58,16 @@ public final class SoftwareVideoSource {
|
|||||||
fileprivate let fd: Int32?
|
fileprivate let fd: Int32?
|
||||||
fileprivate let size: Int32
|
fileprivate let size: Int32
|
||||||
|
|
||||||
|
private let hintVP9: Bool
|
||||||
|
|
||||||
private var enqueuedFrames: [(MediaTrackFrame, CGFloat, CGFloat, Bool)] = []
|
private var enqueuedFrames: [(MediaTrackFrame, CGFloat, CGFloat, Bool)] = []
|
||||||
private var hasReadToEnd: Bool = false
|
private var hasReadToEnd: Bool = false
|
||||||
|
|
||||||
public init(path: String, hintVP9: Bool) {
|
public init(path: String, hintVP9: Bool) {
|
||||||
let _ = FFMpegMediaFrameSourceContextHelpers.registerFFMpegGlobals
|
let _ = FFMpegMediaFrameSourceContextHelpers.registerFFMpegGlobals
|
||||||
|
|
||||||
|
self.hintVP9 = hintVP9
|
||||||
|
|
||||||
var s = stat()
|
var s = stat()
|
||||||
stat(path, &s)
|
stat(path, &s)
|
||||||
self.size = Int32(s.st_size)
|
self.size = Int32(s.st_size)
|
||||||
@ -224,7 +228,7 @@ public final class SoftwareVideoSource {
|
|||||||
if let maxPts = maxPts, CMTimeCompare(decodableFrame.pts, maxPts) < 0 {
|
if let maxPts = maxPts, CMTimeCompare(decodableFrame.pts, maxPts) < 0 {
|
||||||
ptsOffset = maxPts
|
ptsOffset = maxPts
|
||||||
}
|
}
|
||||||
result = (videoStream.decoder.decode(frame: decodableFrame, ptsOffset: ptsOffset), CGFloat(videoStream.rotationAngle), CGFloat(videoStream.aspect), loop)
|
result = (videoStream.decoder.decode(frame: decodableFrame, ptsOffset: ptsOffset, forceARGB: self.hintVP9), CGFloat(videoStream.rotationAngle), CGFloat(videoStream.aspect), loop)
|
||||||
} else {
|
} else {
|
||||||
result = (nil, CGFloat(videoStream.rotationAngle), CGFloat(videoStream.aspect), loop)
|
result = (nil, CGFloat(videoStream.rotationAngle), CGFloat(videoStream.aspect), loop)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,7 +117,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
matchingRecentItemsIds.insert(file.fileId)
|
matchingRecentItemsIds.insert(file.fileId)
|
||||||
}
|
}
|
||||||
recentItemsIds.insert(file.fileId)
|
recentItemsIds.insert(file.fileId)
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
recentAnimatedItems.append(file)
|
recentAnimatedItems.append(file)
|
||||||
} else {
|
} else {
|
||||||
recentItems.append(file)
|
recentItems.append(file)
|
||||||
@ -147,7 +147,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !recentItemsIds.contains(item.file.fileId) {
|
if !recentItemsIds.contains(item.file.fileId) {
|
||||||
if item.file.isAnimatedSticker {
|
if item.file.isAnimatedSticker || item.file.isVideoSticker {
|
||||||
installedAnimatedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
installedAnimatedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
||||||
} else {
|
} else {
|
||||||
installedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
installedItems.append(FoundStickerItem(file: item.file, stringRepresentations: stringRepresentations))
|
||||||
@ -199,7 +199,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
|
|
||||||
for file in cached.items {
|
for file in cached.items {
|
||||||
if !currentItemIds.contains(file.fileId) {
|
if !currentItemIds.contains(file.fileId) {
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
cachedAnimatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
cachedAnimatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
} else {
|
} else {
|
||||||
cachedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
cachedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
@ -230,7 +230,7 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic
|
|||||||
if let file = telegramMediaFileFromApiDocument(sticker), let id = file.id {
|
if let file = telegramMediaFileFromApiDocument(sticker), let id = file.id {
|
||||||
files.append(file)
|
files.append(file)
|
||||||
if !currentItemIds.contains(id) {
|
if !currentItemIds.contains(id) {
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
animatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
animatedItems.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
} else {
|
} else {
|
||||||
items.append(FoundStickerItem(file: file, stringRepresentations: []))
|
items.append(FoundStickerItem(file: file, stringRepresentations: []))
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
{
|
|
||||||
"images" : [
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"scale" : "1x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"filename" : "ReplyReaction@2x.png",
|
|
||||||
"scale" : "2x"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"idiom" : "universal",
|
|
||||||
"filename" : "ReplyReaction@3x.png",
|
|
||||||
"scale" : "3x"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"info" : {
|
|
||||||
"version" : 1,
|
|
||||||
"author" : "xcode"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
@ -34,98 +34,31 @@ f
|
|||||||
n
|
n
|
||||||
Q
|
Q
|
||||||
q
|
q
|
||||||
1.000000 0.000000 -0.000000 1.000000 5.000000 5.523438 cm
|
1.000000 0.000000 -0.000000 1.000000 6.000000 6.409872 cm
|
||||||
1.000000 1.000000 1.000000 scn
|
1.000000 1.000000 1.000000 scn
|
||||||
7.132812 18.054688 m
|
8.990343 0.000000 m
|
||||||
7.234375 18.054688 7.312500 18.117188 7.335938 18.226562 c
|
9.086910 0.000000 9.189914 0.022533 9.299356 0.067596 c
|
||||||
7.523438 19.359375 7.523438 19.359375 8.664062 19.570312 c
|
9.415236 0.112661 9.521460 0.167383 9.618026 0.231760 c
|
||||||
8.781250 19.593750 8.851562 19.664062 8.851562 19.765625 c
|
11.311159 1.319743 12.785408 2.459228 14.040772 3.650215 c
|
||||||
8.851562 19.875000 8.781250 19.937500 8.671875 19.968750 c
|
15.296137 4.847639 16.268240 6.074035 16.957081 7.329399 c
|
||||||
7.515625 20.195312 7.539062 20.195312 7.335938 21.304688 c
|
17.652361 8.584764 18.000000 9.856222 18.000000 11.143776 c
|
||||||
7.312500 21.414062 7.242188 21.476562 7.132812 21.476562 c
|
18.000000 11.942060 17.871244 12.672747 17.613733 13.335836 c
|
||||||
7.031250 21.476562 6.953125 21.406250 6.937500 21.304688 c
|
17.356224 13.998926 16.998926 14.575107 16.541845 15.064377 c
|
||||||
6.726562 20.179688 6.750000 20.171875 5.601562 19.968750 c
|
16.084764 15.553647 15.550429 15.930257 14.938841 16.194204 c
|
||||||
5.484375 19.945312 5.414062 19.867188 5.414062 19.765625 c
|
14.327253 16.458153 13.664163 16.590128 12.949571 16.590128 c
|
||||||
5.414062 19.671875 5.484375 19.593750 5.593750 19.570312 c
|
12.074035 16.590128 11.295064 16.364805 10.612661 15.914163 c
|
||||||
6.750000 19.343750 6.742188 19.351562 6.937500 18.226562 c
|
9.936695 15.463518 9.395923 14.861588 8.990343 14.108368 c
|
||||||
6.953125 18.125000 7.031250 18.054688 7.132812 18.054688 c
|
8.597639 14.855149 8.056867 15.453862 7.368026 15.904506 c
|
||||||
h
|
6.685622 16.361588 5.909871 16.590128 5.040772 16.590128 c
|
||||||
12.695312 15.976562 m
|
4.326180 16.590128 3.659871 16.458153 3.041846 16.194204 c
|
||||||
12.843750 15.976562 12.960938 16.078125 12.968750 16.242188 c
|
2.430258 15.930257 1.895923 15.553647 1.438841 15.064377 c
|
||||||
13.187500 18.023438 13.265625 18.078125 15.085938 18.367188 c
|
0.988197 14.575107 0.634120 13.998926 0.376609 13.335836 c
|
||||||
15.265625 18.382812 15.359375 18.484375 15.359375 18.640625 c
|
0.125536 12.672747 0.000000 11.942060 0.000000 11.143776 c
|
||||||
15.359375 18.781250 15.265625 18.882812 15.125000 18.906250 c
|
0.000000 9.856222 0.344421 8.584764 1.033262 7.329399 c
|
||||||
13.273438 19.273438 13.187500 19.250000 12.968750 21.031250 c
|
1.722103 6.074035 2.694206 4.847639 3.949571 3.650215 c
|
||||||
12.960938 21.187500 12.843750 21.289062 12.695312 21.289062 c
|
5.204936 2.459228 6.679184 1.319743 8.372317 0.231760 c
|
||||||
12.554688 21.289062 12.445312 21.187500 12.429688 21.039062 c
|
8.468884 0.167383 8.571888 0.112661 8.681331 0.067596 c
|
||||||
12.195312 19.218750 12.148438 19.164062 10.281250 18.906250 c
|
8.797211 0.022533 8.900214 0.000000 8.990343 0.000000 c
|
||||||
10.140625 18.890625 10.039062 18.781250 10.039062 18.640625 c
|
|
||||||
10.039062 18.492188 10.140625 18.390625 10.281250 18.367188 c
|
|
||||||
12.148438 17.992188 12.187500 18.007812 12.429688 16.218750 c
|
|
||||||
12.445312 16.078125 12.554688 15.976562 12.695312 15.976562 c
|
|
||||||
h
|
|
||||||
6.531250 2.656250 m
|
|
||||||
9.039062 0.148438 12.257812 0.359375 14.531250 2.640625 c
|
|
||||||
16.179688 4.281250 16.617188 6.031250 16.078125 8.109375 c
|
|
||||||
15.789062 9.585938 14.906250 11.281250 14.250000 12.523438 c
|
|
||||||
13.867188 13.257812 13.398438 14.210938 13.117188 14.546875 c
|
|
||||||
12.804688 14.937500 12.320312 14.984375 11.945312 14.671875 c
|
|
||||||
11.507812 14.320312 11.476562 13.835938 11.726562 13.125000 c
|
|
||||||
12.640625 10.656250 l
|
|
||||||
12.726562 10.437500 12.710938 10.304688 12.625000 10.226562 c
|
|
||||||
12.531250 10.132812 12.414062 10.117188 12.234375 10.289062 c
|
|
||||||
6.367188 16.164062 l
|
|
||||||
5.992188 16.539062 5.406250 16.539062 5.031250 16.164062 c
|
|
||||||
4.664062 15.789062 4.664062 15.203125 5.039062 14.828125 c
|
|
||||||
9.351562 10.515625 l
|
|
||||||
9.171875 10.421875 8.976562 10.320312 8.789062 10.195312 c
|
|
||||||
3.820312 15.164062 l
|
|
||||||
3.445312 15.539062 2.859375 15.539062 2.484375 15.164062 c
|
|
||||||
2.109375 14.789062 2.109375 14.210938 2.484375 13.835938 c
|
|
||||||
7.398438 8.921875 l
|
|
||||||
7.257812 8.757812 7.125000 8.578125 7.000000 8.398438 c
|
|
||||||
2.484375 12.914062 l
|
|
||||||
2.109375 13.289062 1.523438 13.289062 1.148438 12.921875 c
|
|
||||||
0.773438 12.546875 0.781250 11.960938 1.148438 11.585938 c
|
|
||||||
6.046875 6.695312 l
|
|
||||||
5.960938 6.460938 5.898438 6.226562 5.843750 6.007812 c
|
|
||||||
2.429688 9.414062 l
|
|
||||||
2.054688 9.789062 1.476562 9.789062 1.101562 9.421875 c
|
|
||||||
0.726562 9.046875 0.726562 8.460938 1.101562 8.085938 c
|
|
||||||
6.531250 2.656250 l
|
|
||||||
h
|
|
||||||
10.773438 14.898438 m
|
|
||||||
9.507812 16.164062 l
|
|
||||||
9.125000 16.539062 8.539062 16.531250 8.171875 16.164062 c
|
|
||||||
8.148438 16.140625 8.132812 16.125000 8.117188 16.101562 c
|
|
||||||
10.585938 13.632812 l
|
|
||||||
10.570312 14.093750 10.625000 14.515625 10.773438 14.898438 c
|
|
||||||
h
|
|
||||||
17.664062 2.640625 m
|
|
||||||
19.312500 4.289062 19.750000 6.031250 19.218750 8.109375 c
|
|
||||||
18.921875 9.585938 18.046875 11.281250 17.382812 12.523438 c
|
|
||||||
17.007812 13.257812 16.531250 14.210938 16.250000 14.546875 c
|
|
||||||
15.937500 14.929688 15.460938 14.976562 15.078125 14.671875 c
|
|
||||||
14.906250 14.539062 14.789062 14.375000 14.734375 14.195312 c
|
|
||||||
14.953125 13.781250 15.171875 13.359375 15.390625 12.945312 c
|
|
||||||
16.023438 11.742188 16.953125 9.937500 17.242188 8.328125 c
|
|
||||||
17.867188 5.804688 17.257812 3.671875 15.375000 1.796875 c
|
|
||||||
15.031250 1.453125 14.671875 1.156250 14.304688 0.898438 c
|
|
||||||
15.507812 1.046875 16.687500 1.648438 17.664062 2.640625 c
|
|
||||||
h
|
|
||||||
2.304688 0.000000 m
|
|
||||||
2.437500 0.000000 2.523438 0.085938 2.539062 0.218750 c
|
|
||||||
2.804688 1.750000 2.796875 1.773438 4.390625 2.070312 c
|
|
||||||
4.531250 2.101562 4.617188 2.171875 4.617188 2.312500 c
|
|
||||||
4.617188 2.445312 4.531250 2.523438 4.398438 2.546875 c
|
|
||||||
2.796875 2.875000 2.820312 2.890625 2.539062 4.398438 c
|
|
||||||
2.523438 4.531250 2.437500 4.617188 2.304688 4.617188 c
|
|
||||||
2.171875 4.617188 2.093750 4.531250 2.062500 4.398438 c
|
|
||||||
1.781250 2.867188 1.820312 2.843750 0.218750 2.546875 c
|
|
||||||
0.085938 2.523438 0.000000 2.445312 0.000000 2.312500 c
|
|
||||||
0.000000 2.171875 0.078125 2.101562 0.210938 2.070312 c
|
|
||||||
1.820312 1.750000 1.796875 1.742188 2.062500 0.218750 c
|
|
||||||
2.093750 0.085938 2.171875 0.000000 2.304688 0.000000 c
|
|
||||||
h
|
h
|
||||||
f
|
f
|
||||||
n
|
n
|
||||||
@ -135,7 +68,7 @@ endstream
|
|||||||
endobj
|
endobj
|
||||||
|
|
||||||
3 0 obj
|
3 0 obj
|
||||||
5442
|
2356
|
||||||
endobj
|
endobj
|
||||||
|
|
||||||
4 0 obj
|
4 0 obj
|
||||||
@ -166,15 +99,15 @@ xref
|
|||||||
0000000000 65535 f
|
0000000000 65535 f
|
||||||
0000000010 00000 n
|
0000000010 00000 n
|
||||||
0000000034 00000 n
|
0000000034 00000 n
|
||||||
0000005532 00000 n
|
0000002446 00000 n
|
||||||
0000005555 00000 n
|
0000002469 00000 n
|
||||||
0000005728 00000 n
|
0000002642 00000 n
|
||||||
0000005802 00000 n
|
0000002716 00000 n
|
||||||
trailer
|
trailer
|
||||||
<< /ID [ (some) (id) ]
|
<< /ID [ (some) (id) ]
|
||||||
/Root 6 0 R
|
/Root 6 0 R
|
||||||
/Size 7
|
/Size 7
|
||||||
>>
|
>>
|
||||||
startxref
|
startxref
|
||||||
5861
|
2775
|
||||||
%%EOF
|
%%EOF
|
||||||
@ -440,7 +440,10 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
unboundSize = CGSize(width: floor(dimensions.cgSize.width * 0.5), height: floor(dimensions.cgSize.height * 0.5))
|
unboundSize = CGSize(width: floor(dimensions.cgSize.width * 0.5), height: floor(dimensions.cgSize.height * 0.5))
|
||||||
if file.isAnimated {
|
if file.isSticker || file.isAnimatedSticker || file.isVideoSticker {
|
||||||
|
unboundSize = unboundSize.aspectFilled(CGSize(width: 162.0, height: 162.0))
|
||||||
|
isSticker = true
|
||||||
|
} else if file.isAnimated {
|
||||||
unboundSize = unboundSize.aspectFilled(CGSize(width: 480.0, height: 480.0))
|
unboundSize = unboundSize.aspectFilled(CGSize(width: 480.0, height: 480.0))
|
||||||
} else if file.isVideo && !file.isAnimated, case let .constrained(constrainedSize) = sizeCalculation {
|
} else if file.isVideo && !file.isAnimated, case let .constrained(constrainedSize) = sizeCalculation {
|
||||||
if unboundSize.width > unboundSize.height {
|
if unboundSize.width > unboundSize.height {
|
||||||
@ -449,9 +452,6 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
maxDimensions = CGSize(width: constrainedSize.width, height: layoutConstants.video.maxVerticalHeight)
|
maxDimensions = CGSize(width: constrainedSize.width, height: layoutConstants.video.maxVerticalHeight)
|
||||||
}
|
}
|
||||||
maxHeight = maxDimensions.height
|
maxHeight = maxDimensions.height
|
||||||
} else if file.isSticker || file.isAnimatedSticker {
|
|
||||||
unboundSize = unboundSize.aspectFilled(CGSize(width: 162.0, height: 162.0))
|
|
||||||
isSticker = true
|
|
||||||
}
|
}
|
||||||
isInlinePlayableVideo = file.isVideo && !isSecretMedia
|
isInlinePlayableVideo = file.isVideo && !isSecretMedia
|
||||||
} else if let image = media as? TelegramMediaWebFile, let dimensions = image.dimensions {
|
} else if let image = media as? TelegramMediaWebFile, let dimensions = image.dimensions {
|
||||||
@ -712,7 +712,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
updateImageSignal = { synchronousLoad, _ in
|
updateImageSignal = { synchronousLoad, _ in
|
||||||
return chatMessageAnimatedSticker(postbox: context.account.postbox, file: file, small: false, size: dimensions.cgSize.aspectFitted(CGSize(width: 400.0, height: 400.0)))
|
return chatMessageAnimatedSticker(postbox: context.account.postbox, file: file, small: false, size: dimensions.cgSize.aspectFitted(CGSize(width: 400.0, height: 400.0)))
|
||||||
}
|
}
|
||||||
} else if file.isSticker {
|
} else if file.isSticker || file.isVideoSticker {
|
||||||
updateImageSignal = { synchronousLoad, _ in
|
updateImageSignal = { synchronousLoad, _ in
|
||||||
return chatMessageSticker(account: context.account, file: file, small: false)
|
return chatMessageSticker(account: context.account, file: file, small: false)
|
||||||
}
|
}
|
||||||
@ -729,7 +729,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
uploading = true
|
uploading = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.isVideo && !isSecretMedia && automaticPlayback && !uploading {
|
if file.isVideo && !file.isVideoSticker && !isSecretMedia && automaticPlayback && !uploading {
|
||||||
updateVideoFile = file
|
updateVideoFile = file
|
||||||
if hasCurrentVideoNode {
|
if hasCurrentVideoNode {
|
||||||
if let currentFile = currentMedia as? TelegramMediaFile {
|
if let currentFile = currentMedia as? TelegramMediaFile {
|
||||||
@ -751,7 +751,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
replaceVideoNode = false
|
replaceVideoNode = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if file.isAnimatedSticker {
|
if file.isAnimatedSticker || file.isVideoSticker {
|
||||||
updateAnimatedStickerFile = file
|
updateAnimatedStickerFile = file
|
||||||
if hasCurrentAnimatedStickerNode {
|
if hasCurrentAnimatedStickerNode {
|
||||||
if let currentMedia = currentMedia {
|
if let currentMedia = currentMedia {
|
||||||
@ -871,6 +871,8 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let arguments = TransformImageArguments(corners: corners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments)
|
let arguments = TransformImageArguments(corners: corners, imageSize: drawingSize, boundingSize: boundingSize, intrinsicInsets: UIEdgeInsets(), resizeMode: isInlinePlayableVideo ? .fill(.black) : .blurBackground, emptyColor: emptyColor, custom: patternArguments)
|
||||||
|
|
||||||
let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid
|
let imageFrame = CGRect(origin: CGPoint(x: -arguments.insets.left, y: -arguments.insets.top), size: arguments.drawingSize).ensuredValid
|
||||||
@ -1200,14 +1202,14 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
} else if let fetchStatus = self.fetchStatus {
|
} else if let fetchStatus = self.fetchStatus {
|
||||||
switch fetchStatus {
|
switch fetchStatus {
|
||||||
case .Local:
|
case .Local:
|
||||||
if let file = media as? TelegramMediaFile, file.isVideo {
|
if let file = media as? TelegramMediaFile, file.isVideo && !file.isVideoSticker {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if isSecretMedia {
|
} else if isSecretMedia {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if let webpage = webpage, case let .Loaded(content) = webpage.content {
|
} else if let webpage = webpage, case let .Loaded(content) = webpage.content {
|
||||||
if content.embedUrl != nil {
|
if content.embedUrl != nil {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
} else if let file = content.file, file.isVideo, !file.isAnimated {
|
} else if let file = content.file, file.isVideo, !file.isAnimated && !file.isVideoSticker {
|
||||||
progressRequired = true
|
progressRequired = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1335,7 +1337,10 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let file = self.media as? TelegramMediaFile {
|
if let file = self.media as? TelegramMediaFile {
|
||||||
if wideLayout {
|
if file.isVideoSticker {
|
||||||
|
state = .none
|
||||||
|
badgeContent = nil
|
||||||
|
} else if wideLayout {
|
||||||
if let size = file.size {
|
if let size = file.size {
|
||||||
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, formatting: formatting)) / \(dataSizeString(size, forceDecimal: true, formatting: formatting))"
|
let sizeString = "\(dataSizeString(Int(Float(size) * progress), forceDecimal: true, formatting: formatting)) / \(dataSizeString(size, forceDecimal: true, formatting: formatting))"
|
||||||
if let duration = file.duration, !message.flags.contains(.Unsent) {
|
if let duration = file.duration, !message.flags.contains(.Unsent) {
|
||||||
@ -1425,7 +1430,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
state = .secretTimeout(color: messageTheme.mediaOverlayControlColors.foregroundColor, icon: secretProgressIcon, beginTime: beginTime, timeout: timeout, sparks: true)
|
state = .secretTimeout(color: messageTheme.mediaOverlayControlColors.foregroundColor, icon: secretProgressIcon, beginTime: beginTime, timeout: timeout, sparks: true)
|
||||||
} else if isSecretMedia, let secretProgressIcon = secretProgressIcon {
|
} else if isSecretMedia, let secretProgressIcon = secretProgressIcon {
|
||||||
state = .customIcon(secretProgressIcon)
|
state = .customIcon(secretProgressIcon)
|
||||||
} else if let file = media as? TelegramMediaFile {
|
} else if let file = media as? TelegramMediaFile, !file.isVideoSticker {
|
||||||
let isInlinePlayableVideo = file.isVideo && !isSecretMedia && (self.automaticPlayback ?? false)
|
let isInlinePlayableVideo = file.isVideo && !isSecretMedia && (self.automaticPlayback ?? false)
|
||||||
if !isInlinePlayableVideo && file.isVideo {
|
if !isInlinePlayableVideo && file.isVideo {
|
||||||
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
@ -1439,13 +1444,13 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
|
|||||||
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .play(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let file = media as? TelegramMediaFile, let duration = file.duration {
|
if let file = media as? TelegramMediaFile, let duration = file.duration, !file.isVideoSticker {
|
||||||
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : duration, position: playerPosition)
|
||||||
badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
badgeContent = .mediaDownload(backgroundColor: messageTheme.mediaDateAndStatusFillColor, foregroundColor: messageTheme.mediaDateAndStatusTextColor, duration: durationString, size: nil, muted: muted, active: false)
|
||||||
}
|
}
|
||||||
case .Remote:
|
case .Remote:
|
||||||
state = .download(messageTheme.mediaOverlayControlColors.foregroundColor)
|
state = .download(messageTheme.mediaOverlayControlColors.foregroundColor)
|
||||||
if let file = self.media as? TelegramMediaFile {
|
if let file = self.media as? TelegramMediaFile, !file.isVideoSticker {
|
||||||
do {
|
do {
|
||||||
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
let durationString = file.isAnimated ? gifTitle : stringForDuration(playerDuration > 0 ? playerDuration : (file.duration ?? 0), position: playerPosition)
|
||||||
if wideLayout {
|
if wideLayout {
|
||||||
|
|||||||
@ -4,4 +4,4 @@ void encodeRGBAToYUVA(uint8_t *yuva, uint8_t const *argb, int width, int height,
|
|||||||
void resizeAndEncodeRGBAToYUVA(uint8_t *yuva, uint8_t const *argb, int width, int height, int bytesPerRow, int originalWidth, int originalHeight, int originalBytesPerRow);
|
void resizeAndEncodeRGBAToYUVA(uint8_t *yuva, uint8_t const *argb, int width, int height, int bytesPerRow, int originalWidth, int originalHeight, int originalBytesPerRow);
|
||||||
|
|
||||||
void decodeYUVAToRGBA(uint8_t const *yuva, uint8_t *argb, int width, int height, int bytesPerRow);
|
void decodeYUVAToRGBA(uint8_t const *yuva, uint8_t *argb, int width, int height, int bytesPerRow);
|
||||||
void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint8_t const *srcCbData, int srcCbBytesPerRow, uint8_t const *srcCrData, int srcCrBytesPerRow, uint8_t const *alphaData, uint8_t *argb, int width, int height, int bytesPerRow);
|
void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint8_t const *srcCbData, int srcCbBytesPerRow, uint8_t const *srcCrData, int srcCrBytesPerRow, bool hasAlpha, uint8_t const *alphaData, uint8_t *argb, int width, int height, int bytesPerRow);
|
||||||
|
|||||||
@ -169,7 +169,7 @@ void decodeYUVAToRGBA(uint8_t const *yuva, uint8_t *argb, int width, int height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint8_t const *srcCbData, int srcCbBytesPerRow, uint8_t const *srcCrData, int srcCrBytesPerRow, uint8_t const *alphaData, uint8_t *argb, int width, int height, int bytesPerRow) {
|
void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint8_t const *srcCbData, int srcCbBytesPerRow, uint8_t const *srcCrData, int srcCrBytesPerRow, bool hasAlpha, uint8_t const *alphaData, uint8_t *argb, int width, int height, int bytesPerRow) {
|
||||||
static vImage_YpCbCrToARGB info;
|
static vImage_YpCbCrToARGB info;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
@ -204,6 +204,7 @@ void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint
|
|||||||
dest.rowBytes = bytesPerRow;
|
dest.rowBytes = bytesPerRow;
|
||||||
error = vImageConvert_420Yp8_Cb8_Cr8ToARGB8888(&srcYp, &srcCb, &srcCr, &dest, &info, NULL, 0xff, kvImageDoNotTile);
|
error = vImageConvert_420Yp8_Cb8_Cr8ToARGB8888(&srcYp, &srcCb, &srcCr, &dest, &info, NULL, 0xff, kvImageDoNotTile);
|
||||||
|
|
||||||
|
if (hasAlpha) {
|
||||||
for (int y = 0; y < height; y += 1) {
|
for (int y = 0; y < height; y += 1) {
|
||||||
uint8_t *argbRow = argb + y * bytesPerRow;
|
uint8_t *argbRow = argb + y * bytesPerRow;
|
||||||
int alphaRow = y * srcYpBytesPerRow;
|
int alphaRow = y * srcYpBytesPerRow;
|
||||||
@ -212,6 +213,7 @@ void decodeYUVAPlanesToRGBA(uint8_t const *srcYpData, int srcYpBytesPerRow, uint
|
|||||||
argbRow[x * 4] = alphaData[alphaRow + x];
|
argbRow[x * 4] = alphaData[alphaRow + x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
error = vImagePremultiplyData_ARGB8888(&dest, &dest, kvImageDoNotTile);
|
error = vImagePremultiplyData_ARGB8888(&dest, &dest, kvImageDoNotTile);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user