all: gamma correction patch by Arwed von Merkatz <v.merkatz@gmx.net>

parent a1c2c16b
......@@ -2,7 +2,7 @@
* interface.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001, 2003 VideoLAN
* $Id: interface.cpp,v 1.83 2004/01/05 13:00:39 zorglub Exp $
* $Id: interface.cpp,v 1.84 2004/01/22 15:00:10 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -145,6 +145,7 @@ enum
Contrast_Event,
Brightness_Event,
Saturation_Event,
Gamma_Event,
Ratio_Event,
Visual_Event,
......@@ -200,6 +201,7 @@ BEGIN_EVENT_TABLE(Interface, wxFrame)
EVT_COMMAND_SCROLL(Contrast_Event, Interface::OnContrastUpdate)
EVT_COMMAND_SCROLL(Brightness_Event, Interface::OnBrightnessUpdate)
EVT_COMMAND_SCROLL(Saturation_Event, Interface::OnSaturationUpdate)
EVT_COMMAND_SCROLL(Gamma_Event, Interface::OnGammaUpdate)
END_EVENT_TABLE()
......@@ -546,11 +548,21 @@ void Interface::CreateOurExtraPanel()
saturation_sizer->Add(saturation_slider,1,0,0);
saturation_sizer->Layout();
wxBoxSizer *gamma_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *gamma_text = new wxStaticText( extra_frame, -1,
wxU(_("Gamma")) );
gamma_slider = new wxSlider ( extra_frame, Gamma_Event, 0, 0,
100, wxDefaultPosition, wxDefaultSize );
gamma_sizer->Add(gamma_text,1,0,0);
gamma_sizer->Add(gamma_slider,1,0,0);
gamma_sizer->Layout();
adjust_sizer->Add(adjust_check, 1, wxEXPAND, 0);
adjust_sizer->Add(hue_sizer, 1, wxEXPAND, 0);
adjust_sizer->Add(contrast_sizer, 1, wxEXPAND, 0);
adjust_sizer->Add(brightness_sizer, 1, wxEXPAND, 0);
adjust_sizer->Add(saturation_sizer, 1, wxEXPAND, 0);
adjust_sizer->Add(gamma_sizer, 1, wxEXPAND, 0);
extra_sizer->Add(adjust_sizer,1,wxBOTTOM,5);
......@@ -637,6 +649,7 @@ void Interface::CreateOurExtraPanel()
contrast_slider->Enable();
brightness_slider->Enable();
hue_slider->Enable();
gamma_slider->Enable();
}
else
{
......@@ -645,6 +658,7 @@ void Interface::CreateOurExtraPanel()
contrast_slider->Disable();
brightness_slider->Disable();
hue_slider->Disable();
gamma_slider->Disable();
}
if( psz_filters ) free( psz_filters );
......@@ -662,6 +676,9 @@ void Interface::CreateOurExtraPanel()
f_value = config_GetFloat( p_intf, "brightness" );
if( f_value > 0 && f_value < 2 )
brightness_slider->SetValue( (int)(100 * f_value) );
f_value = config_GetFloat( p_intf, "gamma" );
if (f_value > 0 && f_value < 10 )
gamma_slider->SetValue( (int)(10 * f_value) );
extra_frame->Hide();
}
......@@ -983,6 +1000,7 @@ void Interface::OnEnableAdjust(wxCommandEvent& event)
saturation_slider->Enable();
contrast_slider->Enable();
hue_slider->Enable();
gamma_slider->Enable();
}
else
{
......@@ -1025,6 +1043,7 @@ void Interface::OnEnableAdjust(wxCommandEvent& event)
saturation_slider->Disable();
contrast_slider->Disable();
hue_slider->Disable();
gamma_slider->Disable();
}
if(psz_filters) free(psz_filters);
if(psz_new) free(psz_new);
......@@ -1051,6 +1070,11 @@ void Interface::OnContrastUpdate(wxScrollEvent& event)
}
void Interface::OnGammaUpdate(wxScrollEvent& event)
{
config_PutFloat( p_intf , "gamma" , (float)event.GetPosition()/10 );
}
void Interface::OnRatio( wxCommandEvent& event )
{
config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str() );
......
......@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.85 2004/01/15 21:49:07 sigmunau Exp $
* $Id: wxwindows.h,v 1.86 2004/01/22 15:00:10 sigmunau Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -178,6 +178,7 @@ public:
wxSlider *contrast_slider;
wxSlider *saturation_slider;
wxSlider *hue_slider;
wxSlider *gamma_slider;
wxStaticBox *other_box;
wxComboBox *ratio_combo;
......@@ -218,6 +219,7 @@ private:
void OnContrastUpdate( wxScrollEvent& event );
void OnBrightnessUpdate( wxScrollEvent& event );
void OnSaturationUpdate( wxScrollEvent& event );
void OnGammaUpdate( wxScrollEvent& event );
void OnRatio( wxCommandEvent& event );
void OnEnableVisual( wxCommandEvent& event );
......
......@@ -2,7 +2,7 @@
* adjust.c : Contrast/Hue/Saturation/Brightness video plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001, 2002, 2003 VideoLAN
* $Id: adjust.c,v 1.14 2003/10/15 22:49:48 gbazin Exp $
* $Id: adjust.c,v 1.15 2004/01/22 15:00:10 sigmunau Exp $
*
* Authors: Simon Latapie <garf@via.ecp.fr>
*
......@@ -65,6 +65,8 @@ static int SendEvents( vlc_object_t *, char const *,
#define SAT_LONGTEXT N_("Set the image saturation, between 0 and 3. Defaults to 1")
#define LUM_TEXT N_("Set image brightness")
#define LUM_LONGTEXT N_("Set the image brightness, between 0 and 2. Defaults to 1")
#define GAMMA_TEXT N_("Set image gamma")
#define GAMMA_LONGTEXT N_("Set the image gamma, between 0.01 and 10. Defaults to 1")
vlc_module_begin();
......@@ -73,7 +75,8 @@ vlc_module_begin();
add_float_with_range( "brightness", 1.0, 0.0, 2.0, NULL, LUM_TEXT, LUM_LONGTEXT, VLC_FALSE );
add_integer_with_range( "hue", 0, 0, 360, NULL, HUE_TEXT, HUE_LONGTEXT, VLC_FALSE );
add_float_with_range( "saturation", 1.0, 0.0, 3.0, NULL, SAT_TEXT, SAT_LONGTEXT, VLC_FALSE );
set_description( _("contrast/hue/saturation/brightness filter") );
add_float_with_range( "gamma", 1.0, 0.01, 10.0, NULL, GAMMA_TEXT, GAMMA_LONGTEXT, VLC_FALSE );
set_description( _("contrast/hue/saturation/brightness/gamma filter") );
set_capability( "video filter", 0 );
add_shortcut( "adjust" );
set_callbacks( Create, Destroy );
......@@ -204,12 +207,14 @@ static void Destroy( vlc_object_t *p_this )
static void Render( vout_thread_t *p_vout, picture_t *p_pic )
{
int pi_luma[256];
int pi_gamma[256];
picture_t *p_outpic;
uint8_t *p_in, *p_in_v, *p_in_end, *p_line_end;
uint8_t *p_out, *p_out_v;
double f_hue;
double f_gamma;
int32_t i_cont, i_lum;
int i_sat, i_sin, i_cos, i_x, i_y;
int i;
......@@ -233,15 +238,22 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic )
i_lum = (config_GetFloat( p_vout, "brightness" ) - 1.0) * 255;
f_hue = config_GetInt( p_vout, "hue" ) * M_PI / 180;
i_sat = config_GetFloat( p_vout, "saturation" ) * 256;
f_gamma = 1.0 / config_GetFloat( p_vout, "gamma" );
/* Contrast is a fast but kludged function, so I put this gap to be
* cleaner :) */
i_lum += 128 - i_cont / 2;
/* Fill the gamma lookup table */
for( i = 0 ; i < 256 ; i++ )
{
pi_gamma[ i ] = clip( pow(i / 255.0, f_gamma) * 255.0);
}
/* Fill the luma lookup table */
for( i = 0 ; i < 256 ; i++ )
{
pi_luma[ i ] = clip( i_lum + i_cont * i / 256 );
pi_luma[ i ] = pi_gamma[clip( i_lum + i_cont * i / 256)];
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment