<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"><small><br>
<br>
Hi,<br>
<br>
You'll find below and in 2 additional patches the vhs video
filter modified as per your comments.<br>
<br>
It has to be applied after freeze patch and oldmovie patch set<br>
<br>
<br>
Regards<br>
<br>
Vianney<br>
<br>
<br>
---<br>
modules/video_filter/vhs.c | 540
+++++++++++++++++++++++++++++++++++++++++++++<br>
1 file changed, 540 insertions(+)<br>
create mode 100644 modules/video_filter/vhs.c<br>
<br>
diff --git a/modules/video_filter/vhs.c
b/modules/video_filter/vhs.c<br>
new file mode 100644<br>
index 0000000..cd1c450<br>
--- /dev/null<br>
+++ b/modules/video_filter/vhs.c<br>
@@ -0,0 +1,540 @@<br>
+/*****************************************************************************<br>
+ * vhs.c : VHS 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 <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 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 MAX_BLUE_RED_LINES 100<br>
+<br>
+typedef struct {<br>
+ int32_t i_offset;<br>
+ uint16_t i_intensity;<br>
+ bool b_blue_red;<br>
+ uint64_t i_stop_trigger;<br>
+} blue_red_line_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; /* note: each plane may have different
dimensions */<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>
+ int32_t i_phase_speed;<br>
+ int32_t i_phase_ofs;<br>
+ int32_t i_offset_ofs;<br>
+ int32_t i_sliding_ofs;<br>
+ int32_t i_sliding_speed;<br>
+ uint64_t i_offset_trigger;<br>
+ uint64_t i_sliding_trigger;<br>
+ uint64_t i_sliding_stop_trig;<br>
+ bool i_sliding_type_duplicate;<br>
+<br>
+ /* blue red lines effect */<br>
+ uint64_t i_BR_line_trigger;<br>
+ blue_red_line_t *p_BR_lines[MAX_BLUE_RED_LINES];<br>
+<br>
+};<br>
+<br>
+/*****************************************************************************<br>
+ * Prototypes<br>
+
*****************************************************************************/<br>
+<br>
+picture_t *Filter( filter_t *, picture_t * );<br>
+<br>
+int vhs_allocate_data( filter_t *, picture_t * );<br>
+void vhs_free_allocated_data( filter_t * );<br>
+<br>
+int vhs_blue_red_line_effect( filter_t *, picture_t * );<br>
+void vhs_blue_red_dots_effect( filter_t *, picture_t * );<br>
+int vhs_sliding_effect( filter_t *, picture_t * );<br>
+<br>
+int vhs_sliding_effect_apply( filter_t *, picture_t * );<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_("VHS movie effect video filter") )<br>
+ set_shortname( N_("VHS 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>
+{<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>
+ vhs_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( vhs_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 effects on picture<br>
+ */<br>
+ if ( unlikely( vhs_blue_red_line_effect( p_filter,
p_pic_out ) != VLC_SUCCESS ) )<br>
+ return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
+<br>
+ if ( unlikely( vhs_sliding_effect(p_filter, p_pic_out ) !=
VLC_SUCCESS ) )<br>
+ return CopyInfoAndRelease( p_pic_out, p_pic_in );<br>
+<br>
+ vhs_blue_red_dots_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 vhs_allocate_data( filter_t *p_filter, picture_t *p_pic_in
) {<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+<br>
+ vhs_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>
+ vhs_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 /
p_pic_in->p[i_p].i_pixel_pitch;<br>
+ }<br>
+ return VLC_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ * Free allocated data<br>
+ */<br>
+void vhs_free_allocated_data( filter_t *p_filter ) {<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+<br>
+ for ( uint32_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++
)<br>
+ FREENULL( p_sys->p_BR_lines[i_b] );<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>
+/**<br>
+ * Horizontal blue or red lines random management and effect<br>
+ */<br>
+int vhs_blue_red_line_effect( filter_t *p_filter, picture_t
*p_pic_out ) {<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+<br>
+#define BR_LINES_GENERATOR_PERIOD ( TIME_UNIT_PER_S * 50 )<br>
+#define BR_LINES_DURATION ( TIME_UNIT_PER_S * 1/50 )<br>
+<br>
+ /* generate new blue or red lines */<br>
+ if ( p_sys->i_BR_line_trigger <= p_sys->i_cur_time
) {<br>
+ for ( uint32_t i_b = 0; i_b < MAX_BLUE_RED_LINES;
i_b++ )<br>
+ if (p_sys->p_BR_lines[i_b] == NULL) {<br>
+ /* allocate data */<br>
+ p_sys->p_BR_lines[i_b] = calloc( 1,
sizeof(blue_red_line_t) );<br>
+ if ( unlikely( !p_sys->p_BR_lines[i_b] ) )<br>
+ return VLC_ENOMEM;<br>
+<br>
+ /* set random parameters */<br>
+ p_sys->p_BR_lines[i_b]->i_offset =
(unsigned)vlc_mrand48()<br>
+ % __MAX( 1,
p_sys->i_height[Y_PLANE] - 10 )<br>
+ + 5;<br>
+<br>
+ p_sys->p_BR_lines[i_b]->b_blue_red =
(unsigned)vlc_mrand48() & 0x01;<br>
+<br>
+ p_sys->p_BR_lines[i_b]->i_stop_trigger =
p_sys->i_cur_time<br>
+ +
(uint64_t)vlc_mrand48() % BR_LINES_DURATION<br>
+ +
BR_LINES_DURATION / 2;<br>
+<br>
+ break;<br>
+ }<br>
+ p_sys->i_BR_line_trigger = p_sys->i_cur_time<br>
+ + (uint64_t)vlc_mrand48() %
BR_LINES_GENERATOR_PERIOD<br>
+ + BR_LINES_GENERATOR_PERIOD /
2;<br>
+ }<br>
+<br>
+<br>
+ /* manage and apply current blue/red lines */<br>
+ for ( uint8_t i_b = 0; i_b < MAX_BLUE_RED_LINES; i_b++ )<br>
+ if ( p_sys->p_BR_lines[i_b] ) {<br>
+ /* remove outdated ones */<br>
+ if ( p_sys->p_BR_lines[i_b]->i_stop_trigger
<= p_sys->i_cur_time ) {<br>
+ FREENULL( p_sys->p_BR_lines[i_b] );<br>
+ continue;<br>
+ }<br>
+<br>
+ /* otherwise apply */<br>
+ for ( int32_t i_p=0; i_p < p_sys->i_planes;
i_p++ ) {<br>
+ uint32_t i_pix_ofs =
p_sys->p_BR_lines[i_b]->i_offset<br>
+ *
p_pic_out->p[i_p].i_visible_lines<br>
+ /
p_sys->i_height[Y_PLANE]<br>
+ *
p_pic_out->p[i_p].i_pitch;<br>
+<br>
+ switch ( i_p ) {<br>
+ case Y_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs], 127,<br>
+
p_pic_out->p[i_p].i_visible_pitch);<br>
+ break;<br>
+ case U_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs],<br>
+
(p_sys->p_BR_lines[i_b]->b_blue_red?255:0),<br>
+
p_pic_out->p[i_p].i_visible_pitch);<br>
+ break;<br>
+ case V_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs],<br>
+
(p_sys->p_BR_lines[i_b]->b_blue_red?0:255),<br>
+
p_pic_out->p[i_p].i_visible_pitch);<br>
+ break;<br>
+ }<br>
+<br>
+ }<br>
+ }<br>
+ return VLC_SUCCESS;<br>
+}<br>
+<br>
+/**<br>
+ * insert randomly blue and red dots on the picture<br>
+ */<br>
+void vhs_blue_red_dots_effect( filter_t *p_filter, picture_t
*p_pic_out ) {<br>
+#define BR_DOTS_RATIO 10000<br>
+<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<br>
+<br>
+ for ( int32_t i_dots = 0;<br>
+ i_dots < p_sys->i_width[Y_PLANE] *
p_sys->i_height[Y_PLANE] / BR_DOTS_RATIO;<br>
+ i_dots++) {<br>
+<br>
+ uint32_t i_length = (unsigned)vlc_mrand48()<br>
+ % __MAX( 1,
p_sys->i_width[Y_PLANE] / 30 ) + 1;<br>
+<br>
+ uint16_t i_x = (unsigned)vlc_mrand48()<br>
+ % __MAX( 1, p_sys->i_width[Y_PLANE] -
i_length );<br>
+ uint16_t i_y = (unsigned)vlc_mrand48() %
p_sys->i_height[Y_PLANE];<br>
+ bool b_color = ( ( (unsigned)vlc_mrand48() % 2 ) == 0);<br>
+<br>
+ for ( int32_t i_p = 0; i_p < p_sys->i_planes;
i_p++ ) {<br>
+ uint32_t i_pix_ofs = i_y<br>
+ *
p_pic_out->p[i_p].i_visible_lines<br>
+ / p_sys->i_height[Y_PLANE]<br>
+ * p_pic_out->p[i_p].i_pitch<br>
+ + i_x<br>
+ *
p_pic_out->p[i_p].i_pixel_pitch;<br>
+<br>
+ uint32_t i_length_in_plane = i_length<br>
+ *
p_pic_out->p[i_p].i_visible_pitch<br>
+ /
p_pic_out->p[Y_PLANE].i_visible_pitch;<br>
+<br>
+ switch ( i_p ) {<br>
+ case Y_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs], 127,<br>
+ i_length_in_plane );<br>
+ break;<br>
+ case U_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs],<br>
+ (b_color?255:0),<br>
+ i_length_in_plane );<br>
+ break;<br>
+ case V_PLANE:<br>
+ memset(
&p_pic_out->p[i_p].p_pixels[i_pix_ofs],<br>
+ (b_color?0:255),<br>
+ i_length_in_plane );<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+/**<br>
+* sliding effects<br>
+*/<br>
+int vhs_sliding_effect( filter_t *p_filter, picture_t
*p_pic_out ) {<br>
+ filter_sys_t *p_sys = p_filter->p_sys;<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>
+<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 occurs */<br>
+ p_sys->i_offset_trigger = 0;<br>
+ p_sys->i_offset_ofs = (uint32_t)vlc_mrand48()<br>
+ % p_sys->i_height[Y_PLANE];<br>
+ }<br>
+ else<br>
+ p_sys->i_offset_ofs = 0;<br>
+<br>
+<br>
+ /**<br>
+ * phase section<br>
+ */<br>
+<br>
+#define MAX_PHASE_OFS (p_sys->i_height[Y_PLANE]*100/15)<br>
+<br>
+ p_sys->i_phase_speed += MOD( (int32_t)vlc_mrand48(), 3)
- 1;<br>
+ p_sys->i_phase_ofs += p_sys->i_phase_speed;<br>
+ p_sys->i_phase_ofs = VLC_CLIP( p_sys->i_phase_ofs,
-MAX_PHASE_OFS, +MAX_PHASE_OFS);<br>
+ if ( abs( p_sys->i_phase_ofs ) >= MAX_PHASE_OFS )<br>
+ p_sys->i_phase_speed = 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>
+<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>
+<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>
+<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(), 1001 ) - 500;<br>
+ p_sys->i_sliding_type_duplicate =
(unsigned)vlc_mrand48() & 0x01;<br>
+ }<br>
+<br>
+ /* stop trigger disabling sliding effect occurs */<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 stop sliding
on plain pict */<br>
+ if ( abs( p_sys->i_sliding_speed ) < 5 )<br>
+ p_sys->i_sliding_speed += 1;<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>
+ p_sys->i_sliding_type_duplicate = false;<br>
+ }<br>
+ }<br>
+<br>
+ /* update offset */<br>
+ p_sys->i_sliding_ofs = MOD( p_sys->i_sliding_ofs<br>
+ + 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>
+ p_sys->i_height[Y_PLANE] *
100 );<br>
+<br>
+ return vhs_sliding_effect_apply( p_filter, p_pic_out );<br>
+}<br>
+<br>
+/**<br>
+* apply both sliding and offset effect<br>
+*/<br>
+int vhs_sliding_effect_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;<br>
+ if ( !p_sys->i_sliding_type_duplicate ) {<br>
+ p_temp_buf= calloc( p_pic_out->p[i_p].i_lines<br>
+ * p_pic_out->p[i_p].i_pitch,
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>
+ else<br>
+ p_temp_buf = p_pic_out->p[i_p].p_pixels;<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>
+ {<br>
+ int32_t i_ofs = p_sys->i_offset_ofs +
p_sys->i_sliding_ofs;<br>
+<br>
+ if ( ( p_sys->i_sliding_speed == 0 ) ||
!p_sys->i_sliding_type_duplicate )<br>
+ i_ofs += p_sys->i_phase_ofs;<br>
+<br>
+ i_ofs = MOD( i_ofs / 100,
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>
+ if ( !p_sys->i_sliding_type_duplicate )<br>
+ free(p_temp_buf);<br>
+ }<br>
+<br>
+ return VLC_SUCCESS;<br>
+}<br>
-- <br>
1.8.1.2<br>
</small><br>
<br>
<br>
<br>
Le 25/07/2013 13:41, Jean-Baptiste Kempf a écrit :<br>
</div>
<blockquote cite="mid:20130725114153.GC21257@videolan.org"
type="cite">
<pre wrap="">On 25 Jul, Vianney Boyer wrote :
</pre>
<blockquote type="cite">
<pre wrap="">New video filter showing the video like an old VHS tape
</pre>
</blockquote>
<pre wrap="">
Mostly the same remarks as the previous ones.
</pre>
</blockquote>
<br>
</body>
</html>