<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix"><br>
      <small>Hi,<br>
        <br>
        You'll find below and in 2 additional patches the oldmovie video
        filter modified as per your comments.<br>
        <br>
        It has to be applied after freeze patch<br>
        <br>
        <br>
        Regards<br>
        <br>
        Vianney<br>
        <br>
        <br>
        <br>
        ---<br>
         modules/video_filter/oldmovie.c | 874
        ++++++++++++++++++++++++++++++++++++++++<br>
         1 file changed, 874 insertions(+)<br>
         create mode 100644 modules/video_filter/oldmovie.c<br>
        <br>
        diff --git a/modules/video_filter/oldmovie.c
        b/modules/video_filter/oldmovie.c<br>
        new file mode 100644<br>
        index 0000000..a69e7f9<br>
        --- /dev/null<br>
        +++ b/modules/video_filter/oldmovie.c<br>
        @@ -0,0 +1,874 @@<br>
+/*****************************************************************************<br>
        + * oldmovie.c : Old movie effect video filter<br>
        +
*****************************************************************************<br>
        + * Copyright (C) 2013      Vianney Boyer<br>
        + * $Id$<br>
        + *<br>
        + * Authors: Vianney Boyer <vlcvboyer -at- gmail -dot-
        com><br>
        + *<br>
        + * This program is free software; you can redistribute it
        and/or modify it<br>
        + * under the terms of the GNU Lesser General Public License as
        published by<br>
        + * the Free Software Foundation; either version 2.1 of the
        License, or<br>
        + * (at your option) any later version.<br>
        + *<br>
        + * This program is distributed in the hope that it will be
        useful,<br>
        + * but WITHOUT ANY WARRANTY; without even the implied warranty
        of<br>
        + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br>
        + * GNU Lesser General Public License for more details.<br>
        + *<br>
        + * You should have received a copy of the GNU Lesser General
        Public License<br>
        + * along with this program; if not, write to the Free Software
        Foundation,<br>
        + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301,
        USA.<br>
        +
*****************************************************************************/<br>
        +<br>
+/*****************************************************************************<br>
        + * Preamble<br>
        +
*****************************************************************************/<br>
        +<br>
        +#ifdef HAVE_CONFIG_H<br>
        +# include "config.h"<br>
        +#endif<br>
        +<br>
        +#include <math.h><br>
        +<br>
        +#include <vlc_common.h><br>
        +#include <vlc_plugin.h><br>
        +#include <vlc_filter.h><br>
        +#include <vlc_rand.h><br>
        +#include <vlc_mtime.h><br>
        +<br>
        +#include "filter_picture.h"<br>
        +<br>
        +#ifndef M_PI<br>
        +#   define M_PI 3.14159265358979323846<br>
        +#endif<br>
        +#ifndef TIME_UNIT_PER_S<br>
        +#   define TIME_UNIT_PER_S ( ((int64_t) 1) << 32 )<br>
        +#endif<br>
        +<br>
        +static inline int64_t MOD(int64_t a, int64_t b) {<br>
        +    return ( ( a % b ) + b ) % b; }<br>
        +<br>
        +#define SUB_MIN(val, sub_val, min) val = \<br>
        +                       
        ((val-(int32_t)sub_val)<min?min:val-sub_val)<br>
        +#define ADD_MAX(val, add_val, max) val = \<br>
        +                       
        ((val+(int32_t)add_val)>max?max:val+add_val)<br>
        +<br>
        +static inline int32_t PIX_OFS(int32_t i_x, int32_t i_y, plane_t
        *ps_plane) {<br>
        +    return i_x * ps_plane->i_pixel_pitch + i_y *
        ps_plane->i_pitch; }<br>
        +<br>
        +#define CHECK_PIX_OFS(i_x, i_y, ps_plane) ( \<br>
        +        (i_x) >= 0 && (i_y) >= 0 && \<br>
        +        (i_x) * ps_plane->i_pixel_pitch <
        ps_plane->i_visible_pitch && \<br>
        +        (i_y) < ps_plane->i_visible_lines \<br>
        +    )<br>
        +<br>
        +static inline void DARKEN_PIXEL(int32_t i_x, int32_t i_y,<br>
        +    int16_t intensity, plane_t *ps_plane) {<br>
        +    SUB_MIN( ps_plane->p_pixels[ PIX_OFS(i_x, i_y, ps_plane)
        ],<br>
        +        intensity, 0 );<br>
        +}<br>
        +<br>
        +static inline void LIGHTEN_PIXEL(int32_t i_x, int32_t i_y,<br>
        +                                int16_t intensity, plane_t
        *ps_plane) {<br>
        +    ADD_MAX( ps_plane->p_pixels[ PIX_OFS(i_x, i_y, ps_plane)
        ],<br>
        +        intensity, 0xFF );<br>
        +}<br>
        +<br>
        +static inline void CHECK_N_DARKEN_PIXEL(int32_t i_x, int32_t
        i_y,<br>
        +                                int16_t intensity, plane_t
        *ps_plane) {<br>
        +    if ( likely( CHECK_PIX_OFS(i_x, i_y, ps_plane) ) )<br>
        +        DARKEN_PIXEL(i_x, i_y, intensity, ps_plane);<br>
        +}<br>
        +<br>
        +static inline void CHECK_N_LIGHTEN_PIXEL(int32_t i_x, int32_t
        i_y,<br>
        +                                int16_t intensity, plane_t
        *ps_plane) {<br>
        +    if ( likely( CHECK_PIX_OFS(i_x, i_y, ps_plane) ) )<br>
        +        LIGHTEN_PIXEL(i_x, i_y, intensity, ps_plane);<br>
        +}<br>
        +<br>
        +#define MAX_SCRATCH        20<br>
        +#define MAX_HAIR           10<br>
        +#define MAX_DUST           10<br>
        +<br>
        +typedef struct {<br>
        +    int32_t  i_offset;<br>
        +    int32_t  i_width;<br>
        +    uint16_t i_intensity;<br>
        +    uint64_t i_stop_trigger;<br>
        +} scratch_t;<br>
        +<br>
        +typedef struct {<br>
        +    int32_t  i_x, i_y;<br>
        +    uint8_t  i_rotation;<br>
        +    int32_t  i_width;<br>
        +    int32_t  i_length;<br>
        +    int32_t  i_curve;<br>
        +    uint16_t i_intensity;<br>
        +    uint64_t i_stop_trigger;<br>
        +} hair_t;<br>
        +<br>
        +typedef struct {<br>
        +    int32_t  i_x, i_y;<br>
        +    int32_t  i_width;<br>
        +    uint16_t i_intensity;<br>
        +    uint64_t i_stop_trigger;<br>
        +} dust_t;<br>
        +<br>
        +struct filter_sys_t {<br>
        +<br>
        +    /* general data */<br>
        +    bool b_init;<br>
        +    int32_t  i_planes;<br>
        +    int32_t *i_height;<br>
        +    int32_t *i_width;<br>
        +    int32_t *i_visible_pitch;<br>
        +    uint64_t i_start_time;<br>
        +    uint64_t i_last_time;<br>
        +    uint64_t i_cur_time;<br>
        +<br>
        +    /* sliding & offset effect */<br>
        +    uint64_t i_offset_trigger;<br>
        +    uint64_t i_sliding_trigger;<br>
        +    uint64_t i_sliding_stop_trig;<br>
        +    int32_t  i_offset_ofs;<br>
        +    int32_t  i_sliding_ofs;<br>
        +    int32_t  i_sliding_speed;<br>
        +<br>
        +    /* scratch on film */<br>
        +    uint64_t   i_scratch_trigger;<br>
        +    scratch_t *p_scratch[MAX_SCRATCH];<br>
        +<br>
        +    /* hair on lens */<br>
        +    uint64_t   i_hair_trigger;<br>
        +    hair_t    *p_hair[MAX_HAIR];<br>
        +<br>
        +    /* blotch on film */<br>
        +    uint64_t   i_blotch_trigger;<br>
        +<br>
        +    /* dust on lens */<br>
        +    uint64_t   i_dust_trigger;<br>
        +    dust_t    *p_dust[MAX_DUST];<br>
        +};<br>
        +<br>
