AV1 handling

This commit is contained in:
Isaac 2024-11-19 19:42:18 +04:00
parent 7fb53dbd79
commit e3e331c2cd
5 changed files with 19 additions and 6 deletions

View File

@ -3601,7 +3601,7 @@ final class UniversalVideoGalleryItemNode: ZoomableContentGalleryItemNode {
for attribute in qualityFile.media.attributes {
if case let .Video(_, _, _, _, _, videoCodec) = attribute, let videoCodec {
qualityDebugText += " \(videoCodec)"
if videoCodec == "av1" {
if videoCodec == "av1" || videoCodec == "av01" {
qualityDebugText += isHardwareAv1Supported ? " (HW)" : " (SW)"
}
}

View File

@ -39,7 +39,7 @@ public final class ChunkMediaPlayerV2: ChunkMediaPlayer {
func load() {
let reader: MediaDataReader
if self.mediaType == .video && self.codecName == "av1" && isHardwareAv1Supported {
if self.mediaType == .video && (self.codecName == "av1" || self.codecName == "av01") && isHardwareAv1Supported {
reader = AVAssetVideoDataReader(filePath: self.tempFile.path, isVideo: self.mediaType == .video)
} else {
reader = FFMpegMediaDataReader(filePath: self.tempFile.path, isVideo: self.mediaType == .video, codecName: self.codecName)

View File

@ -28,7 +28,7 @@ final class FFMpegMediaDataReader: MediaDataReader {
if self.isVideo {
var passthroughDecoder = true
if codecName == "av1" && !isHardwareAv1Supported {
if (codecName == "av1" || codecName == "av01") && !isHardwareAv1Supported {
passthroughDecoder = false
}
let videoSource = SoftwareVideoReader(path: filePath, hintVP9: false, passthroughDecoder: passthroughDecoder)

View File

@ -25,7 +25,20 @@ public struct HLSCodecConfiguration {
public extension HLSCodecConfiguration {
init(context: AccountContext) {
self.init(isSoftwareAv1Supported: false)
var isSoftwareAv1Supported = false
var length: Int = 4
var cpuCount: UInt32 = 0
sysctlbyname("hw.ncpu", &cpuCount, &length, nil, 0)
if cpuCount >= 6 {
isSoftwareAv1Supported = true
}
if let data = context.currentAppConfiguration.with({ $0 }).data, let value = data["ios_enable_software_av1"] as? Double {
isSoftwareAv1Supported = value != 0.0
}
self.init(isSoftwareAv1Supported: isSoftwareAv1Supported)
}
}
@ -48,7 +61,7 @@ public final class HLSQualitySet {
currentCodec = videoCodec
}
}
if let currentCodec, currentCodec == "av1" {
if let currentCodec, (currentCodec == "av1" || currentCodec == "av01") {
} else {
qualityFiles[key] = baseFile.withMedia(alternativeFile)
}

View File

@ -64,7 +64,7 @@ public final class NativeVideoContent: UniversalVideoContent {
return true
}
if videoCodec == "av1" {
if videoCodec == "av1" || videoCodec == "av01" {
if isHardwareAv1Supported {
return true
} else {