-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
With this sup file:
using current HEAD:
macSubtitleOCR/RLEData.swift:46: Fatal error: Unexpectedly found nil while unwrapping an Optional value
💣 Program crashed: System trap at 0x000000019362cc24
Thread 1 crashed:
0 0x000000019362cc24 closure #1 in closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 240 in libswiftCore.dylib
1 0x000000019362caec closure #1 in closure #1 in _assertionFailure(_:_:file:line:flags:) + 340 in libswiftCore.dylib
2 0x000000019362c494 _assertionFailure(_:_:file:line:flags:) + 188 in libswiftCore.dylib
3 RLEData.decodePGS() + 912 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/Subtitles/RLE/RLEData.swift:46:44
44│
45│ if color == 0x00 {
46│ let flags = iterator.next()!
│ ▲
47│ run = Int(flags & 0x3F)
48│ if flags & 0x40 != 0 {
4 ODS.decodeRLEData() + 136 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/Subtitles/PGS/Parsers/ODS.swift:37:33
35│ func decodeRLEData() throws -> Data {
36│ let rleImageData = RLEData(data: encodedImageData, width: objectWidth, height: objectHeight)
37│ return try rleImageData.decodePGS()
│ ▲
38│ }
39│
5 PGS.parseNextSubtitle(_:_:) + 3440 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/Subtitles/PGS/PGS.swift:119:32
117│ imageWidth: ods.objectWidth,
118│ imageHeight: ods.objectHeight,
119│ imageData: ods.decodeRLEData(),
│ ▲
120│ imagePalette: pds.palette,
121│ numberOfColors: 256)
6 PGS.parseData(_:) + 2732 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/Subtitles/PGS/PGS.swift:42:38
40│ while offset + pgsHeaderLength < buffer.count {
41│ logger.debug("Parsing subtitle at offset: \(offset)")
42│ guard let subtitle = try parseNextSubtitle(buffer, &offset)
│ ▲
43│ else {
44│ if offset + pgsHeaderLength > buffer.count { break }
7 closure #1 in PGS.init(_:) + 52 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/Subtitles/PGS/PGS.swift:24:17
22│ let data = try Data(contentsOf: url)
23│ try data.withUnsafeBytes { (buffer: UnsafeRawBufferPointer) in
24│ try parseData(buffer)
│ ▲
25│ }
26│ }
8 0x000000018395fcfc __DataStorage.withUnsafeBytes<A>(in:apply:) + 88 in Foundation
9 0x0000000183966320 Data._Representation.withUnsafeBytes<A>(_:) + 344 in Foundation
10 0x000000018395e940 Data.withUnsafeBytes<A>(_:) + 16 in Foundation
11 macSubtitleOCR.processInternalDecoder() + 8684 in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/macSubtitleOCR.swift:112:27
110│ } else if input.hasSuffix(".sup") {
111│ // Open the PGS data stream
112│ let PGS = try PGS(URL(fileURLWithPath: input))
│ ▲
113│ let result = try await processSubtitle(PGS.subtitles, trackNumber: 0)
114│ results.append(result)
12 macSubtitleOCR.processInput() in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/macSubtitleOCR.swift:63
61│ }
62│ #else
63│ try await processInternalDecoder()
│ ▲
64│ #endif
65│ }
13 macSubtitleOCR.run() in macSubtitleOCR at /Users/timj/Downloads/macSubtitleOCR/Sources/macSubtitleOCR/macSubtitleOCR.swift:42
40│ do {
41│ let fileHandler = try macSubtitleOCRFileHandler(outputDirectory: outputDirectory)
42│ let results = try await processInput()
│ ▲
43│ try await saveResults(fileHandler: fileHandler, results: results)
44│ } catch let macSubtitleOCRError.fileReadError(string), let macSubtitleOCRError.invalidInputFile(string),
14 static AsyncParsableCommand.main(_:) in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsable Types/AsyncParsableCommand.swift:41
39│ var command = try parseAsRoot(arguments)
40│ if var asyncCommand = command as? AsyncParsableCommand {
41│ try await asyncCommand.run()
│ ▲
42│ } else {
43│ try command.run()
15 static AsyncParsableCommand.main() in macSubtitleOCR at /Users/t/Downloads/macSubtitleOCR/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsable Types/AsyncParsableCommand.swift:61
59│ /// if necessary.
60│ public static func main() async {
61│ await self.main(nil)
│ ▲
62│ }
63│ }
Backtrace took 1.22s
zsh: trace trapwith this sup from the same disc:
I get:
Found invalid image for track: 0, index: 1, creating an empty placeholder!and it only gives half of the first subtitle.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels