|
|
|
|
|
|
564
|
|
564
|
|
|
565
|
if( this.gl ) {
|
565
|
if( this.gl ) {
|
|
566
|
this.gl.useProgram(this.program);
|
566
|
this.gl.useProgram(this.program);
|
|
|
|
567
|
+
|
|
|
|
568
|
+ // WebGL doesn't like Uint8ClampedArrays, so we have to create a
|
|
|
|
569
|
+ // Uint8Array view for each plane
|
|
|
|
570
|
+ this.currentYUint8 = new Uint8Array(this.currentY.buffer),
|
|
|
|
571
|
+ this.currentCrUint8 = new Uint8Array(this.currentCr.buffer),
|
|
|
|
572
|
+ this.currentCbUint8 = new Uint8Array(this.currentCb.buffer);
|
|
567
|
}
|
573
|
}
|
|
568
|
else {
|
574
|
else {
|
|
569
|
this.currentRGBA = this.canvasContext.getImageData(0, 0, this.width, this.height);
|
575
|
this.currentRGBA = this.canvasContext.getImageData(0, 0, this.width, this.height);
|
|
|
|
|
|
|
837
|
|
843
|
|
|
838
|
jsmpeg.prototype.renderFrameGL = function() {
|
844
|
jsmpeg.prototype.renderFrameGL = function() {
|
|
839
|
var gl = this.gl;
|
845
|
var gl = this.gl;
|
|
840
|
-
|
|
|
|
841
|
- // WebGL doesn't like Uint8ClampedArrays, so we have to create a Uint8Array view for
|
|
|
|
842
|
- // each plane
|
|
|
|
843
|
- var uint8Y = new Uint8Array(this.currentY.buffer),
|
|
|
|
844
|
- uint8Cr = new Uint8Array(this.currentCr.buffer),
|
|
|
|
845
|
- uint8Cb = new Uint8Array(this.currentCb.buffer);
|
|
|
|
846
|
|
846
|
|
|
847
|
gl.activeTexture(gl.TEXTURE0);
|
847
|
gl.activeTexture(gl.TEXTURE0);
|
|
848
|
gl.bindTexture(gl.TEXTURE_2D, this.YTexture);
|
848
|
gl.bindTexture(gl.TEXTURE_2D, this.YTexture);
|
|
849
|
|
849
|
|
|
850
|
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.codedWidth, this.height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, uint8Y);
|
|
|
|
|
|
850
|
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.codedWidth, this.height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, this.currentYUint8);
|
|
851
|
|
851
|
|
|
852
|
gl.activeTexture(gl.TEXTURE1);
|
852
|
gl.activeTexture(gl.TEXTURE1);
|
|
853
|
gl.bindTexture(gl.TEXTURE_2D, this.CBTexture);
|
853
|
gl.bindTexture(gl.TEXTURE_2D, this.CBTexture);
|
|
854
|
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.halfWidth, this.height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, uint8Cr);
|
|
|
|
|
|
854
|
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.halfWidth, this.height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, this.currentCrUint8);
|
|
855
|
|
855
|
|
|
856
|
gl.activeTexture(gl.TEXTURE2);
|
856
|
gl.activeTexture(gl.TEXTURE2);
|
|
857
|
gl.bindTexture(gl.TEXTURE_2D, this.CRTexture);
|
857
|
gl.bindTexture(gl.TEXTURE_2D, this.CRTexture);
|
|
858
|
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.halfWidth, this.height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, uint8Cb);
|
|
|
|
|
|
858
|
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, this.halfWidth, this.height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, this.currentCbUint8);
|
|
859
|
|
859
|
|
|
860
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
860
|
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
861
|
};
|
861
|
};
|