|
|
@@ -259,19 +259,28 @@ public final class LNMP4FrameHWDecoder: LNBaseDecoder {
|
|
|
|
|
|
if parser.videoCodecID == .h264 {
|
|
|
guard spsData.count > 0, ppsData.count > 0 else { return false }
|
|
|
- let spsPtr = spsData.withUnsafeBytes { $0.baseAddress!.assumingMemoryBound(to: UInt8.self) }
|
|
|
- let ppsPtr = ppsData.withUnsafeBytes { $0.baseAddress!.assumingMemoryBound(to: UInt8.self) }
|
|
|
- var parameterSetPointers: [UnsafePointer<UInt8>] = [spsPtr, ppsPtr]
|
|
|
- var parameterSetSizes: [Int] = [spsData.count, ppsData.count]
|
|
|
-
|
|
|
- let status = CMVideoFormatDescriptionCreateFromH264ParameterSets(
|
|
|
- allocator: kCFAllocatorDefault,
|
|
|
- parameterSetCount: 2,
|
|
|
- parameterSetPointers: ¶meterSetPointers,
|
|
|
- parameterSetSizes: ¶meterSetSizes,
|
|
|
- nalUnitHeaderLength: 4,
|
|
|
- formatDescriptionOut: &formatDescription
|
|
|
- )
|
|
|
+ let status = spsData.withUnsafeBytes { spsRawPtr in
|
|
|
+ ppsData.withUnsafeBytes { ppsRawPtr in
|
|
|
+ guard let spsBase = spsRawPtr.baseAddress,
|
|
|
+ let ppsBase = ppsRawPtr.baseAddress else {
|
|
|
+ return OSStatus(-50)
|
|
|
+ }
|
|
|
+ var parameterSetPointers: [UnsafePointer<UInt8>] = [
|
|
|
+ spsBase.assumingMemoryBound(to: UInt8.self),
|
|
|
+ ppsBase.assumingMemoryBound(to: UInt8.self)
|
|
|
+ ]
|
|
|
+ var parameterSetSizes: [Int] = [spsData.count, ppsData.count]
|
|
|
+
|
|
|
+ return CMVideoFormatDescriptionCreateFromH264ParameterSets(
|
|
|
+ allocator: kCFAllocatorDefault,
|
|
|
+ parameterSetCount: 2,
|
|
|
+ parameterSetPointers: ¶meterSetPointers,
|
|
|
+ parameterSetSizes: ¶meterSetSizes,
|
|
|
+ nalUnitHeaderLength: 4,
|
|
|
+ formatDescriptionOut: &formatDescription
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
if status != noErr {
|
|
|
initializationError = NSError(domain: Self.errorDomain, code: LNMP4HWDErrorCode.errorCreateVTBDesc.rawValue, userInfo: ["location": fileInfo.filePath])
|
|
|
return false
|
|
|
@@ -282,21 +291,33 @@ public final class LNMP4FrameHWDecoder: LNBaseDecoder {
|
|
|
return false
|
|
|
}
|
|
|
guard vpsData.count > 0, spsData.count > 0, ppsData.count > 0 else { return false }
|
|
|
- let vpsPtr = vpsData.withUnsafeBytes { $0.baseAddress!.assumingMemoryBound(to: UInt8.self) }
|
|
|
- let spsPtr = spsData.withUnsafeBytes { $0.baseAddress!.assumingMemoryBound(to: UInt8.self) }
|
|
|
- let ppsPtr = ppsData.withUnsafeBytes { $0.baseAddress!.assumingMemoryBound(to: UInt8.self) }
|
|
|
- var parameterSetPointers: [UnsafePointer<UInt8>] = [vpsPtr, spsPtr, ppsPtr]
|
|
|
- var parameterSetSizes: [Int] = [vpsData.count, spsData.count, ppsData.count]
|
|
|
-
|
|
|
- let status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(
|
|
|
- allocator: kCFAllocatorDefault,
|
|
|
- parameterSetCount: 3,
|
|
|
- parameterSetPointers: ¶meterSetPointers,
|
|
|
- parameterSetSizes: ¶meterSetSizes,
|
|
|
- nalUnitHeaderLength: 4,
|
|
|
- extensions: nil,
|
|
|
- formatDescriptionOut: &formatDescription
|
|
|
- )
|
|
|
+ let status = vpsData.withUnsafeBytes { vpsRawPtr in
|
|
|
+ spsData.withUnsafeBytes { spsRawPtr in
|
|
|
+ ppsData.withUnsafeBytes { ppsRawPtr in
|
|
|
+ guard let vpsBase = vpsRawPtr.baseAddress,
|
|
|
+ let spsBase = spsRawPtr.baseAddress,
|
|
|
+ let ppsBase = ppsRawPtr.baseAddress else {
|
|
|
+ return OSStatus(-50)
|
|
|
+ }
|
|
|
+ var parameterSetPointers: [UnsafePointer<UInt8>] = [
|
|
|
+ vpsBase.assumingMemoryBound(to: UInt8.self),
|
|
|
+ spsBase.assumingMemoryBound(to: UInt8.self),
|
|
|
+ ppsBase.assumingMemoryBound(to: UInt8.self)
|
|
|
+ ]
|
|
|
+ var parameterSetSizes: [Int] = [vpsData.count, spsData.count, ppsData.count]
|
|
|
+
|
|
|
+ return CMVideoFormatDescriptionCreateFromHEVCParameterSets(
|
|
|
+ allocator: kCFAllocatorDefault,
|
|
|
+ parameterSetCount: 3,
|
|
|
+ parameterSetPointers: ¶meterSetPointers,
|
|
|
+ parameterSetSizes: ¶meterSetSizes,
|
|
|
+ nalUnitHeaderLength: 4,
|
|
|
+ extensions: nil,
|
|
|
+ formatDescriptionOut: &formatDescription
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if status != noErr {
|
|
|
initializationError = NSError(domain: Self.errorDomain, code: LNMP4HWDErrorCode.errorCreateVTBDesc.rawValue, userInfo: ["location": fileInfo.filePath])
|
|
|
return false
|