1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Replaced min(max()) calls with the new function constrain()

This commit is contained in:
Klaus Schmidinger 2012-03-02 10:51:46 +01:00
parent c8808a854b
commit 1e3f6d6da2
5 changed files with 13 additions and 12 deletions

View File

@ -6946,3 +6946,4 @@ Video Disk Recorder Revision History
has been changed to IDLEPRIORITY.
- Added a Query parameter to cDevice::GetDevice(), so that devices can be queried
without side effects when zapping.
- Replaced min(max()) calls with the new function constrain().

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: device.c 2.53 2012/03/02 10:33:35 kls Exp $
* $Id: device.c 2.54 2012/03/02 10:46:06 kls Exp $
*/
#include "device.h"
@ -877,7 +877,7 @@ void cDevice::SetAudioChannel(int AudioChannel)
void cDevice::SetVolume(int Volume, bool Absolute)
{
int OldVolume = volume;
volume = min(max(Absolute ? Volume : volume + Volume, 0), MAXVOLUME);
volume = constrain(Absolute ? Volume : volume + Volume, 0, MAXVOLUME);
SetVolumeDevice(volume);
Absolute |= mute;
cStatus::MsgSetVolume(Absolute ? volume : volume - OldVolume, Absolute);

View File

@ -7,7 +7,7 @@
* Original author: Marco Schlüßler <marco@lordzodiac.de>
* With some input from the "subtitle plugin" by Pekka Virtanen <pekka.virtanen@sci.fi>
*
* $Id: dvbsubtitle.c 2.26 2012/02/25 14:47:44 kls Exp $
* $Id: dvbsubtitle.c 2.27 2012/03/02 10:47:25 kls Exp $
*/
@ -969,9 +969,9 @@ tColor cDvbSubtitleConverter::yuv2rgb(int Y, int Cb, int Cr)
Epb = (Cb - 128);
Epr = (Cr - 128);
/* ITU-R 709 */
Er = max(min(((298 * Ey + 460 * Epr) / 256), 255), 0);
Eg = max(min(((298 * Ey - 55 * Epb - 137 * Epr) / 256), 255), 0);
Eb = max(min(((298 * Ey + 543 * Epb ) / 256), 255), 0);
Er = constrain((298 * Ey + 460 * Epr) / 256, 0, 255);
Eg = constrain((298 * Ey - 55 * Epb - 137 * Epr) / 256, 0, 255);
Eb = constrain((298 * Ey + 543 * Epb ) / 256, 0, 255);
return (Er << 16) | (Eg << 8) | Eb;
}

4
font.c
View File

@ -6,7 +6,7 @@
*
* BiDi support by Osama Alrawab <alrawab@hotmail.com> @2008 Tripoli-Libya.
*
* $Id: font.c 2.9 2012/01/13 09:43:22 kls Exp $
* $Id: font.c 2.10 2012/03/02 10:47:45 kls Exp $
*/
#include "font.h"
@ -396,7 +396,7 @@ cFont *cFont::fonts[eDvbFontSize] = { NULL };
void cFont::SetFont(eDvbFont Font, const char *Name, int CharHeight)
{
cFont *f = CreateFont(Name, min(max(CharHeight, MINFONTSIZE), MAXFONTSIZE));
cFont *f = CreateFont(Name, constrain(CharHeight, MINFONTSIZE, MAXFONTSIZE));
if (!f || !f->Height())
f = new cDummyFont;
delete fonts[Font];

8
osd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: osd.c 2.24 2012/02/22 16:13:04 kls Exp $
* $Id: osd.c 2.25 2012/03/02 10:48:19 kls Exp $
*/
#include "osd.h"
@ -1008,7 +1008,7 @@ void cPixmap::SetLayer(int Layer)
void cPixmap::SetAlpha(int Alpha)
{
Lock();
Alpha = min(max(Alpha, ALPHA_TRANSPARENT), ALPHA_OPAQUE);
Alpha = constrain(Alpha, ALPHA_TRANSPARENT, ALPHA_OPAQUE);
if (Alpha != alpha) {
MarkViewPortDirty(viewPort);
alpha = Alpha;
@ -1648,8 +1648,8 @@ void cOsd::SetOsdPosition(int Left, int Top, int Width, int Height)
{
osdLeft = Left;
osdTop = Top;
osdWidth = min(max(Width, MINOSDWIDTH), MAXOSDWIDTH);
osdHeight = min(max(Height, MINOSDHEIGHT), MAXOSDHEIGHT);
osdWidth = constrain(Width, MINOSDWIDTH, MAXOSDWIDTH);
osdHeight = constrain(Height, MINOSDHEIGHT, MAXOSDHEIGHT);
}
void cOsd::SetAntiAliasGranularity(uint FixedColors, uint BlendColors)