Commit 736e7e75 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

i420_yuy2: only handle visible pixels

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent e29200cb
...@@ -96,8 +96,8 @@ static int Activate( vlc_object_t *p_this ) ...@@ -96,8 +96,8 @@ static int Activate( vlc_object_t *p_this )
if( !vlc_CPU_capable() ) if( !vlc_CPU_capable() )
return VLC_EGENERIC; return VLC_EGENERIC;
if( p_filter->fmt_in.video.i_width & 1 if( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) & 1
|| p_filter->fmt_in.video.i_height & 1 ) || (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) & 1 )
{ {
return -1; return -1;
} }
...@@ -170,11 +170,14 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source, ...@@ -170,11 +170,14 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
int i_x, i_y; int i_x, i_y;
const int i_source_margin = p_source->p[0].i_pitch const int i_source_margin = p_source->p[0].i_pitch
- p_source->p[0].i_visible_pitch; - p_source->p[0].i_visible_pitch
- p_filter->fmt_in.video.i_x_offset;
const int i_source_margin_c = p_source->p[1].i_pitch const int i_source_margin_c = p_source->p[1].i_pitch
- p_source->p[1].i_visible_pitch; - p_source->p[1].i_visible_pitch
- ( p_filter->fmt_in.video.i_x_offset );
const int i_dest_margin = p_dest->p->i_pitch const int i_dest_margin = p_dest->p->i_pitch
- p_dest->p->i_visible_pitch; - p_dest->p->i_visible_pitch
- ( p_filter->fmt_out.video.i_x_offset * 2 );
#if defined (MODULE_NAME_IS_i422_yuy2_sse2) #if defined (MODULE_NAME_IS_i422_yuy2_sse2)
...@@ -182,13 +185,13 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source, ...@@ -182,13 +185,13 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
((intptr_t)p_line|(intptr_t)p_y))) ) ((intptr_t)p_line|(intptr_t)p_y))) )
{ {
/* use faster SSE2 aligned fetch and store */ /* use faster SSE2 aligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_YUYV_ALIGNED ); SSE2_CALL( SSE2_YUV422_YUYV_ALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v );
} }
...@@ -200,13 +203,13 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source, ...@@ -200,13 +203,13 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
} }
else { else {
/* use slower SSE2 unaligned fetch and store */ /* use slower SSE2 unaligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_YUYV_UNALIGNED ); SSE2_CALL( SSE2_YUV422_YUYV_UNALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v );
} }
...@@ -220,9 +223,9 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source, ...@@ -220,9 +223,9 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
#else #else
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
{ {
#if defined (MODULE_NAME_IS_i422_yuy2) #if defined (MODULE_NAME_IS_i422_yuy2)
C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v );
...@@ -233,7 +236,7 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source, ...@@ -233,7 +236,7 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
MMX_CALL( MMX_YUV422_YUYV ); MMX_CALL( MMX_YUV422_YUYV );
#endif #endif
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x-- ; )
{ {
C_YUV422_YUYV( p_line, p_y, p_u, p_v ); C_YUV422_YUYV( p_line, p_y, p_u, p_v );
} }
...@@ -264,11 +267,14 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source, ...@@ -264,11 +267,14 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
int i_x, i_y; int i_x, i_y;
const int i_source_margin = p_source->p[0].i_pitch const int i_source_margin = p_source->p[0].i_pitch
- p_source->p[0].i_visible_pitch; - p_source->p[0].i_visible_pitch
- p_filter->fmt_in.video.i_x_offset;
const int i_source_margin_c = p_source->p[1].i_pitch const int i_source_margin_c = p_source->p[1].i_pitch
- p_source->p[1].i_visible_pitch; - p_source->p[1].i_visible_pitch
- ( p_filter->fmt_in.video.i_x_offset );
const int i_dest_margin = p_dest->p->i_pitch const int i_dest_margin = p_dest->p->i_pitch
- p_dest->p->i_visible_pitch; - p_dest->p->i_visible_pitch
- ( p_filter->fmt_out.video.i_x_offset * 2 );
#if defined (MODULE_NAME_IS_i422_yuy2_sse2) #if defined (MODULE_NAME_IS_i422_yuy2_sse2)
...@@ -276,13 +282,13 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source, ...@@ -276,13 +282,13 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
((intptr_t)p_line|(intptr_t)p_y))) ) ((intptr_t)p_line|(intptr_t)p_y))) )
{ {
/* use faster SSE2 aligned fetch and store */ /* use faster SSE2 aligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_YVYU_ALIGNED ); SSE2_CALL( SSE2_YUV422_YVYU_ALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v );
} }
...@@ -294,13 +300,13 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source, ...@@ -294,13 +300,13 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
} }
else { else {
/* use slower SSE2 unaligned fetch and store */ /* use slower SSE2 unaligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_YVYU_UNALIGNED ); SSE2_CALL( SSE2_YUV422_YVYU_UNALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v );
} }
...@@ -314,9 +320,9 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source, ...@@ -314,9 +320,9 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
#else #else
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
{ {
#if defined (MODULE_NAME_IS_i422_yuy2) #if defined (MODULE_NAME_IS_i422_yuy2)
C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v );
...@@ -327,7 +333,7 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source, ...@@ -327,7 +333,7 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
MMX_CALL( MMX_YUV422_YVYU ); MMX_CALL( MMX_YUV422_YVYU );
#endif #endif
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x-- ; )
{ {
C_YUV422_YVYU( p_line, p_y, p_u, p_v ); C_YUV422_YVYU( p_line, p_y, p_u, p_v );
} }
...@@ -358,11 +364,14 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source, ...@@ -358,11 +364,14 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
int i_x, i_y; int i_x, i_y;
const int i_source_margin = p_source->p[0].i_pitch const int i_source_margin = p_source->p[0].i_pitch
- p_source->p[0].i_visible_pitch; - p_source->p[0].i_visible_pitch
- p_filter->fmt_in.video.i_x_offset;
const int i_source_margin_c = p_source->p[1].i_pitch const int i_source_margin_c = p_source->p[1].i_pitch
- p_source->p[1].i_visible_pitch; - p_source->p[1].i_visible_pitch
- ( p_filter->fmt_in.video.i_x_offset );
const int i_dest_margin = p_dest->p->i_pitch const int i_dest_margin = p_dest->p->i_pitch
- p_dest->p->i_visible_pitch; - p_dest->p->i_visible_pitch
- ( p_filter->fmt_out.video.i_x_offset * 2 );
#if defined (MODULE_NAME_IS_i422_yuy2_sse2) #if defined (MODULE_NAME_IS_i422_yuy2_sse2)
...@@ -370,13 +379,13 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source, ...@@ -370,13 +379,13 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
((intptr_t)p_line|(intptr_t)p_y))) ) ((intptr_t)p_line|(intptr_t)p_y))) )
{ {
/* use faster SSE2 aligned fetch and store */ /* use faster SSE2 aligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_UYVY_ALIGNED ); SSE2_CALL( SSE2_YUV422_UYVY_ALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v );
} }
...@@ -388,13 +397,13 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source, ...@@ -388,13 +397,13 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
} }
else { else {
/* use slower SSE2 unaligned fetch and store */ /* use slower SSE2 unaligned fetch and store */
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
{ {
SSE2_CALL( SSE2_YUV422_UYVY_UNALIGNED ); SSE2_CALL( SSE2_YUV422_UYVY_UNALIGNED );
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
{ {
C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v );
} }
...@@ -408,9 +417,9 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source, ...@@ -408,9 +417,9 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
#else #else
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
{ {
#if defined (MODULE_NAME_IS_i422_yuy2) #if defined (MODULE_NAME_IS_i422_yuy2)
C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v );
...@@ -421,7 +430,7 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source, ...@@ -421,7 +430,7 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
MMX_CALL( MMX_YUV422_UYVY ); MMX_CALL( MMX_YUV422_UYVY );
#endif #endif
} }
for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x-- ; ) for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x-- ; )
{ {
C_YUV422_UYVY( p_line, p_y, p_u, p_v ); C_YUV422_UYVY( p_line, p_y, p_u, p_v );
} }
...@@ -462,9 +471,9 @@ static void I422_Y211( filter_t *p_filter, picture_t *p_source, ...@@ -462,9 +471,9 @@ static void I422_Y211( filter_t *p_filter, picture_t *p_source,
int i_x, i_y; int i_x, i_y;
for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; ) for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
{ {
for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; ) for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
{ {
C_YUV422_Y211( p_line, p_y, p_u, p_v ); C_YUV422_Y211( p_line, p_y, p_u, p_v );
C_YUV422_Y211( p_line, p_y, p_u, p_v ); C_YUV422_Y211( p_line, p_y, p_u, p_v );
......
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