Skip to content

Commit

Permalink
Fix the return of odd-numbered pixels for the x264 encoder (#132)
Browse files Browse the repository at this point in the history
* Fix the return of odd-numbered pixels for the x264 encoder

The point of subtracting a dimension%2 from its actual dimension is to
avoid odd-numbered pixels, so due to variation of DPR from device to
device the subtraction should be done at the end of the pixel calculation.

* Make the variables slightly less universal

---------

Co-authored-by: Seungmin Kim <[email protected]>
  • Loading branch information
PMohanJ and ehfd authored Dec 29, 2023
1 parent 2498ecc commit 7659218
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/gst-web/src/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ class Input {

getWindowResolution() {
return [
parseInt((document.body.offsetWidth - document.body.offsetWidth%2) * window.devicePixelRatio),
parseInt((document.body.offsetHeight - document.body.offsetHeight%2) * window.devicePixelRatio)
parseInt( (() => {var offsetRatioWidth = document.body.offsetWidth * window.devicePixelRatio; return offsetRatioWidth - offsetRatioWidth % 2})() ),
parseInt( (() => {var offsetRatioHeight = document.body.offsetHeight * window.devicePixelRatio; return offsetRatioHeight - offsetRatioHeight % 2})() )
];
}
}
Expand All @@ -562,4 +562,4 @@ function addListener(obj, name, func, ctx) {
function removeListeners(listeners) {
for (const listener of listeners)
listener[0].removeEventListener(listener[1], listener[2]);
}
}

0 comments on commit 7659218

Please sign in to comment.