Skip to content

Commit

Permalink
Add a setup option to enable/disable color balance filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
rofafor committed Mar 14, 2018
1 parent ed1a1d9 commit 5aabe2c
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 23 deletions.
19 changes: 11 additions & 8 deletions po/de_DE.po
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,24 @@ msgstr "60Hz Anzeigemodus"
msgid "Soft start a/v sync"
msgstr "Sanftanlauf A/V Sync"

msgid "Color balance"
msgstr ""

#, c-format
msgid "Brightness (%d..[%d]..%d)"
msgstr "Helligkeit (%d..[%d]..%d)"
msgid " Brightness (%d..[%d]..%d)"
msgstr " Helligkeit (%d..[%d]..%d)"

#, c-format
msgid "Contrast (%d..[%d]..%d)"
msgstr "Kontrast (%d..[%d]..%d)"
msgid " Contrast (%d..[%d]..%d)"
msgstr " Kontrast (%d..[%d]..%d)"

#, c-format
msgid "Saturation (%d..[%d]..%d)"
msgstr "Sättigung (%d..[%d]..%d)"
msgid " Saturation (%d..[%d]..%d)"
msgstr " Sättigung (%d..[%d]..%d)"

#, c-format
msgid "Hue (%d..[%d]..%d)"
msgstr "Farbton (%d..[%d]..%d)"
msgid " Hue (%d..[%d]..%d)"
msgstr " Farbton (%d..[%d]..%d)"

#, c-format
msgid "Skin Tone Enhancement (%d..[%d]..%d)"
Expand Down
54 changes: 39 additions & 15 deletions vaapidevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ static uint32_t ConfigVideoBackground; ///< config video background color
static char ConfigVideo60HzMode; ///< config use 60Hz display mode
static char ConfigVideoSoftStartSync; ///< config use softstart sync

static int ConfigVideoColorBalance = 1; ///< config video color balance
static int ConfigVideoBrightness; ///< config video brightness
static int ConfigVideoContrast = 1; ///< config video contrast
static int ConfigVideoSaturation = 1; ///< config video saturation
Expand Down Expand Up @@ -722,6 +723,7 @@ class cMenuSetupSoft:public cMenuSetupPage
int _60HzMode;
int SoftStartSync;

int ColorBalance;
int Brightness;
int Contrast;
int Saturation;
Expand Down Expand Up @@ -878,18 +880,21 @@ void cMenuSetupSoft::Create(void)
Add(new cMenuEditBoolItem(tr("60hz display mode"), &_60HzMode, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Soft start a/v sync"), &SoftStartSync, trVDR("no"), trVDR("yes")));

if (brightness_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("Brightness (%d..[%d]..%d)"), brightness_min, brightness_def,
brightness_max), &Brightness, brightness_min, brightness_max));
if (contrast_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("Contrast (%d..[%d]..%d)"), contrast_min, contrast_def,
contrast_max), &Contrast, contrast_min, contrast_max));
if (saturation_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("Saturation (%d..[%d]..%d)"), saturation_min, saturation_def,
saturation_max), &Saturation, saturation_min, saturation_max));
if (hue_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("Hue (%d..[%d]..%d)"), hue_min, hue_def, hue_max), &Hue,
hue_min, hue_max));
Add(new cMenuEditBoolItem(tr("Color balance"), &ColorBalance, trVDR("off"), trVDR("on")));
if (ColorBalance) {
if (brightness_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("\040\040Brightness (%d..[%d]..%d)"), brightness_min,
brightness_def, brightness_max), &Brightness, brightness_min, brightness_max));
if (contrast_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("\040\040Contrast (%d..[%d]..%d)"), contrast_min,
contrast_def, contrast_max), &Contrast, contrast_min, contrast_max));
if (saturation_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("\040\040Saturation (%d..[%d]..%d)"), saturation_min,
saturation_def, saturation_max), &Saturation, saturation_min, saturation_max));
if (hue_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("\040\040Hue (%d..[%d]..%d)"), hue_min, hue_def,
hue_max), &Hue, hue_min, hue_max));
}
if (stde_active)
Add(new cMenuEditIntItem(*cString::sprintf(tr("Skin Tone Enhancement (%d..[%d]..%d)"), stde_min, stde_def,
stde_max), &Stde, stde_min, stde_max));
Expand Down Expand Up @@ -942,9 +947,11 @@ void cMenuSetupSoft::Create(void)
Add(new cMenuEditBoolItem(tr("Enable (E-)AC-3 (decoder) downmix"), &AudioDownmix, trVDR("no"), trVDR("yes")));
Add(new cMenuEditBoolItem(tr("Volume control"), &AudioSoftvol, tr("Hardware"), tr("Software")));
Add(new cMenuEditBoolItem(tr("Enable normalize volume"), &AudioNormalize, trVDR("no"), trVDR("yes")));
Add(new cMenuEditIntItem(tr(" Max normalize factor (/1000)"), &AudioMaxNormalize, 0, 10000));
if (AudioNormalize)
Add(new cMenuEditIntItem(tr("\040\040Max normalize factor (/1000)"), &AudioMaxNormalize, 0, 10000));
Add(new cMenuEditBoolItem(tr("Enable volume compression"), &AudioCompression, trVDR("no"), trVDR("yes")));
Add(new cMenuEditIntItem(tr(" Max compression factor (/1000)"), &AudioMaxCompression, 0, 10000));
if (AudioCompression)
Add(new cMenuEditIntItem(tr("\040\040Max compression factor (/1000)"), &AudioMaxCompression, 0, 10000));
Add(new cMenuEditIntItem(tr("Reduce stereo volume (/1000)"), &AudioStereoDescent, 0, 1000));
Add(new cMenuEditIntItem(tr("Audio buffer size (ms)"), &AudioBufferTime, 0, 1000));
}
Expand All @@ -966,23 +973,29 @@ eOSState cMenuSetupSoft::ProcessKey(eKeys key)
int old_resolution_shown[RESOLUTIONS];
int old_denoise[RESOLUTIONS];
int old_sharpen[RESOLUTIONS];
int old_colorbalance;
int old_brightness;
int old_contrast;
int old_saturation;
int old_hue;
int old_stde;
int old_audionormalize;
int old_audiocompression;

