mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 14:45:21 +00:00
- backup old ffmpeg
This commit is contained in:
@@ -27,7 +27,6 @@ typedef struct FFMpegStreamMetrics {
|
|||||||
extern int FFMpegCodecIdH264;
|
extern int FFMpegCodecIdH264;
|
||||||
extern int FFMpegCodecIdHEVC;
|
extern int FFMpegCodecIdHEVC;
|
||||||
extern int FFMpegCodecIdMPEG4;
|
extern int FFMpegCodecIdMPEG4;
|
||||||
extern int FFMpegCodecIdVP9;
|
|
||||||
|
|
||||||
@class FFMpegAVCodecContext;
|
@class FFMpegAVCodecContext;
|
||||||
|
|
||||||
@@ -48,8 +47,6 @@ extern int FFMpegCodecIdVP9;
|
|||||||
- (FFMpegFpsAndTimebase)fpsAndTimebaseForStreamIndex:(int32_t)streamIndex defaultTimeBase:(CMTime)defaultTimeBase;
|
- (FFMpegFpsAndTimebase)fpsAndTimebaseForStreamIndex:(int32_t)streamIndex defaultTimeBase:(CMTime)defaultTimeBase;
|
||||||
- (FFMpegStreamMetrics)metricsForStreamAtIndex:(int32_t)streamIndex;
|
- (FFMpegStreamMetrics)metricsForStreamAtIndex:(int32_t)streamIndex;
|
||||||
|
|
||||||
- (void)forceVideoCodecId:(int)videoCodecId;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ typedef NS_ENUM(NSUInteger, FFMpegAVFrameColorRange) {
|
|||||||
FFMpegAVFrameColorRangeFull
|
FFMpegAVFrameColorRangeFull
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef NS_ENUM(NSUInteger, FFMpegAVFramePixelFormat) {
|
|
||||||
FFMpegAVFramePixelFormatYUV,
|
|
||||||
FFMpegAVFramePixelFormatYUVA
|
|
||||||
};
|
|
||||||
|
|
||||||
@interface FFMpegAVFrame : NSObject
|
@interface FFMpegAVFrame : NSObject
|
||||||
|
|
||||||
@property (nonatomic, readonly) int32_t width;
|
@property (nonatomic, readonly) int32_t width;
|
||||||
@@ -21,7 +16,6 @@ typedef NS_ENUM(NSUInteger, FFMpegAVFramePixelFormat) {
|
|||||||
@property (nonatomic, readonly) int64_t pts;
|
@property (nonatomic, readonly) int64_t pts;
|
||||||
@property (nonatomic, readonly) int64_t duration;
|
@property (nonatomic, readonly) int64_t duration;
|
||||||
@property (nonatomic, readonly) FFMpegAVFrameColorRange colorRange;
|
@property (nonatomic, readonly) FFMpegAVFrameColorRange colorRange;
|
||||||
@property (nonatomic, readonly) FFMpegAVFramePixelFormat pixelFormat;
|
|
||||||
|
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
int FFMpegCodecIdH264 = AV_CODEC_ID_H264;
|
int FFMpegCodecIdH264 = AV_CODEC_ID_H264;
|
||||||
int FFMpegCodecIdHEVC = AV_CODEC_ID_HEVC;
|
int FFMpegCodecIdHEVC = AV_CODEC_ID_HEVC;
|
||||||
int FFMpegCodecIdMPEG4 = AV_CODEC_ID_MPEG4;
|
int FFMpegCodecIdMPEG4 = AV_CODEC_ID_MPEG4;
|
||||||
int FFMpegCodecIdVP9 = AV_CODEC_ID_VP9;
|
|
||||||
|
|
||||||
@interface FFMpegAVFormatContext () {
|
@interface FFMpegAVFormatContext () {
|
||||||
AVFormatContext *_impl;
|
AVFormatContext *_impl;
|
||||||
@@ -145,9 +144,4 @@ int FFMpegCodecIdVP9 = AV_CODEC_ID_VP9;
|
|||||||
return (FFMpegStreamMetrics){ .width = _impl->streams[streamIndex]->codecpar->width, .height = _impl->streams[streamIndex]->codecpar->height, .rotationAngle = rotationAngle, .extradata = _impl->streams[streamIndex]->codecpar->extradata, .extradataSize = _impl->streams[streamIndex]->codecpar->extradata_size };
|
return (FFMpegStreamMetrics){ .width = _impl->streams[streamIndex]->codecpar->width, .height = _impl->streams[streamIndex]->codecpar->height, .rotationAngle = rotationAngle, .extradata = _impl->streams[streamIndex]->codecpar->extradata, .extradataSize = _impl->streams[streamIndex]->codecpar->extradata_size };
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)forceVideoCodecId:(int)videoCodecId {
|
|
||||||
_impl->video_codec_id = videoCodecId;
|
|
||||||
_impl->video_codec = avcodec_find_decoder(videoCodecId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -62,13 +62,4 @@
|
|||||||
return _impl;
|
return _impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (FFMpegAVFramePixelFormat)pixelFormat {
|
|
||||||
switch (_impl->format) {
|
|
||||||
case AV_PIX_FMT_YUVA420P:
|
|
||||||
return FFMpegAVFramePixelFormatYUVA;
|
|
||||||
default:
|
|
||||||
return FFMpegAVFramePixelFormatYUV;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -245,17 +245,6 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pixelBufferRef: CVPixelBuffer?
|
var pixelBufferRef: CVPixelBuffer?
|
||||||
|
|
||||||
let pixelFormat: OSType
|
|
||||||
switch frame.pixelFormat {
|
|
||||||
case .YUV:
|
|
||||||
pixelFormat = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
|
|
||||||
case .YUVA:
|
|
||||||
pixelFormat = kCVPixelFormatType_420YpCbCr8VideoRange_8A_TriPlanar
|
|
||||||
default:
|
|
||||||
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];
|
||||||
let err = CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(kCFAllocatorDefault, pixelBufferPool, auxAttributes as CFDictionary, &pixelBufferRef)
|
let err = CVPixelBufferPoolCreatePixelBufferWithAuxAttributes(kCFAllocatorDefault, pixelBufferPool, auxAttributes as CFDictionary, &pixelBufferRef)
|
||||||
@@ -269,22 +258,21 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
|
|
||||||
var options: [String: Any] = [kCVPixelBufferBytesPerRowAlignmentKey as String: frame.lineSize[0] as NSNumber]
|
var options: [String: Any] = [kCVPixelBufferBytesPerRowAlignmentKey as String: frame.lineSize[0] as NSNumber]
|
||||||
options[kCVPixelBufferIOSurfacePropertiesKey as String] = ioSurfaceProperties
|
options[kCVPixelBufferIOSurfacePropertiesKey as String] = ioSurfaceProperties
|
||||||
|
|
||||||
CVPixelBufferCreate(kCFAllocatorDefault,
|
CVPixelBufferCreate(kCFAllocatorDefault,
|
||||||
Int(frame.width),
|
Int(frame.width),
|
||||||
Int(frame.height),
|
Int(frame.height),
|
||||||
pixelFormat,
|
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange,
|
||||||
options as CFDictionary,
|
options as CFDictionary,
|
||||||
&pixelBufferRef)
|
&pixelBufferRef)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let pixelBuffer = pixelBufferRef else {
|
guard let pixelBuffer = pixelBufferRef else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let srcPlaneSize = Int(frame.lineSize[1]) * Int(frame.height / 2)
|
let srcPlaneSize = Int(frame.lineSize[1]) * Int(frame.height / 2)
|
||||||
let dstPlaneSize = srcPlaneSize * 2
|
let dstPlaneSize = srcPlaneSize * 2
|
||||||
|
|
||||||
let dstPlane: UnsafeMutablePointer<UInt8>
|
let dstPlane: UnsafeMutablePointer<UInt8>
|
||||||
if let (existingDstPlane, existingDstPlaneSize) = self.dstPlane, existingDstPlaneSize == dstPlaneSize {
|
if let (existingDstPlane, existingDstPlaneSize) = self.dstPlane, existingDstPlaneSize == dstPlaneSize {
|
||||||
dstPlane = existingDstPlane
|
dstPlane = existingDstPlane
|
||||||
@@ -297,30 +285,29 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fillDstPlane(dstPlane, frame.data[1]!, frame.data[2]!, srcPlaneSize)
|
fillDstPlane(dstPlane, frame.data[1]!, frame.data[2]!, srcPlaneSize)
|
||||||
|
|
||||||
let status = CVPixelBufferLockBaseAddress(pixelBuffer, [])
|
let status = CVPixelBufferLockBaseAddress(pixelBuffer, [])
|
||||||
if status != kCVReturnSuccess {
|
if status != kCVReturnSuccess {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let bytesPerRowY = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0)
|
let bytePerRowY = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0)
|
||||||
|
|
||||||
let bytesPerRowUV = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1)
|
let bytesPerRowUV = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1)
|
||||||
let bytesPerRowA = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 2)
|
|
||||||
|
|
||||||
var base = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0)!
|
var base = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0)!
|
||||||
if bytesPerRowY == frame.lineSize[0] {
|
if bytePerRowY == frame.lineSize[0] {
|
||||||
memcpy(base, frame.data[0]!, bytesPerRowY * Int(frame.height))
|
memcpy(base, frame.data[0]!, bytePerRowY * Int(frame.height))
|
||||||
} else {
|
} else {
|
||||||
var dest = base
|
var dest = base
|
||||||
var src = frame.data[0]!
|
var src = frame.data[0]!
|
||||||
let linesize = Int(frame.lineSize[0])
|
let linesize = Int(frame.lineSize[0])
|
||||||
for _ in 0 ..< Int(frame.height) {
|
for _ in 0 ..< Int(frame.height) {
|
||||||
memcpy(dest, src, linesize)
|
memcpy(dest, src, linesize)
|
||||||
dest = dest.advanced(by: bytesPerRowY)
|
dest = dest.advanced(by: bytePerRowY)
|
||||||
src = src.advanced(by: linesize)
|
src = src.advanced(by: linesize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1)!
|
base = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1)!
|
||||||
if bytesPerRowUV == frame.lineSize[1] * 2 {
|
if bytesPerRowUV == frame.lineSize[1] * 2 {
|
||||||
memcpy(base, dstPlane, Int(frame.height / 2) * bytesPerRowUV)
|
memcpy(base, dstPlane, Int(frame.height / 2) * bytesPerRowUV)
|
||||||
@@ -334,23 +321,7 @@ public final class FFMpegMediaVideoFrameDecoder: MediaTrackFrameDecoder {
|
|||||||
src = src.advanced(by: linesize)
|
src = src.advanced(by: linesize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if case .YUVA = frame.pixelFormat {
|
|
||||||
base = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 2)!
|
|
||||||
if bytesPerRowA == frame.lineSize[3] {
|
|
||||||
memcpy(base, frame.data[3]!, bytesPerRowA * Int(frame.height))
|
|
||||||
} else {
|
|
||||||
var dest = base
|
|
||||||
var src = frame.data[3]!
|
|
||||||
let linesize = Int(frame.lineSize[3])
|
|
||||||
for _ in 0 ..< Int(frame.height) {
|
|
||||||
memcpy(dest, src, linesize)
|
|
||||||
dest = dest.advanced(by: bytesPerRowA)
|
|
||||||
src = src.advanced(by: linesize)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CVPixelBufferUnlockBaseAddress(pixelBuffer, [])
|
CVPixelBufferUnlockBaseAddress(pixelBuffer, [])
|
||||||
|
|
||||||
var formatRef: CMVideoFormatDescription?
|
var formatRef: CMVideoFormatDescription?
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public final class SoftwareVideoSource {
|
|||||||
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) {
|
||||||
let _ = FFMpegMediaFrameSourceContextHelpers.registerFFMpegGlobals
|
let _ = FFMpegMediaFrameSourceContextHelpers.registerFFMpegGlobals
|
||||||
|
|
||||||
var s = stat()
|
var s = stat()
|
||||||
@@ -74,9 +74,7 @@ public final class SoftwareVideoSource {
|
|||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
let avFormatContext = FFMpegAVFormatContext()
|
let avFormatContext = FFMpegAVFormatContext()
|
||||||
if hintVP9 {
|
|
||||||
avFormatContext.forceVideoCodecId(FFMpegCodecIdVP9)
|
|
||||||
}
|
|
||||||
let ioBufferSize = 64 * 1024
|
let ioBufferSize = 64 * 1024
|
||||||
|
|
||||||
let avIoContext = FFMpegAVIOContext(bufferSize: Int32(ioBufferSize), opaqueContext: Unmanaged.passUnretained(self).toOpaque(), readPacket: readPacketCallback, writePacket: nil, seek: seekCallback)
|
let avIoContext = FFMpegAVIOContext(bufferSize: Int32(ioBufferSize), opaqueContext: Unmanaged.passUnretained(self).toOpaque(), readPacket: readPacketCallback, writePacket: nil, seek: seekCallback)
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ private final class UniversalSoftwareVideoSourceImpl {
|
|||||||
fileprivate var currentNumberOfReads: Int = 0
|
fileprivate var currentNumberOfReads: Int = 0
|
||||||
fileprivate var currentReadBytes: Int = 0
|
fileprivate var currentReadBytes: Int = 0
|
||||||
|
|
||||||
init?(mediaBox: MediaBox, fileReference: FileMediaReference, state: ValuePromise<UniversalSoftwareVideoSourceState>, cancelInitialization: Signal<Bool, NoError>, automaticallyFetchHeader: Bool, hintVP9: Bool = false) {
|
init?(mediaBox: MediaBox, fileReference: FileMediaReference, state: ValuePromise<UniversalSoftwareVideoSourceState>, cancelInitialization: Signal<Bool, NoError>, automaticallyFetchHeader: Bool) {
|
||||||
guard let size = fileReference.media.size else {
|
guard let size = fileReference.media.size else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -134,9 +134,6 @@ private final class UniversalSoftwareVideoSourceImpl {
|
|||||||
self.avIoContext = avIoContext
|
self.avIoContext = avIoContext
|
||||||
|
|
||||||
let avFormatContext = FFMpegAVFormatContext()
|
let avFormatContext = FFMpegAVFormatContext()
|
||||||
if hintVP9 {
|
|
||||||
avFormatContext.forceVideoCodecId(FFMpegCodecIdVP9)
|
|
||||||
}
|
|
||||||
avFormatContext.setIO(avIoContext)
|
avFormatContext.setIO(avIoContext)
|
||||||
|
|
||||||
if !avFormatContext.openInput() {
|
if !avFormatContext.openInput() {
|
||||||
@@ -289,22 +286,19 @@ private final class UniversalSoftwareVideoSourceThreadParams: NSObject {
|
|||||||
let state: ValuePromise<UniversalSoftwareVideoSourceState>
|
let state: ValuePromise<UniversalSoftwareVideoSourceState>
|
||||||
let cancelInitialization: Signal<Bool, NoError>
|
let cancelInitialization: Signal<Bool, NoError>
|
||||||
let automaticallyFetchHeader: Bool
|
let automaticallyFetchHeader: Bool
|
||||||
let hintVP9: Bool
|
|
||||||
|
|
||||||
init(
|
init(
|
||||||
mediaBox: MediaBox,
|
mediaBox: MediaBox,
|
||||||
fileReference: FileMediaReference,
|
fileReference: FileMediaReference,
|
||||||
state: ValuePromise<UniversalSoftwareVideoSourceState>,
|
state: ValuePromise<UniversalSoftwareVideoSourceState>,
|
||||||
cancelInitialization: Signal<Bool, NoError>,
|
cancelInitialization: Signal<Bool, NoError>,
|
||||||
automaticallyFetchHeader: Bool,
|
automaticallyFetchHeader: Bool
|
||||||
hintVP9: Bool
|
|
||||||
) {
|
) {
|
||||||
self.mediaBox = mediaBox
|
self.mediaBox = mediaBox
|
||||||
self.fileReference = fileReference
|
self.fileReference = fileReference
|
||||||
self.state = state
|
self.state = state
|
||||||
self.cancelInitialization = cancelInitialization
|
self.cancelInitialization = cancelInitialization
|
||||||
self.automaticallyFetchHeader = automaticallyFetchHeader
|
self.automaticallyFetchHeader = automaticallyFetchHeader
|
||||||
self.hintVP9 = hintVP9
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,8 +381,8 @@ public final class UniversalSoftwareVideoSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(mediaBox: MediaBox, fileReference: FileMediaReference, automaticallyFetchHeader: Bool = false, hintVP9: Bool = false) {
|
public init(mediaBox: MediaBox, fileReference: FileMediaReference, automaticallyFetchHeader: Bool = false) {
|
||||||
self.thread = Thread(target: UniversalSoftwareVideoSourceThread.self, selector: #selector(UniversalSoftwareVideoSourceThread.entryPoint(_:)), object: UniversalSoftwareVideoSourceThreadParams(mediaBox: mediaBox, fileReference: fileReference, state: self.stateValue, cancelInitialization: self.cancelInitialization.get(), automaticallyFetchHeader: automaticallyFetchHeader, hintVP9: hintVP9))
|
self.thread = Thread(target: UniversalSoftwareVideoSourceThread.self, selector: #selector(UniversalSoftwareVideoSourceThread.entryPoint(_:)), object: UniversalSoftwareVideoSourceThreadParams(mediaBox: mediaBox, fileReference: fileReference, state: self.stateValue, cancelInitialization: self.cancelInitialization.get(), automaticallyFetchHeader: automaticallyFetchHeader))
|
||||||
self.thread.name = "UniversalSoftwareVideoSource"
|
self.thread.name = "UniversalSoftwareVideoSource"
|
||||||
self.thread.start()
|
self.thread.start()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import AVFoundation
|
|
||||||
import AsyncDisplayKit
|
import AsyncDisplayKit
|
||||||
import Display
|
import Display
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
@@ -54,34 +53,6 @@ extension SlotMachineAnimationNode: GenericAnimatedStickerNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class VideoStickerNode: ASDisplayNode, GenericAnimatedStickerNode {
|
|
||||||
private var layerHolder: SampleBufferLayer?
|
|
||||||
var manager: SoftwareVideoLayerFrameManager?
|
|
||||||
|
|
||||||
func setOverlayColor(_ color: UIColor?, animated: Bool) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func update(context: AccountContext, fileReference: FileMediaReference, size: CGSize) {
|
|
||||||
let layerHolder = takeSampleBufferLayer()
|
|
||||||
layerHolder.layer.videoGravity = AVLayerVideoGravity.resizeAspectFill
|
|
||||||
layerHolder.layer.frame = CGRect(origin: CGPoint(), size: size)
|
|
||||||
self.layer.addSublayer(layerHolder.layer)
|
|
||||||
self.layerHolder = layerHolder
|
|
||||||
|
|
||||||
let manager = SoftwareVideoLayerFrameManager(account: context.account, fileReference: fileReference, layerHolder: layerHolder, hintVP9: true)
|
|
||||||
self.manager = manager
|
|
||||||
manager.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
var currentFrameIndex: Int {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func setFrameIndex(_ frameIndex: Int) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChatMessageShareButton: HighlightableButtonNode {
|
class ChatMessageShareButton: HighlightableButtonNode {
|
||||||
private let backgroundNode: NavigationBackgroundNode
|
private let backgroundNode: NavigationBackgroundNode
|
||||||
private let iconNode: ASImageNode
|
private let iconNode: ASImageNode
|
||||||
@@ -201,9 +172,6 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
private var didSetUpAnimationNode = false
|
private var didSetUpAnimationNode = false
|
||||||
private var isPlaying = false
|
private var isPlaying = false
|
||||||
|
|
||||||
private var displayLink: ConstantDisplayLinkAnimator?
|
|
||||||
private var displayLinkTimestamp: Double = 0.0
|
|
||||||
|
|
||||||
private var additionalAnimationNodes: [ChatMessageTransitionNode.DecorationItemNode] = []
|
private var additionalAnimationNodes: [ChatMessageTransitionNode.DecorationItemNode] = []
|
||||||
private var overlayMeshAnimationNode: ChatMessageTransitionNode.DecorationItemNode?
|
private var overlayMeshAnimationNode: ChatMessageTransitionNode.DecorationItemNode?
|
||||||
private var enqueuedAdditionalAnimations: [(Int, Double)] = []
|
private var enqueuedAdditionalAnimations: [(Int, Double)] = []
|
||||||
@@ -465,10 +433,6 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
}
|
}
|
||||||
self.animationNode = animationNode
|
self.animationNode = animationNode
|
||||||
}
|
}
|
||||||
} else if let telegramFile = self.telegramFile, let fileName = telegramFile.fileName, fileName.hasSuffix(".webm") {
|
|
||||||
let videoNode = VideoStickerNode()
|
|
||||||
videoNode.update(context: item.context, fileReference: .standalone(media: telegramFile), size: CGSize(width: 184.0, height: 184.0))
|
|
||||||
self.animationNode = videoNode
|
|
||||||
} else {
|
} else {
|
||||||
let animationNode = AnimatedStickerNode()
|
let animationNode = AnimatedStickerNode()
|
||||||
animationNode.started = { [weak self] in
|
animationNode.started = { [weak self] in
|
||||||
@@ -585,24 +549,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let isPlaying = self.visibilityStatus && !self.forceStopAnimations
|
if let animationNode = self.animationNode as? AnimatedStickerNode {
|
||||||
if let _ = self.animationNode as? VideoStickerNode {
|
|
||||||
let displayLink: ConstantDisplayLinkAnimator
|
|
||||||
if let current = self.displayLink {
|
|
||||||
displayLink = current
|
|
||||||
} else {
|
|
||||||
displayLink = ConstantDisplayLinkAnimator { [weak self] in
|
|
||||||
guard let strongSelf = self, let animationNode = strongSelf.animationNode as? VideoStickerNode else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
animationNode.manager?.tick(timestamp: strongSelf.displayLinkTimestamp)
|
|
||||||
strongSelf.displayLinkTimestamp += 1.0 / 30.0
|
|
||||||
}
|
|
||||||
displayLink.frameInterval = 2
|
|
||||||
self.displayLink = displayLink
|
|
||||||
}
|
|
||||||
self.displayLink?.isPaused = !isPlaying
|
|
||||||
} else if let animationNode = self.animationNode as? AnimatedStickerNode {
|
|
||||||
let isPlaying = self.visibilityStatus && !self.forceStopAnimations
|
let isPlaying = self.visibilityStatus && !self.forceStopAnimations
|
||||||
|
|
||||||
if !isPlaying {
|
if !isPlaying {
|
||||||
@@ -789,8 +736,6 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
imageSize = dimensions.cgSize.aspectFitted(displaySize)
|
imageSize = dimensions.cgSize.aspectFitted(displaySize)
|
||||||
} else if let thumbnailSize = telegramFile.previewRepresentations.first?.dimensions {
|
} else if let thumbnailSize = telegramFile.previewRepresentations.first?.dimensions {
|
||||||
imageSize = thumbnailSize.cgSize.aspectFitted(displaySize)
|
imageSize = thumbnailSize.cgSize.aspectFitted(displaySize)
|
||||||
} else {
|
|
||||||
imageSize = displaySize
|
|
||||||
}
|
}
|
||||||
} else if let emojiFile = emojiFile {
|
} else if let emojiFile = emojiFile {
|
||||||
isEmoji = true
|
isEmoji = true
|
||||||
|
|||||||
@@ -380,10 +380,6 @@ public final class ChatMessageItem: ListViewItem, CustomStringConvertible {
|
|||||||
|
|
||||||
loop: for media in self.message.media {
|
loop: for media in self.message.media {
|
||||||
if let telegramFile = media as? TelegramMediaFile {
|
if let telegramFile = media as? TelegramMediaFile {
|
||||||
if let fileName = telegramFile.fileName, fileName.hasSuffix(".webm") {
|
|
||||||
viewClassName = ChatMessageAnimatedStickerItemNode.self
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
if telegramFile.isAnimatedSticker, let size = telegramFile.size, size > 0 && size <= 128 * 1024 {
|
if telegramFile.isAnimatedSticker, let size = telegramFile.size, size > 0 && size <= 128 * 1024 {
|
||||||
if self.message.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
if self.message.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
if telegramFile.fileId.namespace == Namespaces.Media.CloudFile {
|
if telegramFile.fileId.namespace == Namespaces.Media.CloudFile {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ final class SoftwareVideoLayerFrameManager {
|
|||||||
private let fetchDisposable: Disposable
|
private let fetchDisposable: Disposable
|
||||||
private var dataDisposable = MetaDisposable()
|
private var dataDisposable = MetaDisposable()
|
||||||
private let source = Atomic<SoftwareVideoSource?>(value: nil)
|
private let source = Atomic<SoftwareVideoSource?>(value: nil)
|
||||||
private let hintVP9: Bool
|
|
||||||
|
|
||||||
private var baseTimestamp: Double?
|
private var baseTimestamp: Double?
|
||||||
private var frames: [MediaTrackFrame] = []
|
private var frames: [MediaTrackFrame] = []
|
||||||
@@ -32,7 +31,7 @@ final class SoftwareVideoLayerFrameManager {
|
|||||||
|
|
||||||
private var layerRotationAngleAndAspect: (CGFloat, CGFloat)?
|
private var layerRotationAngleAndAspect: (CGFloat, CGFloat)?
|
||||||
|
|
||||||
init(account: Account, fileReference: FileMediaReference, layerHolder: SampleBufferLayer, hintVP9: Bool = false) {
|
init(account: Account, fileReference: FileMediaReference, layerHolder: SampleBufferLayer) {
|
||||||
var resource = fileReference.media.resource
|
var resource = fileReference.media.resource
|
||||||
var secondaryResource: MediaResource?
|
var secondaryResource: MediaResource?
|
||||||
for attribute in fileReference.media.attributes {
|
for attribute in fileReference.media.attributes {
|
||||||
@@ -47,7 +46,6 @@ final class SoftwareVideoLayerFrameManager {
|
|||||||
nextWorker += 1
|
nextWorker += 1
|
||||||
self.account = account
|
self.account = account
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
self.hintVP9 = hintVP9
|
|
||||||
self.secondaryResource = secondaryResource
|
self.secondaryResource = secondaryResource
|
||||||
self.queue = ThreadPoolQueue(threadPool: workers)
|
self.queue = ThreadPoolQueue(threadPool: workers)
|
||||||
self.layerHolder = layerHolder
|
self.layerHolder = layerHolder
|
||||||
@@ -110,7 +108,7 @@ final class SoftwareVideoLayerFrameManager {
|
|||||||
let size = fileSize(path)
|
let size = fileSize(path)
|
||||||
Logger.shared.log("SoftwareVideo", "loaded video from \(stringForResource(resource)) (file size: \(String(describing: size))")
|
Logger.shared.log("SoftwareVideo", "loaded video from \(stringForResource(resource)) (file size: \(String(describing: size))")
|
||||||
|
|
||||||
let _ = strongSelf.source.swap(SoftwareVideoSource(path: path, hintVP9: strongSelf.hintVP9))
|
let _ = strongSelf.source.swap(SoftwareVideoSource(path: path))
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
38
submodules/ffmpeg/BUILD
vendored
38
submodules/ffmpeg/BUILD
vendored
@@ -120,24 +120,6 @@ filegroup(
|
|||||||
srcs = source_files,
|
srcs = source_files,
|
||||||
)
|
)
|
||||||
|
|
||||||
vpx_headers = [
|
|
||||||
"vp8.h",
|
|
||||||
"vp8cx.h",
|
|
||||||
"vp8dx.h",
|
|
||||||
"vpx_codec.h",
|
|
||||||
"vpx_decoder.h",
|
|
||||||
"vpx_encoder.h",
|
|
||||||
"vpx_frame_buffer.h",
|
|
||||||
"vpx_image.h",
|
|
||||||
"vpx_integer.h",
|
|
||||||
"vpx_version.h",
|
|
||||||
"vpx_ext_ratectrl.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
vpx_libs = [
|
|
||||||
"VPX",
|
|
||||||
]
|
|
||||||
|
|
||||||
opus_headers = [
|
opus_headers = [
|
||||||
"opus.h",
|
"opus.h",
|
||||||
"opus_defines.h",
|
"opus_defines.h",
|
||||||
@@ -154,10 +136,6 @@ genrule(
|
|||||||
name = "libffmpeg_build",
|
name = "libffmpeg_build",
|
||||||
srcs = [
|
srcs = [
|
||||||
":FFMpegSources"
|
":FFMpegSources"
|
||||||
] + [
|
|
||||||
"//third-party/libvpx:Public/vpx/{}".format(x) for x in vpx_headers
|
|
||||||
] + [
|
|
||||||
"//third-party/libvpx:Public/vpx/lib{}.a".format(x) for x in vpx_libs
|
|
||||||
] + [
|
] + [
|
||||||
"//third-party/opus:Public/opus/{}".format(x) for x in opus_headers
|
"//third-party/opus:Public/opus/{}".format(x) for x in opus_headers
|
||||||
] + [
|
] + [
|
||||||
@@ -175,21 +153,6 @@ genrule(
|
|||||||
|
|
||||||
cp -R "submodules/ffmpeg/Sources/FFMpeg" "$$SOURCE_PATH"
|
cp -R "submodules/ffmpeg/Sources/FFMpeg" "$$SOURCE_PATH"
|
||||||
|
|
||||||
mkdir "$$SOURCE_PATH/libvpx"
|
|
||||||
mkdir -p "$$SOURCE_PATH/libvpx/include/vpx"
|
|
||||||
mkdir -p "$$SOURCE_PATH/libvpx/lib"
|
|
||||||
""" +
|
|
||||||
"\n" +
|
|
||||||
"\n".join([
|
|
||||||
"cp $(location //third-party/libvpx:Public/vpx/{}) $$SOURCE_PATH/libvpx/include/vpx/".format(x) for x in vpx_headers
|
|
||||||
]) +
|
|
||||||
"\n" +
|
|
||||||
"\n".join([
|
|
||||||
"cp $(location //third-party/libvpx:Public/vpx/libVPX.a) $$SOURCE_PATH/libvpx/lib/".format(x) for x in vpx_libs
|
|
||||||
]) +
|
|
||||||
"\n" +
|
|
||||||
"""
|
|
||||||
|
|
||||||
mkdir "$$SOURCE_PATH/libopus"
|
mkdir "$$SOURCE_PATH/libopus"
|
||||||
mkdir -p "$$SOURCE_PATH/libopus/include/opus"
|
mkdir -p "$$SOURCE_PATH/libopus/include/opus"
|
||||||
mkdir -p "$$SOURCE_PATH/libopus/lib"
|
mkdir -p "$$SOURCE_PATH/libopus/lib"
|
||||||
@@ -268,7 +231,6 @@ objc_library(
|
|||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
":ffmpeg_lib",
|
":ffmpeg_lib",
|
||||||
"//third-party/libvpx:vpx",
|
|
||||||
"//third-party/opus:opus",
|
"//third-party/opus:opus",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
|
|||||||
@@ -45,10 +45,9 @@ CONFIGURE_FLAGS="--enable-cross-compile --disable-programs \
|
|||||||
--enable-avformat \
|
--enable-avformat \
|
||||||
--disable-xlib \
|
--disable-xlib \
|
||||||
--enable-libopus \
|
--enable-libopus \
|
||||||
--enable-libvpx \
|
|
||||||
--enable-audiotoolbox \
|
--enable-audiotoolbox \
|
||||||
--enable-bsf=aac_adtstoasc \
|
--enable-bsf=aac_adtstoasc \
|
||||||
--enable-decoder=h264,libvpx_vp9,hevc,libopus,mp3,aac,flac,alac_at,pcm_s16le,pcm_s24le,gsm_ms_at \
|
--enable-decoder=h264,hevc,libopus,mp3,aac,flac,alac_at,pcm_s16le,pcm_s24le,gsm_ms_at \
|
||||||
--enable-demuxer=aac,mov,m4v,mp3,ogg,libopus,flac,wav,aiff,matroska \
|
--enable-demuxer=aac,mov,m4v,mp3,ogg,libopus,flac,wav,aiff,matroska \
|
||||||
--enable-parser=aac,h264,mp3,libopus \
|
--enable-parser=aac,h264,mp3,libopus \
|
||||||
--enable-protocol=file \
|
--enable-protocol=file \
|
||||||
@@ -123,7 +122,6 @@ then
|
|||||||
pushd "$SCRATCH/$RAW_ARCH"
|
pushd "$SCRATCH/$RAW_ARCH"
|
||||||
|
|
||||||
LIBOPUS_PATH="$SOURCE_DIR/libopus"
|
LIBOPUS_PATH="$SOURCE_DIR/libopus"
|
||||||
LIBVPX_PATH="$SOURCE_DIR/libvpx"
|
|
||||||
|
|
||||||
CFLAGS="$EXTRA_CFLAGS -arch $ARCH"
|
CFLAGS="$EXTRA_CFLAGS -arch $ARCH"
|
||||||
if [ "$RAW_ARCH" = "i386" -o "$RAW_ARCH" = "x86_64" ]
|
if [ "$RAW_ARCH" = "i386" -o "$RAW_ARCH" = "x86_64" ]
|
||||||
@@ -176,7 +174,7 @@ then
|
|||||||
--extra-ldflags="$LDFLAGS" \
|
--extra-ldflags="$LDFLAGS" \
|
||||||
--prefix="$THIN/$RAW_ARCH" \
|
--prefix="$THIN/$RAW_ARCH" \
|
||||||
--pkg-config="$PKG_CONFIG" \
|
--pkg-config="$PKG_CONFIG" \
|
||||||
--pkg-config-flags="--libopus_path $LIBOPUS_PATH --libvpx_path $LIBVPX_PATH" \
|
--pkg-config-flags="--libopus_path $LIBOPUS_PATH" \
|
||||||
|| exit 1
|
|| exit 1
|
||||||
echo "$CONFIGURE_FLAGS" > "$CONFIGURED_MARKER"
|
echo "$CONFIGURE_FLAGS" > "$CONFIGURED_MARKER"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ elif [ "$1" == "--exists" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
elif [ "$NAME" == "opus" ]; then
|
elif [ "$NAME" == "opus" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$NAME" == "vpx" ]; then
|
|
||||||
exit 0
|
|
||||||
else
|
else
|
||||||
if [ "PRINT_ERRORS" == "1" ]; then
|
if [ "PRINT_ERRORS" == "1" ]; then
|
||||||
echo "Package $NAME was not found in the pkg-config search path."
|
echo "Package $NAME was not found in the pkg-config search path."
|
||||||
@@ -27,15 +25,9 @@ elif [ "$1" == "--exists" ]; then
|
|||||||
elif [ "$1" == "--cflags" ]; then
|
elif [ "$1" == "--cflags" ]; then
|
||||||
NAME="$2"
|
NAME="$2"
|
||||||
LIBOPUS_PATH=""
|
LIBOPUS_PATH=""
|
||||||
LIBVPX_PATH=""
|
|
||||||
if [ "$2" == "--libopus_path" ]; then
|
if [ "$2" == "--libopus_path" ]; then
|
||||||
LIBOPUS_PATH="$3"
|
LIBOPUS_PATH="$3"
|
||||||
NAME="$6"
|
NAME="$4"
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "$4" == "--libvpx_path" ]; then
|
|
||||||
LIBVPX_PATH="$5"
|
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -45,24 +37,15 @@ elif [ "$1" == "--cflags" ]; then
|
|||||||
elif [ "$NAME" == "opus" ]; then
|
elif [ "$NAME" == "opus" ]; then
|
||||||
echo "-I$LIBOPUS_PATH/include/opus"
|
echo "-I$LIBOPUS_PATH/include/opus"
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$NAME" == "vpx" ]; then
|
|
||||||
echo "-I$LIBVPX_PATH/include"
|
|
||||||
exit 0
|
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
elif [ "$1" == "--libs" ]; then
|
elif [ "$1" == "--libs" ]; then
|
||||||
NAME="$2"
|
NAME="$2"
|
||||||
LIBOPUS_PATH=""
|
LIBOPUS_PATH=""
|
||||||
LIBVPX_PATH=""
|
|
||||||
if [ "$2" == "--libopus_path" ]; then
|
if [ "$2" == "--libopus_path" ]; then
|
||||||
LIBOPUS_PATH="$3"
|
LIBOPUS_PATH="$3"
|
||||||
NAME="$6"
|
NAME="$4"
|
||||||
else
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "$4" == "--libvpx_path" ]; then
|
|
||||||
LIBVPX_PATH="$5"
|
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -72,9 +55,6 @@ elif [ "$1" == "--libs" ]; then
|
|||||||
elif [ "$NAME" == "opus" ]; then
|
elif [ "$NAME" == "opus" ]; then
|
||||||
echo "-L$LIBOPUS_PATH/lib -lopus"
|
echo "-L$LIBOPUS_PATH/lib -lopus"
|
||||||
exit 0
|
exit 0
|
||||||
elif [ "$NAME" == "vpx" ]; then
|
|
||||||
echo "-L$LIBVPX_PATH/lib -lVPX"
|
|
||||||
exit 0
|
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user