Commit eb07c341 authored by Laurent Aimar's avatar Laurent Aimar

Fixed...

Fixed colorthres/erase/extract/gaussianblur/gradient/motionblur/motiondetect/noise/psychedelic/sharpen filters.

input and output picture pitches may not be equal (corruptions or segfaults).
parent 6c4aa108
...@@ -186,8 +186,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -186,8 +186,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{ {
picture_t *p_outpic; picture_t *p_outpic;
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
uint8_t *p_in_y, *p_in_u, *p_in_v, *p_in_end_u;
uint8_t *p_out_y, *p_out_u, *p_out_v;
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
int i_simthres = p_sys->i_simthres; int i_simthres = p_sys->i_simthres;
...@@ -204,23 +202,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -204,23 +202,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return NULL; return NULL;
} }
p_in_u = p_pic->p[U_PLANE].p_pixels; /* Copy the Y plane */
p_in_v = p_pic->p[V_PLANE].p_pixels; plane_CopyPixels( &p_outpic->p[Y_PLANE], &p_pic->p[Y_PLANE] );
p_in_y = p_pic->p[Y_PLANE].p_pixels;
p_in_end_u = p_in_u + p_pic->p[U_PLANE].i_visible_lines
* p_pic->p[U_PLANE].i_pitch - 8;
p_out_y = p_outpic->p[Y_PLANE].p_pixels;
p_out_u = p_outpic->p[U_PLANE].p_pixels;
p_out_v = p_outpic->p[V_PLANE].p_pixels;
/* Create grayscale version of input */
vlc_memcpy( p_out_y, p_in_y, p_pic->p[Y_PLANE].i_visible_lines
* p_pic->p[Y_PLANE].i_pitch - 8 );
vlc_memset( p_out_u, 0x80, p_pic->p[U_PLANE].i_visible_lines
* p_pic->p[U_PLANE].i_pitch - 8 );
vlc_memset( p_out_v, 0x80, p_pic->p[U_PLANE].i_visible_lines
* p_pic->p[U_PLANE].i_pitch - 8 );
/* /*
* Do the U and V planes * Do the U and V planes
...@@ -232,31 +215,44 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -232,31 +215,44 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
112 * i_blue + 128) >> 8) + 128; 112 * i_blue + 128) >> 8) + 128;
int i_v = (int8_t)(( 112 * i_red - 94 * i_green - int i_v = (int8_t)(( 112 * i_red - 94 * i_green -
18 * i_blue + 128) >> 8) + 128; 18 * i_blue + 128) >> 8) + 128;
int refu = i_u - 0x80; /*bright red*/ int refu = i_u - 0x80; /*bright red*/
int refv = i_v - 0x80; int refv = i_v - 0x80;
int reflength = sqrt(refu*refu+refv*refv); int reflength = sqrt(refu*refu+refv*refv);
while( p_in_u < p_in_end_u ) { for( int y = 0; y < p_pic->p[U_PLANE].i_visible_lines; y++ )
/* Length of color vector */ {
int inu = (*p_in_u) - 0x80; uint8_t *p_src_u = &p_pic->p[U_PLANE].p_pixels[y * p_pic->p[U_PLANE].i_pitch];
int inv = (*p_in_v) - 0x80; uint8_t *p_src_v = &p_pic->p[V_PLANE].p_pixels[y * p_pic->p[V_PLANE].i_pitch];
int length = sqrt(inu*inu+inv*inv); uint8_t *p_dst_u = &p_outpic->p[U_PLANE].p_pixels[y * p_outpic->p[U_PLANE].i_pitch];
uint8_t *p_dst_v = &p_outpic->p[V_PLANE].p_pixels[y * p_outpic->p[V_PLANE].i_pitch];
int diffu = refu * length - inu *reflength;
int diffv = refv * length - inv *reflength; for( int x = 0; x < p_pic->p[U_PLANE].i_visible_pitch; x++ )
long long int difflen2=diffu*diffu; {
difflen2 +=diffv*diffv; /* Length of color vector */
long long int thres = length*reflength; int inu = *p_src_u - 0x80;
thres *= thres; int inv = *p_src_v - 0x80;
if( length > i_satthres && (difflen2*i_simthres< thres ) ) { int length = sqrt(inu*inu+inv*inv);
*p_out_u = *p_in_u;
*p_out_v = *p_in_v; int diffu = refu * length - inu *reflength;
// fprintf(stderr,"keeping color %d %d\n", length, difflen2); int diffv = refv * length - inv *reflength;
long long int difflen2=diffu*diffu;
difflen2 +=diffv*diffv;
long long int thres = length*reflength;
thres *= thres;
if( length > i_satthres && (difflen2*i_simthres< thres ) )
{
*p_dst_u++ = *p_src_u;
*p_dst_v++ = *p_src_v;
}
else
{
*p_dst_u++ = 0x80;
*p_dst_v++ = 0x80;
}
p_src_u++;
p_src_v++;
} }
p_in_u++;
p_in_v++;
p_out_u++;
p_out_v++;
} }
return CopyInfoAndRelease( p_outpic, p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
...@@ -266,8 +262,6 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) ...@@ -266,8 +262,6 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
{ {
picture_t *p_outpic; picture_t *p_outpic;
filter_sys_t *p_sys = p_filter->p_sys; filter_sys_t *p_sys = p_filter->p_sys;
uint8_t *p_in_y, *p_in_u, *p_in_v, *p_in_end_u;
uint8_t *p_out_y, *p_out_u, *p_out_v;
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
int i_simthres = p_sys->i_simthres; int i_simthres = p_sys->i_simthres;
...@@ -287,22 +281,9 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) ...@@ -287,22 +281,9 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
int i_y_offset, i_u_offset, i_v_offset; int i_y_offset, i_u_offset, i_v_offset;
GetPackedYuvOffsets( p_filter->fmt_in.video.i_chroma, GetPackedYuvOffsets( p_filter->fmt_in.video.i_chroma,
&i_y_offset, &i_u_offset, &i_v_offset ); &i_y_offset, &i_u_offset, &i_v_offset );
p_in_y = p_pic->p->p_pixels+i_y_offset;
p_in_u = p_pic->p->p_pixels+i_u_offset;
p_in_v = p_pic->p->p_pixels+i_v_offset;
p_in_end_u = p_in_u + p_pic->p->i_visible_lines
* p_pic->p->i_pitch - 8;
p_out_y = p_outpic->p->p_pixels+i_y_offset;
p_out_u = p_outpic->p->p_pixels+i_u_offset;
p_out_v = p_outpic->p->p_pixels+i_v_offset;
/* Create grayscale version of input */
vlc_memcpy( p_outpic->p->p_pixels, p_pic->p->p_pixels,
p_pic->p->i_visible_lines * p_pic->p->i_pitch - 8 );
/* /*
* Do the U and V planes * Copy Y and do the U and V planes
*/ */
int i_red = ( i_color & 0xFF0000 ) >> 16; int i_red = ( i_color & 0xFF0000 ) >> 16;
int i_green = ( i_color & 0xFF00 ) >> 8; int i_green = ( i_color & 0xFF00 ) >> 8;
...@@ -315,32 +296,41 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) ...@@ -315,32 +296,41 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
int refv = i_v - 0x80; int refv = i_v - 0x80;
int reflength = sqrt(refu*refu+refv*refv); int reflength = sqrt(refu*refu+refv*refv);
while( p_in_u < p_in_end_u ) { for( int y = 0; y < p_pic->p->i_visible_lines; y++ )
/* Length of color vector */ {
int inu = (*p_in_u) - 0x80; uint8_t *p_src = &p_pic->p->p_pixels[y * p_pic->p->i_pitch];
int inv = (*p_in_v) - 0x80; uint8_t *p_dst = &p_outpic->p->p_pixels[y * p_outpic->p->i_pitch];
int length = sqrt(inu*inu+inv*inv);
for( int x = 0; x < p_pic->p->i_visible_pitch / 4; x++ )
int diffu = refu * length - inu *reflength;
int diffv = refv * length - inv *reflength;
long long int difflen2=diffu*diffu;
difflen2 +=diffv*diffv;
long long int thres = length*reflength;
thres *= thres;
if( length > i_satthres && (difflen2*i_simthres< thres ) ) {
*p_out_u = *p_in_u;
*p_out_v = *p_in_v;
// fprintf(stderr,"keeping color %d %d\n", length, difflen2);
}
else
{ {
*p_out_u = 0x80; p_dst[i_y_offset + 0] = p_src[i_y_offset + 0];
*p_out_v = 0x80; p_dst[i_y_offset + 2] = p_src[i_y_offset + 2];
/* Length of color vector */
int inu = p_src[i_u_offset] - 0x80;
int inv = p_src[i_v_offset] - 0x80;
int length = sqrt(inu*inu+inv*inv);
int diffu = refu * length - inu *reflength;
int diffv = refv * length - inv *reflength;
long long int difflen2=diffu*diffu;
difflen2 +=diffv*diffv;
long long int thres = length*reflength;
thres *= thres;
if( length > i_satthres && (difflen2*i_simthres< thres ) )
{
p_dst[i_u_offset] = p_src[i_u_offset];
p_dst[i_v_offset] = p_src[i_v_offset];
}
else
{
p_dst[i_u_offset] = 0x80;
p_dst[i_v_offset] = 0x80;
}
p_dst += 4;
p_src += 4;
} }
p_in_u+=4;
p_in_v+=4;
p_out_u+=4;
p_out_v+=4;
} }
return CopyInfoAndRelease( p_outpic, p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
......
...@@ -246,13 +246,11 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic, ...@@ -246,13 +246,11 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
for( int i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ ) for( int i_plane = 0; i_plane < p_inpic->i_planes; i_plane++ )
{ {
const int i_pitch = p_inpic->p[i_plane].i_pitch; const int i_pitch = p_outpic->p[i_plane].i_pitch;
const int i_2pitch = i_pitch<<1; const int i_2pitch = i_pitch<<1;
const int i_visible_pitch = p_inpic->p[i_plane].i_visible_pitch; const int i_visible_pitch = p_inpic->p[i_plane].i_visible_pitch;
const int i_lines = p_inpic->p[i_plane].i_lines;
const int i_visible_lines = p_inpic->p[i_plane].i_visible_lines; const int i_visible_lines = p_inpic->p[i_plane].i_visible_lines;
uint8_t *p_inpix = p_inpic->p[i_plane].p_pixels;
uint8_t *p_outpix = p_outpic->p[i_plane].p_pixels; uint8_t *p_outpix = p_outpic->p[i_plane].p_pixels;
uint8_t *p_mask = p_sys->p_mask->A_PIXELS; uint8_t *p_mask = p_sys->p_mask->A_PIXELS;
int i_x = p_sys->i_x, i_y = p_sys->i_y; int i_x = p_sys->i_x, i_y = p_sys->i_y;
...@@ -279,7 +277,7 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic, ...@@ -279,7 +277,7 @@ static void FilterErase( filter_t *p_filter, picture_t *p_inpic,
i_width = __MIN( i_visible_pitch - i_x, i_width ); i_width = __MIN( i_visible_pitch - i_x, i_width );
/* Copy original pixel buffer */ /* Copy original pixel buffer */
vlc_memcpy( p_outpix, p_inpix, i_pitch * i_lines ); plane_CopyPixels( &p_outpic->p[i_plane], &p_inpic->p[i_plane] );
/* Horizontal linear interpolation of masked areas */ /* Horizontal linear interpolation of masked areas */
p_outpix = p_outpic->p[i_plane].p_pixels + i_y*i_pitch + i_x; p_outpix = p_outpic->p[i_plane].p_pixels + i_y*i_pitch + i_x;
......
...@@ -330,19 +330,19 @@ static void get_custom_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -330,19 +330,19 @@ static void get_custom_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch; y2in = y1in + i_in_pitch;
y2out = y1out + i_pitch; y2out = y1out + i_out_pitch;
while( y1in < y1end ) while( y1in < y1end )
{ {
*uout++ = crop( (*y1in * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5]) *uout++ = crop( (*y1in * m[3] + (*uin-U) * m[4] + (*vin-V) * m[5])
...@@ -358,12 +358,12 @@ static void get_custom_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -358,12 +358,12 @@ static void get_custom_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
*y2out++ = crop( (*y2in++ * m[0] + (*uin++ - U) * m[1] + (*vin++ -V) * m[2]) *y2out++ = crop( (*y2in++ * m[0] + (*uin++ - U) * m[1] + (*vin++ -V) * m[2])
/ 65536 ); / 65536 );
} }
y1in += 2*i_pitch - i_visible_pitch; y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch; y1out += 2*i_out_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch; uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
...@@ -377,14 +377,14 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -377,14 +377,14 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
...@@ -399,12 +399,12 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -399,12 +399,12 @@ static void get_custom_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
*y1out++ = crop( (*y1in++ * m[0] + (*uin++ -U) * m[1] + (*vin++ -V) * m[2]) *y1out++ = crop( (*y1in++ * m[0] + (*uin++ -U) * m[1] + (*vin++ -V) * m[2])
/ 65536 ); / 65536 );
} }
y1in += i_pitch - i_visible_pitch; y1in += i_in_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch; y1out += i_out_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch; uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
...@@ -425,11 +425,12 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic, ...@@ -425,11 +425,12 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic,
uint8_t *uout = p_outpic->p->p_pixels + i_u_offset; uint8_t *uout = p_outpic->p->p_pixels + i_u_offset;
uint8_t *vout = p_outpic->p->p_pixels + i_v_offset; uint8_t *vout = p_outpic->p->p_pixels + i_v_offset;
const int i_pitch = p_inpic->p->i_pitch; const int i_in_pitch = p_inpic->p->i_pitch;
const int i_out_pitch = p_outpic->p->i_pitch;
const int i_visible_pitch = p_inpic->p->i_visible_pitch; const int i_visible_pitch = p_inpic->p->i_visible_pitch;
const int i_visible_lines = p_inpic->p->i_visible_lines; const int i_visible_lines = p_inpic->p->i_visible_lines;
const uint8_t *yend = yin + i_visible_lines * i_pitch; const uint8_t *yend = yin + i_visible_lines * i_in_pitch;
while( yin < yend ) while( yin < yend )
{ {
const uint8_t *ylend = yin + i_visible_pitch; const uint8_t *ylend = yin + i_visible_pitch;
...@@ -452,12 +453,12 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic, ...@@ -452,12 +453,12 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic,
uin += 4; uin += 4;
vin += 4; vin += 4;
} }
yin += i_pitch - i_visible_pitch; yin += i_in_pitch - i_visible_pitch;
yout += i_pitch - i_visible_pitch; yout += i_out_pitch - i_visible_pitch;
uin += i_pitch - i_visible_pitch; uin += i_in_pitch - i_visible_pitch;
uout += i_pitch - i_visible_pitch; uout += i_out_pitch - i_visible_pitch;
vin += i_pitch - i_visible_pitch; vin += i_in_pitch - i_visible_pitch;
vout += i_pitch - i_visible_pitch; vout += i_out_pitch - i_visible_pitch;
} }
} }
...@@ -473,19 +474,19 @@ static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -473,19 +474,19 @@ static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch; y2in = y1in + i_in_pitch;
y2out = y1out + i_pitch; y2out = y1out + i_out_pitch;
while( y1in < y1end ) while( y1in < y1end )
{ {
/* /*
...@@ -506,11 +507,11 @@ static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -506,11 +507,11 @@ static void get_red_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
*y2out++ = crop( (*y2in++ * 19594 + (*vin++ - V) * 27473) *y2out++ = crop( (*y2in++ * 19594 + (*vin++ - V) * 27473)
/ 65536 ); / 65536 );
} }
y1in += 2*i_pitch - i_visible_pitch; y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch; y1out += 2*i_out_pitch - i_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
...@@ -527,19 +528,20 @@ static void get_green_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -527,19 +528,20 @@ static void get_green_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch; y2in = y1in + i_in_pitch;
y2out = y1out + i_pitch; y2out = y1out + i_out_pitch;
while( y1in < y1end ) while( y1in < y1end )
{ {
/* /*
...@@ -560,12 +562,12 @@ static void get_green_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -560,12 +562,12 @@ static void get_green_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
*y2out++ = crop( (*y2in++ * 38470 + (*uin++ - U) * -13239 + (*vin++ -V) * -27473) *y2out++ = crop( (*y2in++ * 38470 + (*uin++ - U) * -13239 + (*vin++ -V) * -27473)
/ 65536 ); / 65536 );
} }
y1in += 2*i_pitch - i_visible_pitch; y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch; y1out += 2*i_out_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch; uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
...@@ -581,19 +583,19 @@ static void get_blue_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -581,19 +583,19 @@ static void get_blue_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch; y2in = y1in + i_in_pitch;
y2out = y1out + i_pitch; y2out = y1out + i_out_pitch;
while( y1in < y1end ) while( y1in < y1end )
{ {
/* /*
...@@ -614,11 +616,11 @@ static void get_blue_from_yuv420( picture_t *p_inpic, picture_t *p_outpic, ...@@ -614,11 +616,11 @@ static void get_blue_from_yuv420( picture_t *p_inpic, picture_t *p_outpic,
*y2out++ = crop( (*y2in++ * 7471 + (*uin++ - U) * 13239 ) *y2out++ = crop( (*y2in++ * 7471 + (*uin++ - U) * 13239 )
/ 65536 ); / 65536 );
} }
y1in += 2*i_pitch - i_visible_pitch; y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch; y1out += 2*i_out_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch; uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
...@@ -632,14 +634,14 @@ static void get_red_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -632,14 +634,14 @@ static void get_red_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_inpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
...@@ -659,11 +661,11 @@ static void get_red_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -659,11 +661,11 @@ static void get_red_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
*y1out++ = crop( (*y1in++ * 19595 + (*vin++ - V) * 27473) *y1out++ = crop( (*y1in++ * 19595 + (*vin++ - V) * 27473)
/ 65536 ); / 65536 );
} }
y1in += i_pitch - i_visible_pitch; y1in += i_in_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch; y1out += i_out_pitch - i_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
} }
} }
...@@ -678,14 +680,14 @@ static void get_green_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -678,14 +680,14 @@ static void get_green_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].p_pixels; uint8_t *uout = p_outpic->p[up].p_pixels;
uint8_t *vout = p_outpic->p[vp].p_pixels; uint8_t *vout = p_outpic->p[vp].p_pixels;
const int i_pitch = p_inpic->p[yp].i_pitch; const int i_in_pitch = p_inpic->p[yp].i_pitch;
const int i_out_pitch = p_outpic->p[yp].i_pitch;
const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch; const int i_visible_pitch = p_inpic->p[yp].i_visible_pitch;
const int i_visible_lines = p_inpic->p[yp].i_visible_lines; const int i_visible_lines = p_inpic->p[yp].i_visible_lines;
const int i_uv_pitch = p_inpic->p[up].i_pitch;
const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch; const int i_uv_visible_pitch = p_inpic->p[up].i_visible_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_pitch; const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend ) while( y1in < yend )
{ {
const uint8_t *y1end = y1in + i_visible_pitch; const uint8_t *y1end = y1in + i_visible_pitch;
...@@ -705,12 +707,12 @@ static void get_green_from_yuv422( picture_t *p_inpic, picture_t *p_outpic, ...@@ -705,12 +707,12 @@ static void get_green_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
*y1out++ = crop( (*y1in++ * 38470 + (*uin++-U) * -13239 + (*vin++-V) * -27473) *y1out++ = crop( (*y1in++ * 38470 + (*uin++-U) * -13239 + (*vin++-V) * -27473)
/ 65536 ); / 65536 );
} }
y1in += i_pitch - i_visible_pitch; y1in += i_in_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch; y1out += i_out_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch; uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch; uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch; vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch; vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;