Keep the PGS source resolution through the sup2vob conversion
VobSub conversions of PGS material were downscaled to the 720x480/576 DVD frame — a 1080p source came out of the mux at one quarter of its authored size. The framework's sup2vob façade now always runs the upstream CLI's `--full` mode: fullFramePassthrough keeps every frame's object geometry verbatim, and the idx size line (which the VobSub importer carries into track.width/height and the muxer writes into the subpic track) is the PGS's own PCS canvas, e.g. 1920x1080. The frame-rate-derived DVD frame stays as fallback for streams that define no usable canvas. The conversion output is byte-identical to running `sup2vob --full` on the same .sup. The vendored upstream sources stay untouched apart from one comment — the passthrough is enabled in the adaptation layer, same as the CLI does with its flag. This applies to both PGS paths, which share the conversion: .sup drag-import and PGS-from-MKV via MP42PgsToVobSubConverter. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
57772086a5
commit
837aa1c098
4 files changed
+35
-15
No files matched your search
@@ -17,8 +17,9 @@ import Foundation
|
||||
nonisolated(unsafe) var debugFrames = false
|
||||
|
||||
/// Set by the CLI's `--full`: keep the source frame size with no scaling.
|
||||
/// Upstream declares this in main.swift; inside the framework it stays false —
|
||||
/// imports always downscale to the DVD frame the muxer writes.
|
||||
/// Upstream declares this in main.swift; inside the framework
|
||||
/// MP42SupConverter turns it on for every import — the muxed subpic track
|
||||
/// keeps the PGS's own canvas size instead of the DVD frame.
|
||||
nonisolated(unsafe) var fullFramePassthrough = false
|
||||
|
||||
// MARK: - DVD subtitle frame (post scale + color reduction)
|
||||
|
||||
@@ -20,9 +20,12 @@ import Foundation
|
||||
/// lines — the importer overwrites the track language from the source
|
||||
/// filename, the way the .srt importer does.
|
||||
///
|
||||
/// Mirrors sup2vob's CLI orchestration: PAL/NTSC picked automatically from
|
||||
/// the PGS frame-rate code, BT.709 palette interpretation, frames
|
||||
/// downscaled to the DVD frame the muxer writes.
|
||||
/// Mirrors sup2vob's CLI orchestration with `--full`: BT.709 palette
|
||||
/// interpretation, and the source geometry is kept — frames stay at the
|
||||
/// resolution the PGS itself defines (its PCS canvas, e.g. 1920x1080),
|
||||
/// so the muxed subpic track matches the subtitles' authored size
|
||||
/// instead of being downscaled to the DVD frame. The DVD frame from the
|
||||
/// frame-rate code stays as fallback for a stream with no usable canvas.
|
||||
@objc(convertSupAtURL:toSubAtURL:language:languageName:error:)
|
||||
public static func convertSup(at inputURL: URL,
|
||||
toSubAt subURL: URL,
|
||||
@@ -40,7 +43,21 @@ import Foundation
|
||||
throw conversionError(101, "\(inputURL.lastPathComponent): no compositions found")
|
||||
}
|
||||
|
||||
let resolution = DVDResolution.from(frameRateCode: compositions[0].frameRateCode)
|
||||
// Upstream's `--full` mode: keep the source frames verbatim. The
|
||||
// CLI's main.swift set this global from the flag; enabling it here
|
||||
// is the framework's one behavioral adaptation of the vendored
|
||||
// sources (upstream's logic and geometry code stay untouched).
|
||||
fullFramePassthrough = true
|
||||
|
||||
// The size the muxer writes: the display resolution the PGS itself
|
||||
// declares in its PCS canvas (1920x1080 for a full-HD source). Fall
|
||||
// back to the frame-rate's DVD frame only if the stream defines no
|
||||
// usable canvas.
|
||||
let canvasWidth = compositions[0].canvasWidth
|
||||
let canvasHeight = compositions[0].canvasHeight
|
||||
let resolution = canvasWidth > 0 && canvasHeight > 0
|
||||
? DVDResolution(width: canvasWidth, height: canvasHeight)
|
||||
: DVDResolution.from(frameRateCode: compositions[0].frameRateCode)
|
||||
let result = convertToDVD(compositions, resolution: resolution)
|
||||
guard !result.frames.isEmpty else {
|
||||
throw conversionError(102, "\(inputURL.lastPathComponent): no displayable subtitle frames")
|
||||
|
||||
Reference in new issue
Block a user