Add logencode filter.

This commit is contained in:
Steven Robertson 2015-10-10 18:04:27 -07:00
parent 37245085a9
commit 37e6642d37
3 changed files with 25 additions and 0 deletions

View File

@ -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<float4, cudaTextureType2D> chan4_src;
texture<float, cudaTextureType2D> chan1_src;

View File

@ -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]

View File

@ -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': {}
})