2024-10-19 16:04:20 +02:00
|
|
|
import { AardSettings } from '../../../../common/interfaces/SettingsInterface'
|
2025-10-12 22:03:55 +02:00
|
|
|
import { AardUncertainReason } from '../enums/aard-letterbox-uncertain-reason.enum'
|
|
|
|
|
import { LetterboxOrientation } from '../enums/letterbox-orientation.enum'
|
|
|
|
|
|
|
|
|
|
export interface AardTestResult_SubtitleRegion {
|
|
|
|
|
firstBlank: number,
|
|
|
|
|
lastBlank: number,
|
|
|
|
|
firstSubtitle: number,
|
|
|
|
|
lastSubtitle: number,
|
|
|
|
|
firstImage: number,
|
2025-10-13 17:35:37 +02:00
|
|
|
lastImage: number,
|
|
|
|
|
uncertain: boolean,
|
2025-10-12 22:03:55 +02:00
|
|
|
}
|
2024-10-19 16:04:20 +02:00
|
|
|
|
2024-10-14 00:28:13 +02:00
|
|
|
export interface AardTestResults {
|
|
|
|
|
isFinished: boolean,
|
|
|
|
|
lastStage: number,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxOrientation: LetterboxOrientation,
|
|
|
|
|
lastValidLetterboxOrientation: LetterboxOrientation,
|
|
|
|
|
subtitleDetected: boolean,
|
2024-10-14 00:28:13 +02:00
|
|
|
blackLevel: number, // is cumulative
|
|
|
|
|
blackThreshold: number, // is cumulative
|
|
|
|
|
guardLine: {
|
2025-10-13 17:35:37 +02:00
|
|
|
front: number,
|
|
|
|
|
back: number,
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
|
|
|
|
aspectRatioCheck: {
|
2025-10-13 17:35:37 +02:00
|
|
|
frontCandidate: number,
|
|
|
|
|
backCandidate: number,
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
2024-10-21 01:08:03 +02:00
|
|
|
aspectRatioUncertain: boolean,
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUpdated: boolean,
|
2024-12-31 02:50:33 +01:00
|
|
|
activeAspectRatio: number, // is cumulative
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxSize: number,
|
2024-10-21 01:08:03 +02:00
|
|
|
letterboxOffset: number,
|
2026-06-06 03:27:49 +02:00
|
|
|
letterboxSizeWithSubtitles: number,
|
2025-10-12 22:03:55 +02:00
|
|
|
aspectRatioInvalid: boolean,
|
|
|
|
|
subtitleScan: {
|
|
|
|
|
top: number,
|
|
|
|
|
bottom: number,
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
top: AardTestResult_SubtitleRegion,
|
|
|
|
|
bottom: AardTestResult_SubtitleRegion
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-06-06 03:27:49 +02:00
|
|
|
activeLetterbox: {
|
|
|
|
|
width: number,
|
|
|
|
|
offset: number,
|
|
|
|
|
orientation: LetterboxOrientation
|
|
|
|
|
}
|
2025-10-12 22:03:55 +02:00
|
|
|
aspectRatioUncertainReason?: AardUncertainReason,
|
|
|
|
|
aspectRatioInvalidReason?: string,
|
2024-10-14 00:28:13 +02:00
|
|
|
}
|
|
|
|
|
|
2024-10-19 16:04:20 +02:00
|
|
|
export function initAardTestResults(settings: AardSettings): AardTestResults {
|
2024-10-14 00:28:13 +02:00
|
|
|
return {
|
|
|
|
|
isFinished: true,
|
|
|
|
|
lastStage: 0,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxOrientation: LetterboxOrientation.NotKnown,
|
|
|
|
|
lastValidLetterboxOrientation: LetterboxOrientation.NotKnown,
|
2024-10-19 16:04:20 +02:00
|
|
|
blackLevel: settings.blackLevels.defaultBlack,
|
2024-10-14 00:28:13 +02:00
|
|
|
blackThreshold: 16,
|
|
|
|
|
guardLine: {
|
2025-10-13 17:35:37 +02:00
|
|
|
front: -1,
|
|
|
|
|
back: -1,
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
|
|
|
|
aspectRatioCheck: {
|
2025-10-13 17:35:37 +02:00
|
|
|
frontCandidate: 0,
|
|
|
|
|
backCandidate: 0,
|
2024-10-19 16:04:20 +02:00
|
|
|
},
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUncertain: false,
|
2025-10-12 22:03:55 +02:00
|
|
|
subtitleDetected: false,
|
|
|
|
|
subtitleScan: {
|
|
|
|
|
top: -1,
|
|
|
|
|
bottom: -1,
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
top: {
|
|
|
|
|
firstBlank: -1,
|
|
|
|
|
lastBlank: -1,
|
|
|
|
|
firstSubtitle: -1,
|
|
|
|
|
lastSubtitle: -1,
|
|
|
|
|
firstImage: -1,
|
2025-10-13 17:35:37 +02:00
|
|
|
lastImage: -1,
|
|
|
|
|
uncertain: false,
|
2025-10-12 22:03:55 +02:00
|
|
|
},
|
|
|
|
|
bottom: {
|
|
|
|
|
firstBlank: -1,
|
|
|
|
|
lastBlank: -1,
|
|
|
|
|
firstSubtitle: -1,
|
|
|
|
|
lastSubtitle: -1,
|
|
|
|
|
firstImage: -1,
|
2025-10-13 17:35:37 +02:00
|
|
|
lastImage: -1,
|
|
|
|
|
uncertain: false,
|
2025-10-12 22:03:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-06-06 03:27:49 +02:00
|
|
|
activeLetterbox: {
|
|
|
|
|
width: 0,
|
|
|
|
|
offset: 0,
|
|
|
|
|
orientation: LetterboxOrientation.NotLetterbox
|
|
|
|
|
},
|
2024-10-22 23:43:25 +02:00
|
|
|
aspectRatioUpdated: false,
|
2024-12-31 02:50:33 +01:00
|
|
|
activeAspectRatio: 0,
|
2025-10-12 22:03:55 +02:00
|
|
|
letterboxSize: 0,
|
2024-10-21 01:08:03 +02:00
|
|
|
letterboxOffset: 0,
|
2026-06-06 03:27:49 +02:00
|
|
|
letterboxSizeWithSubtitles: 0,
|
2025-04-22 02:44:28 +02:00
|
|
|
aspectRatioInvalid: false,
|
2024-10-14 00:28:13 +02:00
|
|
|
}
|
|
|
|
|
}
|
2024-10-19 16:04:20 +02:00
|
|
|
|
2024-12-31 03:14:29 +01:00
|
|
|
export function resetGuardLine(results: AardTestResults) {
|
2025-10-13 17:35:37 +02:00
|
|
|
results.guardLine.front = -1;
|
|
|
|
|
results.guardLine.back = -1;
|
2024-12-31 03:14:29 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-19 16:04:20 +02:00
|
|
|
export function resetAardTestResults(results: AardTestResults): void {
|
|
|
|
|
results.isFinished = false;
|
|
|
|
|
results.lastStage = 0;
|
2024-10-22 23:43:25 +02:00
|
|
|
results.aspectRatioUpdated = false;
|
2026-06-06 03:27:49 +02:00
|
|
|
results.aspectRatioUncertainReason = undefined;
|
2025-04-22 02:44:28 +02:00
|
|
|
results.aspectRatioInvalid = false;
|
2025-10-12 22:03:55 +02:00
|
|
|
results.letterboxOrientation = LetterboxOrientation.NotKnown;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function resetSubtitleScanResults(results: AardTestResults): void {
|
|
|
|
|
results.subtitleScan.top = -1;
|
|
|
|
|
results.subtitleScan.bottom = -1;
|
|
|
|
|
|
|
|
|
|
results.subtitleScan.regions.top.firstBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.top.firstSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.top.firstImage = -1;
|
|
|
|
|
results.subtitleScan.regions.top.lastImage = -1;
|
|
|
|
|
|
|
|
|
|
results.subtitleScan.regions.bottom.firstBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastBlank = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.firstSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastSubtitle = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.firstImage = -1;
|
|
|
|
|
results.subtitleScan.regions.bottom.lastImage = -1;
|
2024-10-19 16:04:20 +02:00
|
|
|
}
|
2025-10-12 22:03:55 +02:00
|
|
|
|