Compare commits
No commits in common. "7c5e4101b0279d2ff1c26833c6e3e793c03f7c34" and "c15d7ab28e1377498a9c960bd6380b2c38a6b47b" have entirely different histories.
7c5e4101b0
...
c15d7ab28e
@ -51,7 +51,13 @@ export interface CommandInterface {
|
|||||||
export type SettingsReloadComponent = 'PlayerData' | 'VideoData';
|
export type SettingsReloadComponent = 'PlayerData' | 'VideoData';
|
||||||
export type SettingsReloadFlags = true | SettingsReloadComponent;
|
export type SettingsReloadFlags = true | SettingsReloadComponent;
|
||||||
|
|
||||||
export interface AardSettings {
|
interface SettingsInterface {
|
||||||
|
_updateFlags?: {
|
||||||
|
requireReload?: SettingsReloadFlags,
|
||||||
|
forSite?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
arDetect: {
|
||||||
disabledReason: string, // if automatic aspect ratio has been disabled, show reason
|
disabledReason: string, // if automatic aspect ratio has been disabled, show reason
|
||||||
allowedMisaligned: number, // top and bottom letterbox thickness can differ by this much.
|
allowedMisaligned: number, // top and bottom letterbox thickness can differ by this much.
|
||||||
// Any more and we don't adjust ar.
|
// Any more and we don't adjust ar.
|
||||||
@ -84,7 +90,7 @@ export interface AardSettings {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// NOTE: Black Frame is currently not in use.
|
// samplingInterval: 10, // we sample at columns at (width/this) * [ 1 .. this - 1]
|
||||||
blackframe: {
|
blackframe: {
|
||||||
sufficientColorVariance: number, // calculate difference between average intensity and pixel, for every pixel for every color
|
sufficientColorVariance: number, // calculate difference between average intensity and pixel, for every pixel for every color
|
||||||
// component. Average intensity is normalized to where 0 is black and 1 is biggest value for
|
// component. Average intensity is normalized to where 0 is black and 1 is biggest value for
|
||||||
@ -98,8 +104,6 @@ export interface AardSettings {
|
|||||||
// precedence over cumulative threshold: if blackPixelsCondition is met, the frame is dark
|
// precedence over cumulative threshold: if blackPixelsCondition is met, the frame is dark
|
||||||
// regardless of whether cumulative threshold has been reached.
|
// regardless of whether cumulative threshold has been reached.
|
||||||
},
|
},
|
||||||
|
|
||||||
// Used by old aspect ratio detection algorithm. Pls remove.
|
|
||||||
blackbar: {
|
blackbar: {
|
||||||
blackLevel: number, // everything darker than 10/255 across all RGB components is considered black by
|
blackLevel: number, // everything darker than 10/255 across all RGB components is considered black by
|
||||||
// default. blackLevel can decrease if we detect darker black.
|
// default. blackLevel can decrease if we detect darker black.
|
||||||
@ -120,7 +124,6 @@ export interface AardSettings {
|
|||||||
gradientMaxSD: number, // reserved for future use
|
gradientMaxSD: number, // reserved for future use
|
||||||
antiGradientMode: AntiGradientMode
|
antiGradientMode: AntiGradientMode
|
||||||
},
|
},
|
||||||
// Also not in use, probs.
|
|
||||||
variableBlackbarThresholdOptions: { // In case of poor bitrate videos, jpeg artifacts may cause us issues
|
variableBlackbarThresholdOptions: { // In case of poor bitrate videos, jpeg artifacts may cause us issues
|
||||||
// FOR FUTURE USE
|
// FOR FUTURE USE
|
||||||
enabled: boolean, // allow increasing blackbar threshold
|
enabled: boolean, // allow increasing blackbar threshold
|
||||||
@ -129,18 +132,10 @@ export interface AardSettings {
|
|||||||
thresholdStep: number, // when failing to set aspect ratio, increase threshold by this much
|
thresholdStep: number, // when failing to set aspect ratio, increase threshold by this much
|
||||||
increaseAfterConsecutiveResets: number // increase if AR resets this many times in a row
|
increaseAfterConsecutiveResets: number // increase if AR resets this many times in a row
|
||||||
},
|
},
|
||||||
blackLevels: {
|
|
||||||
defaultBlack: number, // By default, pixels darker than this are considered black.
|
|
||||||
// (If detection algorithm detects darker blacks, black is considered darkest detected pixel)
|
|
||||||
blackTolerance: number, // If pixel is more than this much brighter than blackLevel, it's considered not black
|
|
||||||
// It is not considered a valid image detection if gradient detection is enabled
|
|
||||||
imageDelta: number, // When gradient detection is enabled, pixels this much brighter than black skip gradient detection
|
|
||||||
}
|
|
||||||
sampling: {
|
sampling: {
|
||||||
edgePosition: number; // % of width (max 0.33). Pixels up to this far away from either edge may contain logo.
|
|
||||||
staticCols: number, // we take a column at [0-n]/n-th parts along the width and sample it
|
staticCols: number, // we take a column at [0-n]/n-th parts along the width and sample it
|
||||||
randomCols: number, // we add this many randomly selected columns to the static columns
|
randomCols: number, // we add this many randomly selected columns to the static columns
|
||||||
staticRows: number, // forms grid with staticSampleCols. Determined in the same way. For black frame checks,
|
staticRows: number, // forms grid with staticSampleCols. Determined in the same way. For black frame checks
|
||||||
},
|
},
|
||||||
guardLine: { // all pixels on the guardline need to be black, or else we trigger AR recalculation
|
guardLine: { // all pixels on the guardline need to be black, or else we trigger AR recalculation
|
||||||
// (if AR fails to be recalculated, we reset AR)
|
// (if AR fails to be recalculated, we reset AR)
|
||||||
@ -151,29 +146,16 @@ export interface AardSettings {
|
|||||||
edgeTolerancePx: number, // black edge violation is performed this far from reported 'last black pixel'
|
edgeTolerancePx: number, // black edge violation is performed this far from reported 'last black pixel'
|
||||||
edgeTolerancePercent: null // unused. same as above, except use % of canvas height instead of pixels
|
edgeTolerancePercent: null // unused. same as above, except use % of canvas height instead of pixels
|
||||||
},
|
},
|
||||||
|
fallbackMode: {
|
||||||
|
enabled: boolean,
|
||||||
|
safetyBorderPx: number, // determines the thickness of safety border in fallback mode
|
||||||
|
noTriggerZonePx: number // if we detect edge less than this many pixels thick, we don't correct.
|
||||||
|
},
|
||||||
arSwitchLimiter: { // to be implemented
|
arSwitchLimiter: { // to be implemented
|
||||||
switches: number, // we can switch this many times
|
switches: number, // we can switch this many times
|
||||||
period: number // per this period
|
period: number // per this period
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// pls deprecate and move things used
|
|
||||||
edgeDetection: {
|
edgeDetection: {
|
||||||
slopeTestWidth: number,
|
|
||||||
gradientTestSamples: number, // we check this many pixels below (or above) the suspected edge to check for gradient
|
|
||||||
gradientTestBlackThreshold: number, // if pixel in test sample is brighter than that, we aren't looking at gradient
|
|
||||||
gradientTestDeltaThreshold: number, // if delta between two adjacent pixels in gradient test exceeds this, it's not gradient
|
|
||||||
gradientTestMinDelta: number, // if last pixels of the test sample is less than this brighter than the first -> not gradient
|
|
||||||
|
|
||||||
thresholds: {
|
|
||||||
edgeDetectionLimit: 8, // during scanning of the edge, quit after edge gets detected at this many points
|
|
||||||
minQualitySingleEdge: 6, // At least one of the detected must reach this quality
|
|
||||||
minQualitySecondEdge: 3, // The other edge must reach this quality (must be smaller or equal to single edge quality)
|
|
||||||
}
|
|
||||||
|
|
||||||
maxLetterboxOffset: 0.1, // Upper and lower letterbox can be different by this many (% of height)
|
|
||||||
|
|
||||||
// Previous iteration variables VVVV
|
|
||||||
sampleWidth: number, // we take a sample this wide for edge detection
|
sampleWidth: number, // we take a sample this wide for edge detection
|
||||||
detectionThreshold: number, // sample needs to have this many non-black pixels to be a valid edge
|
detectionThreshold: number, // sample needs to have this many non-black pixels to be a valid edge
|
||||||
confirmationThreshold: number, //
|
confirmationThreshold: number, //
|
||||||
@ -201,15 +183,7 @@ export interface AardSettings {
|
|||||||
// is over 50% of the canvas width
|
// is over 50% of the canvas width
|
||||||
testRowOffset: number // we test this % of height from detected edge
|
testRowOffset: number // we test this % of height from detected edge
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
interface SettingsInterface {
|
|
||||||
_updateFlags?: {
|
|
||||||
requireReload?: SettingsReloadFlags,
|
|
||||||
forSite?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
arDetect: AardSettings,
|
|
||||||
|
|
||||||
ui: {
|
ui: {
|
||||||
inPlayer: {
|
inPlayer: {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* Used to store coordinates of sample columns/rows and the
|
|
||||||
* first x/y position where non-black pixels were detected.
|
|
||||||
*
|
|
||||||
* Arrays are laid out like so:
|
|
||||||
*
|
|
||||||
* We check each row at these positions (columns)
|
|
||||||
* V V V
|
|
||||||
* _________ _________ _________ _____
|
|
||||||
* | x₀ | y₀ | x₁ | y₁ | x₂ | y₂ | ..
|
|
||||||
* '''''''''' ''''''''' ''''''''' '''''
|
|
||||||
* A A A
|
|
||||||
* If checked pixel is non-black, we put current row into
|
|
||||||
* this element of the array.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export interface AardDetectionSample {
|
|
||||||
top?: Int16Array;
|
|
||||||
bottom?: Int16Array;
|
|
||||||
left?: Int16Array;
|
|
||||||
right?: Int16Array;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateSampleArray(samples: number, width: number, topBottom: boolean = true) {
|
|
||||||
const sampleStore = new Int16Array(samples * 2);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We want to reverse-fencepost here.
|
|
||||||
*
|
|
||||||
* Normally, our sample positions would look like this:
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* 0 1 2 3
|
|
||||||
* | :
|
|
||||||
* |————|————|————|————:
|
|
||||||
* | <—— 20 units ——> :
|
|
||||||
* 0 19
|
|
||||||
*
|
|
||||||
* But we'd rather our samples are center-justified.
|
|
||||||
* We can solve this issue by dividing the width into
|
|
||||||
* (samples + 1) slices, and ignoring the first (0)
|
|
||||||
* position:
|
|
||||||
*
|
|
||||||
* 0 1 2 3
|
|
||||||
* :
|
|
||||||
* :———|———|———|———|———:
|
|
||||||
* : :
|
|
||||||
* 0 19
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const sampleInterval = ~~(width / ( samples + 1 ));
|
|
||||||
|
|
||||||
let i = 0, col = 1;
|
|
||||||
while (i < sampleStore.length) {
|
|
||||||
sampleStore[i] = sampleInterval * col * (+topBottom * 4);
|
|
||||||
i++;
|
|
||||||
// initialize to -1 (invalid result)
|
|
||||||
sampleStore[i] = -1;
|
|
||||||
i++;
|
|
||||||
col++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sampleStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resetSamples(samples: AardDetectionSample) {
|
|
||||||
samples.top && resetArray(samples.top);
|
|
||||||
samples.bottom && resetArray(samples.bottom);
|
|
||||||
samples.left && resetArray(samples.left);
|
|
||||||
samples.right && resetArray(samples.right);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetArray(x: Int16Array) {
|
|
||||||
for (let i = 1; i < x.length; i+= 2) {
|
|
||||||
x[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
export interface AardGradientSamples {
|
|
||||||
top: Array<Uint8Array>,
|
|
||||||
bottom: Array<Uint8Array>,
|
|
||||||
left?: Array<Uint8Array>,
|
|
||||||
right?: Array<Uint8Array>,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AardGradientSampleOptions {
|
|
||||||
aspectRatioSamples: number;
|
|
||||||
gradientSamples: number,
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateArray(samplingOptions: AardGradientSampleOptions) {
|
|
||||||
const arr = new Array<Uint8Array>(samplingOptions.aspectRatioSamples)
|
|
||||||
for (let i = 0; i < samplingOptions.aspectRatioSamples; i++) {
|
|
||||||
arr[i] = new Uint8Array(samplingOptions.gradientSamples);
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initAardGradientSamples(letterboxSamplingOptions: AardGradientSampleOptions): AardGradientSamples {
|
|
||||||
return {
|
|
||||||
top: generateArray(letterboxSamplingOptions),
|
|
||||||
bottom: generateArray(letterboxSamplingOptions),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function resetGradientSamples(samples: AardGradientSamples) {
|
|
||||||
for (let i = 0; i < samples.top.length; i++) {
|
|
||||||
for (let j = 0; j < samples.top[i].length; j++) {
|
|
||||||
samples.top[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let i = 0; i < samples.bottom.length; i++) {
|
|
||||||
for (let j = 0; j < samples.bottom[i].length; j++) {
|
|
||||||
samples.top[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (samples.left) {
|
|
||||||
for (let i = 0; i < samples.left.length, i++) {
|
|
||||||
for (let j = 0; j < samples.left[i].length; j++) {
|
|
||||||
samples.left[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (samples.right) {
|
|
||||||
for (let i = 0; i < samples.right.length; i++) {
|
|
||||||
for (let j = 0; j < samples.right[i].length; j++) {
|
|
||||||
samples.right[i][j] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
|||||||
import { AardSettings } from '../../../../common/interfaces/SettingsInterface'
|
|
||||||
|
|
||||||
export interface AardTestResults {
|
export interface AardTestResults {
|
||||||
isFinished: boolean,
|
isFinished: boolean,
|
||||||
lastStage: number,
|
lastStage: number,
|
||||||
@ -16,29 +14,15 @@ export interface AardTestResults {
|
|||||||
top: number, // is cumulative
|
top: number, // is cumulative
|
||||||
bottom: number, // is cumulative
|
bottom: number, // is cumulative
|
||||||
invalidated: boolean
|
invalidated: boolean
|
||||||
},
|
}
|
||||||
aspectRatioCheck: {
|
|
||||||
topRows: [number, number, number],
|
|
||||||
topQuality: [number, number, number],
|
|
||||||
bottomRows: [number, number, number],
|
|
||||||
bottomQuality: [number, number, number],
|
|
||||||
topCandidate: number,
|
|
||||||
topCandidateQuality: number,
|
|
||||||
bottomCandidate: number,
|
|
||||||
bottomCandidateQuality: number,
|
|
||||||
},
|
|
||||||
aspectRatioUncertain: boolean,
|
|
||||||
letterboxWidth: number,
|
|
||||||
letterboxOffset: number,
|
|
||||||
logoDetected: [boolean, boolean, boolean, boolean]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initAardTestResults(settings: AardSettings): AardTestResults {
|
export function initAardTestResults(): AardTestResults {
|
||||||
return {
|
return {
|
||||||
isFinished: true,
|
isFinished: true,
|
||||||
lastStage: 0,
|
lastStage: 0,
|
||||||
notLetterbox: false,
|
notLetterbox: false,
|
||||||
blackLevel: settings.blackLevels.defaultBlack,
|
blackLevel: 0,
|
||||||
blackThreshold: 16,
|
blackThreshold: 16,
|
||||||
guardLine: {
|
guardLine: {
|
||||||
top: -1,
|
top: -1,
|
||||||
@ -50,31 +34,6 @@ export function initAardTestResults(settings: AardSettings): AardTestResults {
|
|||||||
top: -1,
|
top: -1,
|
||||||
bottom: -1,
|
bottom: -1,
|
||||||
invalidated: false,
|
invalidated: false,
|
||||||
},
|
|
||||||
aspectRatioCheck: {
|
|
||||||
topRows: [-1, -1, -1],
|
|
||||||
topQuality: [0, 0, 0],
|
|
||||||
bottomRows: [-1, -1, -1],
|
|
||||||
bottomQuality: [0, 0, 0],
|
|
||||||
topCandidate: 0,
|
|
||||||
topCandidateQuality: 0,
|
|
||||||
bottomCandidate: 0,
|
|
||||||
bottomCandidateQuality: 0,
|
|
||||||
},
|
|
||||||
letterboxWidth: 0,
|
|
||||||
letterboxOffset: 0,
|
|
||||||
logoDetected: [false, false, false, false]
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resetAardTestResults(results: AardTestResults): void {
|
|
||||||
results.isFinished = false;
|
|
||||||
results.lastStage = 0;
|
|
||||||
results.notLetterbox = false;
|
|
||||||
results.guardLine.invalidated = false
|
|
||||||
results.guardLine.cornerViolations[0] = false;
|
|
||||||
results.guardLine.cornerViolations[1] = false;
|
|
||||||
results.guardLine.cornerViolations[2] = false;
|
|
||||||
results.guardLine.cornerViolations[3] = false;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user