export function upscaleOptions(value = {}) { const options = { scale: value.scale ?? 2, target: value.target ?? 'preserve', fps: value.fps ?? 'keep', enhance: value.enhance ?? 'faithful' } if (![2, 4].includes(options.scale) || !['preserve', '1080p', '4k'].includes(options.target) || !['keep', 48, 50, 60].includes(options.fps) || !['faithful', 'sharpen'].includes(options.enhance)) throw new Error('Invalid upscale settings.') return options } export function upscaleDimensions(width, height, options) { if (![width, height].every(n => Number.isFinite(n) && n > 0)) throw new Error('Invalid source resolution.') const factor = options.target === 'preserve' ? options.scale : (options.target === '1080p' ? 1920 : 3840) / Math.max(width, height) return { width: Math.max(2, Math.round(width * factor / 2) * 2), height: Math.max(2, Math.round(height * factor / 2) * 2) } } export function upscaleName(stem, scale, index = 1) { return `${stem}_up${scale}x${index > 1 ? `-${index}` : ''}.mp4` }