mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Fix rotation matrix detection
This commit is contained in:
@@ -592,12 +592,14 @@ export class IsobmffDemuxer extends Demuxer {
|
||||
}
|
||||
|
||||
this.isobmffReader.pos += 2 * 4 + 2 + 2 + 2 + 2;
|
||||
const rotationMatrix: number[] = [];
|
||||
rotationMatrix.push(this.isobmffReader.readFixed_16_16(), this.isobmffReader.readFixed_16_16());
|
||||
const values: number[] = [];
|
||||
values.push(this.isobmffReader.readFixed_16_16(), this.isobmffReader.readFixed_16_16());
|
||||
this.isobmffReader.pos += 4;
|
||||
rotationMatrix.push(this.isobmffReader.readFixed_16_16(), this.isobmffReader.readFixed_16_16());
|
||||
values.push(this.isobmffReader.readFixed_16_16(), this.isobmffReader.readFixed_16_16());
|
||||
|
||||
const matrixIndex = knownMatrixes.findIndex(x => x.every((y, i) => y === rotationMatrix[i]));
|
||||
const matrixIndex = knownMatrixes.findIndex((x) => {
|
||||
return x[0] === values[0] && x[1] === values[1] && x[3] === values[2] && x[4] === values[3];
|
||||
});
|
||||
if (matrixIndex === -1) {
|
||||
// console.warn(`Wacky rotation matrix ${rotationMatrix}; sticking with no rotation.`);
|
||||
track.rotation = 0;
|
||||
|
||||
+3
-3
@@ -127,10 +127,10 @@ export class AsyncMutex {
|
||||
}
|
||||
}
|
||||
|
||||
export const rotationMatrix = (rotationInDegrees: number): TransformationMatrix => {
|
||||
export const rotationMatrix = (rotationInDegrees: Rotation): TransformationMatrix => {
|
||||
const theta = rotationInDegrees * (Math.PI / 180);
|
||||
const cosTheta = Math.cos(theta);
|
||||
const sinTheta = Math.sin(theta);
|
||||
const cosTheta = Math.round(Math.cos(theta));
|
||||
const sinTheta = Math.round(Math.sin(theta));
|
||||
|
||||
// Matrices are post-multiplied in ISOBMFF, meaning this is the transpose of your typical rotation matrix
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user