qt: add device preferences for mmdevice
[vlc.git] / modules / spu / logo.c
blob44b1bca6de636dd602bd8e214fd30f74d4fb72b0
1 /*****************************************************************************
2 * logo.c : logo video plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2003-2006 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Gildas Bazin <gbazin@videolan.org>
8 * Simon Latapie <garf@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
26 * Preamble
27 *****************************************************************************/
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32 #include <assert.h>
34 #include <vlc_common.h>
35 #include <vlc_plugin.h>
36 #include <vlc_filter.h>
37 #include <vlc_mouse.h>
38 #include <vlc_subpicture.h>
39 #include <vlc_url.h>
40 #include <vlc_image.h>
42 #ifdef LoadImage
43 # undef LoadImage
44 #endif
46 /*****************************************************************************
47 * Module descriptor
48 *****************************************************************************/
49 #define FILE_TEXT N_("Logo filenames")
50 #define FILE_LONGTEXT N_("Full path of the image files to use. Format is " \
51 "<image>[,<delay in ms>[,<alpha>]][;<image>[,<delay>[,<alpha>]]][;...]. " \
52 "If you only have one file, simply enter its filename.")
53 #define REPEAT_TEXT N_("Logo animation # of loops")
54 #define REPEAT_LONGTEXT N_("Number of loops for the logo animation. " \
55 "-1 = continuous, 0 = disabled")
56 #define DELAY_TEXT N_("Logo individual image time in ms")
57 #define DELAY_LONGTEXT N_("Individual image display time of 0 - 60000 ms.")
59 #define POSX_TEXT N_("X coordinate")
60 #define POSX_LONGTEXT N_("X coordinate of the logo. You can move the logo " \
61 "by left-clicking it." )
62 #define POSY_TEXT N_("Y coordinate")
63 #define POSY_LONGTEXT N_("Y coordinate of the logo. You can move the logo " \
64 "by left-clicking it." )
65 #define OPACITY_TEXT N_("Opacity of the logo")
66 #define OPACITY_LONGTEXT N_("Logo opacity value " \
67 "(from 0 for full transparency to 255 for full opacity)." )
68 #define POS_TEXT N_("Logo position")
69 #define POS_LONGTEXT N_( \
70 "Enforce the logo position on the video " \
71 "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
72 "also use combinations of these values, eg 6 = top-right).")
74 #define LOGO_HELP N_("Use a local picture as logo on the video")
76 #define CFG_PREFIX "logo-"
78 static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
79 static const char *const ppsz_pos_descriptions[] =
80 { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
81 N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
83 static int OpenSub ( vlc_object_t * );
84 static int OpenVideo( vlc_object_t * );
85 static void Close ( vlc_object_t * );
87 vlc_module_begin ()
88 set_category( CAT_VIDEO )
89 set_subcategory( SUBCAT_VIDEO_SUBPIC )
90 set_help(LOGO_HELP)
91 set_capability( "sub source", 0 )
92 set_callbacks( OpenSub, Close )
93 set_description( N_("Logo sub source") )
94 set_shortname( N_("Logo overlay") )
95 add_shortcut( "logo" )
97 add_loadfile( CFG_PREFIX "file", NULL, FILE_TEXT, FILE_LONGTEXT, false )
98 add_integer( CFG_PREFIX "x", -1, POSX_TEXT, POSX_LONGTEXT, true )
99 add_integer( CFG_PREFIX "y", -1, POSY_TEXT, POSY_LONGTEXT, true )
100 /* default to 1000 ms per image, continuously cycle through them */
101 add_integer( CFG_PREFIX "delay", 1000, DELAY_TEXT, DELAY_LONGTEXT, true )
102 add_integer( CFG_PREFIX "repeat", -1, REPEAT_TEXT, REPEAT_LONGTEXT, true )
103 add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255,
104 OPACITY_TEXT, OPACITY_LONGTEXT, false )
105 add_integer( CFG_PREFIX "position", -1, POS_TEXT, POS_LONGTEXT, false )
106 change_integer_list( pi_pos_values, ppsz_pos_descriptions )
108 /* video output filter submodule */
109 add_submodule ()
110 set_capability( "video filter", 0 )
111 set_callbacks( OpenVideo, Close )
112 set_description( N_("Logo video filter") )
113 add_shortcut( "logo" )
114 vlc_module_end ()
117 /*****************************************************************************
118 * Local prototypes
119 *****************************************************************************/
122 * Structure to hold the set of individual logo image names, times,
123 * transparencies
125 typedef struct
127 int i_delay; /* -1 means use default delay */
128 int i_alpha; /* -1 means use default alpha */
129 picture_t *p_pic;
131 } logo_t;
134 * Logo list structure.
136 typedef struct
138 logo_t *p_logo; /* the parsing's result */
139 unsigned int i_count; /* the number of logo images to be displayed */
141 int i_repeat; /* how often to repeat the images, image time in ms */
142 mtime_t i_next_pic; /* when to bring up a new logo image */
144 unsigned int i_counter; /* index into the list of logo images */
146 int i_delay; /* default delay (0 - 60000 ms) */
147 int i_alpha; /* default alpha */
149 } logo_list_t;
152 * Private logo data holder
154 struct filter_sys_t
156 filter_t *p_blend;
158 vlc_mutex_t lock;
160 logo_list_t list;
162 int i_pos;
163 int i_pos_x;
164 int i_pos_y;
165 bool b_absolute;
167 /* On the fly control variable */
168 bool b_spu_update;
170 /* */
171 bool b_mouse_grab;
174 static const char *const ppsz_filter_options[] = {
175 "file", "x", "y", "delay", "repeat", "opacity", "position", NULL
178 static const char *const ppsz_filter_callbacks[] = {
179 "logo-file",
180 "logo-x",
181 "logo-y",
182 "logo-position",
183 "logo-opacity",
184 "logo-repeat",
185 NULL
188 static int OpenCommon( vlc_object_t *, bool b_sub );
190 static subpicture_t *FilterSub( filter_t *, mtime_t );
191 static picture_t *FilterVideo( filter_t *, picture_t * );
193 static int Mouse( filter_t *, vlc_mouse_t *, const vlc_mouse_t *, const vlc_mouse_t * );
195 static int LogoCallback( vlc_object_t *, char const *,
196 vlc_value_t, vlc_value_t, void * );
198 static void LogoListLoad( vlc_object_t *, logo_list_t *, const char * );
199 static void LogoListUnload( logo_list_t * );
200 static logo_t *LogoListNext( logo_list_t *p_list, mtime_t i_date );
201 static logo_t *LogoListCurrent( logo_list_t *p_list );
204 * Open the sub source
206 static int OpenSub( vlc_object_t *p_this )
208 return OpenCommon( p_this, true );
212 * Open the video filter
214 static int OpenVideo( vlc_object_t *p_this )
216 return OpenCommon( p_this, false );
220 * Common open function
222 static int OpenCommon( vlc_object_t *p_this, bool b_sub )
224 filter_t *p_filter = (filter_t *)p_this;
225 filter_sys_t *p_sys;
226 char *psz_filename;
228 /* */
229 if( !b_sub && !es_format_IsSimilar( &p_filter->fmt_in, &p_filter->fmt_out ) )
231 msg_Err( p_filter, "Input and output format does not match" );
232 return VLC_EGENERIC;
235 /* */
236 p_filter->p_sys = p_sys = malloc( sizeof( *p_sys ) );
237 if( !p_sys )
238 return VLC_ENOMEM;
240 /* */
241 p_sys->p_blend = NULL;
242 if( !b_sub )
245 p_sys->p_blend = filter_NewBlend( VLC_OBJECT(p_filter),
246 &p_filter->fmt_in.video );
247 if( !p_sys->p_blend )
249 free( p_sys );
250 return VLC_EGENERIC;
254 /* */
255 config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
256 p_filter->p_cfg );
258 /* */
259 logo_list_t *p_list = &p_sys->list;
261 psz_filename = var_CreateGetStringCommand( p_filter, "logo-file" );
262 if( !psz_filename )
264 if( p_sys->p_blend )
265 filter_DeleteBlend( p_sys->p_blend );
266 free( p_sys );
267 return VLC_ENOMEM;
269 if( *psz_filename == '\0' )
270 msg_Warn( p_this, "no logo file specified" );
272 p_list->i_alpha = var_CreateGetIntegerCommand( p_filter, "logo-opacity");
273 p_list->i_alpha = VLC_CLIP( p_list->i_alpha, 0, 255 );
274 p_list->i_delay = var_CreateGetIntegerCommand( p_filter, "logo-delay" );
275 p_list->i_repeat = var_CreateGetIntegerCommand( p_filter, "logo-repeat" );
277 p_sys->i_pos = var_CreateGetIntegerCommand( p_filter, "logo-position" );
278 p_sys->i_pos_x = var_CreateGetIntegerCommand( p_filter, "logo-x" );
279 p_sys->i_pos_y = var_CreateGetIntegerCommand( p_filter, "logo-y" );
280 p_sys->b_absolute = (p_sys->i_pos < 0);
282 /* Ignore aligment if a position is given for video filter */
283 if( !b_sub && p_sys->i_pos_x >= 0 && p_sys->i_pos_y >= 0 )
284 p_sys->i_pos = 0;
286 vlc_mutex_init( &p_sys->lock );
287 LogoListLoad( p_this, p_list, psz_filename );
288 p_sys->b_spu_update = true;
289 p_sys->b_mouse_grab = false;
291 for( int i = 0; ppsz_filter_callbacks[i]; i++ )
292 var_AddCallback( p_filter, ppsz_filter_callbacks[i],
293 LogoCallback, p_sys );
295 /* Misc init */
296 if( b_sub )
298 p_filter->pf_sub_source = FilterSub;
300 else
302 p_filter->pf_video_filter = FilterVideo;
303 p_filter->pf_video_mouse = Mouse;
306 free( psz_filename );
307 return VLC_SUCCESS;
311 * Common close function
313 static void Close( vlc_object_t *p_this )
315 filter_t *p_filter = (filter_t *)p_this;
316 filter_sys_t *p_sys = p_filter->p_sys;
318 for( int i = 0; ppsz_filter_callbacks[i]; i++ )
319 var_DelCallback( p_filter, ppsz_filter_callbacks[i],
320 LogoCallback, p_sys );
322 if( p_sys->p_blend )
323 filter_DeleteBlend( p_sys->p_blend );
325 vlc_mutex_destroy( &p_sys->lock );
326 LogoListUnload( &p_sys->list );
327 free( p_sys );
331 * Sub source
333 static subpicture_t *FilterSub( filter_t *p_filter, mtime_t date )
335 filter_sys_t *p_sys = p_filter->p_sys;
336 logo_list_t *p_list = &p_sys->list;
338 subpicture_t *p_spu;
339 subpicture_region_t *p_region;
340 video_format_t fmt;
341 picture_t *p_pic;
342 logo_t *p_logo;
344 vlc_mutex_lock( &p_sys->lock );
345 /* Basic test: b_spu_update occurs on a dynamic change,
346 & i_next_pic is the general timer, when to
347 look at updating the logo image */
349 if( ( !p_sys->b_spu_update && p_list->i_next_pic > date ) ||
350 !p_list->i_repeat )
352 vlc_mutex_unlock( &p_sys->lock );
353 return NULL;
356 /* adjust index to the next logo */
357 p_logo = LogoListNext( p_list, date );
358 p_sys->b_spu_update = false;
360 p_pic = p_logo->p_pic;
362 /* Allocate the subpicture internal data. */
363 p_spu = filter_NewSubpicture( p_filter );
364 if( !p_spu )
365 goto exit;
367 p_spu->b_absolute = p_sys->b_absolute;
368 p_spu->i_start = date;
369 p_spu->i_stop = 0;
370 p_spu->b_ephemer = true;
372 /* Send an empty subpicture to clear the display when needed */
373 if( p_list->i_repeat != -1 && p_list->i_counter == 0 )
375 p_list->i_repeat--;
376 if( p_list->i_repeat < 0 )
377 goto exit;
379 if( !p_pic || !p_logo->i_alpha ||
380 ( p_logo->i_alpha == -1 && !p_list->i_alpha ) )
381 goto exit;
383 /* Create new SPU region */
384 memset( &fmt, 0, sizeof(video_format_t) );
385 fmt.i_chroma = VLC_CODEC_YUVA;
386 fmt.i_sar_num = fmt.i_sar_den = 1;
387 fmt.i_width = fmt.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
388 fmt.i_height = fmt.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
389 fmt.i_x_offset = fmt.i_y_offset = 0;
390 p_region = subpicture_region_New( &fmt );
391 if( !p_region )
393 msg_Err( p_filter, "cannot allocate SPU region" );
394 subpicture_Delete( p_spu );
395 p_spu = NULL;
396 goto exit;
399 /* */
400 picture_Copy( p_region->p_picture, p_pic );
402 /* where to locate the logo: */
403 if( p_sys->i_pos < 0 )
404 { /* set to an absolute xy */
405 p_region->i_align = SUBPICTURE_ALIGN_RIGHT | SUBPICTURE_ALIGN_TOP;
406 p_spu->b_absolute = true;
408 else
409 { /* set to one of the 9 relative locations */
410 p_region->i_align = p_sys->i_pos;
411 p_spu->b_absolute = false;
414 p_region->i_x = p_sys->i_pos_x > 0 ? p_sys->i_pos_x : 0;
415 p_region->i_y = p_sys->i_pos_y > 0 ? p_sys->i_pos_y : 0;
417 p_spu->p_region = p_region;
419 p_spu->i_alpha = ( p_logo->i_alpha != -1 ?
420 p_logo->i_alpha : p_list->i_alpha );
422 exit:
423 vlc_mutex_unlock( &p_sys->lock );
425 return p_spu;
429 * Video filter
431 static picture_t *FilterVideo( filter_t *p_filter, picture_t *p_src )
433 filter_sys_t *p_sys = p_filter->p_sys;
434 logo_list_t *p_list = &p_sys->list;
436 picture_t *p_dst = filter_NewPicture( p_filter );
437 if( !p_dst )
438 goto exit;
440 picture_Copy( p_dst, p_src );
442 /* */
443 vlc_mutex_lock( &p_sys->lock );
445 logo_t *p_logo;
446 if( p_list->i_next_pic < p_src->date )
447 p_logo = LogoListNext( p_list, p_src->date );
448 else
449 p_logo = LogoListCurrent( p_list );
451 /* */
452 const picture_t *p_pic = p_logo->p_pic;
453 if( p_pic )
455 const video_format_t *p_fmt = &p_pic->format;
456 const int i_dst_w = p_filter->fmt_out.video.i_visible_width;
457 const int i_dst_h = p_filter->fmt_out.video.i_visible_height;
459 if( p_sys->i_pos )
461 if( p_sys->i_pos & SUBPICTURE_ALIGN_BOTTOM )
463 p_sys->i_pos_y = i_dst_h - p_fmt->i_visible_height;
465 else if ( !(p_sys->i_pos & SUBPICTURE_ALIGN_TOP) )
467 p_sys->i_pos_y = ( i_dst_h - p_fmt->i_visible_height ) / 2;
469 else
471 p_sys->i_pos_y = 0;
474 if( p_sys->i_pos & SUBPICTURE_ALIGN_RIGHT )
476 p_sys->i_pos_x = i_dst_w - p_fmt->i_visible_width;
478 else if ( !(p_sys->i_pos & SUBPICTURE_ALIGN_LEFT) )
480 p_sys->i_pos_x = ( i_dst_w - p_fmt->i_visible_width ) / 2;
482 else
484 p_sys->i_pos_x = 0;
488 if( p_sys->i_pos_x < 0 || p_sys->i_pos_y < 0 )
490 msg_Warn( p_filter,
491 "logo(%ix%i) doesn't fit into video(%ix%i)",
492 p_fmt->i_visible_width, p_fmt->i_visible_height,
493 i_dst_w,i_dst_h );
494 p_sys->i_pos_x = (p_sys->i_pos_x > 0) ? p_sys->i_pos_x : 0;
495 p_sys->i_pos_y = (p_sys->i_pos_y > 0) ? p_sys->i_pos_y : 0;
498 /* */
499 const int i_alpha = p_logo->i_alpha != -1 ? p_logo->i_alpha : p_list->i_alpha;
500 if( filter_ConfigureBlend( p_sys->p_blend, i_dst_w, i_dst_h, p_fmt ) ||
501 filter_Blend( p_sys->p_blend, p_dst, p_sys->i_pos_x, p_sys->i_pos_y,
502 p_pic, i_alpha ) )
504 msg_Err( p_filter, "failed to blend a picture" );
507 vlc_mutex_unlock( &p_sys->lock );
509 exit:
510 picture_Release( p_src );
511 return p_dst;
514 static int Mouse( filter_t *p_filter, vlc_mouse_t *p_mouse,
515 const vlc_mouse_t *p_old, const vlc_mouse_t *p_new )
517 filter_sys_t *p_sys = p_filter->p_sys;
519 vlc_mutex_lock( &p_sys->lock );
520 logo_t *p_logo = LogoListCurrent( &p_sys->list );
521 const picture_t *p_pic = p_logo->p_pic;
523 if( p_pic )
525 const video_format_t *p_fmt = &p_pic->format;
526 const int i_logo_w = p_fmt->i_visible_width;
527 const int i_logo_h = p_fmt->i_visible_height;
529 /* Check if we are over the logo */
530 const bool b_over = p_new->i_x >= p_sys->i_pos_x &&
531 p_new->i_x < p_sys->i_pos_x + i_logo_w &&
532 p_new->i_y >= p_sys->i_pos_y &&
533 p_new->i_y < p_sys->i_pos_y + i_logo_h;
535 if( b_over && vlc_mouse_HasPressed( p_old, p_new, MOUSE_BUTTON_LEFT ) )
536 p_sys->b_mouse_grab = true;
537 else if( vlc_mouse_HasReleased( p_old, p_new, MOUSE_BUTTON_LEFT ) )
538 p_sys->b_mouse_grab = false;
540 if( p_sys->b_mouse_grab )
542 int i_dx, i_dy;
543 vlc_mouse_GetMotion( &i_dx, &i_dy, p_old, p_new );
544 p_sys->i_pos_x = VLC_CLIP( p_sys->i_pos_x + i_dx, 0,
545 p_filter->fmt_in.video.i_width - i_logo_w );
546 p_sys->i_pos_y = VLC_CLIP( p_sys->i_pos_y + i_dy, 0,
547 p_filter->fmt_in.video.i_height - i_logo_h );
550 if( p_sys->b_mouse_grab || b_over )
552 vlc_mutex_unlock( &p_sys->lock );
553 return VLC_EGENERIC;
556 vlc_mutex_unlock( &p_sys->lock );
558 *p_mouse = *p_new;
559 return VLC_SUCCESS;
562 /*****************************************************************************
563 * Callback to update params on the fly
564 *****************************************************************************/
565 static int LogoCallback( vlc_object_t *p_this, char const *psz_var,
566 vlc_value_t oldval, vlc_value_t newval, void *p_data )
568 VLC_UNUSED(oldval);
569 filter_sys_t *p_sys = (filter_sys_t *)p_data;
570 logo_list_t *p_list = &p_sys->list;
572 vlc_mutex_lock( &p_sys->lock );
573 if( !strcmp( psz_var, "logo-file" ) )
575 LogoListUnload( p_list );
576 LogoListLoad( p_this, p_list, newval.psz_string );
578 else if ( !strcmp( psz_var, "logo-x" ) )
580 p_sys->i_pos_x = newval.i_int;
582 else if ( !strcmp( psz_var, "logo-y" ) )
584 p_sys->i_pos_y = newval.i_int;
586 else if ( !strcmp( psz_var, "logo-position" ) )
588 p_sys->i_pos = newval.i_int;
590 else if ( !strcmp( psz_var, "logo-opacity" ) )
592 p_list->i_alpha = VLC_CLIP( newval.i_int, 0, 255 );
594 else if ( !strcmp( psz_var, "logo-repeat" ) )
596 p_list->i_repeat = newval.i_int;
598 p_sys->b_spu_update = true;
599 vlc_mutex_unlock( &p_sys->lock );
601 return VLC_SUCCESS;
605 * It loads the logo image into memory.
607 static picture_t *LoadImage( vlc_object_t *p_this, const char *psz_filename )
609 if( !psz_filename )
610 return NULL;
612 video_format_t fmt_in;
613 video_format_Init( &fmt_in, 0 );
615 video_format_t fmt_out;
616 video_format_Init( &fmt_out, VLC_CODEC_YUVA );
618 image_handler_t *p_image = image_HandlerCreate( p_this );
619 if( !p_image )
620 return NULL;
622 char *psz_url = vlc_path2uri( psz_filename, NULL );
623 picture_t *p_pic = image_ReadUrl( p_image, psz_url, &fmt_in, &fmt_out );
624 free( psz_url );
625 image_HandlerDelete( p_image );
627 return p_pic;
631 * It loads the logo images into memory.
633 * Read the logo-file input switch, obtaining a list of images and
634 * associated durations and transparencies. Store the image(s), and
635 * times. An image without a stated time or opacity will use the
636 * logo-delay and logo-opacity values.
638 static void LogoListLoad( vlc_object_t *p_this, logo_list_t *p_logo_list,
639 const char *psz_filename )
641 char *psz_list; /* the list: <logo>[,[<delay>[,[<alpha>]]]][;...] */
642 char *psz_original;
643 logo_t *p_logo; /* the parsing's result */
645 p_logo_list->i_counter = 0;
646 p_logo_list->i_next_pic = 0;
648 psz_original = psz_list = strdup( psz_filename );
650 if( !psz_list )
651 return;
653 /* Count the number logos == number of ';' + 1 */
654 p_logo_list->i_count = 1;
655 for( unsigned i = 0; i < strlen( psz_list ); i++ )
657 if( psz_list[i] == ';' )
658 p_logo_list->i_count++;
661 p_logo_list->p_logo =
662 p_logo = calloc( p_logo_list->i_count, sizeof(*p_logo) );
664 if( !p_logo )
666 free( psz_list );
667 return;
670 /* Fill the data */
671 for( unsigned i = 0; i < p_logo_list->i_count; i++ )
673 char *p_c = strchr( psz_list, ';' );
674 char *p_c2 = strchr( psz_list, ',' );
676 p_logo[i].i_alpha = -1; /* use default settings */
677 p_logo[i].i_delay = -1; /* use default settings */
679 if( p_c2 && ( p_c2 < p_c || !p_c ) )
681 /* <logo>,<delay>[,<alpha>] type */
682 if( p_c2[1] != ',' && p_c2[1] != ';' && p_c2[1] != '\0' )
683 p_logo[i].i_delay = atoi( p_c2+1 );
684 *p_c2 = '\0';
685 if( ( p_c2 = strchr( p_c2+1, ',' ) )
686 && ( p_c2 < p_c || !p_c ) && p_c2[1] != ';' && p_c2[1] != '\0' )
687 p_logo[i].i_alpha = atoi( p_c2 + 1 );
689 else
691 /* <logo> type */
692 if( p_c )
693 *p_c = '\0';
696 msg_Dbg( p_this, "logo file name %s, delay %d, alpha %d",
697 psz_list, p_logo[i].i_delay, p_logo[i].i_alpha );
698 p_logo[i].p_pic = LoadImage( p_this, psz_list );
699 if( !p_logo[i].p_pic )
701 msg_Warn( p_this, "error while loading logo %s, will be skipped",
702 psz_list );
705 if( p_c )
706 psz_list = &p_c[1];
709 /* initialize so that on the first update it will wrap back to 0 */
710 p_logo_list->i_counter = p_logo_list->i_count - 1;
712 free( psz_original );
716 * Unload a list of logo and release associated ressources.
718 static void LogoListUnload( logo_list_t *p_list )
720 for( unsigned i = 0; i < p_list->i_count; i++ )
722 logo_t *p_logo = &p_list->p_logo[i];
724 if( p_logo->p_pic )
725 picture_Release( p_logo->p_pic );
727 free( p_list->p_logo );
731 * Go to the next logo and return its pointer.
733 static logo_t *LogoListNext( logo_list_t *p_list, mtime_t i_date )
735 p_list->i_counter = ( p_list->i_counter + 1 ) % p_list->i_count;
737 logo_t *p_logo = LogoListCurrent( p_list );
739 p_list->i_next_pic = i_date + ( p_logo->i_delay != -1 ?
740 p_logo->i_delay : p_list->i_delay ) * 1000;
741 return p_logo;
744 * Return the current logo pointer
746 static logo_t *LogoListCurrent( logo_list_t *p_list )
748 return &p_list->p_logo[p_list->i_counter];