diff --git a/src/common/components/ActionAlt.vue b/src/common/components/ActionAlt.vue
index 47cf2e2..5964ac2 100644
--- a/src/common/components/ActionAlt.vue
+++ b/src/common/components/ActionAlt.vue
@@ -5,7 +5,7 @@
- 🗙
+ 🗙
🗙
🖉
{{action.name}}
diff --git a/src/common/enums/stretch.enum.js b/src/common/enums/stretch.enum.js
index a5c0915..130f92b 100644
--- a/src/common/enums/stretch.enum.js
+++ b/src/common/enums/stretch.enum.js
@@ -3,6 +3,8 @@ var Stretch = Object.freeze({
Basic: 1,
Hybrid: 2,
Conditional: 3,
+ Fixed: 4,
+ FixedSource: 5,
Default: -1
});
diff --git a/src/ext/conf/ActionList.js b/src/ext/conf/ActionList.js
index c41f906..8032ea1 100644
--- a/src/ext/conf/ActionList.js
+++ b/src/ext/conf/ActionList.js
@@ -72,6 +72,20 @@ var ActionList = {
},{
name: 'Thin borders',
arg: Stretch.Conditional,
+ },{
+ name: 'Fixed (source)',
+ arg: Stretch.FixedSource,
+ customArg: true,
+ scopes: {
+ page: true,
+ }
+ },{
+ name: 'Fixed (displayed)',
+ arg: Stretch.Fixed,
+ customArg: true,
+ scopes: {
+ page: true,
+ }
},{
name: 'Default',
arg: Stretch.Default,
diff --git a/src/ext/conf/ExtConfPatches.js b/src/ext/conf/ExtConfPatches.js
index b14c719..8912888 100644
--- a/src/ext/conf/ExtConfPatches.js
+++ b/src/ext/conf/ExtConfPatches.js
@@ -1,5 +1,6 @@
// How to use:
// version: {ExtensionConf object, but only properties that get overwritten}
+import Stretch from '../../common/enums/stretch.enum';
const ExtensionConfPatch = [
{
@@ -146,6 +147,7 @@ const ExtensionConfPatch = [
show: true,
}
}, {
+ userAdded: true,
name: 'Persist crop while on page',
label: 'Until page load',
cmd: [{
@@ -164,6 +166,7 @@ const ExtensionConfPatch = [
show: true,
}
}, {
+ userAdded: true,
name: 'Persist crop for current session',
label: 'Current session',
cmd: [{
@@ -252,6 +255,50 @@ const ExtensionConfPatch = [
}
},
}
+ }, {
+ forVersion: '4.4.2',
+ updateFn: (userOptions, defaultOptions) => {
+ try {
+ userOptions.actions.push(
+ {
+ name: 'Stretch source to 4:3',
+ label: '4:3 stretch (src)',
+ cmd: [{
+ action: 'set-stretch',
+ arg: Stretch.FixedSource,
+ customArg: 1.33,
+ }],
+ scopes: {
+ page: {
+ show: true
+ }
+ },
+ playerUi: {
+ show: true,
+ path: 'crop'
+ }
+ }, {
+ name: 'Stretch source to 16:9',
+ label: '16:9 stretch (src)',
+ cmd: [{
+ action: 'set-stretch',
+ arg: Stretch.FixedSource,
+ customArg: 1.77,
+ }],
+ scopes: {
+ page: {
+ show: true,
+ }
+ },
+ playerUi: {
+ show: true,
+ path: 'crop'
+ }
+ });
+ } catch (e) {
+ console.error("PROBLEM APPLYING SETTINGS", e);
+ }
+ }
}
];
diff --git a/src/ext/conf/ExtensionConf.js b/src/ext/conf/ExtensionConf.js
index e9f99c0..052c2d8 100644
--- a/src/ext/conf/ExtensionConf.js
+++ b/src/ext/conf/ExtensionConf.js
@@ -285,6 +285,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
+ userAdded: true,
name: 'Set aspect ratio to 16:9',
label: '16:9',
cmd: [{
@@ -312,6 +313,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
+ userAdded: true,
name: 'Set aspect ratio to 21:9 (2.39:1)',
label: '21:9',
cmd: [{
@@ -339,6 +341,7 @@ var ExtensionConf = {
path: 'crop'
}
}, {
+ userAdded: true,
name: 'Set aspect ratio to 18:9',
label: '18:9',
cmd: [{
@@ -651,6 +654,41 @@ var ExtensionConf = {
show: true,
}
}
+ }, // NEW OPTIONS
+ {
+ name: 'Stretch source to 4:3',
+ label: '4:3 stretch (src)',
+ cmd: [{
+ action: 'set-stretch',
+ arg: Stretch.FixedSource,
+ customArg: 1.33,
+ }],
+ scopes: {
+ page: {
+ show: true,
+ }
+ },
+ playerUi: {
+ show: true,
+ path: 'crop'
+ }
+ }, {
+ name: 'Stretch source to 16:9',
+ label: '16:9 stretch (src)',
+ cmd: [{
+ action: 'set-stretch',
+ arg: Stretch.FixedSource,
+ customArg: 1.77,
+ }],
+ scopes: {
+ page: {
+ show: true,
+ }
+ },
+ playerUi: {
+ show: true,
+ path: 'crop'
+ }
},
//
// A L I G N M E N T
@@ -920,8 +958,8 @@ var ExtensionConf = {
}
}
},
-],
-whatsNewChecked: true,
+ ],
+ whatsNewChecked: true,
// -----------------------------------------
// ::: SITE CONFIGURATION :::
// -----------------------------------------
diff --git a/src/ext/lib/comms/CommsClient.js b/src/ext/lib/comms/CommsClient.js
index cd8c7d9..1f96ed1 100644
--- a/src/ext/lib/comms/CommsClient.js
+++ b/src/ext/lib/comms/CommsClient.js
@@ -65,7 +65,7 @@ class CommsClient {
this.pageInfo.setVideoAlignment(message.arg, message.playing);
this.pageInfo.restoreAr();
} else if (message.cmd === "set-stretch") {
- this.pageInfo.setStretchMode(message.arg, message.playing);
+ this.pageInfo.setStretchMode(message.arg, message.playing, message.customArg);
} else if (message.cmd === 'set-keyboard') {
this.pageInfo.setKeyboardShortcutsEnabled(message.arg)
} else if (message.cmd === "autoar-start") {
diff --git a/src/ext/lib/video-data/PageInfo.js b/src/ext/lib/video-data/PageInfo.js
index 6e055a9..024a6c7 100644
--- a/src/ext/lib/video-data/PageInfo.js
+++ b/src/ext/lib/video-data/PageInfo.js
@@ -490,18 +490,18 @@ class PageInfo {
}
}
- setStretchMode(sm, playingOnly){
+ setStretchMode(stretchMode, playingOnly, fixedStretchRatio){
// TODO: find a way to only change aspect ratio for one video
if (playingOnly) {
for(var vd of this.videos){
if (vd.isPlaying()) {
- vd.setStretchMode(sm)
+ vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
} else {
for(var vd of this.videos){
- vd.setStretchMode(sm)
+ vd.setStretchMode(stretchMode, fixedStretchRatio)
}
}
}
diff --git a/src/ext/lib/video-data/VideoData.js b/src/ext/lib/video-data/VideoData.js
index beccc6f..11eb481 100644
--- a/src/ext/lib/video-data/VideoData.js
+++ b/src/ext/lib/video-data/VideoData.js
@@ -359,11 +359,11 @@ class VideoData {
this.resizer.restore();
}
- setStretchMode(stretchMode){
+ setStretchMode(stretchMode, fixedStretchRatio){
if (this.invalid) {
return;
}
- this.resizer.setStretchMode(stretchMode);
+ this.resizer.setStretchMode(stretchMode, fixedStretchRatio);
}
setZoom(zoomLevel, no_announce){
diff --git a/src/ext/lib/video-transform/Resizer.js b/src/ext/lib/video-transform/Resizer.js
index dd87f6b..5b6c1af 100644
--- a/src/ext/lib/video-transform/Resizer.js
+++ b/src/ext/lib/video-transform/Resizer.js
@@ -242,7 +242,9 @@ class Resizer {
}
// do stretch thingy
- if (this.stretcher.mode === Stretch.NoStretch || this.stretcher.mode === Stretch.Conditional){
+ if (this.stretcher.mode === Stretch.NoStretch
+ || this.stretcher.mode === Stretch.Conditional
+ || this.stretcher.mode === Stretch.FixedSource){
var stretchFactors = this.scaler.calculateCrop(ar);
if(! stretchFactors || stretchFactors.error){
@@ -255,15 +257,23 @@ class Resizer {
}
return;
}
- if(this.stretcher.mode === Stretch.Conditional){
- this.stretcher.applyConditionalStretch(stretchFactors, ar.ratio);
- }
- this.logger.log('info', 'debug', "[Resizer::setAr] Processed stretch factors for ", this.stretcher.mode === Stretch.NoStretch ? 'stretch-free crop.' : 'crop with conditional stretch.', 'Stretch factors are:', stretchFactors);
+ if (this.stretcher.mode === Stretch.Conditional){
+ this.stretcher.applyConditionalStretch(stretchFactors, ar.ratio);
+ } else if (this.stretcher.mode === Stretch.FixedSource) {
+ this.stretcher.applyStretchFixedSource(stretchFactors);
+ }
+ this.logger.log('info', 'debug', "[Resizer::setAr] Processed stretch factors for ",
+ this.stretcher.mode === Stretch.NoStretch ? 'stretch-free crop.' :
+ this.stretcher.mode === Stretch.Conditional ? 'crop with conditional stretch.' : 'crop with fixed stretch',
+ 'Stretch factors are:', stretchFactors
+ );
} else if (this.stretcher.mode === Stretch.Hybrid) {
var stretchFactors = this.stretcher.calculateStretch(ar.ratio);
this.logger.log('info', 'debug', '[Resizer::setAr] Processed stretch factors for hybrid stretch/crop. Stretch factors are:', stretchFactors);
+ } else if (this.stretcher.mode === Stretch.Fixed) {
+ var stretchFactors = this.stretchFactors.calculateStretchFixed(ar.ratio)
} else if (this.stretcher.mode === Stretch.Basic) {
var stretchFactors = this.stretcher.calculateBasicStretch();
this.logger.log('info', 'debug', '[Resizer::setAr] Processed stretch factors for basic stretch. Stretch factors are:', stretchFactors);
@@ -296,8 +306,8 @@ class Resizer {
return this.lastAr;
}
- setStretchMode(stretchMode){
- this.stretcher.setStretchMode(stretchMode);
+ setStretchMode(stretchMode, fixedStretchRatio){
+ this.stretcher.setStretchMode(stretchMode, fixedStretchRatio);
this.restore();
}
@@ -459,8 +469,6 @@ class Resizer {
'\nwdiff, hdiffAfterZoom:', wdiffAfterZoom, 'x', hdiffAfterZoom,
'\n\n---- data out ----\n',
'translate:', translate);
- console.trace();
-
return translate;
}
diff --git a/src/ext/lib/video-transform/Stretcher.js b/src/ext/lib/video-transform/Stretcher.js
index b54f94d..2a5f48f 100644
--- a/src/ext/lib/video-transform/Stretcher.js
+++ b/src/ext/lib/video-transform/Stretcher.js
@@ -15,12 +15,16 @@ class Stretcher {
this.logger = videoData.logger;
this.settings = videoData.settings;
this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
+ this.fixedStretchRatio = undefined;
}
- setStretchMode(stretchMode) {
+ setStretchMode(stretchMode, fixedStretchRatio) {
if (stretchMode === Stretch.Default) {
this.mode = this.settings.getDefaultStretchMode(window.location.hostname);
} else {
+ if (stretchMode === Stretch.Fixed || stretchMode == Stretch.FixedSource) {
+ this.fixedStretchRatio = fixedStretchRatio;
+ }
this.mode = stretchMode;
}
}
@@ -95,9 +99,43 @@ class Stretcher {
};
}
- calculateStretch(actualAr) {
- var playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
- var videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
+ applyStretchFixedSource(postCropStretchFactors) {
+ const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
+ const playerAr = this.conf.player.dimensions.width / this.conf.player.dimensions.height;
+
+ const squezeFactor = this.fixedStretchRatio / videoAr;
+
+ // Whether squeezing happens on X or Y axis depends on whether required AR is wider or narrower than
+ // the player, in which the video is displayed
+ // * we squeeze X axis, if target AR is narrower than player size
+ // * we squeeze Y axis, if target AR is wider than the player size
+
+ this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we got:
+postCropStretchFactors: x=${postCropStretchFactors.xFactor} y=${postCropStretchFactors.yFactor}
+fixedStretchRatio: ${this.fixedStretchRatio}
+videoAr: ${videoAr}
+playerAr: ${playerAr}
+squeezeFactor: ${squezeFactor}`, '\nvideo', this.conf.video);
+
+
+ if (this.fixedStretchRatio < playerAr) {
+ postCropStretchFactors.xFactor *= squezeFactor;
+ } else {
+ postCropStretchFactors.yFactor *= squezeFactor;
+ }
+
+ this.logger.log('info', 'stretcher', `[Stretcher::applyStretchFixedSource] here's what we'll apply:\npostCropStretchFactors: x=${postCropStretchFactors.x} y=${postCropStretchFactors.y}`);
+
+ return postCropStretchFactors;
+ }
+
+ calculateStretchFixed(actualAr) {
+ return this.calculateStretch(actualAr, this.fixedStretchRatio);
+ }
+
+ calculateStretch(actualAr, playerArOverride) {
+ const playerAr = playerArOverride || this.conf.player.dimensions.width / this.conf.player.dimensions.height;
+ const videoAr = this.conf.video.videoWidth / this.conf.video.videoHeight;
if (! actualAr){
actualAr = playerAr;
@@ -158,7 +196,7 @@ class Stretcher {
// video is letterboxed by player
// actual is pillarboxed by video
stretchFactors.xFactor = actualAr / playerAr;
- stretchFActors.yFactor = actualAr / playerAr;
+ stretchFactors.yFactor = actualAr / playerAr;
this.logger.log('info', 'stretcher', "[Stretcher.js::calculateStretch] stretching strategy 5")
} else {
diff --git a/src/options/controls-settings/AddEditActionPopup.vue b/src/options/controls-settings/AddEditActionPopup.vue
index 10a929f..b390da7 100644
--- a/src/options/controls-settings/AddEditActionPopup.vue
+++ b/src/options/controls-settings/AddEditActionPopup.vue
@@ -229,7 +229,7 @@ export default {
},
saveSettings() {
if (this.currentCmdIndex < 0) {
- this.settings.active.actions.push(this.action);
+ this.settings.active.actions.push({...this.action, ...{userAdded: true}});
}
this.settings.save();
this.close();
diff --git a/src/popup/panels/VideoPanel.vue b/src/popup/panels/VideoPanel.vue
index 3e66185..a75d401 100644
--- a/src/popup/panels/VideoPanel.vue
+++ b/src/popup/panels/VideoPanel.vue
@@ -22,6 +22,7 @@
>
+ You can change or add additional aspect ratios on the settings page (in 'actions&shortcuts' menu).