old_general = General;
old_video = Video;
old_audio = Audio;
memcpy(old_resolution_shown, ResolutionShown, sizeof(ResolutionShown));
memcpy(old_denoise, Denoise, sizeof(Denoise));
memcpy(old_sharpen, Sharpen, sizeof(Sharpen));
old_colorbalance = ColorBalance;
old_brightness = Brightness;
old_contrast = Contrast;
old_saturation = Saturation;
old_hue = Hue;
old_stde = Stde;
old_audionormalize = AudioNormalize;
old_audiocompression = AudioCompression;
state = cMenuSetupPage::ProcessKey(key);

if (state == osUnknown) {
Expand All @@ -1001,7 +1014,10 @@ eOSState cMenuSetupSoft::ProcessKey(eKeys key)
if (key != kNone) {
// update menu only, if something on the structure has changed
// this is needed because VDR menus are evil slow
if (old_general != General || old_video != Video || old_audio != Audio) {
if (old_general != General || old_video != Video || old_audio != Audio || old_colorbalance != ColorBalance
|| old_audionormalize != AudioNormalize || old_audiocompression != AudioCompression) {
if (old_colorbalance != ColorBalance)
VideoSetColorBalance(ColorBalance);
Create(); // update menu
} else {
for (int i = 0; i < RESOLUTIONS; ++i) {
Expand Down Expand Up @@ -1068,6 +1084,7 @@ cMenuSetupSoft::cMenuSetupSoft(void)
_60HzMode = ConfigVideo60HzMode;
SoftStartSync = ConfigVideoSoftStartSync;

ColorBalance = ConfigVideoColorBalance;
Brightness = ConfigVideoBrightness;
Contrast = ConfigVideoContrast;
Saturation = ConfigVideoSaturation;
Expand Down Expand Up @@ -1121,6 +1138,7 @@ cMenuSetupSoft::~cMenuSetupSoft()
VideoSetDenoise(ConfigVideoDenoise);
VideoSetSharpen(ConfigVideoSharpen);
}
VideoSetColorBalance(ConfigVideoColorBalance);
VideoSetBrightness(ConfigVideoBrightness);
VideoSetContrast(ConfigVideoContrast);
VideoSetSaturation(ConfigVideoSaturation);
Expand Down Expand Up @@ -1155,6 +1173,8 @@ void cMenuSetupSoft::Store(void)
SetupStore("SoftStartSync", ConfigVideoSoftStartSync = SoftStartSync);
VideoSetSoftStartSync(ConfigVideoSoftStartSync);

SetupStore("ColorBalance", ConfigVideoColorBalance = ColorBalance);
VideoSetColorBalance(ConfigVideoColorBalance);
SetupStore("Brightness", ConfigVideoBrightness = Brightness);
VideoSetBrightness(ConfigVideoBrightness);
SetupStore("Contrast", ConfigVideoContrast = Contrast);
Expand Down Expand Up @@ -2310,6 +2330,10 @@ bool cPluginVaapiDevice::SetupParse(const char *name, const char *value)
VideoSetSoftStartSync(ConfigVideoSoftStartSync = atoi(value));
return true;
}
if (!strcasecmp(name, "ColorBalance")) {
VideoSetColorBalance(ConfigVideoColorBalance = atoi(value));
return true;
}
if (!strcasecmp(name, "Brightness")) {
VideoSetBrightness(ConfigVideoBrightness = atoi(value));
return true;
Expand Down
19 changes: 19 additions & 0 deletions video.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ static char VideoSurfaceModesChanged; ///< flag surface modes changed

static uint32_t VideoBackground; ///< video background color

/// Default color balance filter mode..
static int VideoColorBalance = 1;

/// Default skin tone enhancement mode.
static int VideoSkinToneEnhancement = 0;

Expand Down Expand Up @@ -1812,6 +1815,12 @@ static VASurfaceID *VaapiApplyFilters(VaapiDecoder * decoder, int top_field)
continue;
}

/* Skip color balance filters if value is set to 0 ("off") */
if (decoder->vpp_cbal_buf && decoder->filters[i] == *decoder->vpp_cbal_buf) {
if (!VideoColorBalance)
continue;
}

/* Skip denoise if value is set to 0 ("off") */
if (decoder->vpp_denoise_buf && decoder->filters[i] == *decoder->vpp_denoise_buf) {
if (!VideoDenoise[decoder->Resolution])
Expand Down Expand Up @@ -5170,6 +5179,16 @@ static VAStatus VaapiVideoSetColorbalance(VABufferID * buf, int Index, float val
return va_status;
}

///
/// Set color balance mode.
///
/// @param onoff on / off
///
void VideoSetColorBalance(int onoff)
{
VideoColorBalance = onoff;
}

///
/// Set brightness adjustment.
///
Expand Down
3 changes: 3 additions & 0 deletions video.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ extern void VideoSet60HzMode(int);
/// Set soft start audio/video sync.
extern void VideoSetSoftStartSync(int);

/// Set color balance mode.
extern void VideoSetColorBalance(int);

/// Set brightness adjustment.
extern void VideoSetBrightness(int);

Expand Down

0 comments on commit 5aabe2c

Please sign in to comment.