From: Luke Kenneth Casson Leighton Date: Thu, 29 Jul 2021 21:58:02 +0000 (+0100) Subject: use coefficient table in iDCT X-Git-Tag: xlen-bcd~183 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=47070117f47ca66f8792bd382e48f02dfbd8085e;p=openpower-isa.git use coefficient table in iDCT --- diff --git a/src/openpower/decoder/isa/fastdct-test.py b/src/openpower/decoder/isa/fastdct-test.py index c3aacd6b..72414d5c 100644 --- a/src/openpower/decoder/isa/fastdct-test.py +++ b/src/openpower/decoder/isa/fastdct-test.py @@ -28,7 +28,7 @@ import fastdctlee, naivedct, remap_dct_yield class FastDctTest(unittest.TestCase): def test_fast_dct_lee_vs_naive(self): - for i in range(3, 10): + for i in range(3, 4): n = 2**i vector = FastDctTest.nonrandom_vector(n) expect = naivedct.transform(vector) diff --git a/src/openpower/decoder/isa/fastdctlee.py b/src/openpower/decoder/isa/fastdctlee.py index 2ab421fb..16de9cb7 100644 --- a/src/openpower/decoder/isa/fastdctlee.py +++ b/src/openpower/decoder/isa/fastdctlee.py @@ -347,13 +347,13 @@ def inverse_transform_iter(vec): # this table could be cached and used multiple times rather than # computed every time. ctable = [] - size = n - while size >= 2: + size = 2 + while size <= n: halfsize = size // 2 for i in range(n//size): for ci in range(halfsize): ctable.append((math.cos((ci + 0.5) * math.pi / size) * 2.0)) - size //= 2 + size *= 2 # first divide element 0 by 2 vec[0] /= 2.0 @@ -408,8 +408,8 @@ def inverse_transform_iter(vec): for ci, (jl, jh) in enumerate(zip(j, jr)): #t1, t2 = vec[ri[ji[jl]]], vec[ri[ji[jh]]] t1, t2 = vec[ji[jl]], vec[ji[jl+halfsize]] - coeff = (math.cos((ci + 0.5) * math.pi / size) * 2.0) - #coeff = ctable[k] + #coeff = (math.cos((ci + 0.5) * math.pi / size) * 2.0) + coeff = ctable[k] k += 1 # normally DCT would use jl+halfsize not jh, here. # to be able to work in-place, the idea is to perform a