本文整理汇总了C++中CLIP函数的典型用法代码示例。如果您正苦于以下问题:C++ CLIP函数的具体用法?C++ CLIP怎么用?C++ CLIP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CLIP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CLIP
bool CGondolierSlider::SignalObject(CSignalObject *msg) {
_arrayIndex = CLIP(_arrayIndex, 0, 10);
_sliderRect1 = _sliderRect2;
_sliderRect1.translate(_bounds.left, _bounds.top);
_sliderRect1.translate(0, ARRAY[_arrayIndex]);
loadFrame(_arrayIndex);
CSignalObject signalMsg;
signalMsg._numValue = 10 - _arrayIndex;
signalMsg._strValue = _fieldFC ? "Fly" : "Tos";
signalMsg.execute(_string3);
return true;
}
示例2: hsv_to_yuv
int HSV::hsv_to_yuv(int &y, int &u, int &v, float h, float s, float va, int max)
{
float r, g, b;
int r_i, g_i, b_i;
HSV::hsv_to_rgb(r, g, b, h, s, va);
r = r * max + 0.5;
g = g * max + 0.5;
b = b * max + 0.5;
r_i = (int)CLIP(r, 0, max);
g_i = (int)CLIP(g, 0, max);
b_i = (int)CLIP(b, 0, max);
int y2, u2, v2;
if(max == 0xffff)
yuv_static.rgb_to_yuv_16(r_i, g_i, b_i, y2, u2, v2);
else
yuv_static.rgb_to_yuv_8(r_i, g_i, b_i, y2, u2, v2);
y = y2;
u = u2;
v = v2;
return 0;
}
示例3: setMaxFreq
float setMaxFreq ( t_CKFLOAT p )
{
const float nyquist = srate / 2;
if (p == 0) p = nyquist;
float max = CLIP(p, minfreq, nyquist);
if (max != maxfreq)
{
maxfreq = max;
spectdelay->set_delay_freqrange(minfreq, maxfreq);
spectdelay->set_freqrange(minfreq, maxfreq);
}
return max;
}
示例4: CLIP
void MidiPlayer::setVolume(int volume) {
volume = CLIP(volume, 0, 255);
if (_masterVolume == volume)
return;
Common::StackLock lock(_mutex);
_masterVolume = volume;
for (int i = 0; i < kNumChannels; ++i) {
if (_channelsTable[i]) {
_channelsTable[i]->volume(_channelsVolume[i] * _masterVolume / 255);
}
}
}
示例5: vorbis_synthesis_pcmout
bool TheoraDecoder::VorbisAudioTrack::decodeSamples() {
float **pcm;
// if there's pending, decoded audio, grab it
int ret = vorbis_synthesis_pcmout(&_vorbisDSP, &pcm);
if (ret > 0) {
if (!_audioBuffer) {
_audioBuffer = (ogg_int16_t *)malloc(AUDIOFD_FRAGSIZE * sizeof(ogg_int16_t));
assert(_audioBuffer);
}
int channels = _audStream->isStereo() ? 2 : 1;
int count = _audioBufferFill / 2;
int maxsamples = ((AUDIOFD_FRAGSIZE - _audioBufferFill) / channels) >> 1;
int i;
for (i = 0; i < ret && i < maxsamples; i++) {
for (int j = 0; j < channels; j++) {
int val = CLIP((int)rint(pcm[j][i] * 32767.f), -32768, 32767);
_audioBuffer[count++] = val;
}
}
vorbis_synthesis_read(&_vorbisDSP, i);
_audioBufferFill += (i * channels) << 1;
if (_audioBufferFill == AUDIOFD_FRAGSIZE) {
byte flags = Audio::FLAG_16BITS;
if (_audStream->isStereo())
flags |= Audio::FLAG_STEREO;
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::FLAG_LITTLE_ENDIAN;
#endif
_audStream->queueBuffer((byte *)_audioBuffer, AUDIOFD_FRAGSIZE, DisposeAfterUse::YES, flags);
// The audio mixer is now responsible for the old audio buffer.
// We need to create a new one.
_audioBuffer = 0;
_audioBufferFill = 0;
}
return true;
}
return false;
}
示例6: mlib_ImageAffine_s16_3ch_nn
mlib_status
mlib_ImageAffine_s16_3ch_nn(
mlib_affine_param *param)
{
DECLAREVAR_NN();
DTYPE *dstLineEnd;
for (j = yStart; j <= yFinish; j++) {
mlib_s32 pix0, pix1, pix2;
CLIP(3);
dstLineEnd = (DTYPE *) dstData + 3 * xRight;
ySrc = MLIB_POINTER_SHIFT(Y);
Y += dY;
xSrc = X >> MLIB_SHIFT;
X += dX;
srcPixelPtr = MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
pix0 = srcPixelPtr[0];
pix1 = srcPixelPtr[1];
pix2 = srcPixelPtr[2];
ySrc = MLIB_POINTER_SHIFT(Y);
Y += dY;
xSrc = X >> MLIB_SHIFT;
X += dX;
#ifdef __SUNPRO_C
#pragma pipeloop(0)
#endif /* __SUNPRO_C */
for (; dstPixelPtr < dstLineEnd; dstPixelPtr += 3) {
srcPixelPtr =
MLIB_POINTER_GET(lineAddr, ySrc) + 3 * xSrc;
ySrc = MLIB_POINTER_SHIFT(Y);
Y += dY;
xSrc = X >> MLIB_SHIFT;
X += dX;
dstPixelPtr[0] = pix0;
dstPixelPtr[1] = pix1;
dstPixelPtr[2] = pix2;
pix0 = srcPixelPtr[0];
pix1 = srcPixelPtr[1];
pix2 = srcPixelPtr[2];
}
dstPixelPtr[0] = pix0;
dstPixelPtr[1] = pix1;
dstPixelPtr[2] = pix2;
}
return (MLIB_SUCCESS);
}
示例7: lock
void MusicPlayer::setVolume(int volume) {
Common::StackLock lock(_mutex);
volume = CLIP(volume, 0, 255);
if (_masterVolume == volume)
return;
_masterVolume = volume;
for (int i = 0; i < 16; ++i) {
if (_channel[i]) {
setChannelVolume(i);
}
}
}
示例8: CLIP
void ConsoleWindow::highlightClip(uint32 &x, uint32 &y) const {
y = CLIP<uint32>(y, 0, _lines.size());
uint32 minX, maxX;
if (y == 0) {
minX = _prompt->get().size();
maxX = _prompt->get().size() + _input->get().size();
} else {
minX = 0;
maxX = _lines[_lines.size() - y]->get().size();
}
x = CLIP(x, minX, maxX);
}
示例9: quoteblock
/*
* accumulate a blockquote.
*
* one sick horrible thing about blockquotes is that even though
* it just takes ^> to start a quote, following lines, if quoted,
* assume that the prefix is ``> ''. This means that code needs
* to be indented *5* spaces from the leading '>', but *4* spaces
* from the start of the line. This does not appear to be
* documented in the reference implementation, but it's the
* way the markdown sample web form at Daring Fireball works.
*/
static Line *
quoteblock(Paragraph *p, DWORD flags)
{
Line *t, *q;
int qp;
for ( t = p->text; t ; t = q ) {
if ( isquote(t) ) {
/* clip leading spaces */
for (qp = 0; T(t->text)[qp] != '>'; qp ++)
/* assert: the first nonblank character on this line
* will be a >
*/;
/* clip '>' */
qp++;
/* clip next space, if any */
if ( T(t->text)[qp] == ' ' )
qp++;
CLIP(t->text, 0, qp);
UNCHECK(t);
t->dle = mkd_firstnonblank(t);
}
q = skipempty(t->next);
if ( (q == 0) || ((q != t->next) && (!isquote(q) || isdivmarker(q,1,flags))) ) {
___mkd_freeLineRange(t, q);
t = q;
break;
}
}
if ( isdivmarker(p->text,0,flags) ) {
char *prefix = "class";
int i;
q = p->text;
p->text = p->text->next;
if ( (i = szmarkerclass(1+T(q->text))) == 3 )
/* and this would be an "%id:" prefix */
prefix="id";
if ( p->ident = malloc(4+strlen(prefix)+S(q->text)) )
sprintf(p->ident, "%s=\"%.*s\"", prefix, S(q->text)-(i+2),
T(q->text)+(i+1) );
___mkd_freeLine(q);
}
return t;
}
示例10: CLIP
bool CGondolierSlider::SignalObject(CSignalObject *msg) {
_sliderIndex = CLIP(_sliderIndex, 0, 10);
_thumbRect = _defaultThumbRect;
_thumbRect.translate(_bounds.left, _bounds.top);
_thumbRect.translate(0, Y_OFFSETS[_sliderIndex]);
loadFrame(_sliderIndex);
CSignalObject signalMsg;
signalMsg._numValue = 10 - _sliderIndex;
signalMsg._strValue = _sliderNum ? "Fly" : "Tos";
signalMsg.execute(_signalTarget);
return true;
}
示例11: process
void process (struct dt_iop_module_t *self, dt_dev_pixelpipe_iop_t *piece, void *ivoid, void *ovoid, const dt_iop_roi_t *roi_in, const dt_iop_roi_t *roi_out)
{
dt_iop_relight_data_t *data = (dt_iop_relight_data_t *)piece->data;
const int ch = piece->colors;
// Precalculate parameters for gauss function
const float a = 1.0; // Height of top
const float b = -1.0+(data->center*2); // Center of top
const float c = (data->width/10.0)/2.0; // Width
#ifdef _OPENMP
#pragma omp parallel for default(none) shared(roi_out, ivoid, ovoid, data) schedule(static)
#endif
for(int k=0; k<roi_out->height; k++)
{
float *in = ((float *)ivoid) + ch*k*roi_out->width;
float *out = ((float *)ovoid) + ch*k*roi_out->width;
for(int j=0; j<roi_out->width; j++,in+=ch,out+=ch)
{
const float lightness = in[0]/100.0;
const float x = -1.0+(lightness*2.0);
float gauss = GAUSS(a,b,c,x);
if(isnan(gauss) || isinf(gauss))
gauss = 0.0;
float relight = 1.0 / exp2f ( -data->ev * CLIP(gauss));
if(isnan(relight) || isinf(relight))
relight = 1.0;
out[0] = 100.0*CLIP (lightness*relight);
out[1] = in[1];
out[2] = in[2];
}
}
}
示例12: yuv420pto422
/*jpeg decoding 420 planar to 422
* args:
* out: pointer to data output of idct (macroblocks yyyy u v)
* pic: pointer to picture buffer (yuyv)
* stride: picture stride
*/
static void yuv420pto422(int * out,uint8_t *pic,int stride)
{
int j, k;
uint8_t *pic0, *pic1;
int *outy, *outu, *outv;
int outy1 = 0;
int outy2 = 8;
//yyyyuv
pic0 = pic;
pic1 = pic + stride;
outy = out;
outu = out + 64 * 4;
outv = out + 64 * 5;
for (j = 0; j < 8; j++)
{
for (k = 0; k < 8; k++)
{
if( k == 4)
{
outy1 += 56;
outy2 += 56;
}
*pic0++ = CLIP(outy[outy1]); //y1 line 1
*pic0++ = CLIP(128 + *outu); //u line 1-2
*pic0++ = CLIP(outy[outy1+1]); //y2 line 1
*pic0++ = CLIP(128 + *outv); //v line 1-2
*pic1++ = CLIP(outy[outy2]); //y1 line 2
*pic1++ = CLIP(128 + *outu); //u line 1-2
*pic1++ = CLIP(outy[outy2+1]); //y2 line 2
*pic1++ = CLIP(128 + *outv); //v line 1-2
outy1 +=2; outy2 += 2; outu++; outv++;
}
if(j==3)
{
outy = out + 128;
}
else
{
outy += 16;
}
outy1 = 0;
outy2 = 8;
pic0 += 2 * (stride -16);
pic1 += 2 * (stride -16);
}
}
示例13: pcmfile_seek_samples
int
pcmfile_seek_samples(PcmFile *pf, int64_t offset, int whence)
{
int64_t byte_offset;
uint64_t newpos, fpos, dst, dsz;
if(pf == NULL || pf->io.fp == NULL) return -1;
if(pf->block_align <= 0) return -1;
if(pf->filepos < pf->data_start) return -1;
if(pf->data_size == 0) return 0;
fpos = pf->filepos;
dst = pf->data_start;
dsz = pf->data_size;
byte_offset = offset;
byte_offset *= pf->block_align;
// calculate new destination within file
switch(whence) {
case PCM_SEEK_SET:
newpos = dst + CLIP(byte_offset, 0, (int64_t)dsz);
break;
case PCM_SEEK_CUR:
newpos = fpos - MIN(-byte_offset, (int64_t)(fpos - dst));
newpos = MIN(newpos, dst + dsz);
break;
case PCM_SEEK_END:
newpos = dst + dsz - CLIP(byte_offset, 0, (int64_t)dsz);
break;
default: return -1;
}
// seek to the destination point
if(pcmfile_seek_set(pf, newpos)) return -1;
return 0;
}
示例14: jit_gl_videoplane_draw
t_jit_err jit_gl_videoplane_draw(t_jit_gl_videoplane *x)
{
t_jit_err result = JIT_ERR_NONE;
GLenum prim;
CLIP (x->nudge,0.,0.5);
prim = (x->gridmode) ? GL_TRIANGLE_STRIP : GL_QUAD_STRIP;
if (x->recalc) {
jit_gl_videoplane_recalc(x);
if (x->displaylist)
{
t_jit_gl_context ctx;
// cache/restore context in case in capture mode
ctx = jit_gl_get_context();
jit_ob3d_set_context(x);
if (x->dlref) {
glDeleteLists(x->dlref,1);
x->dlref = 0;
}
if (x->dlref=glGenLists(1)) {
glNewList(x->dlref, GL_COMPILE);
if (x->chunk&&x->chunk->m_vertex)
draw_grid(x,x->chunk->m_vertex, prim);
glEndList();
}
jit_gl_set_context(ctx);
}
x->recalc = 0;
}
// draw our chunk of OpenGL geometry.
if (x->chunk&&x->chunk->m_vertex) {
if (!jit_attr_getlong(x,gensym("matrixoutput"))) {
if (x->displaylist&&x->dlref)
glCallList(x->dlref);
else
draw_grid(x,x->chunk->m_vertex, prim);
} else{
color_surface(x);
result = jit_ob3d_draw_chunk(x->ob3d, x->chunk); //output matrix
}
}
return result;
}
示例15: headerblock
static Line *
headerblock(Paragraph *pp, int htyp)
{
Line *ret = 0;
Line *p = pp->text;
int i, j;
switch (htyp) {
case SETEXT:
/* p->text is header, p->next->text is -'s or ='s
*/
pp->hnumber = (T(p->next->text)[0] == '=') ? 1 : 2;
ret = p->next->next;
___mkd_freeLine(p->next);
p->next = 0;
break;
case ETX:
/* p->text is ###header###, so we need to trim off
* the leading and trailing `#`'s
*/
for (i=0; (T(p->text)[i] == T(p->text)[0]) && (i < S(p->text)-1)
&& (i < 6); i++)
;
pp->hnumber = i;
while ( (i < S(p->text)) && isspace(T(p->text)[i]) )
++i;
CLIP(p->text, 0, i);
UNCHECK(p);
for (j=S(p->text); (j > 1) && (T(p->text)[j-1] == '#'); --j)
;
while ( j && isspace(T(p->text)[j-1]) )
--j;
S(p->text) = j;
ret = p->next;
p->next = 0;
break;
}
return ret;
}