+ /* Copy the Y plane */
+ plane_CopyPixels( &p_outpic->p[Y_PLANE], &p_pic->p[Y_PLANE] );
+
+ /*
+ * Do the U and V planes
+ */
+ int i_red = ( i_color & 0xFF0000 ) >> 16;
+ int i_green = ( i_color & 0xFF00 ) >> 8;
+ int i_blue = i_color & 0xFF;
+ int i_u = (int8_t)(( -38 * i_red - 74 * i_green +
+ 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);
+
+ 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++;
+ }
+ }
+
+ return CopyInfoAndRelease( p_outpic, p_pic );
+}
+
+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;
+
+ vlc_mutex_lock( &p_sys->lock );
+ int i_simthres = p_sys->i_simthres;
+ int i_satthres = p_sys->i_satthres;
+ int i_color = p_sys->i_color;
+ vlc_mutex_unlock( &p_sys->lock );
+
+ if( !p_pic ) return NULL;