+/*****************************************************************************<br>
        + * Prototypes<br>
        +
*****************************************************************************/<br>
        +<br>
        +picture_t *Filter( filter_t *, picture_t * );<br>
        +<br>
        +int  oldmovie_allocate_data( filter_t *, picture_t * );<br>
        +void oldmovie_free_allocated_data( filter_t * );<br>
        +<br>
        +void oldmovie_shutter_effect( filter_t *, picture_t * );<br>
        +int  oldmovie_sliding_offset_effect( filter_t *, picture_t * );<br>
        +void oldmovie_black_n_white_effect( picture_t * );<br>
        +int  oldmovie_dark_border_effect( filter_t *, picture_t * );<br>
        +int  oldmovie_film_scratch_effect( filter_t *, picture_t * );<br>
        +void oldmovie_film_blotch_effect( filter_t *, picture_t * );<br>
        +void oldmovie_film_dust_effect( filter_t *, picture_t * );<br>
        +int  oldmovie_lens_hair_effect( filter_t *, picture_t * );<br>
        +int  oldmovie_lens_dust_effect( filter_t *, picture_t * );<br>
        +<br>
        +void oldmovie_define_hair_location( filter_t *p_filter, hair_t*
        ps_hair );<br>
        +void oldmovie_define_dust_location( filter_t *p_filter, dust_t*
        ps_dust );<br>
        +int  oldmovie_sliding_offset_apply( filter_t *p_filter,
        picture_t *p_pic_out );<br>
        +<br>
