예제 #1
0
def print_block_table(block_codepoints):
    for block in block_codepoints:
        byte_no = bits2codepoint(block)
        character = chr(byte_no)
        print("%s %4s %3s %s" % (
            list2str(block), hex(byte_no), byte_no, repr(character)
        ))
예제 #2
0
def print_block_table(block_codepoints):
    for block in block_codepoints:
        byte_no = bits2codepoint(block)
        character = chr(byte_no)
        print "%s %4s %3s %s" % (
            list2str(block), hex(byte_no), byte_no, repr(character)
        )
예제 #3
0
    def sync_bitstream(self, bitstream):
        log.debug("start sync bitstream at wave pos: %s" % bitstream.pformat_pos())
        bitstream.sync(32) # Sync bitstream to wave sinus cycle

#         test_bitstream = list(itertools.islice(bitstream, 258 * 8))
#         print_bitlist(test_bitstream)

        log.debug("Searching for lead-in byte at wave pos: %s" % bitstream.pformat_pos())

        # Searching for lead-in byte
        lead_in_pattern = list(codepoints2bitstream(self.cfg.LEAD_BYTE_CODEPOINT))
        max_pos = self.cfg.LEAD_BYTE_LEN * 8
        try:
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived as err:
            log.error("Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                self.cfg.LEAD_BYTE_LEN, err
            ))
        except PatternNotFound as err:
            log.error("Error: Leader-Byte '%s' (%s) doesn't exist in bitstream! (%s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT), err
            ))
        else:
            log.info("Leader-Byte '%s' (%s) found at %i Bytes (wave pos: %s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                leader_pos, bitstream.pformat_pos()
            ))

        log.debug("Search for sync-byte at wave pos: %s" % bitstream.pformat_pos())

        # Search for sync-byte
        sync_pattern = list(codepoints2bitstream(self.cfg.SYNC_BYTE_CODEPOINT))
        max_search_bits = self.cfg.MAX_SYNC_BYTE_SEARCH * 8
        try:
            sync_pos = find_iter_window(bitstream, sync_pattern, max_search_bits)
        except MaxPosArraived as err:
            raise SyncByteNotFoundError(
                "Error: Sync-Byte '%s' (%s) not found in the first %i Bytes! (%s)" % (
                    list2str(sync_pattern), hex(self.cfg.SYNC_BYTE_CODEPOINT),
                    self.cfg.MAX_SYNC_BYTE_SEARCH, err
                )
            )
        except PatternNotFound as err:
            raise SyncByteNotFoundError(
                "Error: Sync-Byte '%s' (%s) doesn't exist in bitstream! (%s)" % (
                    list2str(sync_pattern), hex(self.cfg.SYNC_BYTE_CODEPOINT),
                    err
                )
            )
        else:
            log.info("Sync-Byte '%s' (%s) found at %i Bytes (wave pos: %s)" % (
                list2str(sync_pattern), hex(self.cfg.SYNC_BYTE_CODEPOINT),
                sync_pos, bitstream.pformat_pos()
            ))
예제 #4
0
    def sync_bitstream(self, bitstream):
        log.debug("start sync bitstream at wave pos: %s" % bitstream.pformat_pos())
        bitstream.sync(32) # Sync bitstream to wave sinus cycle

#         test_bitstream = list(itertools.islice(bitstream, 258 * 8))
#         print_bitlist(test_bitstream)

        log.debug("Searching for lead-in byte at wave pos: %s" % bitstream.pformat_pos())

        # Searching for lead-in byte
        lead_in_pattern = list(codepoints2bitstream(self.cfg.LEAD_BYTE_CODEPOINT))
        max_pos = self.cfg.LEAD_BYTE_LEN * 8
        try:
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived, err:
            log.error("Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                self.cfg.LEAD_BYTE_LEN, err
            ))
예제 #5
0
class BitstreamHandler(BitstreamHandlerBase):
    """
    feed with wave bitstream
    """
    def get_block_info(self, bitstream):
        # convert the raw bitstream to codepoint stream
        codepoint_stream = bitstream2codepoints(bitstream)

        return super(BitstreamHandler, self).get_block_info(codepoint_stream)

    def sync_bitstream(self, bitstream):
        log.debug("start sync bitstream at wave pos: %s" %
                  bitstream.pformat_pos())
        bitstream.sync(32)  # Sync bitstream to wave sinus cycle

        #         test_bitstream = list(itertools.islice(bitstream, 258 * 8))
        #         print_bitlist(test_bitstream)

        log.debug("Searching for lead-in byte at wave pos: %s" %
                  bitstream.pformat_pos())

        # Searching for lead-in byte
        lead_in_pattern = list(
            codepoints2bitstream(self.cfg.LEAD_BYTE_CODEPOINT))
        max_pos = self.cfg.LEAD_BYTE_LEN * 8
        try:
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived, err:
            log.error(
                "Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)"
                %
                (list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                 self.cfg.LEAD_BYTE_LEN, err))
        except PatternNotFound, err:
            log.error(
                "Error: Leader-Byte '%s' (%s) doesn't exist in bitstream! (%s)"
                % (list2str(lead_in_pattern), hex(
                    self.cfg.LEAD_BYTE_CODEPOINT), err))
