motiondetect.c
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:20k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * motiondetec.c : Second version of a motion detection plugin.
  3.  *****************************************************************************
  4.  * Copyright (C) 2000-2008 the VideoLAN team
  5.  * $Id: aaf8f3149dd66e25929b3a68d7acd933367ad30e $
  6.  *
  7.  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  *
  14.  * This program is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with this program; if not, write to the Free Software
  21.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  22.  *****************************************************************************/
  23. /*****************************************************************************
  24.  * Preamble
  25.  *****************************************************************************/
  26. #ifdef HAVE_CONFIG_H
  27. # include "config.h"
  28. #endif
  29. #include <vlc_common.h>
  30. #include <vlc_plugin.h>
  31. #include <vlc_sout.h>
  32. #include <vlc_vout.h>
  33. #include "vlc_filter.h"
  34. #include "filter_picture.h"
  35. /*****************************************************************************
  36.  * Module descriptor
  37.  *****************************************************************************/
  38. static int  Create    ( vlc_object_t * );
  39. static void Destroy   ( vlc_object_t * );
  40. #define FILTER_PREFIX "motiondetect-"
  41. vlc_module_begin ()
  42.     set_description( N_("Motion detect video filter") )
  43.     set_shortname( N_( "Motion Detect" ))
  44.     set_category( CAT_VIDEO )
  45.     set_subcategory( SUBCAT_VIDEO_VFILTER )
  46.     set_capability( "video filter2", 0 )
  47.     add_shortcut( "motion" )
  48.     set_callbacks( Create, Destroy )
  49. vlc_module_end ()
  50. /*****************************************************************************
  51.  * Local prototypes
  52.  *****************************************************************************/
  53. static picture_t *Filter( filter_t *, picture_t * );
  54. static picture_t *FilterPacked( filter_t *, picture_t * );
  55. static void GaussianConvolution( uint32_t *, uint32_t *, int, int, int );
  56. static int FindShapes( uint32_t *, uint32_t *, int, int, int,
  57.                        int *, int *, int *, int *, int *);
  58. static void Draw( filter_t *p_filter, uint8_t *p_pix, int i_pix_pitch, int i_pix_size );
  59. #define NUM_COLORS (5000)
  60. struct filter_sys_t
  61. {
  62.     bool b_old;
  63.     picture_t *p_old;
  64.     uint32_t *p_buf;
  65.     uint32_t *p_buf2;
  66.     /* */
  67.     int i_colors;
  68.     int colors[NUM_COLORS];
  69.     int color_x_min[NUM_COLORS];
  70.     int color_x_max[NUM_COLORS];
  71.     int color_y_min[NUM_COLORS];
  72.     int color_y_max[NUM_COLORS];
  73. };
  74. /*****************************************************************************
  75.  * Create
  76.  *****************************************************************************/
  77. static int Create( vlc_object_t *p_this )
  78. {
  79.     filter_t *p_filter = (filter_t *)p_this;
  80.     const video_format_t *p_fmt = &p_filter->fmt_in.video;
  81.     filter_sys_t *p_sys;
  82.     switch( p_fmt->i_chroma )
  83.     {
  84.         CASE_PLANAR_YUV
  85.             p_filter->pf_video_filter = Filter;
  86.             break;
  87.         CASE_PACKED_YUV_422
  88.             p_filter->pf_video_filter = FilterPacked;
  89.             break;
  90.         default:
  91.             msg_Err( p_filter, "Unsupported input chroma (%4s)",
  92.                      (char*)&(p_fmt->i_chroma) );
  93.             return VLC_EGENERIC;
  94.     }
  95.     /* Allocate structure */
  96.     p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
  97.     if( p_filter->p_sys == NULL )
  98.         return VLC_ENOMEM;
  99.     p_sys->b_old = false;
  100.     p_sys->p_old = picture_New( p_fmt->i_chroma,
  101.                                 p_fmt->i_width, p_fmt->i_height, 0 );
  102.     p_sys->p_buf  = calloc( p_fmt->i_width * p_fmt->i_height, sizeof(*p_sys->p_buf) );
  103.     p_sys->p_buf2 = calloc( p_fmt->i_width * p_fmt->i_height, sizeof(*p_sys->p_buf) );
  104.     if( !p_sys->p_old || !p_sys->p_buf || !p_sys->p_buf2 )
  105.     {
  106.         free( p_sys->p_buf2 );
  107.         free( p_sys->p_buf );
  108.         if( p_sys->p_old )
  109.             picture_Release( p_sys->p_old );
  110.         return VLC_ENOMEM;
  111.     }
  112.     return VLC_SUCCESS;
  113. }
  114. /*****************************************************************************
  115.  * Destroy
  116.  *****************************************************************************/
  117. static void Destroy( vlc_object_t *p_this )
  118. {
  119.     filter_t *p_filter = (filter_t *)p_this;
  120.     filter_sys_t *p_sys = p_filter->p_sys;
  121.     free( p_sys->p_buf2 );
  122.     free( p_sys->p_buf );
  123.     picture_Release( p_sys->p_old );
  124.     free( p_sys );
  125. }
  126. /*****************************************************************************
  127.  * Filter YUV Planar
  128.  *****************************************************************************/
  129. static picture_t *Filter( filter_t *p_filter, picture_t *p_inpic )
  130. {
  131.     filter_sys_t *p_sys = p_filter->p_sys;
  132.     const video_format_t *p_fmt = &p_filter->fmt_in.video;
  133.     picture_t *p_outpic;
  134.     uint8_t *p_oldpix   = p_sys->p_old->p[Y_PLANE].p_pixels;
  135.     const int i_old_pitch = p_sys->p_old->p[Y_PLANE].i_pitch;
  136.     uint32_t *p_buf = p_sys->p_buf;
  137.     uint32_t *p_buf2= p_sys->p_buf2;
  138.     unsigned x, y;
  139.     if( !p_inpic )
  140.         return NULL;
  141.     const uint8_t *p_inpix = p_inpic->p[Y_PLANE].p_pixels;
  142.     const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
  143.     if( !p_sys->b_old )
  144.     {
  145.         picture_Copy( p_sys->p_old, p_inpic );
  146.         p_sys->b_old = true;
  147.         return p_inpic;
  148.     }
  149.     p_outpic = filter_NewPicture( p_filter );
  150.     if( !p_outpic )
  151.     {
  152.         picture_Release( p_inpic );
  153.         return NULL;
  154.     }
  155.     picture_Copy( p_outpic, p_inpic );
  156.     /**
  157.      * Substract Y planes
  158.      */
  159.     for( y = 0; y < p_fmt->i_height; y++ )
  160.     {
  161.         for( x = 0; x < p_fmt->i_width; x++ )
  162.             p_buf2[y*p_fmt->i_width+x] = abs( p_inpix[y*i_src_pitch+x] - p_oldpix[y*i_old_pitch+x] );
  163.     }
  164.     int i_chroma_dx;
  165.     int i_chroma_dy;
  166.     switch( p_inpic->format.i_chroma )
  167.     {
  168.         case VLC_FOURCC('I','4','2','0'):
  169.         case VLC_FOURCC('I','Y','U','V'):
  170.         case VLC_FOURCC('J','4','2','0'):
  171.         case VLC_FOURCC('Y','V','1','2'):
  172.             i_chroma_dx = 2;
  173.             i_chroma_dy = 2;
  174.             break;
  175.         case VLC_FOURCC('I','4','2','2'):
  176.         case VLC_FOURCC('J','4','2','2'):
  177.             i_chroma_dx = 2;
  178.             i_chroma_dy = 1;
  179.             break;
  180.         default:
  181.             msg_Warn( p_filter, "Not taking chroma into account" );
  182.             i_chroma_dx = 0;
  183.             i_chroma_dy = 0;
  184.             break;
  185.     }
  186.     if( i_chroma_dx != 0 && i_chroma_dy != 0 )
  187.     {
  188.         const uint8_t *p_inpix_u = p_inpic->p[U_PLANE].p_pixels;
  189.         const uint8_t *p_inpix_v = p_inpic->p[V_PLANE].p_pixels;
  190.         const int i_src_pitch_u = p_inpic->p[U_PLANE].i_pitch;
  191.         const int i_src_pitch_v = p_inpic->p[V_PLANE].i_pitch;
  192.         const uint8_t *p_oldpix_u = p_sys->p_old->p[U_PLANE].p_pixels;
  193.         const uint8_t *p_oldpix_v = p_sys->p_old->p[V_PLANE].p_pixels;
  194.         const int i_old_pitch_u = p_sys->p_old->p[U_PLANE].i_pitch;
  195.         const int i_old_pitch_v = p_sys->p_old->p[V_PLANE].i_pitch;
  196.         for( y = 0; y < p_fmt->i_height/i_chroma_dy; y++ )
  197.         {
  198.             for( x = 0; x < p_fmt->i_width/i_chroma_dx; x ++ )
  199.             {
  200.                 const int d = abs( p_inpix_u[y*i_src_pitch_u+x] - p_oldpix_u[y*i_old_pitch_u+x] ) +
  201.                               abs( p_inpix_v[y*i_src_pitch_v+x] - p_oldpix_v[y*i_old_pitch_v+x] );
  202.                 int i, j;
  203.                 for( j = 0; j < i_chroma_dy; j++ )
  204.                 {
  205.                     for( i = 0; i < i_chroma_dx; i++ )
  206.                         p_buf2[i_chroma_dy*p_fmt->i_width*j + i_chroma_dx*i] = d;
  207.                 }
  208.             }
  209.         }
  210.     }
  211.     /**
  212.      * Get the areas where movement was detected
  213.      */
  214.     p_sys->i_colors = FindShapes( p_buf2, p_buf, p_fmt->i_width, p_fmt->i_width, p_fmt->i_height,
  215.                                   p_sys->colors, p_sys->color_x_min, p_sys->color_x_max, p_sys->color_y_min, p_sys->color_y_max );
  216.     /**
  217.      * Count final number of shapes
  218.      * Draw rectangles (there can be more than 1 moving shape in 1 rectangle)
  219.      */
  220.     Draw( p_filter, p_outpic->p[Y_PLANE].p_pixels, p_outpic->p[Y_PLANE].i_pitch, 1 );
  221.     /**
  222.      * We're done. Lets keep a copy of the picture
  223.      * TODO we may just picture_Release with a latency of 1 if the filters/vout
  224.      * handle it correctly */
  225.     picture_Copy( p_sys->p_old, p_inpic );
  226.     picture_Release( p_inpic );
  227.     return p_outpic;
  228. }
  229. /*****************************************************************************
  230.  * Filter YUV Packed
  231.  *****************************************************************************/
  232. static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_inpic )
  233. {
  234.     filter_sys_t *p_sys = p_filter->p_sys;
  235.     const video_format_t *p_fmt = &p_filter->fmt_in.video;
  236.     picture_t *p_outpic;
  237.     const uint8_t *p_inpix = p_inpic->p[Y_PLANE].p_pixels;
  238.     const int i_src_pitch = p_inpic->p[Y_PLANE].i_pitch;
  239.     uint8_t *p_oldpix   = p_sys->p_old->p[Y_PLANE].p_pixels;
  240.     const int i_old_pitch = p_sys->p_old->p[Y_PLANE].i_pitch;
  241.     uint32_t *p_buf = p_sys->p_buf;
  242.     uint32_t *p_buf2= p_sys->p_buf2;
  243.     int i_y_offset, i_u_offset, i_v_offset;
  244.     unsigned x, y;
  245.     if( GetPackedYuvOffsets( p_fmt->i_chroma,
  246.                              &i_y_offset, &i_u_offset, &i_v_offset ) )
  247.     {
  248.         msg_Warn( p_filter, "Unsupported input chroma (%4s)",
  249.                   (char*)&p_fmt->i_chroma );
  250.         return p_inpic;
  251.     }
  252.     if( !p_sys->b_old )
  253.     {
  254.         picture_Copy( p_sys->p_old, p_inpic );
  255.         p_sys->b_old = true;
  256.         return p_inpic;
  257.     }
  258.     p_outpic = filter_NewPicture( p_filter );
  259.     if( !p_outpic )
  260.     {
  261.         picture_Release( p_inpic );
  262.         return NULL;
  263.     }
  264.     picture_Copy( p_outpic, p_inpic );
  265.     /* Substract all planes at once */
  266.     for( y = 0; y < p_fmt->i_height; y++ )
  267.     {
  268.         for( x = 0; x < p_fmt->i_width; x+=2 )
  269.         {
  270.             int i;
  271.             int d;
  272.             d = abs( p_inpix[y*i_src_pitch+2*x+i_u_offset] - p_oldpix[y*i_old_pitch+2*x+i_u_offset] ) +
  273.                 abs( p_inpix[y*i_src_pitch+2*x+i_v_offset] - p_oldpix[y*i_old_pitch+2*x+i_v_offset] );
  274.             for( i = 0; i < 2; i++ )
  275.                 p_buf2[y*p_fmt->i_width+x+i] =
  276.                     abs( p_inpix[y*i_src_pitch+2*(x+i)+i_y_offset] - p_oldpix[y*i_old_pitch+2*(x+i)+i_y_offset] ) + d;
  277.         }
  278.     }
  279.     /**
  280.      * Get the areas where movement was detected
  281.      */
  282.     p_sys->i_colors = FindShapes( p_buf2, p_buf, p_fmt->i_width, p_fmt->i_width, p_fmt->i_height,
  283.                                   p_sys->colors, p_sys->color_x_min, p_sys->color_x_max, p_sys->color_y_min, p_sys->color_y_max );
  284.     /**
  285.      * Count final number of shapes
  286.      * Draw rectangles (there can be more than 1 moving shape in 1 rectangle)
  287.      */
  288.     Draw( p_filter, &p_outpic->p[Y_PLANE].p_pixels[i_y_offset], p_outpic->p[Y_PLANE].i_pitch, 2 );
  289.     /**
  290.      * We're done. Lets keep a copy of the picture
  291.      * TODO we may just picture_Release with a latency of 1 if the filters/vout
  292.      * handle it correctly */
  293.     picture_Copy( p_sys->p_old, p_inpic );
  294.     picture_Release( p_inpic );
  295.     return p_outpic;
  296. }
  297. /*****************************************************************************
  298.  * Gaussian Convolution
  299.  *****************************************************************************
  300.  *    Gaussian convolution ( sigma == 1.4 )
  301.  *
  302.  *    |  2  4  5  4  2  |   |  2  4  4  4  2 |
  303.  *    |  4  9 12  9  4  |   |  4  8 12  8  4 |
  304.  *    |  5 12 15 12  5  | ~ |  4 12 16 12  4 |
  305.  *    |  4  9 12  9  4  |   |  4  8 12  8  4 |
  306.  *    |  2  4  5  4  2  |   |  2  4  4  4  2 |
  307.  *****************************************************************************/
  308. static void GaussianConvolution( uint32_t *p_inpix, uint32_t *p_smooth,
  309.                                  int i_src_pitch, int i_num_lines,
  310.                                  int i_src_visible )
  311. {
  312.     int x,y;
  313.     /* A bit overkill but ... simpler */
  314.     memset( p_smooth, 0, sizeof(*p_smooth) * i_src_pitch * i_num_lines );
  315.     for( y = 2; y < i_num_lines - 2; y++ )
  316.     {
  317.         for( x = 2; x < i_src_visible - 2; x++ )
  318.         {
  319.             p_smooth[y*i_src_visible+x] = (uint32_t)(
  320.               /* 2 rows up */
  321.                 ( p_inpix[(y-2)*i_src_pitch+x-2] )
  322.               + ((p_inpix[(y-2)*i_src_pitch+x-1]
  323.               +   p_inpix[(y-2)*i_src_pitch+x]
  324.               +   p_inpix[(y-2)*i_src_pitch+x+1])<<1 )
  325.               + ( p_inpix[(y-2)*i_src_pitch+x+2] )
  326.               /* 1 row up */
  327.               + ((p_inpix[(y-1)*i_src_pitch+x-2]
  328.               + ( p_inpix[(y-1)*i_src_pitch+x-1]<<1 )
  329.               + ( p_inpix[(y-1)*i_src_pitch+x]*3 )
  330.               + ( p_inpix[(y-1)*i_src_pitch+x+1]<<1 )
  331.               +   p_inpix[(y-1)*i_src_pitch+x+2]
  332.               /* */
  333.               +   p_inpix[y*i_src_pitch+x-2]
  334.               + ( p_inpix[y*i_src_pitch+x-1]*3 )
  335.               + ( p_inpix[y*i_src_pitch+x]<<2 )
  336.               + ( p_inpix[y*i_src_pitch+x+1]*3 )
  337.               +   p_inpix[y*i_src_pitch+x+2]
  338.               /* 1 row down */
  339.               +   p_inpix[(y+1)*i_src_pitch+x-2]
  340.               + ( p_inpix[(y+1)*i_src_pitch+x-1]<<1 )
  341.               + ( p_inpix[(y+1)*i_src_pitch+x]*3 )
  342.               + ( p_inpix[(y+1)*i_src_pitch+x+1]<<1 )
  343.               +   p_inpix[(y+1)*i_src_pitch+x+2] )<<1 )
  344.               /* 2 rows down */
  345.               + ( p_inpix[(y+2)*i_src_pitch+x-2] )
  346.               + ((p_inpix[(y+2)*i_src_pitch+x-1]
  347.               +   p_inpix[(y+2)*i_src_pitch+x]
  348.               +   p_inpix[(y+2)*i_src_pitch+x+1])<<1 )
  349.               + ( p_inpix[(y+2)*i_src_pitch+x+2] )
  350.               ) >> 6 /* 115 */;
  351.         }
  352.     }
  353. }
  354. /*****************************************************************************
  355.  *
  356.  *****************************************************************************/
  357. static int FindShapes( uint32_t *p_diff, uint32_t *p_smooth,
  358.                        int i_pitch, int i_visible, int i_lines,
  359.                        int *colors,
  360.                        int *color_x_min, int *color_x_max,
  361.                        int *color_y_min, int *color_y_max )
  362. {
  363.     int last = 1;
  364.     int i, j;
  365.     /**
  366.      * Apply some smoothing to remove noise
  367.      */
  368.     GaussianConvolution( p_diff, p_smooth, i_pitch, i_lines, i_visible );
  369.     /**
  370.      * Label the shapes and build the labels dependencies list
  371.      */
  372.     for( j = 0; j < i_pitch; j++ )
  373.     {
  374.         p_smooth[j] = 0;
  375.         p_smooth[(i_lines-1)*i_pitch+j] = 0;
  376.     }
  377.     for( i = 1; i < i_lines-1; i++ )
  378.     {
  379.         p_smooth[i*i_pitch] = 0;
  380.         for( j = 1; j < i_pitch-1; j++ )
  381.         {
  382.             if( p_smooth[i*i_pitch+j] > 15 )
  383.             {
  384.                 if( p_smooth[(i-1)*i_pitch+j-1] )
  385.                 {
  386.                     p_smooth[i*i_pitch+j] = p_smooth[(i-1)*i_pitch+j-1];
  387.                 }
  388.                 else if( p_smooth[(i-1)*i_pitch+j] )
  389.                     p_smooth[i*i_pitch+j] = p_smooth[(i-1)*i_pitch+j];
  390.                 else if( p_smooth[i*i_pitch+j-1] )
  391.                     p_smooth[i*i_pitch+j] = p_smooth[i*i_pitch+j-1];
  392.                 else
  393.                 {
  394.                     if( last < NUM_COLORS )
  395.                     {
  396.                         p_smooth[i*i_pitch+j] = last;
  397.                         colors[last] = last;
  398.                         last++;
  399.                     }
  400.                 }
  401.                 #define CHECK( A ) 
  402.                 if( p_smooth[A] && p_smooth[A] != p_smooth[i*i_pitch+j] ) 
  403.                 { 
  404.                     if( p_smooth[A] < p_smooth[i*i_pitch+j] ) 
  405.                         colors[p_smooth[i*i_pitch+j]] = p_smooth[A]; 
  406.                     else 
  407.                         colors[p_smooth[A]] = p_smooth[i*i_pitch+j]; 
  408.                 }
  409.                 CHECK( i*i_pitch+j-1 );
  410.                 CHECK( (i-1)*i_pitch+j-1 );
  411.                 CHECK( (i-1)*i_pitch+j );
  412.                 CHECK( (i-1)*i_pitch+j+1 );
  413.                 #undef CHECK
  414.             }
  415.             else
  416.             {
  417.                 p_smooth[i*i_pitch+j] = 0;
  418.             }
  419.         }
  420.         p_smooth[i*i_pitch+j] = 0;
  421.     }
  422.     /**
  423.      * Initialise empty rectangle list
  424.      */
  425.     for( i = 1; i < last; i++ )
  426.     {
  427.         color_x_min[i] = -1;
  428.         color_x_max[i] = -1;
  429.         color_y_min[i] = -1;
  430.         color_y_max[i] = -1;
  431.     }
  432.     /**
  433.      * Compute rectangle coordinates
  434.      */
  435.     for( i = 0; i < i_pitch * i_lines; i++ )
  436.     {
  437.         if( p_smooth[i] )
  438.         {
  439.             while( colors[p_smooth[i]] != (int)p_smooth[i] )
  440.                 p_smooth[i] = colors[p_smooth[i]];
  441.             if( color_x_min[p_smooth[i]] == -1 )
  442.             {
  443.                 color_x_min[p_smooth[i]] =
  444.                 color_x_max[p_smooth[i]] = i % i_pitch;
  445.                 color_y_min[p_smooth[i]] =
  446.                 color_y_max[p_smooth[i]] = i / i_pitch;
  447.             }
  448.             else
  449.             {
  450.                 int x = i % i_pitch, y = i / i_pitch;
  451.                 if( x < color_x_min[p_smooth[i]] )
  452.                     color_x_min[p_smooth[i]] = x;
  453.                 if( x > color_x_max[p_smooth[i]] )
  454.                     color_x_max[p_smooth[i]] = x;
  455.                 if( y < color_y_min[p_smooth[i]] )
  456.                     color_y_min[p_smooth[i]] = y;
  457.                 if( y > color_y_max[p_smooth[i]] )
  458.                     color_y_max[p_smooth[i]] = y;
  459.             }
  460.         }
  461.     }
  462.     /**
  463.      * Merge overlaping rectangles
  464.      */
  465.     for( i = 1; i < last; i++ )
  466.     {
  467.         if( colors[i] != i ) continue;
  468.         if( color_x_min[i] == -1 ) continue;
  469.         for( j = i+1; j < last; j++ )
  470.         {
  471.             if( colors[j] != j ) continue;
  472.             if( color_x_min[j] == -1 ) continue;
  473.             if( __MAX( color_x_min[i], color_x_min[j] ) < __MIN( color_x_max[i], color_x_max[j] ) &&
  474.                 __MAX( color_y_min[i], color_y_min[j] ) < __MIN( color_y_max[i], color_y_max[j] ) )
  475.             {
  476.                 color_x_min[i] = __MIN( color_x_min[i], color_x_min[j] );
  477.                 color_x_max[i] = __MAX( color_x_max[i], color_x_max[j] );
  478.                 color_y_min[i] = __MIN( color_y_min[i], color_y_min[j] );
  479.                 color_y_max[i] = __MAX( color_y_max[i], color_y_max[j] );
  480.                 color_x_min[j] = -1;
  481.                 j = 0;
  482.             }
  483.         }
  484.     }
  485.     return last;
  486. }
  487. static void Draw( filter_t *p_filter, uint8_t *p_pix, int i_pix_pitch, int i_pix_size )
  488. {
  489.     filter_sys_t *p_sys = p_filter->p_sys;
  490.     int i, j;
  491.     for( i = 1, j = 0; i < p_sys->i_colors; i++ )
  492.     {
  493.         int x, y;
  494.         if( p_sys->colors[i] != i )
  495.             continue;
  496.         const int color_x_min = p_sys->color_x_min[i];
  497.         const int color_x_max = p_sys->color_x_max[i];
  498.         const int color_y_min = p_sys->color_y_min[i];
  499.         const int color_y_max = p_sys->color_y_max[i];
  500.         if( color_x_min == -1 )
  501.             continue;
  502.         if( ( color_y_max - color_y_min ) * ( color_x_max - color_x_min ) < 16 )
  503.             continue;
  504.         j++;
  505.         y = color_y_min;
  506.         for( x = color_x_min; x <= color_x_max; x++ )
  507.             p_pix[y*i_pix_pitch+x*i_pix_size] = 0xff;
  508.         y = color_y_max;
  509.         for( x = color_x_min; x <= color_x_max; x++ )
  510.             p_pix[y*i_pix_pitch+x*i_pix_size] = 0xff;
  511.         x = color_x_min;
  512.         for( y = color_y_min; y <= color_y_max; y++ )
  513.             p_pix[y*i_pix_pitch+x*i_pix_size] = 0xff;
  514.         x = color_x_max;
  515.         for( y = color_y_min; y <= color_y_max; y++ )
  516.             p_pix[y*i_pix_pitch+x*i_pix_size] = 0xff;
  517.     }
  518.     msg_Dbg( p_filter, "Counted %d moving shapes.", j );
  519. }