From 6f1374d4c551a544f1990a871b842c16ffcb208e Mon Sep 17 00:00:00 2001 From: andri lim Date: Mon, 13 Apr 2020 20:55:50 +0700 Subject: [PATCH] gc:arc refactor add LFS_ZERO, LFS_PREDEFINED, LFS_ENTROPY filter and tests --- nimPNG/filters.nim | 155 +++++++++++++++++++++++++++++------------ tests/randutils.nim | 2 +- tests/test_filters.nim | 73 +++++++++++++++++-- 3 files changed, 180 insertions(+), 50 deletions(-) diff --git a/nimPNG/filters.nim b/nimPNG/filters.nim index ae215ef..e60d6aa 100644 --- a/nimPNG/filters.nim +++ b/nimPNG/filters.nim @@ -1,3 +1,5 @@ +import math + type PNGFilter* = enum FLT_NONE, @@ -40,7 +42,7 @@ proc filterScanline*(output: var openArray[byte], input: openArray[byte], byteWi of FLT_PAETH: for i in 0.. 0: + output[0] = byte(FLT_NONE) # filterType byte + filterScanline(output.toOpenArray(1, output.len-1), # skip filterType + input, byteWidth, lineBytes, FLT_NONE) -proc filterMinsum(output: var DataBuf, input: DataBuf, w, h, bpp: int) = + # next line start from 1 + var prevIndex = 0 + for y in 1.. 0: + output[0] = byte(predefinedFilters[0]) # filterType byte + filterScanline(output.toOpenArray(1, output.len-1), # skip filterType + input, byteWidth, lineBytes, predefinedFilters[0]) + # next line start from 1 + var prevIndex = 0 + for y in 1.. 0: + unfilterScanLine(output, + input.toOpenArray(1, input.len-1), # skip the filterType + byteWidth, lineBytes, + PNGFilter(input[0])) + + # next line start from 1 + var prevIndex = 0 + for y in 1..