diff --git a/cuburn/code/filters.py b/cuburn/code/filters.py index c5d4547..6b187f9 100644 --- a/cuburn/code/filters.py +++ b/cuburn/code/filters.py @@ -67,6 +67,16 @@ fma_buf(float4 *dst, const float4 *src, float scale) { } ''') +yuvfilterlib = devlib(deps=[yuvlib], defs=r''' +__global__ void +yuv_to_rgb(float4 *dst, const float4 *src) { + GET_IDX(i); + float4 pix = src[i]; + yuvo2rgb(pix); + dst[i] = pix; +} +''') + denblurlib = devlib(deps=[texshearlib], decls=''' texture chan4_src; texture chan1_src; @@ -261,7 +271,6 @@ haloclip(float4 *pixbuf, const float *denbuf, float gamma_m_1) { float ls = powf(pix.w, gamma_m_1) / fmaxf(1.0f, areaval); scale_float4(pix, ls); - yuvo2rgb(pix); pixbuf[i] = pix; } ''') @@ -302,7 +311,6 @@ smearclip(float4 *pixbuf, const float4 *smearbuf, ls = (1.0f - frac) * lingam + frac * ls; } scale_float4(pix, ls); - yuvo2rgb(pix); pixbuf[i] = pix; } ''') @@ -319,7 +327,6 @@ colorclip(float4 *pixbuf, float vibrance, float highpow, pixbuf[i] = make_float4(0, 0, 0, 0); return; } - yuvo2rgb(pix); float4 opix = pix; float alpha = powf(pix.w, gamma); diff --git a/cuburn/filters.py b/cuburn/filters.py index 5a2dd52..e208563 100644 --- a/cuburn/filters.py +++ b/cuburn/filters.py @@ -50,6 +50,16 @@ class Filter(object): return register_ +@Filter.register('yuv') +class YuvFilterLib(Filter, ClsMod): + lib = code.filters.yuvfilterlib + + def apply(self, fb, gprof, params, dim, tc, stream=None): + launch2('yuv_to_rgb', self.mod, stream, dim, + fb.d_back, fb.d_front) + fb.flip() + + @Filter.register('bilateral') class Bilateral(Filter, ClsMod): lib = code.filters.bilaterallib @@ -171,4 +181,5 @@ class ColorClip(Filter, ClsMod): fb.d_front, vib, hipow, gam, lin, lingam) def create(gprof): - return [Filter.filter_map[f]() for f in gprof.filter_order] + 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 3ea8109..36c723e 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')} + , 'yuv': {} }) camera = (