From 0825dacdb8f414973d1947e5ac794ce36f4283d5 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 10 Jul 2018 21:58:26 +0200 Subject: [PATCH] fixed autodetection on netflix (and anywhere with fallbackMode, hopefully) --- js/conf/Debug.js | 2 ++ js/lib/PlayerData.js | 11 ++++++++--- js/modules/ArDetect.js | 20 ++++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/js/conf/Debug.js b/js/conf/Debug.js index 5ebdc0a..1c1d516 100644 --- a/js/conf/Debug.js +++ b/js/conf/Debug.js @@ -21,6 +21,8 @@ Debug = { debugDetection: true }, debugCanvas: { + // enabled: true, + // guardLine: true enabled: false, guardLine: false } diff --git a/js/lib/PlayerData.js b/js/lib/PlayerData.js index d8353a9..b25a9ce 100644 --- a/js/lib/PlayerData.js +++ b/js/lib/PlayerData.js @@ -225,10 +225,15 @@ class PlayerData { checkPlayerSizeChange(){ if(Debug.debug){ - if(this.element == undefined) - console.log("[PlayerDetect] player size changed. reason: player element undefined"); + if(this.element == undefined){ + // return true; + } - if(this.dimensions.fullscreen){ + // if(!this.dimensions) { + // return true; + // } + + if(this.dimensions && this.dimensions.fullscreen){ if(! PlayerData.isFullScreen()){ console.log("[PlayerDetect] player size changed. reason: exited fullscreen"); } diff --git a/js/modules/ArDetect.js b/js/modules/ArDetect.js index 6ed8d53..f257e6d 100644 --- a/js/modules/ArDetect.js +++ b/js/modules/ArDetect.js @@ -536,14 +536,14 @@ class ArDetector { //#endregion // this means we don't have letterbox - if ( currentMaxVal > (this.blackLevel + ExtensionConf.arDetect.blackbarTreshold) || (currentMaxVal - currentMinVal) > ExtensionConf.arDetect.blackbarTreshold ){ + if ( currentMaxVal > (this.blackLevel + ExtensionConf.arDetect.blackbarTreshold) || (currentMaxVal - currentMinVal) > ExtensionConf.arDetect.blackbarTreshold*4 ){ // Če ne zaznamo letterboxa, kličemo reset. Lahko, da je bilo razmerje stranic popravljeno na roke. Možno je tudi, // da je letterbox izginil. // If we don't detect letterbox, we reset aspect ratio to aspect ratio of the video file. The aspect ratio could // have been corrected manually. It's also possible that letterbox (that was there before) disappeared. if(Debug.debug){ - console.log("%c[ArDetect::_ard_vdraw] no edge detected. canvas has no edge.", "color: #aaf"); + console.log(`%c[ArDetect::_ard_vdraw] no edge detected. canvas has no edge.\ncurrentMaxVal: ${currentMaxVal}\nBlack level (+ treshold):${this.blackLevel} (${this.blackLevel + ExtensionConf.arDetect.blackbarTreshold})\n---diff test---\nmaxVal-minVal: ${ (currentMaxVal - currentMinVal)}\ntreshold: ${ExtensionConf.arDetect.blackbarTreshold}`, "color: #aaf"); } // Pogledamo, ali smo že kdaj ponastavili CSS. Če še nismo, potem to storimo. Če smo že, potem ne. @@ -576,7 +576,7 @@ class ArDetector { // let's check if we're cropping too much (or whatever) var guardLineOut; - guardLineOut = this.guardLine.check(image, fallbackMode); + guardLineOut = this.guardLine.check(image, this.fallbackMode); if (guardLineOut.blackbarFail) { // add new ssamples to our sample columns for(var col of guardLineOut.offenders){ @@ -588,7 +588,7 @@ class ArDetector { // if both succeed, then aspect ratio hasn't changed. // if we're in fallback mode and blackbar test failed, we restore CSS - if (fallbackMode && guardLineOut.blackbarFail) { + if (this.fallbackMode && guardLineOut.blackbarFail) { this.conf.resizer.reset({type: "auto", ar: null}); this.guardLine.reset(); this.noLetterboxCanvasReset = true; @@ -664,8 +664,16 @@ class ArDetector { // if(!textEdge){ this.processAr(edgePost); - // we also know edges for guardline, so set them - this.guardLine.setBlackbar({top: edgePost.guardLineTop, bottom: edgePost.guardLineBottom}); + // we also know edges for guardline, so set them. + // we need to be mindful of fallbackMode though + if (!this.fallbackMode) { + this.guardLine.setBlackbar({top: edgePost.guardLineTop, bottom: edgePost.guardLineBottom}); + } else { + if (this.conf.player.dimensions){ + this.guardLine.setBlackbar({top: 0, bottom: this.conf.player.dimensions.height - 1}) + } + } + // } // else{ // console.log("detected text on edges, dooing nothing")