mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-04-20 16:41:30 -04:00
Add a 'plainclip' filter.
This is useful for doing color manipulation on output renders, either by hand in color grading software or automatically using renormalization based on image statistics.
This commit is contained in:
parent
14f755e434
commit
746aee9a75
@ -328,6 +328,28 @@ smearclip(float4 *pixbuf, const float4 *smearbuf,
|
||||
}
|
||||
''')
|
||||
|
||||
plaincliplib = devlib(deps=[yuvlib], defs=r'''
|
||||
__global__ void
|
||||
plainclip(float4 *pixbuf, float gamma_m_1, float linrange, float lingam,
|
||||
float brightness) {
|
||||
GET_IDX(i);
|
||||
float4 pix = pixbuf[i];
|
||||
|
||||
if (pix.w <= 0) {
|
||||
pixbuf[i] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
float ls = powf(pix.w, gamma_m_1);
|
||||
if (pix.w < linrange) {
|
||||
float frac = pix.w / linrange;
|
||||
ls = (1.0f - frac) * lingam + frac * ls;
|
||||
}
|
||||
scale_float4(pix, ls * brightness);
|
||||
pixbuf[i] = pix;
|
||||
}
|
||||
''')
|
||||
|
||||
colorcliplib = devlib(deps=[yuvlib], defs=r'''
|
||||
__global__ void
|
||||
colorclip(float4 *pixbuf, float vibrance, float highpow,
|
||||
|
@ -180,6 +180,15 @@ class ColorClip(Filter, ClsMod):
|
||||
launch2('colorclip', self.mod, stream, dim,
|
||||
fb.d_front, vib, hipow, gam, lin, lingam)
|
||||
|
||||
@Filter.register('plainclip')
|
||||
class PlainClip(Filter, ClsMod):
|
||||
lib = code.filters.plaincliplib
|
||||
def apply(self, fb, gprof, params, dim, tc, stream=None):
|
||||
gam, lin, lingam = calc_lingam(gprof.filters.colorclip, tc)
|
||||
launch2('plainclip', self.mod, stream, dim,
|
||||
fb.d_front, f32(gam-1), lin, lingam,
|
||||
f32(gprof.filters.plainclip.brightness(tc)))
|
||||
|
||||
|
||||
@Filter.register('logencode')
|
||||
class LogEncode(Filter, ClsMod):
|
||||
|
@ -53,6 +53,7 @@ filters = (
|
||||
}
|
||||
, 'haloclip': {}
|
||||
, 'smearclip': {'width': scalespline(0.7, d='Spatial stdev of filter')}
|
||||
, 'plainclip': {'brightness': scalespline(1.0, d='Linear brightness')}
|
||||
, 'logscale': {'brightness': scalespline(4, d='Log-scale brightness')}
|
||||
, 'logencode': {'degamma': scalespline(2.2)}
|
||||
, 'yuv': {}
|
||||
|
Loading…
Reference in New Issue
Block a user