From a5bf3ec1e0f88556acd401b6aa302b92a4e16a57 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 30 Jan 2021 10:38:45 +0100 Subject: [PATCH 01/68] Remove redundant code --- src/ext/lib/video-transform/Resizer.js | 36 -------------------------- 1 file changed, 36 deletions(-) diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index 6b056eb..1176df6 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -182,42 +182,6 @@ class Resizer { this.conf.pageInfo.updateCurrentCrop(ar); } - // if (ar.type === AspectRatio.Automatic || - // ar.type === AspectRatio.Reset && this.lastAr.type === AspectRatio.Initial) { - // // some sites do things that interfere with our site (and aspect ratio setting in general) - // // first, we check whether video contains anything we don't like - // if (siteSettings?.autoarPreventConditions?.videoStyleString) { - // const styleString = (this.video.getAttribute('style') || '').split(';'); - - // if (siteSettings.autoarPreventConditions.videoStyleString.containsProperty) { - // const bannedProperties = siteSettings.autoarPreventConditions.videoStyleString.containsProperty; - // for (const prop in bannedProperties) { - // for (const s of styleString) { - // if (s.trim().startsWith(prop)) { - - // // check if css property has a list of allowed values: - // if (bannedProperties[prop].allowedValues) { - // const styleValue = s.split(':')[1].trim(); - - // // check if property value is on the list of allowed values - // // if it's not, we aren't allowed to start aard - // if (bannedProperties[prop].allowedValues.indexOf(styleValue) === -1) { - // this.logger.log('error', 'debug', "%c[Resizer::setAr] video style contains forbidden css property/value combo: ", "color: #900, background: #100", prop, " — we aren't allowed to start autoar.") - // return; - // } - // } else { - // // no allowed values, no problem. We have forbidden property - // // and this means aard can't start. - // this.logger.log('info', 'debug', "%c[Resizer::setAr] video style contains forbidden css property: ", "color: #900, background: #100", prop, " — we aren't allowed to start autoar.") - // return; - // } - // } - // } - // } - // } - // } - // } - if (lastAr) { this.lastAr = this.calculateRatioForLegacyOptions(lastAr); ar = this.calculateRatioForLegacyOptions(ar); From 9a0c0ba8107de38cd7ad9e061f6eaafdab263549 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 30 Jan 2021 12:16:27 +0100 Subject: [PATCH 02/68] whitespace --- src/ext/lib/video-data/PlayerData.js | 1 + src/ext/lib/video-transform/Stretcher.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/ext/lib/video-data/PlayerData.js b/src/ext/lib/video-data/PlayerData.js index 3d787ca..7e4b69d 100644 --- a/src/ext/lib/video-data/PlayerData.js +++ b/src/ext/lib/video-data/PlayerData.js @@ -37,6 +37,7 @@ if (process.env.CHANNEL !== 'stable'){ */ class PlayerData { + constructor(videoData) { try { this.logger = videoData.logger; diff --git a/src/ext/lib/video-transform/Stretcher.js b/src/ext/lib/video-transform/Stretcher.js index ea9306e..f767517 100644 --- a/src/ext/lib/video-transform/Stretcher.js +++ b/src/ext/lib/video-transform/Stretcher.js @@ -187,6 +187,7 @@ squeezeFactor: ${squeezeFactor}`, '\nvideo', this.conf.video); this.logger.log('info', 'stretcher', "[Stretcher.js::calculateStretch] stretching strategy 3") } + } else { // player adds LETTERBOX From 5bd29524375404a6e679c04b5c62264125f6f73a Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sat, 30 Jan 2021 12:16:37 +0100 Subject: [PATCH 03/68] Fix chrome bug .. hopefully --- src/ext/lib/video-transform/Resizer.js | 2 ++ src/ext/lib/video-transform/Scaler.js | 24 +++++++++++++ src/ext/lib/video-transform/Stretcher.js | 43 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js index 1176df6..024b46e 100644 --- a/src/ext/lib/video-transform/Resizer.js +++ b/src/ext/lib/video-transform/Resizer.js @@ -269,6 +269,8 @@ class Resizer { this.zoom.applyZoom(stretchFactors); + this.stretcher.chromeBugMitigation(stretchFactors); + var translate = this.computeOffsets(stretchFactors); this.applyCss(stretchFactors, translate); } diff --git a/src/ext/lib/video-transform/Scaler.js b/src/ext/lib/video-transform/Scaler.js index b625ac2..e972646 100644 --- a/src/ext/lib/video-transform/Scaler.js +++ b/src/ext/lib/video-transform/Scaler.js @@ -180,6 +180,30 @@ class Scaler { this.logger.log('info', 'scaler', "[Scaler::calculateCrop] Crop factor calculated — ", videoDimensions.xFactor); + // Workaround for Chrome/Edge issue where zooming too much results in video being stretched incorrectly + /** + * Bug description — if the following are true: + * * user is using Chrome or Edge (but surprisingly not Opera) + * * user is using hardware acceleration + * * user is using a noVideo card + * * user is in full screen mode + * Then the video will do Stretch.Basic no matter what you put in `transform: scale(x,y)`. + * + * Because this issue happens regardless of how you upscale the video (doesn't matter if you use transform:scale + * or width+height or anything else), the aspect ratio needs to be limited _before_ applying arCorrectionFactor + * (note that arCorrectionFactor is usually <= 1, as it conpensates for zooming that height=[>100%] on