| 2533 | } |
| 2534 | |
| 2535 | function parseWebP(riff) { |
| 2536 | var VP8 = riff.RIFF[0].WEBP[0]; |
| 2537 | |
| 2538 | var frameStart = VP8.indexOf('\x9d\x01\x2a'); // A VP8 keyframe starts with the 0x9d012a header |
| 2539 | for (var i = 0, c = []; i < 4; i++) { |
| 2540 | c[i] = VP8.charCodeAt(frameStart + 3 + i); |
| 2541 | } |
| 2542 | |
| 2543 | var width, height, tmp; |
| 2544 | |
| 2545 | //the code below is literally copied verbatim from the bitstream spec |
| 2546 | tmp = (c[1] << 8) | c[0]; |
| 2547 | width = tmp & 0x3FFF; |
| 2548 | tmp = (c[3] << 8) | c[2]; |
| 2549 | height = tmp & 0x3FFF; |
| 2550 | return { |
| 2551 | width: width, |
| 2552 | height: height, |
| 2553 | data: VP8, |
| 2554 | riff: riff |
| 2555 | }; |
| 2556 | } |
| 2557 | |
| 2558 | function getStrLength(string, offset) { |
| 2559 | return parseInt(string.substr(offset + 4, 4).split('').map(function(i) { |