From: Jer Noble Date: Thu, 6 Dec 2012 19:37:23 +0000 (-0800) Subject: First version. X-Git-Url: http://id.pley.net/movie_parser.git/commitdiff_plain/86cb3dcb7102f7c715c323bbd1c62f4f136ddfab?ds=sidebyside First version. --- 86cb3dcb7102f7c715c323bbd1c62f4f136ddfab diff --git a/Atom.js b/Atom.js new file mode 100644 index 0000000..50ba17f --- /dev/null +++ b/Atom.js @@ -0,0 +1,26 @@ +var Atom = function(buffer, offset) { + this.size = 0; + this.type = ''; + this.childAtoms = []; + + return this.parse(buffer, offset) +}; + +Atom.prototype.parse = function(buffer, offset) +{ + // 'offset' is optional. + if (arguments.length < 2) + offset = 0; + + // Atoms are 8 bytes minimum. + if (buffer.byteLength - offset < 8) + return null; + + var view = new DataView(buffer, offset, 4); + this.size = view.getUint32(0); + + var typeArrayView = new Uint8Array(buffer, offset + 4, 4); + this.type = String.fromCharCode.apply(null, typeArrayView); + + return this; +}; \ No newline at end of file diff --git a/AtomTester.html b/AtomTester.html new file mode 100644 index 0000000..789e246 --- /dev/null +++ b/AtomTester.html @@ -0,0 +1,32 @@ + + + AtomTester + + + + + + \ No newline at end of file