Fix issue with 1px letterbox in atuodetection

This commit is contained in:
Tamius Han 2019-08-24 22:35:56 +02:00
parent d7b3508f85
commit dba9b054d4
3 changed files with 106 additions and 94 deletions
src/ext/lib/ar-detect

View File

@ -765,11 +765,15 @@ class ArDetector {
if(Debug.debug && Debug.debugArDetect){
console.log(`%c[ArDetect::frameCheck] Triggering aspect ration change! new ar: ${newAr}`, "color: #aaf");
}
this.processAr(newAr);
// we also know edges for guardline, so set them.
// we need to be mindful of fallbackMode though
// if edges are okay and not invalid, we also
// allow automatic aspect ratio correction. If edges
// are bogus, we remain aspect ratio unchanged.
try {
if (!this.fallbackMode) {
// throws error if top/bottom are invalid
this.guardLine.setBlackbar({top: edgePost.guardLineTop, bottom: edgePost.guardLineBottom});
} else {
if (this.conf.player.dimensions){
@ -783,6 +787,14 @@ class ArDetector {
}
}
this.processAr(newAr);
} catch (e) {
// edges weren't gucci, so we'll just reset
// the aspect ratio to defaults
this.guardline.reset();
this.conf.resizer.setAr({type: AspectRatio.Automatic, ratio: this.getDefaultAr()});
}
// }
// else{
// console.log("detected text on edges, dooing nothing")

View File

@ -34,9 +34,7 @@ class GuardLine {
// to odstrani vse neveljavne nastavitve in vse možnosti, ki niso smiselne
// this removes any configs with invalid values or values that dont make sense
if (bbTop < 0 || bbBottom >= this.conf.canvas.height ){
console.log("%c[GuardLine::setBlackbar] INVALID SETTINGS IN GUARDLINE","background: #000; color: #fff")
this.reset();
return;
throw "INVALID_SETTINGS_IN_GUARDLINE"
}
this.blackbar = {

View File

@ -623,7 +623,9 @@ class EdgeDetect{
if (reverseSearchDirection) {
increment = -this.conf.canvasImageDataRowLength;
arrayStart = bottom - this.conf.canvasImageDataRowLength;
// don't subtract this.conf.canvasImageDataRowLength — it has already been accounted for
// when we calculated bottom and top
arrayStart = bottom;
arrayEnd = top;
// this is a hack so we get pointer-like things rather than values