                 // Debug dump the SPS
                 var spsLength:uint = spsList[i].length;
 
-                //trace("SPS #" + i + " profile " + spsList[i][1] + "   " + Hex.fromArray(spsList[i], true));
+                //trace("SPS #" + i + " profile=" + spsList[i][1] + "   " + Hex.fromArray(spsList[i], true));
 
                 var eg:ExpGolomb = new ExpGolomb(spsList[i]);
                 // constraint_set[0-5]_flag, u(1), reserved_zero_2bits u(2), level_idc u(8)
-                eg.readBits(16);
+                eg.readBits(8);
+                eg.readBits(24);
                 //trace("Saw id " + eg.readUE());
 
                 avcc.position = cursor;

            {
                var ppsLength:uint = ppsList[i].length;
                //trace("PPS length #" + i + " is " + ppsLength + "   " + Hex.fromArray(ppsList[i], true));
                avcc.position = cursor;
                ppsList[i].position = 0;
                avcc.writeShort(ppsLength);

            sps.writeBytes(bytes, cursor, length);

            var ourEg:ExpGolomb = new ExpGolomb(sps);
            ourEg.readBits(8);
            ourEg.readBits(24);
            var ourId:int = ourEg.readUE();

            // If not present in list add it!
            for(var i:int=0; i<spsList.length; i++)
            {
                // If it matches our ID, replace it.
                var eg:ExpGolomb = new ExpGolomb(spsList[i]);
                eg.readBits(8);
                eg.readBits(24);
                var foundId:int = eg.readUE();

                if(foundId != ourId)
                    continue;

                //trace("Got SPS match for " + foundId + "!");
                spsList[i] = sps;
                return;
            }

            // Maybe we do have to add it!
            spsList.push(sps);
        }

        /**
