Commit 577fb0b7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

modules/video_chroma/davinci.c: Resizer: optimize non fullscreen case

Optimize for the case where fullscreen is not requested. In that case just
copy the lines into a black destination picture and let the TV do the scaling.
If your TV does not do scaling, then you will see the video in original format.

If the source and destination picture are not of the same chroma (YVUV), then
use the resizer to do chroma conversion and scale at the same time.
parent 15a19ff8
...@@ -70,6 +70,7 @@ struct filter_sys_t ...@@ -70,6 +70,7 @@ struct filter_sys_t
int i_out_size; int i_out_size;
bool b_inited; bool b_inited;
bool b_scale;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -132,6 +133,7 @@ static int Open( filter_t *p_this ) ...@@ -132,6 +133,7 @@ static int Open( filter_t *p_this )
} }
p_sys->b_inited = false; p_sys->b_inited = false;
p_sys->b_scale = config_GetInt( p_filter->p_libvlc, "fullscreen" );
if( p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma ) if( p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma )
msg_Dbg( p_filter, "Davinci resizer %4.4s to %4.4s converter", msg_Dbg( p_filter, "Davinci resizer %4.4s to %4.4s converter",
...@@ -151,7 +153,6 @@ static void Close( filter_t *p_filter ) ...@@ -151,7 +153,6 @@ static void Close( filter_t *p_filter )
FreeBuffer( p_filter, p_sys->p_in, &p_sys->i_in_size ); FreeBuffer( p_filter, p_sys->p_in, &p_sys->i_in_size );
FreeBuffer( p_filter, p_sys->p_out, &p_sys->i_out_size ); FreeBuffer( p_filter, p_sys->p_out, &p_sys->i_out_size );
close( p_sys->i_fd ); close( p_sys->i_fd );
free( p_sys ); free( p_sys );
} }
...@@ -172,7 +173,7 @@ static uint8_t *GetBuffer( filter_t *p_filter, int buf_type, int size, ...@@ -172,7 +173,7 @@ static uint8_t *GetBuffer( filter_t *p_filter, int buf_type, int size,
reqbufs.size = size; reqbufs.size = size;
reqbufs.count = 1; reqbufs.count = 1;
#if 1 #if 0
msg_Dbg( p_filter, "Asking %s for buffers: size 0x%x, count %d", msg_Dbg( p_filter, "Asking %s for buffers: size 0x%x, count %d",
buf_type == RSZ_BUF_IN ? "input" : "output", buf_type == RSZ_BUF_IN ? "input" : "output",
reqbufs.size, reqbufs.count ); reqbufs.size, reqbufs.count );
...@@ -193,7 +194,7 @@ static uint8_t *GetBuffer( filter_t *p_filter, int buf_type, int size, ...@@ -193,7 +194,7 @@ static uint8_t *GetBuffer( filter_t *p_filter, int buf_type, int size,
return NULL; return NULL;
} }
#if 1 #if 0
msg_Dbg( p_filter, "Got buffer: index %d, offset 0x%x", msg_Dbg( p_filter, "Got buffer: index %d, offset 0x%x",
buffer.index, buffer.offset ); buffer.index, buffer.offset );
#endif #endif
...@@ -310,6 +311,9 @@ static void DAVINCI_RESIZER( filter_t *p_filter, picture_t *p_source, picture_t ...@@ -310,6 +311,9 @@ static void DAVINCI_RESIZER( filter_t *p_filter, picture_t *p_source, picture_t
{ {
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
if( p_sys->b_scale ||
p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma )
{
if( !p_sys->b_inited && if( !p_sys->b_inited &&
Init( p_filter, p_source, p_dest ) != VLC_SUCCESS ) Init( p_filter, p_source, p_dest ) != VLC_SUCCESS )
return; return;
...@@ -323,4 +327,57 @@ static void DAVINCI_RESIZER( filter_t *p_filter, picture_t *p_source, picture_t ...@@ -323,4 +327,57 @@ static void DAVINCI_RESIZER( filter_t *p_filter, picture_t *p_source, picture_t
} }
memcpy( p_dest->p->p_pixels, p_sys->p_out, p_sys->i_out_size ); memcpy( p_dest->p->p_pixels, p_sys->p_out, p_sys->i_out_size );
}
if( !p_sys->b_scale &&
p_filter->fmt_out.video.i_chroma == VLC_FOURCC('U','Y','V','Y') )
{
/* Do not resize the picture to fullscreen, but center it instead.
* First make picture entirely black, then fill in the video.
*/
memset( p_dest->p->p_pixels, 0x88888888, p_dest->p->i_pitch * p_dest->p->i_visible_lines );
for( int i_plane = 0; i_plane < p_dest->i_planes; i_plane++ )
{
if( p_source->p[i_plane].i_pitch == p_dest->p[i_plane].i_pitch )
{
/* There are margins, but with the same width : perfect ! */
vlc_memcpy( p_dest->p[i_plane].p_pixels, p_source->p[i_plane].p_pixels,
p_source->p[i_plane].i_pitch * p_source->p[i_plane].i_visible_lines );
}
else
{
uint8_t *p_in = p_source->p[i_plane].p_pixels;
uint8_t *p_out = p_dest->p[i_plane].p_pixels;
int i_x_offset = (p_filter->fmt_out.video.i_width - p_source->format.i_width) /
(p_source->p[i_plane].i_pixel_pitch);
int i_y_offset = (p_filter->fmt_out.video.i_height - p_source->format.i_height) >> 1;
int i_x = i_x_offset * p_source->p[i_plane].i_pixel_pitch;
int i_x_clip, i_y_clip;
/* Check boundaries, clip the image if necessary */
i_x_clip = ( i_x + p_source->p[i_plane].i_visible_pitch ) - p_dest->p[i_plane].i_visible_pitch;
i_x_clip = ( i_x_clip > 0 ) ? i_x_clip : 0;
i_y_clip = ( i_y_offset + p_source->p[i_plane].i_visible_lines ) - p_dest->p[i_plane].i_visible_lines;
i_y_clip = ( i_y_clip > 0 ) ? i_y_clip : 0;
if( ( i_y_offset <= p_dest->p[i_plane].i_visible_lines ) &&
( i_x <= p_dest->p[i_plane].i_visible_pitch ) )
{
int i_line;
p_out += ( i_y_offset * p_dest->p[i_plane].i_pitch );
for( i_line = 0; i_line < ( p_source->p[i_plane].i_visible_lines - i_y_clip ); i_line++ )
{
vlc_memcpy( p_out + i_x, p_in,
p_source->p[i_plane].i_visible_pitch - i_x_clip );
p_in += p_source->p[i_plane].i_pitch;
p_out += p_dest->p[i_plane].i_pitch;
}
}
}
}
}
} }
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