From 78da45d468ddcf8ffb9965c1a1700af8191670fb Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Sun, 31 Oct 2021 23:18:44 +0100 Subject: [PATCH] cosmetic stuff --- .vscode/settings.json | 1 + src/ext/lib/video-transform/Resizer.ts | 7 ---- src/ext/lib/video-transform/Scaler.ts | 58 +++++++++++--------------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 70a754e..2436251 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -50,6 +50,7 @@ "tablist", "tamius", "textbox", + "ultrawide", "ultrawidify", "unmark", "unmarking", diff --git a/src/ext/lib/video-transform/Resizer.ts b/src/ext/lib/video-transform/Resizer.ts index 60f6603..4270ad3 100644 --- a/src/ext/lib/video-transform/Resizer.ts +++ b/src/ext/lib/video-transform/Resizer.ts @@ -257,12 +257,6 @@ class Resizer { this.lastAr = {type: ar.type, ratio: ar.ratio}; } - // if (this.extensionMode === ExtensionMode.Basic && !PlayerData.isFullScreen() && ar.type !== AspectRatioType.Reset) { - // // don't actually apply or calculate css when using basic mode if not in fullscreen - // // ... unless we're resetting the aspect ratio to original - // return; - // } - if (! this.video) { this.conf.destroy(); } @@ -336,7 +330,6 @@ class Resizer { this.applyCss(stretchFactors, translate); } - toFixedAr() { // converting to fixed AR means we also turn off autoAR this.setAr({ diff --git a/src/ext/lib/video-transform/Scaler.ts b/src/ext/lib/video-transform/Scaler.ts index d87664e..e1d9a65 100644 --- a/src/ext/lib/video-transform/Scaler.ts +++ b/src/ext/lib/video-transform/Scaler.ts @@ -8,10 +8,10 @@ import Logger from '../Logger'; export enum CropStrategy { /** * Nomenclature explained: - * + * * SP - stream AR < player AR * PS - the opposite of ↑ - * + * * ArDominant - given aspect ratio is bigger than stream AR and player AR * PSDominant - stream AR or player AR are bigger than given aspect ratio */ @@ -31,7 +31,6 @@ export type VideoDimensions = { actualHeight?: number; } -// računa velikost videa za približevanje/oddaljevanje // does video size calculations for zooming/cropping @@ -46,14 +45,12 @@ class Scaler { this.conf = videoData; this.logger = videoData.logger; } - - // Skrbi za "stare" možnosti, kot na primer "na širino zaslona", "na višino zaslona" in "ponastavi". - // Približevanje opuščeno. - // handles "legacy" options, such as 'fit to widht', 'fit to height' and AspectRatioType.Reset. No zoom tho + + // handles "legacy" options, such as 'fit to width', 'fit to height' and AspectRatioType.Reset. No zoom tho modeToAr (ar) { if (ar.type !== AspectRatioType.FitWidth && ar.type !== AspectRatioType.FitHeight && ar.ratio) { - return ar.ratio; + return ar.ratio; } let ratioOut; @@ -64,21 +61,18 @@ class Scaler { return null; } - + if (!this.conf.player.dimensions) { ratioOut = screen.width / screen.height; } else { ratioOut = this.conf.player.dimensions.width / this.conf.player.dimensions.height; } - - // POMEMBNO: lastAr je potrebno nastaviti šele po tem, ko kličemo _res_setAr(). _res_setAr() predvideva, - // da želimo nastaviti statično (type: 'static') razmerje stranic — tudi, če funkcijo kličemo tu oz. v ArDetect. - // + // IMPORTANT NOTE: lastAr needs to be set after _res_setAr() is called, as _res_setAr() assumes we're - // setting a static aspect ratio (even if the function is called from here or ArDetect). - + // setting a static aspect ratio (even if the function is called from here or ArDetect). + let fileAr = this.conf.video.videoWidth / this.conf.video.videoHeight; - + if (ar.type === AspectRatioType.FitWidth) { ratioOut > fileAr ? ratioOut : fileAr ar.ratio = ratioOut; @@ -102,16 +96,16 @@ class Scaler { /** * STEP 1: NORMALIZE ASPECT RATIO * - * Video width is normalized based on 100% of the parent. That means if the player AR + * Video width is normalized based on 100% of the parent. That means if the player AR * is narrower than video ar, we need to pre-downscale the video. This scaling already - * undoes any zoom that style="height:123%" on the video element adds. - * - * There are few exceptions and additional caveatss: + * undoes any zoom that style="height:123%" on the video element adds. + * + * There are few exceptions and additional caveats: * * AspectRatioType.FitHeight: we don't want to pre-downscale the video at all, as things * will be scaled to fit height as-is. * * When player is wider than stream, we want to undo any height compensations site * tacks on the video tag. - * + * * Quick notes: * * when I say 'video AR', I actually mean aspect ratio after we've compensated for * any possible 'height:' stuffs in the style attribute of the video tag @@ -135,7 +129,7 @@ class Scaler { if(!this.conf.video){ this.logger.log('info', 'debug', "[Scaler::calculateCrop] ERROR — no video detected. Conf:", this.conf, "video:", this.conf.video, "video dimensions:", this.conf.video && this.conf.video.videoWidth, '×', this.conf.video && this.conf.video.videoHeight); - + this.conf.destroy(); return {error: "no_video"}; } @@ -164,19 +158,17 @@ class Scaler { return {error: "this.conf.player.dimensions_error"}; } - // zdaj lahko končno začnemo računati novo velikost videa // we can finally start computing required video dimensions now: - // Dejansko razmerje stranic datoteke/