trtc-electron-sdk 9.3.112-beta.1 → 9.3.112-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -74,7 +74,6 @@ class Renderer {
|
|
|
74
74
|
this.yuv = null;
|
|
75
75
|
this.element = null;
|
|
76
76
|
this.canvas = null;
|
|
77
|
-
this.view = null;
|
|
78
77
|
}
|
|
79
78
|
refreshCanvas() {
|
|
80
79
|
}
|
|
@@ -109,11 +108,49 @@ class Renderer {
|
|
|
109
108
|
this.canvas.style.transform = 'rotateY(180deg)';
|
|
110
109
|
}
|
|
111
110
|
}
|
|
111
|
+
_adjustImageData(imageData) {
|
|
112
|
+
const { width, height, yUint8Array, uUint8Array, vUint8Array } = imageData;
|
|
113
|
+
const widthBase = 8;
|
|
114
|
+
const w8Modulo = width % widthBase;
|
|
115
|
+
if (w8Modulo !== 0) {
|
|
116
|
+
const newWidth = width - w8Modulo;
|
|
117
|
+
const newYSize = newWidth * height;
|
|
118
|
+
const newYArrayBuffer = new ArrayBuffer(newYSize);
|
|
119
|
+
const newYUint8Array = new Uint8Array(newYArrayBuffer);
|
|
120
|
+
let oldIndex = -1, newIndex = -1;
|
|
121
|
+
for (let h = 0; h < height; h += 1) {
|
|
122
|
+
for (let w = 0; w < newWidth; w += 1) {
|
|
123
|
+
oldIndex = width * h + w;
|
|
124
|
+
newIndex = newWidth * h + w;
|
|
125
|
+
newYUint8Array[newIndex] = yUint8Array[oldIndex];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const oldChromaWidth = width / 2;
|
|
129
|
+
const newChromaWidth = newWidth / 2;
|
|
130
|
+
const chromaHeight = height / 2;
|
|
131
|
+
const newChromaSize = newChromaWidth * chromaHeight;
|
|
132
|
+
const newUArrayBuffer = new ArrayBuffer(newChromaSize);
|
|
133
|
+
const newUInt8Array = new Uint8Array(newUArrayBuffer);
|
|
134
|
+
const newVArrayBuffer = new ArrayBuffer(newChromaSize);
|
|
135
|
+
const newVInt8Array = new Uint8Array(newVArrayBuffer);
|
|
136
|
+
for (let h = 0; h < chromaHeight; h += 1) {
|
|
137
|
+
for (let w = 0; w < newChromaWidth; w += 1) {
|
|
138
|
+
oldIndex = oldChromaWidth * h + w;
|
|
139
|
+
newIndex = newChromaWidth * h + w;
|
|
140
|
+
newUInt8Array[newIndex] = uUint8Array[oldIndex];
|
|
141
|
+
newVInt8Array[newIndex] = vUint8Array[oldIndex];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return Object.assign(Object.assign({}, imageData), { width: newWidth, height, yUint8Array: newYUint8Array, uUint8Array: newUInt8Array, vUint8Array: newVInt8Array });
|
|
145
|
+
}
|
|
146
|
+
return imageData;
|
|
147
|
+
}
|
|
112
148
|
drawFrame(imageData) {
|
|
113
149
|
if (!this.ready) {
|
|
114
150
|
this.ready = true;
|
|
115
151
|
this.event.emit('ready');
|
|
116
152
|
}
|
|
153
|
+
imageData = this._adjustImageData(imageData);
|
|
117
154
|
const mirror = 0;
|
|
118
155
|
const contentWidth = imageData.width;
|
|
119
156
|
const contentHeight = imageData.height;
|
package/liteav/trtc.js
CHANGED
|
@@ -3322,7 +3322,7 @@ class TRTCCloud extends events_1.EventEmitter {
|
|
|
3322
3322
|
let ulen = width * height / 4;
|
|
3323
3323
|
let ydata = new Uint8Array(data, 0, ylen);
|
|
3324
3324
|
let udata = new Uint8Array(data, ylen, ulen);
|
|
3325
|
-
let vdata = new Uint8Array(data, ylen + ulen,
|
|
3325
|
+
let vdata = new Uint8Array(data, ylen + ulen, ulen);
|
|
3326
3326
|
renderer.drawFrame({
|
|
3327
3327
|
width: width,
|
|
3328
3328
|
height: height,
|