示例#1
0
文件: raw.py 项目: evildmp/pymaging
    def fill_bit_buffer(self):
        while self.GetBits < 25:    # #define MIN_GET_BITS  (32-7)
            if self.DataBytesLeft > 0: # Are there some data?
                # Attempt to read a byte
                if self.unread_marker != 0:
                    # can't advance past a marker

                    # There should be enough bits still left in the data segment
                    # if so, just break out of the outer while loop.
                    # if (self.GetBits >= nbits)
                    if (self.GetBits >= 0):
                        break

                uc = byteord(self.Data[self.DataPos])
                self.DataPos += 1
                self.DataBytesLeft -= 1

                # If it's 0xFF, check and discard stuffed zero byte
                if uc == 0xFF:
                    while uc == 0xFF:
                        uc = byteord(self.Data[self.DataPos])
                        self.DataPos += 1
                        self.DataBytesLeft -= 1

                    if uc == 0:
                        # Found FF/00, which represents an FF data byte
                        uc = 0xFF
                    else:
                        # Oops, it's actually a marker indicating end of compressed data.
                        # Better put it back for use later

                        self.unread_marker = uc

                        # There should be enough bits still left in the data segment
                        # if so, just break out of the outer while loop.
                        # if (self.GetBits >= nbits)
                        if (self.GetBits >= 0):
                            break

                self.GetBuff = int(self.GetBuff << 8) | uc
                self.GetBits += 8
            else:
                break
示例#2
0
文件: raw.py 项目: evildmp/pymaging
 def read_word(self):
     byte1, byte2 = self.Data[self.DataPos:self.DataPos+2]
     self.DataPos += 2
     output = (byteord(byte1)<<8) + byteord(byte2)
     return output
示例#3
0
文件: raw.py 项目: evildmp/pymaging
 def read_byte(self):
     byte = self.Data[self.DataPos]
     self.DataPos += 1
     output = byteord(byte)
     return output