예제 #6
0
    def sync_bitstream(self, bitstream):
        log.debug("start sync bitstream at wave pos: %s" %
                  bitstream.pformat_pos())
        bitstream.sync(32)  # Sync bitstream to wave sinus cycle

        #         test_bitstream = list(itertools.islice(bitstream, 258 * 8))
        #         print_bitlist(test_bitstream)

        log.debug("Searching for lead-in byte at wave pos: %s" %
                  bitstream.pformat_pos())

        # Searching for lead-in byte
        lead_in_pattern = list(
            codepoints2bitstream(self.cfg.LEAD_BYTE_CODEPOINT))
        max_pos = self.cfg.LEAD_BYTE_LEN * 8
        try:
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived, err:
            log.error(
                "Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)"
                %
                (list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                 self.cfg.LEAD_BYTE_LEN, err))
예제 #7
0
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived, err:
            log.error(
                "Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)"
                %
                (list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                 self.cfg.LEAD_BYTE_LEN, err))
        except PatternNotFound, err:
            log.error(
                "Error: Leader-Byte '%s' (%s) doesn't exist in bitstream! (%s)"
                % (list2str(lead_in_pattern), hex(
                    self.cfg.LEAD_BYTE_CODEPOINT), err))
        else:
            log.info(
                "Leader-Byte '%s' (%s) found at %i Bytes (wave pos: %s)" %
                (list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                 leader_pos, bitstream.pformat_pos()))

        log.debug("Search for sync-byte at wave pos: %s" %
                  bitstream.pformat_pos())

        # Search for sync-byte
        sync_pattern = list(codepoints2bitstream(self.cfg.SYNC_BYTE_CODEPOINT))
        max_search_bits = self.cfg.MAX_SYNC_BYTE_SEARCH * 8
        try:
            sync_pos = find_iter_window(bitstream, sync_pattern,
                                        max_search_bits)
        except MaxPosArraived, err:
            raise SyncByteNotFoundError(
                "Error: Sync-Byte '%s' (%s) not found in the first %i Bytes! (%s)"
                % (list2str(sync_pattern), hex(self.cfg.SYNC_BYTE_CODEPOINT),
예제 #8
0
        lead_in_pattern = list(codepoints2bitstream(self.cfg.LEAD_BYTE_CODEPOINT))
        max_pos = self.cfg.LEAD_BYTE_LEN * 8
        try:
            leader_pos = find_iter_window(bitstream, lead_in_pattern, max_pos)
        except MaxPosArraived, err:
            log.error("Error: Leader-Byte '%s' (%s) not found in the first %i Bytes! (%s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                self.cfg.LEAD_BYTE_LEN, err
            ))
        except PatternNotFound, err:
            log.error("Error: Leader-Byte '%s' (%s) doesn't exist in bitstream! (%s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT), err
            ))
        else:
            log.info("Leader-Byte '%s' (%s) found at %i Bytes (wave pos: %s)" % (
                list2str(lead_in_pattern), hex(self.cfg.LEAD_BYTE_CODEPOINT),
                leader_pos, bitstream.pformat_pos()
            ))

        log.debug("Search for sync-byte at wave pos: %s" % bitstream.pformat_pos())

        # Search for sync-byte
        sync_pattern = list(codepoints2bitstream(self.cfg.SYNC_BYTE_CODEPOINT))
        max_search_bits = self.cfg.MAX_SYNC_BYTE_SEARCH * 8
        try:
            sync_pos = find_iter_window(bitstream, sync_pattern, max_search_bits)
        except MaxPosArraived, err:
            raise SyncByteNotFoundError(
                "Error: Sync-Byte '%s' (%s) not found in the first %i Bytes! (%s)" % (
                    list2str(sync_pattern), hex(self.cfg.SYNC_BYTE_CODEPOINT),
                    self.cfg.MAX_SYNC_BYTE_SEARCH, err