@staticmethod<EOL><INDENT>def defilter(cur, prev, filter_type, bpp=<NUM_LIT:4>):<DEDENT>
if filter_type == <NUM_LIT:0>:  <EOL><INDENT>return cur<EOL><DEDENT>elif filter_type == <NUM_LIT:1>:  <EOL><INDENT>xp = <NUM_LIT:0><EOL>for xc in range(bpp, len(cur)):<EOL><INDENT>cur[xc] = (cur[xc] + cur[xp]) % <NUM_LIT><EOL>xp += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif filter_type == <NUM_LIT:2>:  <EOL><INDENT>for xc in range(len(cur)):<EOL><INDENT>cur[xc] = (cur[xc] + prev[xc]) % <NUM_LIT><EOL><DEDENT><DEDENT>elif filter_type == <NUM_LIT:3>:  <EOL><INDENT>xp = <NUM_LIT:0><EOL>for i in range(bpp):<EOL><INDENT>cur[i] = (cur[i] + prev[i] // <NUM_LIT:2>) % <NUM_LIT><EOL><DEDENT>for xc in range(bpp, len(cur)):<EOL><INDENT>cur[xc] = (cur[xc] + ((cur[xp] + prev[xc]) // <NUM_LIT:2>)) % <NUM_LIT><EOL>xp += <NUM_LIT:1><EOL><DEDENT><DEDENT>elif filter_type == <NUM_LIT:4>:  <EOL><INDENT>xp = <NUM_LIT:0><EOL>for i in range(bpp):<EOL><INDENT>cur[i] = (cur[i] + prev[i]) % <NUM_LIT><EOL><DEDENT>for xc in range(bpp, len(cur)):<EOL><INDENT>a = cur[xp]<EOL>b = prev[xc]<EOL>c = prev[xp]<EOL>p = a + b - c<EOL>pa = abs(p - a)<EOL>pb = abs(p - b)<EOL>pc = abs(p - c)<EOL>if pa <= pb and pa <= pc:<EOL><INDENT>value = a<EOL><DEDENT>elif pb <= pc:<EOL><INDENT>value = b<EOL><DEDENT>else:<EOL><INDENT>value = c<EOL><DEDENT>cur[xc] = (cur[xc] + value) % <NUM_LIT><EOL>xp += <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(filter_type))<EOL><DEDENT>return cur<EOL>
Decode a chunk