Convert YUV to RGB before filtering

This commit is contained in:
Steven Robertson 2015-10-10 15:59:57 -07:00
parent abcb3fa50f
commit 0ce1b51d16
3 changed files with 23 additions and 4 deletions

View File

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

View File

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

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')}
, 'yuv': {}
})
camera = (