Commit a2768deb authored by Jean-Paul Saman's avatar Jean-Paul Saman

Removal of dead code

parent c3358bd5
......@@ -54,227 +54,6 @@ static void osd_StatesFree( vlc_object_t *, osd_state_t * );
static picture_t *osd_LoadImage( vlc_object_t *, const char *);
#if 0
/*****************************************************************************
* osd_YuvaYuvp
*****************************************************************************/
static picture_t *osd_YuvaYuvp( vlc_object_t *p_this, picture_t *p_picture )
{
video_format_t *p_fmt = NULL;
int i = 0, j = 0, n = 0, p = 0;
int i_max_entries = 256;
#ifdef RANDOM_DITHERING
int i_seed = 0xdeadbeef; /* random seed */
#else
int *pi_delta = NULL;
#endif
int i_pixels = p_picture->p[0].i_visible_lines
* p_picture->p[0].i_pitch;
int i_iterator = p_picture->p[0].i_visible_lines * 3 / 4
* p_picture->p[0].i_pitch
+ p_picture->p[0].i_pitch * 1 / 3;
int i_tolerance = 0;
p_fmt = (video_format_t*) malloc( sizeof( video_format_t ) );
if( !p_fmt )
{
msg_Err( p_this, "couldn't allocate video_format_t ... aborting YUVA to YUVP conversion of picture" );
return p_picture;
}
p_fmt->i_chroma = VLC_FOURCC('Y','U','V','P');
p_fmt->p_palette = (video_palette_t *) malloc( sizeof( video_palette_t ) );
if( !p_fmt->p_palette )
{
msg_Err( p_this, "couldn't allocate video_palette_t ... aborting YUVA to YUVP conversion of picture" );
free( p_fmt );
return p_picture;
}
p_fmt->p_palette->i_entries = 0;
/* Find best iterator using Euclide’s algorithm */
for( ; i_iterator > 1 ; i_iterator-- )
{
int a = i_pixels;
int b = i_iterator;
int c;
while( b )
{
c = a % b;
a = b;
b = c;
}
if( a == 1 )
{
break;
}
}
/* Count colors, build best palette */
for( i_tolerance = 0; i_tolerance < 128; i_tolerance++ )
{
vlc_bool_t b_success = VLC_TRUE;
p_fmt->p_palette->i_entries = 0;
for( i = 0; i < i_pixels ; )
{
uint8_t y = 0, u = 0, v = 0, a = 0;
y = p_picture->p[0].p_pixels[i];
u = p_picture->p[1].p_pixels[i];
v = p_picture->p[2].p_pixels[i];
a = p_picture->p[3].p_pixels[i];
for( j = 0; j < p_fmt->p_palette->i_entries; j++ )
{
if( abs((int)p_fmt->p_palette->palette[j][0] - (int)y) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][1] - (int)u) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][2] - (int)v) <= i_tolerance &&
abs((int)p_fmt->p_palette->palette[j][3] - (int)a) <= i_tolerance / 2 )
{
break;
}
}
if( j == p_fmt->p_palette->i_entries )
{
p_fmt->p_palette->palette[j][0] = y;
p_fmt->p_palette->palette[j][1] = u;
p_fmt->p_palette->palette[j][2] = v;
p_fmt->p_palette->palette[j][3] = a;
p_fmt->p_palette->i_entries++;
}
if( p_fmt->p_palette->i_entries >= i_max_entries )
{
b_success = VLC_FALSE;
break;
}
i += i_iterator;
if( i > i_pixels )
{
i -= i_pixels;
}
}
if( b_success )
{
break;
}
}
#if OSD_MENU_DEBUG
msg_Dbg( p_this, "best palette has %d colors", p_fmt->p_palette->i_entries );
#endif
#ifndef RANDOM_DITHERING
pi_delta = malloc( ( p_picture->p[0].i_pitch + 1 ) * sizeof(int) * 4 );
if( !pi_delta )
{
msg_Err( p_this, "couldn't allocate video_palette_t ... aborting YUVA to YUVP conversion of picture" );
free( p_fmt->p_palette );
free( p_fmt );
return p_picture;
}
for( i = 0; i < (p_picture->p[0].i_pitch + 1) * 4 ; i++ )
{
pi_delta[ i ] = 0;
}
#endif
/* Fill image with our new colours */
for( p = 0; p < p_picture->p[0].i_visible_lines ; p++ )
{
int i_ydelta = 0, i_udelta = 0, i_vdelta = 0, i_adelta = 0;
for( n = 0; n < p_picture->p[0].i_pitch ; n++ )
{
int i_offset = p * p_picture->p[0].i_pitch + n;
int y, u, v, a;
int i_mindist, i_best;
y = (int)p_picture->p[0].p_pixels[i_offset];
u = (int)p_picture->p[1].p_pixels[i_offset];
v = (int)p_picture->p[2].p_pixels[i_offset];
a = (int)p_picture->p[3].p_pixels[i_offset];
/* Add dithering compensation */
#ifdef RANDOM_DITHERING
y += ((i_seed & 0xff) - 0x80) * i_tolerance / 0x80;
u += (((i_seed >> 8) & 0xff) - 0x80) * i_tolerance / 0x80;
v += (((i_seed >> 16) & 0xff) - 0x80) * i_tolerance / 0x80;
a += (((i_seed >> 24) & 0xff) - 0x80) * i_tolerance / 0x80;
#else
y += i_ydelta + pi_delta[ n * 4 ];
u += i_udelta + pi_delta[ n * 4 + 1 ];
v += i_vdelta + pi_delta[ n * 4 + 2 ];
a += i_adelta + pi_delta[ n * 4 + 3 ];
#endif
/* Find best colour in palette */
for( i_mindist = 99999999, i_best = 0, j = 0; j < p_fmt->p_palette->i_entries; j++ )
{
int i_dist = 0;
i_dist += abs((int)p_fmt->p_palette->palette[j][0] - y);
i_dist += abs((int)p_fmt->p_palette->palette[j][1] - u);
i_dist += abs((int)p_fmt->p_palette->palette[j][2] - v);
i_dist += 2 * abs((int)p_fmt->p_palette->palette[j][3] - a);
if( i_dist < i_mindist )
{
i_mindist = i_dist;
i_best = j;
}
}
/* Set pixel to best color */
p_picture->p[0].p_pixels[i_offset] = i_best;
/* Update dithering state */
#ifdef RANDOM_DITHERING
i_seed = (i_seed * 0x1283837) ^ 0x789479 ^ (i_seed >> 13);
#else
i_ydelta = y - (int)p_fmt->p_palette->palette[i_best][0];
i_udelta = u - (int)p_fmt->p_palette->palette[i_best][1];
i_vdelta = v - (int)p_fmt->p_palette->palette[i_best][2];
i_adelta = a - (int)p_fmt->p_palette->palette[i_best][3];
pi_delta[ n * 4 ] = i_ydelta * 3 / 8;
pi_delta[ n * 4 + 1 ] = i_udelta * 3 / 8;
pi_delta[ n * 4 + 2 ] = i_vdelta * 3 / 8;
pi_delta[ n * 4 + 3 ] = i_adelta * 3 / 8;
i_ydelta = i_ydelta * 5 / 8;
i_udelta = i_udelta * 5 / 8;
i_vdelta = i_vdelta * 5 / 8;
i_adelta = i_adelta * 5 / 8;
#endif
}
}
#ifndef RANDOM_DITHERING
free( pi_delta );
#endif
/* pad palette */
for( i = p_fmt->p_palette->i_entries; i < i_max_entries; i++ )
{
p_fmt->p_palette->palette[i][0] = 0;
p_fmt->p_palette->palette[i][1] = 0;
p_fmt->p_palette->palette[i][2] = 0;
p_fmt->p_palette->palette[i][3] = 0;
}
p_fmt->p_palette->i_entries = i_max_entries;
#if OSD_MENU_DEBUG
msg_Dbg( p_this, "best palette has %d colors", p_fmt->p_palette->i_entries );
#endif
p_picture->format.i_chroma = VLC_FOURCC('Y','U','V','P');
if( p_picture->format.p_palette )
free( p_picture->format.p_palette );
p_picture->format.p_palette = p_fmt->p_palette;
free( p_fmt );
return p_picture;
}
#endif
/*****************************************************************************
* osd_LoadImage: loads the logo image into memory
*****************************************************************************/
......
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