'Digs into movi list, looking for a Video Object Layer header in an
mpeg4 stream in order to determine aspect ratio.'

def _parseLISTmovi(self, size, file):

    i = 0
    n_dc = 0
    done = False
    while ((i < min(((1024 * 1024) * 5), (size - 8))) and (n_dc < 5)):
        data = file.read(8)
        if (ord(data[0]) == 0):
            data = (data[1:] + file.read(1))
            i += 1
        (key, sz) = struct.unpack(u'<4sI', data)
        if ((key[2:] != u'dc') or (sz > (1024 * 500))):
            file.seek(sz, 1)
            i += (8 + sz)
            continue
        n_dc += 1
        data = file.read(sz)
        pos = 0
        startcode = 255
        def bits(v, o, n):
            return ((v & (((2 ** n) - 1) << ((64 - n) - o))) >> ((64 - n) - o))
        while (pos < sz):
            startcode = (((startcode << 8) | ord(data[pos])) & 4294967295)
            pos += 1
            if ((startcode & 4294967040) != 256):
                continue
            if (288 <= startcode <= 303):
                v = struct.unpack(u'>Q', data[pos:(pos + 8)])[0]
                offset = 10
                if bits(v, 9, 1):
                    offset += 7
                ar_info = bits(v, offset, 4)
                if (ar_info == 15):
                    num = bits(v, (offset + 4), 8)
                    den = bits(v, (offset + 12), 8)
                else:
                    (num, den) = PIXEL_ASPECT.get(ar_info, (0, 0))
                if (0 not in [num, den]):
                    (width, height) = (self.video[(-1)].width, self.video[(-1)].height)
                    self.video[(-1)].aspect = (((num / float(den)) * width) / height)
                done = True
                break
            startcode = 255
        i += (8 + len(data))
        if done:
            break
    if (i < size):
        file.seek((size - i), 1)
