From 37e6642d37b66f19a940c6cdaabc56436716fdbf Mon Sep 17 00:00:00 2001 From: Steven Robertson Date: Sat, 10 Oct 2015 18:04:27 -0700 Subject: [PATCH] Add logencode filter. --- cuburn/code/filters.py | 13 +++++++++++++ cuburn/filters.py | 11 +++++++++++ cuburn/genome/specs.py | 1 + 3 files changed, 25 insertions(+) diff --git a/cuburn/code/filters.py b/cuburn/code/filters.py index 6b187f9..01f8691 100644 --- a/cuburn/code/filters.py +++ b/cuburn/code/filters.py @@ -77,6 +77,19 @@ yuv_to_rgb(float4 *dst, const float4 *src) { } ''') +logencodelib = devlib(defs=r''' +__global__ void +logencode(float4 *dst, const float4 *src, float degamma) { + GET_IDX(i); + float4 pix = src[i]; + pix.x = log2f(powf(pix.x, degamma)) / 12.0f + 1.0f; + pix.y = log2f(powf(pix.y, degamma)) / 12.0f + 1.0f; + pix.z = log2f(powf(pix.z, degamma)) / 12.0f + 1.0f; + pix.w = log2f(powf(pix.w, degamma)) / 12.0f + 1.0f; + dst[i] = pix; +} +''') + denblurlib = devlib(deps=[texshearlib], decls=''' texture chan4_src; texture chan1_src; diff --git a/cuburn/filters.py b/cuburn/filters.py index e208563..80488ed 100644 --- a/cuburn/filters.py +++ b/cuburn/filters.py @@ -180,6 +180,17 @@ class ColorClip(Filter, ClsMod): launch2('colorclip', self.mod, stream, dim, fb.d_front, vib, hipow, gam, lin, lingam) + +@Filter.register('logencode') +class LogEncode(Filter, ClsMod): + lib = code.filters.logencodelib + def apply(self, fb, gprof, params, dim, tc, stream=None): + degamma = f32(params.degamma(tc)) + + launch2('logencode', self.mod, stream, dim, + fb.d_back, fb.d_front, degamma) + fb.flip() + def create(gprof): order = ['yuv'] + gprof.filter_order return [Filter.filter_map[f]() for f in order] diff --git a/cuburn/genome/specs.py b/cuburn/genome/specs.py index ad8129a..940de91 100644 --- a/cuburn/genome/specs.py +++ b/cuburn/genome/specs.py @@ -54,6 +54,7 @@ filters = ( , 'haloclip': {} , 'smearclip': {'width': scalespline(0.7, d='Spatial stdev of filter')} , 'logscale': {'brightness': scalespline(4, d='Log-scale brightness')} + , 'logencode': {'degamma': scalespline(2.2)} , 'yuv': {} })