shithub: h264bsd

Download patch

ref: 93218e30ee1318532ff85a6111c97aa231cd0a0c
parent: 6866ab687ccd1b19d21f2125d63c9bd4c75735e9
author: Chris Jarabek <chris.jarabek@gmail.com>
date: Wed Feb 12 08:32:42 EST 2014

Fixed YUV->RGB conversion.

--- a/js/h264bsd.js
+++ b/js/h264bsd.js
@@ -189,6 +189,8 @@
     var croppingInfo = H264Decoder.getCroppingInfo_(self.Module, self.pStorage);
 
     //Return bytes according to the requested format
+    var mbWidth = H264Decoder.h264bsdPicWidth_(self.Module, self.pStorage)*16;
+    var mbHeight = H264Decoder.h264bsdPicHeight_(self.Module, self.pStorage)*16;
     if (self.useWebGL){
 		ret = {
 		    encoding: 'YUV',
@@ -195,17 +197,17 @@
 		    picture: bytes, 
 		    height: croppingInfo.height, 
 		    width: croppingInfo.width,
-		    mbWidth: (H264Decoder.h264bsdPicWidth_(self.Module, self.pStorage)*16),
-		    mbHeight: (H264Decoder.h264bsdPicHeight_(self.Module, self.pStorage)*16)
+		    mbWidth: mbWidth,
+		    mbHeight: mbHeight
 		};		
     }else{
 		ret = {
 			encoding: 'RGB',
-		    picture: H264Decoder.convertYUV2RGB_(bytes, croppingInfo, self), 
+		    picture: H264Decoder.convertYUV2RGB_(bytes, croppingInfo, self, mbWidth, mbHeight),
 		    height: croppingInfo.height, 
 		    width: croppingInfo.width,
-  		    mbWidth: (H264Decoder.h264bsdPicWidth_(self.Module, self.pStorage)*16),
-		    mbHeight: (H264Decoder.h264bsdPicHeight_(self.Module, self.pStorage)*16)
+  		    mbWidth: mbWidth,
+		    mbHeight: mbHeight
 		};
     }
     
@@ -279,9 +281,9 @@
 };
 
 //If WebGL Canvas is not availble, this will convert an array of yuv bytes into an array of rgb bytes
-H264Decoder.convertYUV2RGB_ = function(yuvBytes, croppingInfo, exCtx){
-	var width = croppingInfo.width - croppingInfo.left;
-	var height = croppingInfo.height - croppingInfo.top;
+H264Decoder.convertYUV2RGB_ = function(yuvBytes, croppingInfo, exCtx, mbWidth, mbHeight){
+	var width = mbWidth - croppingInfo.left;
+	var height = mbHeight - croppingInfo.top;
 	var rgbBytes = new Uint8ClampedArray(4 * height * width);
 
 	var lumaSize = width * height;