示例#1
0
文件: decoder.py 项目: walafc0/soclib
    def mkmasks(self, slices, base=None):
        #       print "mkmasks(%r, %r)"%(slices, base)
        my_bl = packer.slices_to_bitlist(self.__packer.slices())
        de_bl = packer.slices_to_bitlist(slices)
        assert set(de_bl) <= set(my_bl), ValueError(de_bl, my_bl)
        poss = [""]
        mask = ""
        if base == None:
            base = "X" * len(my_bl)
        for n, b in enumerate(my_bl):
            if b in de_bl:
                poss = map(lambda x:x+"0", poss) \
                       + map(lambda x:x+"1", poss)
                mask = "%s" + mask
            else:
                mask = base[-1 - n] + mask
        if len(poss) > 1:
            masks = []
            for x in poss:
                m = mask % tuple(list(x))
                masks.append(m)


#               print "  ", m
        else:
            masks = [mask]
        return sorted(masks)
示例#2
0
文件: decoder.py 项目: walafc0/soclib
    def mkmasks(self, slices, base = None):
#       print "mkmasks(%r, %r)"%(slices, base)
        my_bl = packer.slices_to_bitlist(self.__packer.slices())
        de_bl = packer.slices_to_bitlist(slices)
        assert set(de_bl) <= set(my_bl), ValueError(de_bl, my_bl)
        poss = [""]
        mask = ""
        if base == None:
            base = "X"*len(my_bl)
        for n, b in enumerate(my_bl):
            if b in de_bl:
                poss = map(lambda x:x+"0", poss) \
                       + map(lambda x:x+"1", poss)
                mask = "%s"+mask
            else:
                mask = base[-1-n]+mask
        if len(poss) > 1:
            masks = []
            for x in poss:
                m = mask%tuple(list(x))
                masks.append(m)
#               print "  ", m
        else:
            masks = [mask]
        return sorted(masks)
示例#3
0
文件: decoder.py 项目: walafc0/soclib
def get_useless_bits(slices, values):
    useful_bits = list(sorted(packer.slices_to_bitlist(slices)))
    useless_bits = []

    for n, bit in enumerate(useful_bits):
        idem = True
        for i in range(1 << len(useful_bits)):
            idem &= (values[i | (1 << n)] == values[i & ~(1 << n)])
        if idem:
            useless_bits.append((n, bit))
    return useless_bits
示例#4
0
文件: decoder.py 项目: walafc0/soclib
def get_useless_bits(slices, values):
    useful_bits = list(sorted(packer.slices_to_bitlist(slices)))
    useless_bits = []

    for n, bit in enumerate(useful_bits):
        idem = True
        for i in range(1<<len(useful_bits)):
            idem &= ( values[i | (1<<n)] == values[i & ~(1<<n)] )
        if idem:
            useless_bits.append((n,bit))
    return useless_bits