+/*****************************************************************************<br>
        + * Module descriptor<br>
        +
*****************************************************************************/<br>
        +<br>
        +int  Open ( vlc_object_t * );<br>
        +void Close( vlc_object_t * );<br>
        +<br>
        +vlc_module_begin()<br>
        +    set_description( N_("Old movie effect video filter") )<br>
        +    set_shortname( N_( "Old movie" ))<br>
        +    set_capability( "video filter2", 0 )<br>
        +    set_category( CAT_VIDEO )<br>
        +    set_subcategory( SUBCAT_VIDEO_VFILTER )<br>
        +<br>
        +    set_callbacks( Open, Close )<br>
        +vlc_module_end()<br>
        +<br>
        +/**<br>
        + * Open the filter<br>
        + */<br>
        +int Open( vlc_object_t *p_this ) {<br>
        +    filter_t *p_filter = (filter_t *)p_this;<br>
        +    filter_sys_t *p_sys;<br>
        +<br>
        +    /* Assert video in match with video out */<br>
        +    if( !es_format_IsSimilar( &p_filter->fmt_in,
        &p_filter->fmt_out ) ) {<br>
        +        msg_Err( p_filter, "Input and output format does not
        match" );<br>
        +        return VLC_EGENERIC;<br>
        +    }<br>
        +<br>
        +    /* Reject 0 bpp and unsupported chroma */<br>
        +    const vlc_fourcc_t fourcc =
        p_filter->fmt_in.video.i_chroma;<br>
        +    const vlc_chroma_description_t *p_chroma =<br>
        +        vlc_fourcc_GetChromaDescription(
        p_filter->fmt_in.video.i_chroma );<br>
        +    if( !p_chroma || p_chroma->pixel_size == 0<br>
        +        || p_chroma->plane_count < 3 ||
        p_chroma->pixel_size > 1<br>
        +        || !vlc_fourcc_IsYUV( fourcc ) ) {<br>
        +<br>
        +        msg_Err( p_filter, "Unsupported chroma (%4.4s)",
        (char*)&fourcc );<br>
        +        return VLC_EGENERIC;<br>
        +    }<br>
        +<br>
        +    /* Allocate structure */<br>
        +    p_filter->p_sys = p_sys = calloc( 1, sizeof(*p_sys) );<br>
        +    if( unlikely( !p_sys ) )<br>
        +        return VLC_ENOMEM;<br>
        +<br>
        +    /* init data */<br>
        +    p_filter->pf_video_filter = Filter;<br>
        +    p_sys->i_start_time = p_sys->i_cur_time =
        p_sys->i_last_time = NTPtime64();<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Close the filter<br>
        + */<br>
        +void Close( vlc_object_t *p_this ) {<br>
        +    filter_t *p_filter  = (filter_t *)p_this;<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    /* Free allocated memory */<br>
        +    oldmovie_free_allocated_data( p_filter );<br>
        +    free( p_sys );<br>
        +}<br>
        +<br>
        +/**<br>
        + * Filter a picture<br>
        + */<br>
        +picture_t *Filter( filter_t *p_filter, picture_t *p_pic_in ) {<br>
        +    if( unlikely( !p_pic_in || !p_filter ) )<br>
        +        return NULL;<br>
        +<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    picture_t *p_pic_out = filter_NewPicture( p_filter );<br>
        +    if( unlikely( !p_pic_out ) ) {<br>
        +        picture_Release( p_pic_in );<br>
        +        return NULL;<br>
        +    }<br>
        +<br>
        +   /*<br>
        +    * manage time<br>
        +    */<br>
        +    p_sys->i_last_time = p_sys->i_cur_time;<br>
        +    p_sys->i_cur_time  = NTPtime64();<br>
        +<br>
        +   /*<br>
        +    * allocate data<br>
        +    */<br>
        +    if ( unlikely( !p_sys->b_init ) )<br>
        +        if ( unlikely( oldmovie_allocate_data( p_filter,
        p_pic_in ) != VLC_SUCCESS ) ) {<br>
        +            picture_Release( p_pic_in );<br>
        +            return NULL;<br>
        +        }<br>
        +    p_sys->b_init = true;<br>
        +<br>
        +   /*<br>
        +    * preset output pic: raw copy src to dst<br>
        +    */<br>
        +    picture_CopyPixels(p_pic_out, p_pic_in);<br>
        +<br>
        +   /*<br>
        +    * apply several effects on picture<br>
        +    */<br>
        +    oldmovie_black_n_white_effect( p_pic_out );<br>
        +<br>
        +    /* simulates projector shutter blinking effect */<br>
        +    oldmovie_shutter_effect(p_filter, p_pic_out);<br>
        +<br>
        +    if ( unlikely( oldmovie_sliding_offset_effect( p_filter,
        p_pic_out ) != VLC_SUCCESS ) )<br>
        +        return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
        +<br>
        +    oldmovie_dark_border_effect( p_filter, p_pic_out );<br>
        +<br>
        +    if ( unlikely( oldmovie_film_scratch_effect(p_filter,
        p_pic_out) != VLC_SUCCESS ) )<br>
        +        return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
        +<br>
        +    oldmovie_film_blotch_effect(p_filter, p_pic_out);<br>
        +<br>
        +    if ( unlikely( oldmovie_lens_hair_effect( p_filter,
        p_pic_out ) != VLC_SUCCESS ) )<br>
        +        return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
        +<br>
        +    if ( unlikely( oldmovie_lens_dust_effect( p_filter,
        p_pic_out ) != VLC_SUCCESS ) )<br>
        +        return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
        +<br>
        +    oldmovie_film_dust_effect( p_filter, p_pic_out );<br>
        +<br>
        +    return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
        +}<br>
        +<br>
        +/*<br>
        + * Allocate data<br>
        + */<br>
        +int oldmovie_allocate_data( filter_t *p_filter, picture_t
        *p_pic_in ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    oldmovie_free_allocated_data( p_filter );<br>
        +<br>
        +   /*<br>
        +    * take into account different characteristics for each
        plane<br>
        +    */<br>
        +    p_sys->i_planes = p_pic_in->i_planes;<br>
        +    p_sys->i_height = calloc( p_sys->i_planes,
        sizeof(int32_t) );<br>
        +    p_sys->i_width  = calloc( p_sys->i_planes,
        sizeof(int32_t) );<br>
        +    p_sys->i_visible_pitch = calloc( p_sys->i_planes,
        sizeof(int32_t) );<br>
        +<br>
        +    if( unlikely( !p_sys->i_height || !p_sys->i_width ||
        !p_sys->i_visible_pitch ) ) {<br>
        +        oldmovie_free_allocated_data( p_filter );<br>
        +        return VLC_ENOMEM;<br>
        +    }<br>
        +<br>
        +    for (int32_t i_p=0; i_p < p_sys->i_planes; i_p++) {<br>
        +        p_sys->i_visible_pitch [i_p] = (int)
        p_pic_in->p[i_p].i_visible_pitch;<br>
        +        p_sys->i_height[i_p]         = (int)
        p_pic_in->p[i_p].i_visible_lines;<br>
        +        p_sys->i_width [i_p]         = (int)
        p_pic_in->p[i_p].i_visible_pitch<br>
        +                                     /
        p_pic_in->p[i_p].i_pixel_pitch;<br>
        +    }<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Free allocated data<br>
        + */<br>
        +void oldmovie_free_allocated_data( filter_t *p_filter ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    for ( uint32_t i_s = 0; i_s < MAX_SCRATCH; i_s++ )<br>
        +        FREENULL(p_sys->p_scratch[i_s]);<br>
        +<br>
        +    for ( uint32_t i_h = 0; i_h < MAX_HAIR; i_h++ )<br>
        +        FREENULL(p_sys->p_hair[i_h]);<br>
        +<br>
        +    for ( uint32_t i_d = 0; i_d < MAX_DUST; i_d++ )<br>
        +        FREENULL(p_sys->p_dust[i_d]);<br>
        +<br>
        +    p_sys->i_planes = 0;<br>
        +    FREENULL( p_sys->i_height );<br>
        +    FREENULL( p_sys->i_width );<br>
        +    FREENULL( p_sys->i_visible_pitch );<br>
        +}<br>
        +<br>
        +/**<br>
        + * Projector shutter effect<br>
        + */<br>
        +void oldmovie_shutter_effect( filter_t *p_filter, picture_t
        *p_pic_out ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +#define SHUTTER_FREQ      2<br>
        +#define SHUTTER_SPEED     25<br>
        +#define SHUTTER_HEIGHT    1.5<br>
        +<br>
        +#define SHUTTER_INTENSITY 50<br>
        +<br>
        +#define SUB_FRAME (p_sys->i_cur_time % (TIME_UNIT_PER_S /
        SHUTTER_FREQ))<br>
        +<br>
        +   /*<br>
        +    * depending on current time: define shutter location on
        picture<br>
        +    */<br>
        +    int32_t i_shutter_sup = VLC_CLIP((int64_t)SUB_FRAME<br>
        +                                      *
        p_pic_out->p[Y_PLANE].i_visible_lines<br>
        +                                      * SHUTTER_SPEED /
        TIME_UNIT_PER_S,<br>
        +                                      0,
        p_pic_out->p[Y_PLANE].i_visible_lines);<br>
        +<br>
        +    int32_t i_shutter_inf = VLC_CLIP((int64_t)SUB_FRAME<br>
        +                                      *
        p_pic_out->p[Y_PLANE].i_visible_lines<br>
        +                                      * SHUTTER_SPEED /
        TIME_UNIT_PER_S<br>
        +                                      - SHUTTER_HEIGHT *
        p_pic_out->p[Y_PLANE].i_visible_lines,<br>
        +                                      0,
        p_pic_out->p[Y_PLANE].i_visible_lines);<br>
        +<br>
        +    int32_t i_width = p_pic_out->p[Y_PLANE].i_visible_pitch<br>
        +                    / p_pic_out->p[Y_PLANE].i_pixel_pitch;<br>
        +<br>
        +   /*<br>
        +    * darken pixels currently occulted by shutter<br>
        +    */<br>
        +    for ( int32_t i_y = i_shutter_inf; i_y < i_shutter_sup;
        i_y++ )<br>
        +        for ( int32_t i_x = 0; i_x < i_width; i_x++ )<br>
        +            DARKEN_PIXEL( i_x, i_y, SHUTTER_INTENSITY,
        &p_pic_out->p[Y_PLANE] );<br>
        +}<br>
        +<br>
        +/**<br>
        + * sliding & offset effect<br>
        + */<br>
        +int oldmovie_sliding_offset_effect( filter_t *p_filter,
        picture_t *p_pic_out ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +<br>
        +   /**<br>
        +    * one shot offset section<br>
        +    */<br>
        +<br>
        +#define OFFSET_AVERAGE_PERIOD   (10 * TIME_UNIT_PER_S)<br>
        +<br>
        +    /* start trigger to be (re)initialized */<br>
        +    if ( p_sys->i_offset_trigger == 0<br>
        +         || p_sys->i_sliding_speed != 0 ) { /* do not mix
        sliding and offset */<br>
        +        /* random trigger for offset effect */<br>
        +        p_sys->i_offset_trigger = p_sys->i_cur_time<br>
        +                                + ( (uint64_t) vlc_mrand48() )
        % OFFSET_AVERAGE_PERIOD<br>
        +                                + OFFSET_AVERAGE_PERIOD / 2;<br>
        +        p_sys->i_offset_ofs = 0;<br>
        +    } else if ( p_sys->i_offset_trigger <=
        p_sys->i_cur_time ) {<br>
        +        /* trigger for offset effect */<br>
        +        p_sys->i_offset_trigger = 0;<br>
        +        p_sys->i_offset_ofs = MOD( ( (uint32_t)vlc_mrand48()
        ),<br>
        +                                  p_sys->i_height[Y_PLANE] )
        * 100;<br>
        +    } else<br>
        +        p_sys->i_offset_ofs = 0;<br>
        +<br>
        +<br>
        +    /**<br>
        +    * sliding section<br>
        +    */<br>
        +<br>
        +#define SLIDING_AVERAGE_PERIOD   (20 * TIME_UNIT_PER_S)<br>
        +#define SLIDING_AVERAGE_DURATION ( 3 * TIME_UNIT_PER_S)<br>
        +<br>
        +    /* start trigger to be (re)initialized */<br>
        +    if (    ( p_sys->i_sliding_stop_trig  == 0 )<br>
        +         && ( p_sys->i_sliding_trigger    == 0 )<br>
        +         && ( p_sys->i_sliding_speed      == 0 ) ) {<br>
        +        /* random trigger which enable sliding effect */<br>
        +        p_sys->i_sliding_trigger = p_sys->i_cur_time<br>
        +                                 + ( (uint64_t) vlc_mrand48() )
        % SLIDING_AVERAGE_PERIOD<br>
        +                                 + SLIDING_AVERAGE_PERIOD / 2;<br>
        +    }<br>
        +    /* start trigger just occurs */<br>
        +    else if (    ( p_sys->i_sliding_stop_trig  == 0 )<br>
        +              && ( p_sys->i_sliding_trigger    <=
        p_sys->i_cur_time )<br>
        +              && ( p_sys->i_sliding_speed      == 0
        ) ) {<br>
        +        /* init sliding parameters */<br>
        +        p_sys->i_sliding_trigger   = 0;<br>
        +        p_sys->i_sliding_stop_trig = p_sys->i_cur_time<br>
        +                                   + ((uint64_t) vlc_mrand48()
        ) % SLIDING_AVERAGE_DURATION<br>
        +                                   + SLIDING_AVERAGE_DURATION /
        2;<br>
        +        p_sys->i_sliding_ofs = 0;<br>
        +        /* note: sliding speed unit = image per 100 s */<br>
        +        p_sys->i_sliding_speed = MOD(((int32_t)
        vlc_mrand48() ), 201) - 100;<br>
        +    }<br>
        +    /* stop trigger disabling sliding effect */<br>
        +    else if (   ( p_sys->i_sliding_stop_trig  <=
        p_sys->i_cur_time )<br>
        +             && ( p_sys->i_sliding_trigger    == 0 )
        ) {<br>
        +<br>
        +        /* first increase speed to ensure we will come back to
        stable image */<br>
        +        if ( abs(p_sys->i_sliding_speed) < 50 )<br>
        +            p_sys->i_sliding_speed += 5;<br>
        +<br>
        +        /* check if offset is close to 0 and then ready to stop
        */<br>
        +        if ( abs( p_sys->i_sliding_ofs ) < abs(
        p_sys->i_sliding_speed<br>
        +             * p_sys->i_height[Y_PLANE]<br>
        +             * ( p_sys->i_cur_time - p_sys->i_last_time )
        / TIME_UNIT_PER_S )<br>
        +             ||  abs( p_sys->i_sliding_ofs ) <
        p_sys->i_height[Y_PLANE] * 100 / 20 ) {<br>
        +<br>
        +            /* reset sliding parameters */<br>
        +            p_sys->i_sliding_ofs     =
        p_sys->i_sliding_speed = 0;<br>
        +            p_sys->i_sliding_trigger =
        p_sys->i_sliding_stop_trig = 0;<br>
        +        }<br>
        +    }<br>
        +<br>
        +    /* update offset */<br>
        +    p_sys->i_sliding_ofs += p_sys->i_sliding_speed *
        p_sys->i_height[Y_PLANE]<br>
        +                         * ( p_sys->i_cur_time -
        p_sys->i_last_time )<br>
        +                         / TIME_UNIT_PER_S;<br>
        +<br>
        +    p_sys->i_sliding_ofs = MOD( p_sys->i_sliding_ofs,<br>
        +                                p_sys->i_height[Y_PLANE] *
        100 );<br>
        +<br>
        +    /* apply offset */<br>
        +    return oldmovie_sliding_offset_apply( p_filter, p_pic_out
        );<br>
        +}<br>
        +<br>
        +/**<br>
        +* apply both sliding and offset effect<br>
        +*/<br>
        +int oldmovie_sliding_offset_apply( filter_t *p_filter,
        picture_t *p_pic_out )<br>
        +{<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    for ( uint8_t i_p = 0; i_p < p_pic_out->i_planes;
        i_p++ ) {<br>
        +        /* first allocate temporary buffer for swap operation
        */<br>
        +        uint8_t *p_temp_buf = calloc(
        p_pic_out->p[i_p].i_lines * p_pic_out->p[i_p].i_pitch,<br>
        +                                      sizeof(uint8_t) );<br>
        +        if ( unlikely( !p_temp_buf ) )<br>
        +            return VLC_ENOMEM;<br>
        +        memcpy( p_temp_buf,p_pic_out->p[i_p].p_pixels,<br>
        +                p_pic_out->p[i_p].i_lines *
        p_pic_out->p[i_p].i_pitch );<br>
        +<br>
        +        /* copy lines to output_pic */<br>
        +        for ( int32_t i_y = 0; i_y <
        p_pic_out->p[i_p].i_visible_lines; i_y++ ) {<br>
        +            int32_t i_ofs = MOD( ( p_sys->i_offset_ofs +
        p_sys->i_sliding_ofs )<br>
        +                                 /100,<br>
        +                                 p_sys->i_height[Y_PLANE] );<br>
        +            i_ofs *= p_pic_out->p[i_p].i_visible_lines;<br>
        +            i_ofs /= p_sys->i_height[Y_PLANE];<br>
        +<br>
        +            memcpy( &p_pic_out->p[i_p].p_pixels[ i_y *
        p_pic_out->p[i_p].i_pitch ],<br>
        +                    &p_temp_buf[ ( ( i_y + i_ofs ) %
        p_pic_out->p[i_p].i_visible_lines ) *
        p_pic_out->p[i_p].i_pitch ],<br>
        +                    p_pic_out->p[i_p].i_visible_pitch);<br>
        +        }<br>
        +        free( p_temp_buf );<br>
        +    }<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Black and white transform including a touch of sepia effect<br>
        + */<br>
        +void oldmovie_black_n_white_effect( picture_t *p_pic_out )<br>
        +{<br>
        +    for ( int32_t i_y = 0; i_y <
        p_pic_out->p[Y_PLANE].i_visible_lines; i_y++ )<br>
        +        for ( int32_t i_x = 0; i_x <
        p_pic_out->p[Y_PLANE].i_visible_pitch;<br>
        +              i_x += p_pic_out->p[Y_PLANE].i_pixel_pitch ) {<br>
        +<br>
        +            uint32_t i_pix_ofs =
        i_x+i_y*p_pic_out->p[Y_PLANE].i_pitch;<br>
        +            p_pic_out->p[Y_PLANE].p_pixels[i_pix_ofs] -=
        p_pic_out->p[Y_PLANE].p_pixels[i_pix_ofs] >> 2;<br>
        +            p_pic_out->p[Y_PLANE].p_pixels[i_pix_ofs] += 30;<br>
        +        }<br>
        +<br>
        +    memset( p_pic_out->p[U_PLANE].p_pixels, 122,<br>
        +            p_pic_out->p[U_PLANE].i_lines *
        p_pic_out->p[U_PLANE].i_pitch );<br>
        +    memset( p_pic_out->p[V_PLANE].p_pixels, 132,<br>
        +            p_pic_out->p[V_PLANE].i_lines *
        p_pic_out->p[V_PLANE].i_pitch );<br>
        +}<br>
        +<br>
        +/**<br>
        + * Smooth darker borders effect<br>
        + */<br>
        +int oldmovie_dark_border_effect( filter_t *p_filter, picture_t
        *p_pic_out )<br>
        +{<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +#define BORDER_DIST 20<br>
        +<br>
        +    for ( int32_t i_y = 0; i_y <
        p_sys->i_height[Y_PLANE]; i_y++ )<br>
        +        for ( int32_t i_x = 0; i_x <
        p_sys->i_width[Y_PLANE]; i_x++ ) {<br>
        +<br>
        +            int32_t i_x_border_dist = __MIN( i_x,
        p_sys->i_width[Y_PLANE] - i_x);<br>
        +            int32_t i_y_border_dist = __MIN( i_y,
        p_sys->i_height[Y_PLANE] - i_y);<br>
        +<br>
        +            int32_t i_border_dist = __MAX(BORDER_DIST -
        i_x_border_dist,0)<br>
        +                                  + __MAX(BORDER_DIST -
        i_y_border_dist,0);<br>
        +<br>
        +            i_border_dist = __MIN(BORDER_DIST, i_border_dist);<br>
        +<br>
        +            if ( i_border_dist == 0 )<br>
        +                continue;<br>
        +<br>
        +            uint32_t i_pix_ofs = i_x *
        p_pic_out->p[Y_PLANE].i_pixel_pitch<br>
        +                               + i_y *
        p_pic_out->p[Y_PLANE].i_pitch;<br>
        +<br>
        +            SUB_MIN(
        p_pic_out->p[Y_PLANE].p_pixels[i_pix_ofs],<br>
        +                     i_border_dist * 255 / BORDER_DIST, 0 );<br>
        +        }<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Vertical scratch random management and effect<br>
        + */<br>
        +int oldmovie_film_scratch_effect( filter_t *p_filter, picture_t
        *p_pic_out )<br>
        +{<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +#define SCRATCH_GENERATOR_PERIOD ( TIME_UNIT_PER_S * 2 )<br>
        +#define SCRATCH_DURATION         ( TIME_UNIT_PER_S * 1 / 2)<br>
        +<br>
        +    /* generate new scratch */<br>
        +    if ( p_sys->i_scratch_trigger <= p_sys->i_cur_time
        ) {<br>
        +        for ( uint32_t i_s = 0; i_s < MAX_SCRATCH; i_s++ )<br>
        +            if ( p_sys->p_scratch[i_s] == NULL ) {<br>
        +                /* allocate data */<br>
        +                p_sys->p_scratch[i_s] = calloc( 1,
        sizeof(scratch_t) );<br>
        +                if ( unlikely( !p_sys->p_scratch[i_s] ) )<br>
        +                    return VLC_ENOMEM;<br>
        +<br>
        +                /* set random parameters */<br>
        +                p_sys->p_scratch[i_s]->i_offset = ( (
        (unsigned)vlc_mrand48() )<br>
        +                                                % __MAX(
        p_sys->i_width[Y_PLANE] - 10, 1 ) )<br>
        +                                                + 5;<br>
        +                p_sys->p_scratch[i_s]->i_width  = ( (
        (unsigned)vlc_mrand48() )<br>
        +                                                % __MAX(
        p_sys->i_width[Y_PLANE] / 500, 1 ) )<br>
        +                                                + 1;<br>
        +                p_sys->p_scratch[i_s]->i_intensity =
        (unsigned) vlc_mrand48() % 50 + 10;<br>
        +                p_sys->p_scratch[i_s]->i_stop_trigger =
        p_sys->i_cur_time<br>
        +                                                      +
        (uint64_t) vlc_mrand48() % SCRATCH_DURATION<br>
        +                                                      +
        SCRATCH_DURATION / 2;<br>
        +<br>
        +                break;<br>
        +            }<br>
        +        p_sys->i_scratch_trigger = p_sys->i_cur_time<br>
        +                                 + ( (uint64_t)vlc_mrand48() )
        % SCRATCH_GENERATOR_PERIOD<br>
        +                                 + SCRATCH_GENERATOR_PERIOD /
        2;<br>
        +    }<br>
        +<br>
        +    /* manage and apply current scratch */<br>
        +    for ( uint32_t i_s = 0; i_s < MAX_SCRATCH; i_s++ )<br>
        +        if ( p_sys->p_scratch[i_s] ) {<br>
        +            /* remove outdated scratch */<br>
        +            if ( p_sys->p_scratch[i_s]->i_stop_trigger
        <= p_sys->i_cur_time ) {<br>
        +                FREENULL( p_sys->p_scratch[i_s] );<br>
        +                continue;<br>
        +            }<br>
        +<br>
        +            /* otherwise apply scratch */<br>
        +            for ( int32_t i_y = 0; i_y <
        p_pic_out->p[Y_PLANE].i_visible_lines; i_y++ )<br>
        +                for ( int32_t i_x =
        p_sys->p_scratch[i_s]->i_offset;<br>
        +                      i_x <
        __MIN(p_sys->p_scratch[i_s]->i_offset<br>
        +                      + p_sys->p_scratch[i_s]->i_width,
        p_sys->i_width[Y_PLANE] );<br>
        +                      i_x++ )<br>
        +                    DARKEN_PIXEL( i_x, i_y,
        p_sys->p_scratch[i_s]->i_intensity,<br>
        +                                  &p_pic_out->p[Y_PLANE]
        );<br>
        +        }<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Blotch addition<br>
        + *    bigger than dust but only during one frame (due to a
        local film damage)<br>
        + */<br>
        +void oldmovie_film_blotch_effect( filter_t *p_filter, picture_t
        *p_pic_out )<br>
        +{<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +#define BLOTCH_GENERATOR_PERIOD ( TIME_UNIT_PER_S * 5 )<br>
        +<br>
        +    /* generate blotch */<br>
        +    if ( p_sys->i_blotch_trigger <= p_sys->i_cur_time
        ) {<br>
        +        /* set random parameters */<br>
        +        int32_t i_bx =        (unsigned)vlc_mrand48() %
        p_sys->i_width[Y_PLANE];<br>
        +        int32_t i_by =        (unsigned)vlc_mrand48() %
        p_sys->i_height[Y_PLANE];<br>
        +        int32_t i_width =     (unsigned)vlc_mrand48() % __MAX(
        1, p_sys->i_width[Y_PLANE] / 10 ) + 1;<br>
        +        int32_t i_intensity = (unsigned)vlc_mrand48() % 50 +
        20;<br>
        +<br>
        +        if ( (unsigned)vlc_mrand48() & 0x01 ) {<br>
        +            /* draw dark blotch */<br>
        +            for ( int32_t i_y = -i_width + 1; i_y < i_width;
        i_y++ )<br>
        +                for ( int32_t i_x = -i_width + 1; i_x <
        i_width; i_x++ )<br>
        +                    if ( i_x * i_x + i_y * i_y <= i_width *
        i_width )<br>
        +                        CHECK_N_DARKEN_PIXEL( i_x + i_bx, i_y +
        i_by,<br>
        +                                              i_intensity,
        &p_pic_out->p[Y_PLANE] );<br>
        +        } else {<br>
        +            /* draw light blotch */<br>
        +            for ( int32_t i_y = -i_width+1; i_y < i_width;
        i_y++ )<br>
        +                for ( int32_t i_x = -i_width+1; i_x <
        i_width; i_x++ )<br>
        +                    if ( i_x * i_x + i_y * i_y <= i_width *
        i_width )<br>
        +                        CHECK_N_LIGHTEN_PIXEL( i_x + i_bx, i_y
        + i_by,<br>
        +                                               i_intensity,
        &p_pic_out->p[Y_PLANE] );<br>
        +        }<br>
        +<br>
        +        p_sys->i_blotch_trigger = p_sys->i_cur_time<br>
        +                                + (uint64_t)vlc_mrand48() %
        BLOTCH_GENERATOR_PERIOD<br>
        +                                + BLOTCH_GENERATOR_PERIOD / 2;<br>
        +    }<br>
        +}<br>
        +<br>
        +/**<br>
        + * Dust dots addition, visible during one frame only (film
        damages)<br>
        + */<br>
        +void oldmovie_film_dust_effect( filter_t *p_filter, picture_t
        *p_pic_out ) {<br>
        +#define ONESHOT_DUST_RATIO 1000<br>
        +<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    for ( int32_t i_dust = 0;<br>
        +          i_dust < p_sys->i_width[Y_PLANE] *
        p_sys->i_height[Y_PLANE] / ONESHOT_DUST_RATIO;<br>
        +          i_dust++)<br>
        +        if ( (unsigned)vlc_mrand48() % 5 < 3 )<br>
        +            DARKEN_PIXEL( (unsigned)vlc_mrand48() %
        p_sys->i_width[Y_PLANE],<br>
        +                          (unsigned)vlc_mrand48() %
        p_sys->i_height[Y_PLANE],<br>
        +                          150, &p_pic_out->p[Y_PLANE] );<br>
        +        else<br>
        +            LIGHTEN_PIXEL( (unsigned)vlc_mrand48() %
        p_sys->i_width[Y_PLANE],<br>
        +                           (unsigned)vlc_mrand48() %
        p_sys->i_height[Y_PLANE],<br>
        +                           50, &p_pic_out->p[Y_PLANE] );<br>
        +}<br>
        +<br>
        +/**<br>
        + * Hair and dust on projector lens<br>
        + *<br>
        + */<br>
        +#define HAIR_GENERATOR_PERIOD ( TIME_UNIT_PER_S * 50  )<br>
        +#define HAIR_DURATION         ( TIME_UNIT_PER_S * 50  )<br>
        +#define DUST_GENERATOR_PERIOD ( TIME_UNIT_PER_S * 100 )<br>
        +#define DUST_DURATION         ( TIME_UNIT_PER_S * 4   )<br>
        +<br>
        +/**<br>
        + * Define hair location on the lens and timeout<br>
        + *<br>
        + */<br>
        +void oldmovie_define_hair_location( filter_t *p_filter, hair_t*
        ps_hair ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    ps_hair->i_x = (unsigned)vlc_mrand48() %
        p_sys->i_width[Y_PLANE];<br>
        +    ps_hair->i_y = (unsigned)vlc_mrand48() %
        p_sys->i_height[Y_PLANE];<br>
        +    ps_hair->i_rotation = (unsigned)vlc_mrand48() % 200;<br>
        +<br>
        +    ps_hair->i_stop_trigger = p_sys->i_cur_time<br>
        +                            + (uint64_t)vlc_mrand48() %
        HAIR_DURATION<br>
        +                            + HAIR_DURATION / 2;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Show black hair on the screen<br>
        + *       after random duration it is removed or re-located<br>
        + */<br>
        +int oldmovie_lens_hair_effect( filter_t *p_filter, picture_t
        *p_pic_out ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    /* generate new hair */<br>
        +    if ( p_sys->i_hair_trigger <= p_sys->i_cur_time )
        {<br>
        +        for ( uint32_t i_h = 0; i_h < MAX_HAIR; i_h++ )<br>
        +            if ( p_sys->p_hair[i_h] == NULL ) {<br>
        +                /* allocate data */<br>
        +                p_sys->p_hair[i_h] = calloc( 1,
        sizeof(hair_t) );<br>
        +                if ( unlikely( !p_sys->p_hair[i_h] ) )<br>
        +                    return VLC_ENOMEM;<br>
        +<br>
        +                /* set random parameters */<br>
        +                p_sys->p_hair[i_h]->i_length =
        (unsigned)vlc_mrand48()<br>
        +                                             % (
        p_sys->i_width[Y_PLANE] / 3 ) + 5;<br>
        +                p_sys->p_hair[i_h]->i_curve  = MOD(
        (int32_t)vlc_mrand48(), 80 ) - 40;<br>
        +                p_sys->p_hair[i_h]->i_width  =
        (unsigned)vlc_mrand48()<br>
        +                                             % __MAX( 1,
        p_sys->i_width[Y_PLANE] / 1500 ) + 1;<br>
        +                p_sys->p_hair[i_h]->i_intensity =
        (unsigned)vlc_mrand48() % 50 + 20;<br>
        +<br>
        +                oldmovie_define_hair_location( p_filter,
        p_sys->p_hair[i_h] );<br>
        +<br>
        +                break;<br>
        +            }<br>
        +        p_sys->i_hair_trigger = p_sys->i_cur_time<br>
        +                              + (uint64_t)vlc_mrand48() %
        HAIR_GENERATOR_PERIOD<br>
        +                              + HAIR_GENERATOR_PERIOD / 2;<br>
        +    }<br>
        +<br>
        +    /* manage and apply current hair */<br>
        +    for ( uint32_t i_h = 0; i_h < MAX_HAIR; i_h++ )<br>
        +        if ( p_sys->p_hair[i_h] ) {<br>
        +            /* remove outdated ones */<br>
        +            if ( p_sys->p_hair[i_h]->i_stop_trigger <=
        p_sys->i_cur_time ) {<br>
        +                /* select between moving or removing hair */<br>
        +                if ( (unsigned)vlc_mrand48() % 2 == 0 )<br>
        +                    /* move hair */<br>
        +                    oldmovie_define_hair_location( p_filter,
        p_sys->p_hair[i_h] );<br>
        +                else {<br>
        +                    /* remove hair */<br>
        +                    FREENULL( p_sys->p_hair[i_h] );<br>
        +                    continue;<br>
        +                }<br>
        +            }<br>
        +<br>
        +            /* draw hair */<br>
        +            double  f_base_x   =
        (double)p_sys->p_hair[i_h]->i_x;<br>
        +            double  f_base_y   =
        (double)p_sys->p_hair[i_h]->i_y;<br>
        +<br>
        +            for ( int32_t i_l = 0; i_l <
        p_sys->p_hair[i_h]->i_length; i_l++ ) {<br>
        +                uint32_t i_current_rot =
        p_sys->p_hair[i_h]->i_rotation<br>
        +                                       +
        p_sys->p_hair[i_h]->i_curve * i_l / 100;<br>
        +                f_base_x += cos( (double)i_current_rot / 128.0
        * M_PI );<br>
        +                f_base_y += sin( (double)i_current_rot / 128.0
        * M_PI );<br>
        +                double f_current_x = f_base_x;<br>
        +                double f_current_y = f_base_y;<br>
        +                for ( int32_t i_w = 0; i_w <
        p_sys->p_hair[i_h]->i_width; i_w++ ) {<br>
        +                    f_current_x += sin( (double)i_current_rot /
        128.0 * M_PI );<br>
        +                    f_current_y += cos( (double)i_current_rot /
        128.0 * M_PI );<br>
        +                    CHECK_N_DARKEN_PIXEL( (int32_t)
        f_current_x,<br>
        +                                          (int32_t)
        f_current_y,<br>
        +                                         
        p_sys->p_hair[i_h]->i_intensity,<br>
        +                                         
        &p_pic_out->p[Y_PLANE] );<br>
        +                }<br>
        +            }<br>
        +        }<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Define dust location on the lens and timeout<br>
        + *<br>
        + */<br>
        +void oldmovie_define_dust_location( filter_t *p_filter, dust_t*
        ps_dust ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    ps_dust->i_x = (unsigned)vlc_mrand48() %
        p_sys->i_width[Y_PLANE];<br>
        +    ps_dust->i_y = (unsigned)vlc_mrand48() %
        p_sys->i_height[Y_PLANE];<br>
        +<br>
        +    ps_dust->i_stop_trigger = p_sys->i_cur_time<br>
        +                            + (uint64_t)vlc_mrand48() %
        HAIR_DURATION<br>
        +                            + HAIR_DURATION / 2;<br>
        +<br>
        +<br>
        +    ps_dust->i_x = MOD( (int32_t)vlc_mrand48(),
        p_sys->i_width[Y_PLANE]  );<br>
        +    ps_dust->i_y = MOD( (int32_t)vlc_mrand48(),
        p_sys->i_height[Y_PLANE] );<br>
        +<br>
        +    ps_dust->i_stop_trigger = p_sys->i_cur_time<br>
        +                            + (uint64_t)vlc_mrand48() %
        DUST_DURATION<br>
        +                            + DUST_DURATION / 2;<br>
        +}<br>
        +<br>
        +/**<br>
        + * Dust addition<br>
        + *    smaller than blotch but will remain on the screen for
        long time<br>
        + */<br>
        +int oldmovie_lens_dust_effect( filter_t *p_filter, picture_t
        *p_pic_out ) {<br>
        +    filter_sys_t *p_sys = p_filter->p_sys;<br>
        +<br>
        +    /* generate new dust */<br>
        +    if ( p_sys->i_dust_trigger <= p_sys->i_cur_time )
        {<br>
        +        for ( uint32_t i_d = 0; i_d < MAX_DUST; i_d++ )<br>
        +            if ( p_sys->p_dust[i_d] == NULL ) {<br>
        +                /* allocate data */<br>
        +                p_sys->p_dust[i_d] = calloc( 1,
        sizeof(dust_t) );<br>
        +                if ( unlikely( !p_sys->p_dust[i_d] ) )<br>
        +                    return VLC_ENOMEM;<br>
        +<br>
        +                /* set random parameters */<br>
        +                oldmovie_define_dust_location( p_filter,
        p_sys->p_dust[i_d] );<br>
        +                p_sys->p_dust[i_d]->i_width = MOD(
        (int32_t)vlc_mrand48(), 5 ) + 1;<br>
        +                p_sys->p_dust[i_d]->i_intensity =
        (unsigned)vlc_mrand48() % 30 + 30;<br>
        +<br>
        +                break;<br>
        +            }<br>
        +        p_sys->i_dust_trigger = p_sys->i_cur_time<br>
        +                              + (uint64_t)vlc_mrand48() %
        DUST_GENERATOR_PERIOD<br>
        +                              + DUST_GENERATOR_PERIOD / 2;<br>
        +    }<br>
        +<br>
        +    /* manage and apply current dust */<br>
        +    for ( uint32_t i_d = 0; i_d < MAX_DUST; i_d++ )<br>
        +        if ( p_sys->p_dust[i_d] ) {<br>
        +            /* remove outdated ones */<br>
        +            if ( p_sys->p_dust[i_d]->i_stop_trigger <=
        p_sys->i_cur_time ) {<br>
        +                /* select between moving or removing dust */<br>
        +                if ( (unsigned)vlc_mrand48() % 2 == 0 )<br>
        +                    /* move dust */<br>
        +                    oldmovie_define_dust_location( p_filter,
        p_sys->p_dust[i_d] );<br>
        +                else {<br>
        +                    /* remove dust */<br>
        +                    FREENULL( p_sys->p_dust[i_d] );<br>
        +                    continue;<br>
        +                }<br>
        +            }<br>
        +<br>
        +            /* draw dust */<br>
        +            for ( int32_t i_y =
        -p_sys->p_dust[i_d]->i_width + 1; i_y <
        p_sys->p_dust[i_d]->i_width; i_y++ )<br>
        +                for ( int32_t i_x =
        -p_sys->p_dust[i_d]->i_width + 1; i_x <
        p_sys->p_dust[i_d]->i_width; i_x++ )<br>
        +                    if ( i_x * i_x + i_y * i_y <=
        p_sys->p_dust[i_d]->i_width *
        p_sys->p_dust[i_d]->i_width )<br>
        +                        CHECK_N_DARKEN_PIXEL( i_x +
        p_sys->p_dust[i_d]->i_x,<br>
        +                                              i_y +
        p_sys->p_dust[i_d]->i_y,<br>
        +                                             
        p_sys->p_dust[i_d]->i_intensity,<br>
        +                                             
        &p_pic_out->p[Y_PLANE] );<br>
        +        }<br>
        +<br>
        +    return VLC_SUCCESS;<br>
        +}<br>
        -- <br>
        1.8.1.2<br>
        <br>
        <br>
      </small><br>
      <br>
      <br>
      Le 25/07/2013 13:41, Jean-Baptiste Kempf a écrit :<br>
    </div>
    <blockquote cite="mid:20130725114130.GB21257@videolan.org"
      type="cite">
      <pre wrap="">On 25 Jul, Vianney Boyer wrote :
</pre>
      <blockquote type="cite">
        <pre wrap="">New video filter making the video like an old movie (projector,
damages on film...)
</pre>
      </blockquote>
      <pre wrap="">
Same remarks as freeze apply

</pre>
      <blockquote type="cite">
        <pre wrap="">+#define SUB_MIN(val, sub_val, min) val = \
+ ((val-(int32_t)sub_val)<min?min:val-sub_val)
+#define ADD_MAX(val, add_val, max) val = \
+ ((val+(int32_t)add_val)>max?max:val+add_val)
+
+#define PIX_OFS(i_x, i_y, s_plane) ( \
+        (i_x) * s_plane.i_pixel_pitch \
+      + (i_y) * s_plane.i_pitch \
+    )
+
+#define CHECK_PIX_OFS(i_x, i_y, s_plane) ( \
+        (i_x) >= 0 && (i_y) >= 0 && \
+        (i_x) * s_plane.i_pixel_pitch < s_plane.i_visible_pitch && \
+        (i_y) < s_plane.i_visible_lines \
+    )
+
+#define DARKEN_PIXEL(i_x, i_y, intensity, s_plane) \
+        SUB_MIN(s_plane.p_pixels[ PIX_OFS(i_x, i_y, s_plane) ],
intensity, 0)
+
+#define LIGHTEN_PIXEL(i_x, i_y, intensity, s_plane) \
+        ADD_MAX(s_plane.p_pixels[PIX_OFS(i_x, i_y, s_plane)],
intensity, 0xFF)
+
+#define CHECK_N_DARKEN_PIXEL(i_x, i_y, intensity, s_plane) \
+        if ( CHECK_PIX_OFS(i_x, i_y, s_plane) ) \
+            DARKEN_PIXEL(i_x, i_y, intensity, s_plane) \
+
+#define CHECK_N_LIGHTEN_PIXEL(i_x, i_y, intensity, s_plane) \
+        if ( CHECK_PIX_OFS(i_x, i_y, s_plane) ) \
+            LIGHTEN_PIXEL(i_x, i_y, intensity, s_plane) \
</pre>
      </blockquote>
      <pre wrap="">
Shouldn't some be static inline?

</pre>
      <blockquote type="cite">
        <pre wrap="">+#define CFG_PREFIX "oldmovie-"
</pre>
      </blockquote>
      <pre wrap="">
unused.

Really cool filter!

Best regards,

</pre>
    </blockquote>
    <br>
  </body>
</html>