| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <style> | 4 <style> |
| 5 body { | 5 body { |
| 6 color: white; | 6 color: white; |
| 7 background-color: black; | 7 background-color: black; |
| 8 } | 8 } |
| 9 </style> | 9 </style> |
| 10 </head> | 10 </head> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 log(message); | 111 log(message); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 function verifyVideo() { | 115 function verifyVideo() { |
| 116 var videoElem = document.querySelector('video'); | 116 var videoElem = document.querySelector('video'); |
| 117 var offscreen = document.createElement('canvas'); | 117 var offscreen = document.createElement('canvas'); |
| 118 offscreen.width = videoElem.videoWidth; | 118 offscreen.width = videoElem.videoWidth; |
| 119 offscreen.height = videoElem.videoHeight; | 119 offscreen.height = videoElem.videoHeight; |
| 120 offscreen.getContext('2d') | 120 offscreen.getContext('2d').drawImage(videoElem, 0, 0, offscreen.width, |
| 121 .drawImage(videoElem, 0, 0, offscreen.width, offscreen.height); | 121 offscreen.height); |
| 122 | 122 |
| 123 videoData = getCanvasPixels(offscreen); | 123 videoData = getCanvasPixels(offscreen); |
| 124 if (!videoData) | 124 if (!videoData) |
| 125 return false; | 125 return false; |
| 126 | 126 |
| 127 // Check the color of a givel pixel |x,y| in |imgData| against an | 127 // Check the color of a givel pixel |x,y| in |imgData| against an |
| 128 // expected value, |expected|, with up to |allowedError| difference. | 128 // expected value, |expected|, with up to |allowedError| difference. |
| 129 function checkColor(imgData, x, y, stride, expected, allowedError) { | 129 function checkColor(imgData, x, y, stride, expected, allowedError) { |
| 130 for (var i = 0; i < 3; ++i) { | 130 for (var i = 0; i < 3; ++i) { |
| 131 if (Math.abs(imgData[(x + y * stride) * 4 + i] - expected) > | 131 var actual = imgData[(x + y * stride) * 4 + i]; |
| 132 allowedError) { | 132 if (Math.abs(actual - expected) > allowedError) { |
| 133 log('Color didn\'t match at (' + x + ', ' + y + '). Expected: ' + |
| 134 expected + ', actual: ' + actual); |
| 133 return false; | 135 return false; |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 return true; | 138 return true; |
| 137 } | 139 } |
| 138 | 140 |
| 139 // Check one pixel in each quadrant (in the upper left, away from | 141 // Check one pixel in each quadrant (in the upper left, away from |
| 140 // boundaries and the text, to avoid compression artifacts). | 142 // boundaries and the text, to avoid compression artifacts). |
| 141 // Also allow a small error, for the same reason. | 143 // Also allow a small error, for the same reason. |
| 142 | 144 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 meanSquaredError /= width * height; | 225 meanSquaredError /= width * height; |
| 224 log('Mean squared error: ' + meanSquaredError); | 226 log('Mean squared error: ' + meanSquaredError); |
| 225 diffCtx.putImageData(diffIData, 0, 0); | 227 diffCtx.putImageData(diffIData, 0, 0); |
| 226 maskCtx.putImageData(maskIData, 0, 0); | 228 maskCtx.putImageData(maskIData, 0, 0); |
| 227 document.getElementById('diff').style.visibility = 'visible'; | 229 document.getElementById('diff').style.visibility = 'visible'; |
| 228 document.getElementById('mask').style.visibility = 'visible'; | 230 document.getElementById('mask').style.visibility = 'visible'; |
| 229 } | 231 } |
| 230 </script> | 232 </script> |
| 231 </body> | 233 </body> |
| 232 </html> | 234 </html> |
| OLD | NEW |