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 )
{
picture_t *p_outpic;
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 );
int i_simthres = p_sys->i_simthres;
......@@ -204,23 +202,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return NULL;
}
p_in_u = p_pic->p[U_PLANE].p_pixels;
p_in_v = p_pic->p[V_PLANE].p_pixels;
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 );
/* Copy the Y plane */
plane_CopyPixels( &p_outpic->p[Y_PLANE], &p_pic->p[Y_PLANE] );
/*
* Do the U and V planes
......@@ -232,31 +215,44 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
112 * i_blue + 128) >> 8) + 128;
int i_v = (int8_t)(( 112 * i_red - 94 * i_green -
18 * i_blue + 128) >> 8) + 128;
int refu = i_u - 0x80; /*bright red*/
int refv = i_v - 0x80;
int reflength = sqrt(refu*refu+refv*refv);
while( p_in_u < p_in_end_u ) {
/* Length of color vector */
int inu = (*p_in_u) - 0x80;
int inv = (*p_in_v) - 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_out_u = *p_in_u;
*p_out_v = *p_in_v;
// fprintf(stderr,"keeping color %d %d\n", length, difflen2);
for( int y = 0; y < p_pic->p[U_PLANE].i_visible_lines; y++ )
{
uint8_t *p_src_u = &p_pic->p[U_PLANE].p_pixels[y * p_pic->p[U_PLANE].i_pitch];
uint8_t *p_src_v = &p_pic->p[V_PLANE].p_pixels[y * p_pic->p[V_PLANE].i_pitch];
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];
for( int x = 0; x < p_pic->p[U_PLANE].i_visible_pitch; x++ )
{
/* Length of color vector */
int inu = *p_src_u - 0x80;
int inv = *p_src_v - 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_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 );
......@@ -266,8 +262,6 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
{
picture_t *p_outpic;
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 );
int i_simthres = p_sys->i_simthres;
......@@ -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;
GetPackedYuvOffsets( p_filter->fmt_in.video.i_chroma,
&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_green = ( i_color & 0xFF00 ) >> 8;
......@@ -315,32 +296,41 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
int refv = i_v - 0x80;
int reflength = sqrt(refu*refu+refv*refv);
while( p_in_u < p_in_end_u ) {
/* Length of color vector */
int inu = (*p_in_u) - 0x80;
int inv = (*p_in_v) - 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_out_u = *p_in_u;
*p_out_v = *p_in_v;
// fprintf(stderr,"keeping color %d %d\n", length, difflen2);
}
else
for( int y = 0; y < p_pic->p->i_visible_lines; y++ )
{
uint8_t *p_src = &p_pic->p->p_pixels[y * p_pic->p->i_pitch];
uint8_t *p_dst = &p_outpic->p->p_pixels[y * p_outpic->p->i_pitch];
for( int x = 0; x < p_pic->p->i_visible_pitch / 4; x++ )
{
*p_out_u = 0x80;
*p_out_v = 0x80;
p_dst[i_y_offset + 0] = p_src[i_y_offset + 0];
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 );
......
......@@ -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++ )
{
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_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;
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_mask = p_sys->p_mask->A_PIXELS;
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,
i_width = __MIN( i_visible_pitch - i_x, i_width );
/* 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 */
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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch;
y2out = y1out + i_pitch;
y2in = y1in + i_in_pitch;
y2out = y1out + i_out_pitch;
while( y1in < y1end )
{
*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,
*y2out++ = crop( (*y2in++ * m[0] + (*uin++ - U) * m[1] + (*vin++ -V) * m[2])
/ 65536 );
}
y1in += 2*i_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_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,
......@@ -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 *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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
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,
*y1out++ = crop( (*y1in++ * m[0] + (*uin++ -U) * m[1] + (*vin++ -V) * m[2])
/ 65536 );
}
y1in += i_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += i_in_pitch - i_visible_pitch;
y1out += i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_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,
uint8_t *uout = p_outpic->p->p_pixels + i_u_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_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 )
{
const uint8_t *ylend = yin + i_visible_pitch;
......@@ -452,12 +453,12 @@ static void get_custom_from_packedyuv422( picture_t *p_inpic,
uin += 4;
vin += 4;
}
yin += i_pitch - i_visible_pitch;
yout += i_pitch - i_visible_pitch;
uin += i_pitch - i_visible_pitch;
uout += i_pitch - i_visible_pitch;
vin += i_pitch - i_visible_pitch;
vout += i_pitch - i_visible_pitch;
yin += i_in_pitch - i_visible_pitch;
yout += i_out_pitch - i_visible_pitch;
uin += i_in_pitch - i_visible_pitch;
uout += i_out_pitch - i_visible_pitch;
vin += i_in_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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch;
y2out = y1out + i_pitch;
y2in = y1in + i_in_pitch;
y2out = y1out + i_out_pitch;
while( y1in < y1end )
{
/*
......@@ -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)
/ 65536 );
}
y1in += 2*i_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_out_pitch - i_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch;
y2out = y1out + i_pitch;
y2in = y1in + i_in_pitch;
y2out = y1out + i_out_pitch;
while( y1in < y1end )
{
/*
......@@ -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)
/ 65536 );
}
y1in += 2*i_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
const uint8_t *y1end = y1in + i_visible_pitch;
y2in = y1in + i_pitch;
y2out = y1out + i_pitch;
y2in = y1in + i_in_pitch;
y2out = y1out + i_out_pitch;
while( y1in < y1end )
{
/*
......@@ -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 )
/ 65536 );
}
y1in += 2*i_pitch - i_visible_pitch;
y1out += 2*i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += 2*i_in_pitch - i_visible_pitch;
y1out += 2*i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
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,
*y1out++ = crop( (*y1in++ * 19595 + (*vin++ - V) * 27473)
/ 65536 );
}
y1in += i_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += i_in_pitch - i_visible_pitch;
y1out += i_out_pitch - i_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_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,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
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,
*y1out++ = crop( (*y1in++ * 38470 + (*uin++-U) * -13239 + (*vin++-V) * -27473)
/ 65536 );
}
y1in += i_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vin += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += i_in_pitch - i_visible_pitch;
y1out += i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vin += p_inpic->p[vp].i_pitch - i_uv_visible_pitch;
vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
}
}
......@@ -724,14 +726,14 @@ static void get_blue_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
uint8_t *uout = p_outpic->p[up].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_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 uint8_t *yend = y1in + i_visible_lines * i_pitch;
const uint8_t *yend = y1in + i_visible_lines * i_in_pitch;
while( y1in < yend )
{
const uint8_t *y1end = y1in + i_visible_pitch;
......@@ -751,11 +753,11 @@ static void get_blue_from_yuv422( picture_t *p_inpic, picture_t *p_outpic,
*y1out++ = crop( (*y1in++ * 7471 + (*uin++ - U) * 13239 )
/ 65536 );
}
y1in += i_pitch - i_visible_pitch;
y1out += i_pitch - i_visible_pitch;
uin += i_uv_pitch - i_uv_visible_pitch;
uout += i_uv_pitch - i_uv_visible_pitch;
vout += i_uv_pitch - i_uv_visible_pitch;
y1in += i_in_pitch - i_visible_pitch;
y1out += i_out_pitch - i_visible_pitch;
uin += p_inpic->p[up].i_pitch - i_uv_visible_pitch;
uout += p_outpic->p[up].i_pitch - i_uv_visible_pitch;
vout += p_outpic->p[vp].i_pitch - i_uv_visible_pitch;
}
}
......
......@@ -252,7 +252,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
const int i_visible_lines = p_pic->p[i_plane].i_visible_lines;
const int i_visible_pitch = p_pic->p[i_plane].i_visible_pitch;
const int i_pitch = p_pic->p[i_plane].i_pitch;
const int i_in_pitch = p_pic->p[i_plane].i_pitch;
int i_line, i_col;
const int x_factor = p_pic->p[Y_PLANE].i_visible_pitch/i_visible_pitch-1;
......@@ -264,7 +264,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
type_t t_value = 0;
int x;
const int c = i_line*i_pitch+i_col;
const int c = i_line*i_in_pitch+i_col;
for( x = __MAX( -i_dim, -i_col*(x_factor+1) );
x <= __MIN( i_dim, (i_visible_pitch - i_col)*(x_factor+1) + 1 );
x++ )
......@@ -281,17 +281,17 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
type_t t_value = 0;
int y;
const int c = i_line*i_pitch+i_col;
const int c = i_line*i_in_pitch+i_col;
for( y = __MAX( -i_dim, (-i_line)*(y_factor+1) );
y <= __MIN( i_dim, (i_visible_lines - i_line)*(y_factor+1) - 1 );
y++ )
{
t_value += pt_distribution[y+i_dim] *
pt_buffer[c+(y>>y_factor)*i_pitch];
pt_buffer[c+(y>>y_factor)*i_in_pitch];
}
const type_t t_scale = pt_scale[(i_line<<y_factor)*(i_pitch<<x_factor)+(i_col<<x_factor)];
p_out[c] = (uint8_t)(t_value / t_scale); // FIXME wouldn't it be better to round instead of trunc ?
const type_t t_scale = pt_scale[(i_line<<y_factor)*(i_in_pitch<<x_factor)+(i_col<<x_factor)];
p_out[i_line * p_outpic->p[i_plane].i_pitch + i_col] = (uint8_t)(t_value / t_scale); // FIXME wouldn't it be better to round instead of trunc ?
}
}
}
......
......@@ -360,12 +360,8 @@ static void FilterGradient( filter_t *p_filter, picture_t *p_inpic,
if( p_filter->p_sys->b_cartoon )
{
vlc_memcpy( p_outpic->p[U_PLANE].p_pixels,
p_inpic->p[U_PLANE].p_pixels,
p_outpic->p[U_PLANE].i_lines * p_outpic->p[U_PLANE].i_pitch );
vlc_memcpy( p_outpic->p[V_PLANE].p_pixels,
p_inpic->p[V_PLANE].p_pixels,
p_outpic->p[V_PLANE].i_lines * p_outpic->p[V_PLANE].i_pitch );
plane_CopyPixels( &p_outpic->p[U_PLANE], &p_inpic->p[U_PLANE] );
plane_CopyPixels( &p_outpic->p[V_PLANE], &p_inpic->p[V_PLANE] );
}
else
{
......@@ -504,12 +500,8 @@ static void FilterEdge( filter_t *p_filter, picture_t *p_inpic,
if( p_filter->p_sys->b_cartoon )
{
vlc_memcpy( p_outpic->p[U_PLANE].p_pixels,
p_inpic->p[U_PLANE].p_pixels,
p_outpic->p[U_PLANE].i_lines * p_outpic->p[U_PLANE].i_pitch );
vlc_memcpy( p_outpic->p[V_PLANE].p_pixels,
p_inpic->p[V_PLANE].p_pixels,
p_outpic->p[V_PLANE].i_lines * p_outpic->p[V_PLANE].i_pitch );
plane_CopyPixels( &p_outpic->p[U_PLANE], &p_inpic->p[U_PLANE] );
plane_CopyPixels( &p_outpic->p[V_PLANE], &p_inpic->p[V_PLANE] );
}
else
{
......@@ -687,15 +679,9 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
vlc_memset( p_hough, 0, i_diag * i_nb_steps * sizeof(int) );
vlc_memcpy(
p_outpic->p[Y_PLANE].p_pixels, p_inpic->p[Y_PLANE].p_pixels,
p_outpic->p[Y_PLANE].i_lines * p_outpic->p[Y_PLANE].i_pitch );
vlc_memcpy(
p_outpic->p[U_PLANE].p_pixels, p_inpic->p[U_PLANE].p_pixels,
p_outpic->p[U_PLANE].i_lines * p_outpic->p[U_PLANE].i_pitch );
vlc_memcpy(
p_outpic->p[V_PLANE].p_pixels, p_inpic->p[V_PLANE].p_pixels,
p_outpic->p[V_PLANE].i_lines * p_outpic->p[V_PLANE].i_pitch );
plane_CopyPixels( &p_outpic->p[Y_PLANE], &p_inpic->p[Y_PLANE] );
plane_CopyPixels( &p_outpic->p[U_PLANE], &p_inpic->p[U_PLANE] );
plane_CopyPixels( &p_outpic->p[V_PLANE], &p_inpic->p[V_PLANE] );
GaussianConvolution( p_inpic, p_smooth );
......
......@@ -43,7 +43,6 @@ static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static picture_t *Filter ( filter_t *, picture_t * );
static void RenderBlur ( filter_sys_t *, picture_t *, picture_t * );
static void Copy ( filter_t *, picture_t * );
static int MotionBlurCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
......@@ -79,11 +78,11 @@ static const char *const ppsz_filter_options[] = {
*****************************************************************************/
struct filter_sys_t
{
picture_t *p_tmp;