Skip to content

Commit

Permalink
xros
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed Dec 1, 2023
1 parent 01614bf commit e546231
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion FFmpegKit
8 changes: 5 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import PackageDescription
let package = Package(
name: "KSPlayer",
defaultLocalization: "en",
platforms: [.macOS(.v10_15),
// .visionOS(.v1),
.iOS(.v13), .tvOS(.v13)],
platforms: [.macOS(.v10_15), .macCatalyst(.v13), .iOS(.v13), .tvOS(.v13)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
Expand Down Expand Up @@ -35,6 +33,10 @@ let package = Package(
]
)
var ffmpegKitPath = FileManager.default.currentDirectoryPath + "/FFmpegKit"
if !FileManager.default.fileExists(atPath: ffmpegKitPath) {
ffmpegKitPath = FileManager.default.currentDirectoryPath + "../FFmpegKit"
}

if !FileManager.default.fileExists(atPath: ffmpegKitPath) {
ffmpegKitPath = FileManager.default.currentDirectoryPath + "/KSPlayer/FFmpegKit"
}
Expand Down
9 changes: 6 additions & 3 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import PackageDescription
let package = Package(
name: "KSPlayer",
defaultLocalization: "en",
platforms: [.macOS(.v10_15),
.visionOS(.v1),
.iOS(.v13), .tvOS(.v13)],
platforms: [.macOS(.v10_15), .macCatalyst(.v13), .iOS(.v13), .tvOS(.v13),
.visionOS(.v1)],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
Expand Down Expand Up @@ -36,6 +35,10 @@ let package = Package(
)

var ffmpegKitPath = FileManager.default.currentDirectoryPath + "/FFmpegKit"
if !FileManager.default.fileExists(atPath: ffmpegKitPath) {
ffmpegKitPath = FileManager.default.currentDirectoryPath + "../FFmpegKit"
}

if !FileManager.default.fileExists(atPath: ffmpegKitPath) {
ffmpegKitPath = FileManager.default.currentDirectoryPath + "/KSPlayer/FFmpegKit"
}
Expand Down
10 changes: 4 additions & 6 deletions Sources/KSPlayer/MEPlayer/Resample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,11 @@ class VideoSwresample: FrameChange {
pbuf.aspectRatio = frame.sample_aspect_ratio.size
pbuf.yCbCrMatrix = frame.colorspace.ycbcrMatrix
pbuf.colorPrimaries = frame.color_primaries.colorPrimaries
pbuf.transferFunction = frame.color_trc.transferFunction
// vt_pixbuf_set_colorspace
if let transferFunction = frame.color_trc.transferFunction {
pbuf.transferFunction = transferFunction
if transferFunction == kCVImageBufferTransferFunction_UseGamma {
let gamma = NSNumber(value: frame.color_trc == AVCOL_TRC_GAMMA22 ? 2.2 : 2.8)
CVBufferSetAttachment(pbuf, kCVImageBufferGammaLevelKey, gamma, .shouldPropagate)
}
if pbuf.transferFunction == kCVImageBufferTransferFunction_UseGamma {
let gamma = NSNumber(value: frame.color_trc == AVCOL_TRC_GAMMA22 ? 2.2 : 2.8)
CVBufferSetAttachment(pbuf, kCVImageBufferGammaLevelKey, gamma, .shouldPropagate)
}
if let chroma = frame.chroma_location.chroma {
CVBufferSetAttachment(pbuf, kCVImageBufferChromaLocationTopFieldKey, chroma, .shouldPropagate)
Expand Down
5 changes: 2 additions & 3 deletions Sources/KSPlayer/Metal/PixelBufferProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,19 @@ class PixelBuffer: PixelBufferProtocol {
let colorPrimaries: CFString?
let transferFunction: CFString?
let yCbCrMatrix: CFString?
let colorspace: CGColorSpace?
private let format: AVPixelFormat
private let formats: [MTLPixelFormat]
private let widths: [Int]
private let heights: [Int]
private let buffers: [MTLBuffer?]
private let lineSize: [Int]
public var colorspace: CGColorSpace? {
attachmentsDic.flatMap { CVImageBufferCreateColorSpaceFromAttachments($0)?.takeUnretainedValue() }
}

init(frame: AVFrame) {
yCbCrMatrix = frame.colorspace.ycbcrMatrix
colorPrimaries = frame.color_primaries.colorPrimaries
transferFunction = frame.color_trc.transferFunction
colorspace = KSOptions.colorSpace(ycbcrMatrix: yCbCrMatrix, transferFunction: transferFunction)
var attachments = [CFString: CFString]()
attachments[kCVImageBufferColorPrimariesKey] = colorPrimaries
attachments[kCVImageBufferTransferFunctionKey] = transferFunction
Expand Down

0 comments on commit e546231

Please sign in to comment.