Esempio n. 1
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()
            ))
Esempio n. 2
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
            ))
Esempio n. 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, 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))
Esempio n. 4
0
                % (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))
        except PatternNotFound, 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()))
Esempio n. 5
0
            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
                )
            )
        except PatternNotFound, 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: