From: Luke Kenneth Casson Leighton Date: Mon, 19 Jul 2021 14:50:23 +0000 (+0100) Subject: create coefficient table for DCT outside of loops X-Git-Tag: xlen-bcd~253 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1dfeb8d8757f83335b4fa6aa9909f396820f5697;p=openpower-isa.git create coefficient table for DCT outside of loops --- diff --git a/src/openpower/decoder/isa/fastdctlee.py b/src/openpower/decoder/isa/fastdctlee.py index cb47063a..97b95363 100644 --- a/src/openpower/decoder/isa/fastdctlee.py +++ b/src/openpower/decoder/isa/fastdctlee.py @@ -149,6 +149,12 @@ def transform2(vec): # and pretend we LDed the data in bit-reversed order as well vec = [vec[reverse_bits(i, levels)] for i in range(n)] + # create cos coefficient table + coeffs = [] + for ci in range(n): + coeffs.append((math.cos((ci + 0.5) * math.pi / n) * 2.0)) + + # start the inner butterfly size = n while size >= 2: halfsize = size // 2 @@ -163,11 +169,11 @@ def transform2(vec): print (" xform jr", j, jr) for ci, (jl, jh) in enumerate(zip(j, jr)): t1, t2 = vec[ri[jl]], vec[ri[jh]] - coeff = (math.cos((ci + 0.5) * math.pi / size) * 2.0) # normally DCT would use jl+halfsize not jh, here. # to be able to work in-place, the idea is to perform a # high-half reverse/swap afterwards. however actually # we swap the *indices* + coeff = coeffs[k] vec[ri[jl]] = t1 + t2 vec[ri[jh]] = (t1 - t2) * (1/coeff) print (" ", size, i, k, "ci", ci,