1 /*****************************************************************************
2 * video_output.c : video output thread
4 * This module describes the programming interface for video output threads.
5 * It includes functions allowing to open a new thread, send pictures to a
6 * thread, and destroy a previously oppened video output thread.
7 *****************************************************************************
8 * Copyright (C) 2000-2007 VLC authors and VideoLAN
11 * Authors: Vincent Seguin <seguin@via.ecp.fr>
12 * Gildas Bazin <gbazin@videolan.org>
13 * Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU Lesser General Public License as published by
17 * the Free Software Foundation; either version 2.1 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with this program; if not, write to the Free Software Foundation,
27 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
28 *****************************************************************************/
30 /*****************************************************************************
32 *****************************************************************************/
37 #include <vlc_common.h>
39 #include <stdlib.h> /* free() */
45 #include <vlc_filter.h>
46 #include <vlc_vout_osd.h>
47 #include <vlc_image.h>
50 #include "vout_internal.h"
51 #include "interlacing.h"
54 /*****************************************************************************
56 *****************************************************************************/
57 static void *Thread(void *);
58 static void VoutDestructor(vlc_object_t *);
60 /* Maximum delay between 2 displayed pictures.
61 * XXX it is needed for now but should be removed in the long term.
63 #define VOUT_REDISPLAY_DELAY (INT64_C(80000))
66 * Late pictures having a delay higher than this value are thrashed.
68 #define VOUT_DISPLAY_LATE_THRESHOLD (INT64_C(20000))
70 /* Better be in advance when awakening than late... */
71 #define VOUT_MWAIT_TOLERANCE (INT64_C(4000))
74 static int VoutValidateFormat(video_format_t *dst,
75 const video_format_t *src)
77 if (src->i_width <= 0 || src->i_width > 8192 ||
78 src->i_height <= 0 || src->i_height > 8192)
80 if (src->i_sar_num <= 0 || src->i_sar_den <= 0)
84 video_format_Copy(dst, src);
85 dst->i_chroma = vlc_fourcc_GetCodec(VIDEO_ES, src->i_chroma);
86 vlc_ureduce( &dst->i_sar_num, &dst->i_sar_den,
87 src->i_sar_num, src->i_sar_den, 50000 );
88 if (dst->i_sar_num <= 0 || dst->i_sar_den <= 0) {
92 video_format_FixRgb(dst);
95 static void VideoFormatCopyCropAr(video_format_t *dst,
96 const video_format_t *src)
98 video_format_CopyCrop(dst, src);
99 dst->i_sar_num = src->i_sar_num;
100 dst->i_sar_den = src->i_sar_den;
102 static bool VideoFormatIsCropArEqual(video_format_t *dst,
103 const video_format_t *src)
105 return dst->i_sar_num * src->i_sar_den == dst->i_sar_den * src->i_sar_num &&
106 dst->i_x_offset == src->i_x_offset &&
107 dst->i_y_offset == src->i_y_offset &&
108 dst->i_visible_width == src->i_visible_width &&
109 dst->i_visible_height == src->i_visible_height;
112 static vout_thread_t *VoutCreate(vlc_object_t *object,
113 const vout_configuration_t *cfg)
115 video_format_t original;
116 if (VoutValidateFormat(&original, cfg->fmt))
119 /* Allocate descriptor */
120 vout_thread_t *vout = vlc_custom_create(object,
121 sizeof(*vout) + sizeof(*vout->p),
124 video_format_Clean(&original);
129 vout->p = (vout_thread_sys_t*)&vout[1];
131 vout->p->original = original;
132 vout->p->dpb_size = cfg->dpb_size;
134 vout_control_Init(&vout->p->control);
135 vout_control_PushVoid(&vout->p->control, VOUT_CONTROL_INIT);
137 vout_statistic_Init(&vout->p->statistic);
139 vout_snapshot_Init(&vout->p->snapshot);
141 /* Initialize locks */
142 vlc_mutex_init(&vout->p->picture_lock);
143 vlc_mutex_init(&vout->p->filter.lock);
144 vlc_mutex_init(&vout->p->spu_lock);
146 /* Initialize subpicture unit */
147 vout->p->spu = spu_Create(vout);
149 /* Take care of some "interface/control" related initialisations */
152 vout->p->title.show = var_InheritBool(vout, "video-title-show");
153 vout->p->title.timeout = var_InheritInteger(vout, "video-title-timeout");
154 vout->p->title.position = var_InheritInteger(vout, "video-title-position");
156 /* Get splitter name if present */
157 char *splitter_name = var_InheritString(vout, "video-splitter");
158 if (splitter_name && *splitter_name) {
159 vout->p->splitter_name = splitter_name;
165 vout_InitInterlacingSupport(vout, vout->p->displayed.is_interlaced);
168 vlc_object_set_destructor(vout, VoutDestructor);
171 if (vlc_clone(&vout->p->thread, Thread, vout,
172 VLC_THREAD_PRIORITY_OUTPUT)) {
173 spu_Destroy(vout->p->spu);
174 vlc_object_release(vout);
178 vout_control_WaitEmpty(&vout->p->control);
181 msg_Err(vout, "video output creation failed");
182 vout_CloseAndRelease(vout);
186 vout->p->input = cfg->input;
188 spu_Attach(vout->p->spu, vout->p->input, true);
193 vout_thread_t *(vout_Request)(vlc_object_t *object,
194 const vout_configuration_t *cfg)
196 vout_thread_t *vout = cfg->vout;
197 if (cfg->change_fmt && !cfg->fmt) {
199 vout_CloseAndRelease(vout);
203 /* If a vout is provided, try reusing it */
205 if (vout->p->input != cfg->input) {
207 spu_Attach(vout->p->spu, vout->p->input, false);
208 vout->p->input = cfg->input;
210 spu_Attach(vout->p->spu, vout->p->input, true);
213 if (cfg->change_fmt) {
214 vout_control_cmd_t cmd;
215 vout_control_cmd_Init(&cmd, VOUT_CONTROL_REINIT);
218 vout_control_Push(&vout->p->control, &cmd);
219 vout_control_WaitEmpty(&vout->p->control);
222 if (!vout->p->dead) {
223 msg_Dbg(object, "reusing provided vout");
224 vout_IntfReinit(vout);
227 vout_CloseAndRelease(vout);
229 msg_Warn(object, "cannot reuse provided vout");
231 return VoutCreate(object, cfg);
234 void vout_Close(vout_thread_t *vout)
239 spu_Attach(vout->p->spu, vout->p->input, false);
241 vout_snapshot_End(&vout->p->snapshot);
243 vout_control_PushVoid(&vout->p->control, VOUT_CONTROL_CLEAN);
244 vlc_join(vout->p->thread, NULL);
246 vlc_mutex_lock(&vout->p->spu_lock);
247 spu_Destroy(vout->p->spu);
249 vlc_mutex_unlock(&vout->p->spu_lock);
253 static void VoutDestructor(vlc_object_t *object)
255 vout_thread_t *vout = (vout_thread_t *)object;
257 /* Make sure the vout was stopped first */
258 //assert(!vout->p_module);
260 free(vout->p->splitter_name);
262 /* Destroy the locks */
263 vlc_mutex_destroy(&vout->p->spu_lock);
264 vlc_mutex_destroy(&vout->p->picture_lock);
265 vlc_mutex_destroy(&vout->p->filter.lock);
266 vout_control_Clean(&vout->p->control);
269 vout_statistic_Clean(&vout->p->statistic);
272 vout_snapshot_Clean(&vout->p->snapshot);
274 video_format_Clean(&vout->p->original);
278 void vout_ChangePause(vout_thread_t *vout, bool is_paused, mtime_t date)
280 vout_control_cmd_t cmd;
281 vout_control_cmd_Init(&cmd, VOUT_CONTROL_PAUSE);
282 cmd.u.pause.is_on = is_paused;
283 cmd.u.pause.date = date;
284 vout_control_Push(&vout->p->control, &cmd);
286 vout_control_WaitEmpty(&vout->p->control);
289 void vout_GetResetStatistic(vout_thread_t *vout, int *displayed, int *lost)
291 vout_statistic_GetReset( &vout->p->statistic, displayed, lost );
294 void vout_Flush(vout_thread_t *vout, mtime_t date)
296 vout_control_PushTime(&vout->p->control, VOUT_CONTROL_FLUSH, date);
297 vout_control_WaitEmpty(&vout->p->control);
300 void vout_Reset(vout_thread_t *vout)
302 vout_control_PushVoid(&vout->p->control, VOUT_CONTROL_RESET);
303 vout_control_WaitEmpty(&vout->p->control);
306 bool vout_IsEmpty(vout_thread_t *vout)
308 vlc_mutex_lock(&vout->p->picture_lock);
310 picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
312 picture_Release(picture);
314 vlc_mutex_unlock(&vout->p->picture_lock);
319 void vout_FixLeaks( vout_thread_t *vout )
321 vlc_mutex_lock(&vout->p->picture_lock);
323 picture_t *picture = picture_fifo_Peek(vout->p->decoder_fifo);
325 picture = picture_pool_Get(vout->p->decoder_pool);
329 picture_Release(picture);
330 /* Not all pictures has been displayed yet or some are
332 vlc_mutex_unlock(&vout->p->picture_lock);
336 /* There is no reason that no pictures are available, force one
337 * from the pool, becarefull with it though */
338 msg_Err(vout, "pictures leaked, trying to workaround");
341 picture_pool_NonEmpty(vout->p->decoder_pool, false);
343 vlc_mutex_unlock(&vout->p->picture_lock);
345 void vout_NextPicture(vout_thread_t *vout, mtime_t *duration)
347 vout_control_cmd_t cmd;
348 vout_control_cmd_Init(&cmd, VOUT_CONTROL_STEP);
349 cmd.u.time_ptr = duration;
351 vout_control_Push(&vout->p->control, &cmd);
352 vout_control_WaitEmpty(&vout->p->control);
355 void vout_DisplayTitle(vout_thread_t *vout, const char *title)
358 vout_control_PushString(&vout->p->control, VOUT_CONTROL_OSD_TITLE, title);
361 void vout_PutSubpicture( vout_thread_t *vout, subpicture_t *subpic )
363 vout_control_cmd_t cmd;
364 vout_control_cmd_Init(&cmd, VOUT_CONTROL_SUBPICTURE);
365 cmd.u.subpicture = subpic;
367 vout_control_Push(&vout->p->control, &cmd);
369 int vout_RegisterSubpictureChannel( vout_thread_t *vout )
371 int channel = SPU_DEFAULT_CHANNEL;
373 vlc_mutex_lock(&vout->p->spu_lock);
375 channel = spu_RegisterChannel(vout->p->spu);
376 vlc_mutex_unlock(&vout->p->spu_lock);
380 void vout_FlushSubpictureChannel( vout_thread_t *vout, int channel )
382 vout_control_PushInteger(&vout->p->control, VOUT_CONTROL_FLUSH_SUBPICTURE,
387 * It retreives a picture from the vout or NULL if no pictures are
390 * You MUST call vout_PutPicture or vout_ReleasePicture on it.
392 * You may use vout_HoldPicture(paired with vout_ReleasePicture) to keep a
393 * read-only reference.
395 picture_t *vout_GetPicture(vout_thread_t *vout)
398 vlc_mutex_lock(&vout->p->picture_lock);
399 picture_t *picture = picture_pool_Get(vout->p->decoder_pool);
401 picture_Reset(picture);
402 VideoFormatCopyCropAr(&picture->format, &vout->p->original);
404 vlc_mutex_unlock(&vout->p->picture_lock);
410 * It gives to the vout a picture to be displayed.
412 * The given picture MUST comes from vout_GetPicture.
414 * Becareful, after vout_PutPicture is called, picture_t::p_next cannot be
417 void vout_PutPicture(vout_thread_t *vout, picture_t *picture)
419 vlc_mutex_lock(&vout->p->picture_lock);
421 picture->p_next = NULL;
422 picture_fifo_Push(vout->p->decoder_fifo, picture);
424 vlc_mutex_unlock(&vout->p->picture_lock);
426 vout_control_Wake(&vout->p->control);
430 * It releases a picture retreived by vout_GetPicture.
432 void vout_ReleasePicture(vout_thread_t *vout, picture_t *picture)
434 vlc_mutex_lock(&vout->p->picture_lock);
436 picture_Release(picture);
438 vlc_mutex_unlock(&vout->p->picture_lock);
440 vout_control_Wake(&vout->p->control);
444 * It increment the reference counter of a picture retreived by
447 void vout_HoldPicture(vout_thread_t *vout, picture_t *picture)
449 vlc_mutex_lock(&vout->p->picture_lock);
451 picture_Hold(picture);
453 vlc_mutex_unlock(&vout->p->picture_lock);
457 int vout_GetSnapshot(vout_thread_t *vout,
458 block_t **image_dst, picture_t **picture_dst,
460 const char *type, mtime_t timeout)
462 picture_t *picture = vout_snapshot_Get(&vout->p->snapshot, timeout);
464 msg_Err(vout, "Failed to grab a snapshot");
469 vlc_fourcc_t codec = VLC_CODEC_PNG;
470 if (type && image_Type2Fourcc(type))
471 codec = image_Type2Fourcc(type);
473 const int override_width = var_InheritInteger(vout, "snapshot-width");
474 const int override_height = var_InheritInteger(vout, "snapshot-height");
476 if (picture_Export(VLC_OBJECT(vout), image_dst, fmt,
477 picture, codec, override_width, override_height)) {
478 msg_Err(vout, "Failed to convert image for snapshot");
479 picture_Release(picture);
484 *picture_dst = picture;
486 picture_Release(picture);
490 /* vout_Control* are usable by anyone at anytime */
491 void vout_ControlChangeFullscreen(vout_thread_t *vout, bool fullscreen)
493 vout_control_PushBool(&vout->p->control, VOUT_CONTROL_FULLSCREEN,
496 void vout_ControlChangeOnTop(vout_thread_t *vout, bool is_on_top)
498 vout_control_PushBool(&vout->p->control, VOUT_CONTROL_ON_TOP,
501 void vout_ControlChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
503 vout_control_PushBool(&vout->p->control, VOUT_CONTROL_DISPLAY_FILLED,
506 void vout_ControlChangeZoom(vout_thread_t *vout, int num, int den)
508 vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ZOOM,
511 void vout_ControlChangeSampleAspectRatio(vout_thread_t *vout,
512 unsigned num, unsigned den)
514 vout_control_PushPair(&vout->p->control, VOUT_CONTROL_ASPECT_RATIO,
517 void vout_ControlChangeCropRatio(vout_thread_t *vout,
518 unsigned num, unsigned den)
520 vout_control_PushPair(&vout->p->control, VOUT_CONTROL_CROP_RATIO,
523 void vout_ControlChangeCropWindow(vout_thread_t *vout,
524 int x, int y, int width, int height)
526 vout_control_cmd_t cmd;
527 vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_WINDOW);
528 cmd.u.window.x = __MAX(x, 0);
529 cmd.u.window.y = __MAX(y, 0);
530 cmd.u.window.width = __MAX(width, 0);
531 cmd.u.window.height = __MAX(height, 0);
533 vout_control_Push(&vout->p->control, &cmd);
535 void vout_ControlChangeCropBorder(vout_thread_t *vout,
536 int left, int top, int right, int bottom)
538 vout_control_cmd_t cmd;
539 vout_control_cmd_Init(&cmd, VOUT_CONTROL_CROP_BORDER);
540 cmd.u.border.left = __MAX(left, 0);
541 cmd.u.border.top = __MAX(top, 0);
542 cmd.u.border.right = __MAX(right, 0);
543 cmd.u.border.bottom = __MAX(bottom, 0);
545 vout_control_Push(&vout->p->control, &cmd);
547 void vout_ControlChangeFilters(vout_thread_t *vout, const char *filters)
549 vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_FILTERS,
552 void vout_ControlChangeSubSources(vout_thread_t *vout, const char *filters)
554 vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_SUB_SOURCES,
557 void vout_ControlChangeSubFilters(vout_thread_t *vout, const char *filters)
559 vout_control_PushString(&vout->p->control, VOUT_CONTROL_CHANGE_SUB_FILTERS,
562 void vout_ControlChangeSubMargin(vout_thread_t *vout, int margin)
564 vout_control_PushInteger(&vout->p->control, VOUT_CONTROL_CHANGE_SUB_MARGIN,
569 static void VoutGetDisplayCfg(vout_thread_t *vout, vout_display_cfg_t *cfg, const char *title)
571 /* Load configuration */
572 cfg->is_fullscreen = var_CreateGetBool(vout, "fullscreen");
573 cfg->display.title = title;
574 const int display_width = var_CreateGetInteger(vout, "width");
575 const int display_height = var_CreateGetInteger(vout, "height");
576 cfg->display.width = display_width > 0 ? display_width : 0;
577 cfg->display.height = display_height > 0 ? display_height : 0;
578 cfg->is_display_filled = var_CreateGetBool(vout, "autoscale");
579 unsigned msar_num, msar_den;
580 if (var_InheritURational(vout, &msar_num, &msar_den, "monitor-par") ||
581 msar_num <= 0 || msar_den <= 0) {
585 cfg->display.sar.num = msar_num;
586 cfg->display.sar.den = msar_den;
587 unsigned zoom_den = 1000;
588 unsigned zoom_num = zoom_den * var_CreateGetFloat(vout, "scale");
589 vlc_ureduce(&zoom_num, &zoom_den, zoom_num, zoom_den, 0);
590 cfg->zoom.num = zoom_num;
591 cfg->zoom.den = zoom_den;
592 cfg->align.vertical = VOUT_DISPLAY_ALIGN_CENTER;
593 cfg->align.horizontal = VOUT_DISPLAY_ALIGN_CENTER;
594 const int align_mask = var_CreateGetInteger(vout, "align");
595 if (align_mask & 0x1)
596 cfg->align.horizontal = VOUT_DISPLAY_ALIGN_LEFT;
597 else if (align_mask & 0x2)
598 cfg->align.horizontal = VOUT_DISPLAY_ALIGN_RIGHT;
599 if (align_mask & 0x4)
600 cfg->align.vertical = VOUT_DISPLAY_ALIGN_TOP;
601 else if (align_mask & 0x8)
602 cfg->align.vertical = VOUT_DISPLAY_ALIGN_BOTTOM;
605 vout_window_t * vout_NewDisplayWindow(vout_thread_t *vout, vout_display_t *vd,
606 const vout_window_cfg_t *cfg)
609 vout_window_cfg_t cfg_override = *cfg;
611 if (!var_InheritBool( vout, "embedded-video"))
612 cfg_override.is_standalone = true;
614 if (vout->p->window.is_unused && vout->p->window.object) {
615 assert(!vout->p->splitter_name);
616 if (!cfg_override.is_standalone == !vout->p->window.cfg.is_standalone &&
617 cfg_override.type == vout->p->window.cfg.type) {
618 /* Reuse the stored window */
619 msg_Dbg(vout, "Reusing previous vout window");
620 vout_window_t *window = vout->p->window.object;
621 if (cfg_override.width != vout->p->window.cfg.width ||
622 cfg_override.height != vout->p->window.cfg.height)
623 vout_window_SetSize(window,
624 cfg_override.width, cfg_override.height);
625 vout->p->window.is_unused = false;
626 vout->p->window.cfg = cfg_override;
630 vout_window_Delete(vout->p->window.object);
631 vout->p->window.is_unused = true;
632 vout->p->window.object = NULL;
635 vout_window_t *window = vout_window_New(VLC_OBJECT(vout), "$window",
639 if (!vout->p->splitter_name) {
640 vout->p->window.is_unused = false;
641 vout->p->window.cfg = cfg_override;
642 vout->p->window.object = window;
647 void vout_DeleteDisplayWindow(vout_thread_t *vout, vout_display_t *vd,
648 vout_window_t *window)
651 if (!vout->p->window.is_unused && vout->p->window.object == window) {
652 vout->p->window.is_unused = true;
653 } else if (vout->p->window.is_unused && vout->p->window.object && !window) {
654 vout_window_Delete(vout->p->window.object);
655 vout->p->window.is_unused = true;
656 vout->p->window.object = NULL;
658 vout_window_Delete(window);
663 static picture_t *VoutVideoFilterInteractiveNewPicture(filter_t *filter)
665 vout_thread_t *vout = (vout_thread_t*)filter->p_owner;
667 picture_t *picture = picture_pool_Get(vout->p->private_pool);
669 picture_Reset(picture);
670 VideoFormatCopyCropAr(&picture->format, &filter->fmt_out.video);
674 static picture_t *VoutVideoFilterStaticNewPicture(filter_t *filter)
676 vout_thread_t *vout = (vout_thread_t*)filter->p_owner;
678 vlc_assert_locked(&vout->p->filter.lock);
679 if (filter_chain_GetLength(vout->p->filter.chain_interactive) == 0)
680 return VoutVideoFilterInteractiveNewPicture(filter);
682 return picture_NewFromFormat(&filter->fmt_out.video);
684 static void VoutVideoFilterDelPicture(filter_t *filter, picture_t *picture)
687 picture_Release(picture);
689 static int VoutVideoFilterStaticAllocationSetup(filter_t *filter, void *data)
691 filter->pf_video_buffer_new = VoutVideoFilterStaticNewPicture;
692 filter->pf_video_buffer_del = VoutVideoFilterDelPicture;
693 filter->p_owner = data; /* vout */
696 static int VoutVideoFilterInteractiveAllocationSetup(filter_t *filter, void *data)
698 filter->pf_video_buffer_new = VoutVideoFilterInteractiveNewPicture;
699 filter->pf_video_buffer_del = VoutVideoFilterDelPicture;
700 filter->p_owner = data; /* vout */
703 static void ThreadFilterFlush(vout_thread_t *vout, bool is_locked)
705 if (vout->p->displayed.current)
706 picture_Release( vout->p->displayed.current );
707 vout->p->displayed.current = NULL;
709 if (vout->p->displayed.next)
710 picture_Release( vout->p->displayed.next );
711 vout->p->displayed.next = NULL;
714 vlc_mutex_lock(&vout->p->filter.lock);
715 filter_chain_VideoFlush(vout->p->filter.chain_static);
716 filter_chain_VideoFlush(vout->p->filter.chain_interactive);
718 vlc_mutex_unlock(&vout->p->filter.lock);
726 static void ThreadChangeFilters(vout_thread_t *vout,
727 const video_format_t *source,
731 ThreadFilterFlush(vout, is_locked);
733 vlc_array_t array_static;
734 vlc_array_t array_interactive;
736 vlc_array_init(&array_static);
737 vlc_array_init(&array_interactive);
738 char *current = filters ? strdup(filters) : NULL;
742 char *next = config_ChainCreate(&name, &cfg, current);
745 vout_filter_t *e = xmalloc(sizeof(*e));
748 if (!strcmp(e->name, "deinterlace") ||
749 !strcmp(e->name, "postproc")) {
750 vlc_array_append(&array_static, e);
752 vlc_array_append(&array_interactive, e);
756 config_ChainDestroy(cfg);
764 vlc_mutex_lock(&vout->p->filter.lock);
766 es_format_t fmt_target;
767 es_format_InitFromVideo(&fmt_target, source ? source : &vout->p->filter.format);
769 es_format_t fmt_current = fmt_target;
771 for (int a = 0; a < 2; a++) {
772 vlc_array_t *array = a == 0 ? &array_static :
774 filter_chain_t *chain = a == 0 ? vout->p->filter.chain_static :
775 vout->p->filter.chain_interactive;
777 filter_chain_Reset(chain, &fmt_current, &fmt_current);
778 for (int i = 0; i < vlc_array_count(array); i++) {
779 vout_filter_t *e = vlc_array_item_at_index(array, i);
780 msg_Dbg(vout, "Adding '%s' as %s", e->name, a == 0 ? "static" : "interactive");
781 if (!filter_chain_AppendFilter(chain, e->name, e->cfg, NULL, NULL)) {
782 msg_Err(vout, "Failed to add filter '%s'", e->name);
783 config_ChainDestroy(e->cfg);
788 fmt_current = *filter_chain_GetFmtOut(chain);
789 vlc_array_clear(array);
791 VideoFormatCopyCropAr(&fmt_target.video, &fmt_current.video);
792 if (!es_format_IsSimilar(&fmt_current, &fmt_target)) {
793 msg_Dbg(vout, "Adding a filter to compensate for format changes");
794 if (!filter_chain_AppendFilter(vout->p->filter.chain_interactive, NULL, NULL,
795 &fmt_current, &fmt_target)) {
796 msg_Err(vout, "Failed to compensate for the format changes, removing all filters");
797 filter_chain_Reset(vout->p->filter.chain_static, &fmt_target, &fmt_target);
798 filter_chain_Reset(vout->p->filter.chain_interactive, &fmt_target, &fmt_target);
802 if (vout->p->filter.configuration != filters) {
803 free(vout->p->filter.configuration);
804 vout->p->filter.configuration = filters ? strdup(filters) : NULL;
807 video_format_Clean(&vout->p->filter.format);
808 video_format_Copy(&vout->p->filter.format, source);
812 vlc_mutex_unlock(&vout->p->filter.lock);
817 static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse, bool is_late_dropped)
821 vlc_mutex_lock(&vout->p->filter.lock);
823 picture_t *picture = filter_chain_VideoFilter(vout->p->filter.chain_static, NULL);
824 assert(!reuse || !picture);
828 if (reuse && vout->p->displayed.decoded) {
829 decoded = picture_Hold(vout->p->displayed.decoded);
831 decoded = picture_fifo_Pop(vout->p->decoder_fifo);
832 if (is_late_dropped && decoded && !decoded->b_force) {
833 const mtime_t predicted = mdate() + 0; /* TODO improve */
834 const mtime_t late = predicted - decoded->date;
835 if (late > VOUT_DISPLAY_LATE_THRESHOLD) {
836 msg_Warn(vout, "picture is too late to be displayed (missing %d ms)", (int)(late/1000));
837 picture_Release(decoded);
840 } else if (late > 0) {
841 msg_Dbg(vout, "picture might be displayed late (missing %d ms)", (int)(late/1000));
845 !VideoFormatIsCropArEqual(&decoded->format, &vout->p->filter.format))
846 ThreadChangeFilters(vout, &decoded->format, vout->p->filter.configuration, true);
852 if (vout->p->displayed.decoded)
853 picture_Release(vout->p->displayed.decoded);
855 vout->p->displayed.decoded = picture_Hold(decoded);
856 vout->p->displayed.timestamp = decoded->date;
857 vout->p->displayed.is_interlaced = !decoded->b_progressive;
859 picture = filter_chain_VideoFilter(vout->p->filter.chain_static, decoded);
862 vlc_mutex_unlock(&vout->p->filter.lock);
864 vout_statistic_AddLost(&vout->p->statistic, lost_count);
868 assert(!vout->p->displayed.next);
869 if (!vout->p->displayed.current)
870 vout->p->displayed.current = picture;
872 vout->p->displayed.next = picture;
876 static int ThreadDisplayRenderPicture(vout_thread_t *vout, bool is_forced)
878 vout_thread_sys_t *sys = vout->p;
879 vout_display_t *vd = vout->p->display.vd;
881 picture_t *torender = picture_Hold(vout->p->displayed.current);
883 vout_chrono_Start(&vout->p->render);
885 vlc_mutex_lock(&vout->p->filter.lock);
886 picture_t *filtered = filter_chain_VideoFilter(vout->p->filter.chain_interactive, torender);
887 vlc_mutex_unlock(&vout->p->filter.lock);
892 if (filtered->date != vout->p->displayed.current->date)
893 msg_Warn(vout, "Unsupported timestamp modifications done by chain_interactive");
896 * Get the subpicture to be displayed
898 const bool do_snapshot = vout_snapshot_IsRequested(&vout->p->snapshot);
899 mtime_t render_subtitle_date;
900 if (vout->p->pause.is_on)
901 render_subtitle_date = vout->p->pause.date;
903 render_subtitle_date = filtered->date > 1 ? filtered->date : mdate();
904 mtime_t render_osd_date = mdate(); /* FIXME wrong */
907 * Get the subpicture to be displayed
909 const bool do_dr_spu = !do_snapshot &&
910 vd->info.subpicture_chromas &&
911 *vd->info.subpicture_chromas != 0;
912 const bool do_early_spu = !do_dr_spu &&
914 sys->display.use_dr ||
916 !vout_IsDisplayFiltered(vd) ||
917 vd->fmt.i_width * vd->fmt.i_height <= vd->source.i_width * vd->source.i_height);
919 const vlc_fourcc_t *subpicture_chromas;
920 video_format_t fmt_spu;
922 vout_display_place_t place;
923 vout_display_PlacePicture(&place, &vd->source, vd->cfg, false);
925 fmt_spu = vd->source;
926 if (fmt_spu.i_width * fmt_spu.i_height < place.width * place.height) {
927 fmt_spu.i_sar_num = vd->cfg->display.sar.num;
928 fmt_spu.i_sar_den = vd->cfg->display.sar.den;
930 fmt_spu.i_visible_width = place.width;
932 fmt_spu.i_visible_height = place.height;
934 subpicture_chromas = vd->info.subpicture_chromas;
937 fmt_spu = vd->source;
940 fmt_spu.i_sar_num = vd->cfg->display.sar.num;
941 fmt_spu.i_sar_den = vd->cfg->display.sar.den;
943 subpicture_chromas = NULL;
945 if (vout->p->spu_blend &&
946 vout->p->spu_blend->fmt_out.video.i_chroma != fmt_spu.i_chroma) {
947 filter_DeleteBlend(vout->p->spu_blend);
948 vout->p->spu_blend = NULL;
949 vout->p->spu_blend_chroma = 0;
951 if (!vout->p->spu_blend && vout->p->spu_blend_chroma != fmt_spu.i_chroma) {
952 vout->p->spu_blend_chroma = fmt_spu.i_chroma;
953 vout->p->spu_blend = filter_NewBlend(VLC_OBJECT(vout), &fmt_spu);
954 if (!vout->p->spu_blend)
955 msg_Err(vout, "Failed to create blending filter, OSD/Subtitles will not work");
959 subpicture_t *subpic = spu_Render(vout->p->spu,
960 subpicture_chromas, &fmt_spu,
962 render_subtitle_date, render_osd_date,
968 * - be sure to end up with a direct buffer.
969 * - blend subtitles, and in a fast access buffer
971 bool is_direct = vout->p->decoder_pool == vout->p->display_pool;
972 picture_t *todisplay = filtered;
973 if (do_early_spu && subpic) {
974 todisplay = picture_pool_Get(vout->p->private_pool);
976 VideoFormatCopyCropAr(&todisplay->format, &filtered->format);
977 picture_Copy(todisplay, filtered);
978 if (vout->p->spu_blend)
979 picture_BlendSubpicture(todisplay, vout->p->spu_blend, subpic);
981 picture_Release(filtered);
982 subpicture_Delete(subpic);
990 if (!is_direct && todisplay) {
991 direct = picture_pool_Get(vout->p->display_pool);
993 VideoFormatCopyCropAr(&direct->format, &todisplay->format);
994 picture_Copy(direct, todisplay);
996 picture_Release(todisplay);
1003 subpicture_Delete(subpic);
1004 return VLC_EGENERIC;
1008 * Take a snapshot if requested
1011 vout_snapshot_Set(&vout->p->snapshot, &vd->source, direct);
1013 /* Render the direct buffer */
1014 assert(vout_IsDisplayFiltered(vd) == !sys->display.use_dr);
1015 vout_UpdateDisplaySourceProperties(vd, &direct->format);
1016 if (sys->display.use_dr) {
1017 vout_display_Prepare(vd, direct, subpic);
1019 sys->display.filtered = vout_FilterDisplay(vd, direct);
1020 if (sys->display.filtered) {
1021 if (!do_dr_spu && !do_early_spu && vout->p->spu_blend && subpic)
1022 picture_BlendSubpicture(sys->display.filtered, vout->p->spu_blend, subpic);
1023 vout_display_Prepare(vd, sys->display.filtered, do_dr_spu ? subpic : NULL);
1025 if (!do_dr_spu && subpic)
1026 subpicture_Delete(subpic);
1027 if (!sys->display.filtered)
1028 return VLC_EGENERIC;
1031 vout_chrono_Stop(&vout->p->render);
1035 if (((i++)%10) == 0)
1036 msg_Info(vout, "render: avg %d ms var %d ms",
1037 (int)(vout->p->render.avg/1000), (int)(vout->p->render.var/1000));
1041 /* Wait the real date (for rendering jitter) */
1043 mtime_t delay = direct->date - mdate();
1045 msg_Warn(vout, "picture is late (%lld ms)", delay / 1000);
1048 mwait(direct->date);
1050 /* Display the direct buffer returned by vout_RenderPicture */
1051 vout->p->displayed.date = mdate();
1052 vout_display_Display(vd,
1053 sys->display.filtered ? sys->display.filtered
1056 sys->display.filtered = NULL;
1058 vout_statistic_AddDisplayed(&vout->p->statistic, 1);
1063 static int ThreadDisplayPicture(vout_thread_t *vout,
1064 bool now, mtime_t *deadline)
1066 bool is_late_dropped = vout->p->is_late_dropped && !vout->p->pause.is_on && !now;
1067 bool first = !vout->p->displayed.current;
1068 if (first && ThreadDisplayPreparePicture(vout, true, is_late_dropped)) /* FIXME not sure it is ok */
1069 return VLC_EGENERIC;
1070 if (!vout->p->pause.is_on || now) {
1071 while (!vout->p->displayed.next) {
1072 if (ThreadDisplayPreparePicture(vout, false, is_late_dropped)) {
1078 const mtime_t date = mdate();
1079 const mtime_t render_delay = vout_chrono_GetHigh(&vout->p->render) + VOUT_MWAIT_TOLERANCE;
1081 mtime_t date_next = VLC_TS_INVALID;
1082 if (!vout->p->pause.is_on && vout->p->displayed.next)
1083 date_next = vout->p->displayed.next->date - render_delay;
1085 /* FIXME/XXX we must redisplay the last decoded picture (because
1086 * of potential vout updated, or filters update or SPU update)
1087 * For now a high update period is needed but it coulmd be removed
1089 * - vout module emits events from theselves.
1090 * - *and* SPU is modified to emit an event or a deadline when needed.
1092 * So it will be done latter.
1094 mtime_t date_refresh = VLC_TS_INVALID;
1095 if (vout->p->displayed.date > VLC_TS_INVALID)
1096 date_refresh = vout->p->displayed.date + VOUT_REDISPLAY_DELAY - render_delay;
1099 if (date_next != VLC_TS_INVALID)
1100 drop |= date_next + 0 <= date;
1102 bool refresh = false;
1103 if (date_refresh > VLC_TS_INVALID)
1104 refresh = date_refresh <= date;
1106 if (!first && !refresh && !drop) {
1107 if (date_next != VLC_TS_INVALID && date_refresh != VLC_TS_INVALID)
1108 *deadline = __MIN(date_next, date_refresh);
1109 else if (date_next != VLC_TS_INVALID)
1110 *deadline = date_next;
1111 else if (date_refresh != VLC_TS_INVALID)
1112 *deadline = date_refresh;
1113 return VLC_EGENERIC;
1117 picture_Release(vout->p->displayed.current);
1118 vout->p->displayed.current = vout->p->displayed.next;
1119 vout->p->displayed.next = NULL;
1121 if (!vout->p->displayed.current)
1122 return VLC_EGENERIC;
1124 bool is_forced = now || (!drop && refresh) || vout->p->displayed.current->b_force;
1125 return ThreadDisplayRenderPicture(vout, is_forced);
1128 static void ThreadManage(vout_thread_t *vout,
1130 vout_interlacing_support_t *interlacing)
1132 vlc_mutex_lock(&vout->p->picture_lock);
1134 *deadline = VLC_TS_INVALID;
1136 if (ThreadDisplayPicture(vout, false, deadline))
1140 const bool picture_interlaced = vout->p->displayed.is_interlaced;
1142 vlc_mutex_unlock(&vout->p->picture_lock);
1145 vout_SetInterlacingState(vout, interlacing, picture_interlaced);
1147 vout_ManageWrapper(vout);
1150 static void ThreadDisplaySubpicture(vout_thread_t *vout,
1151 subpicture_t *subpicture)
1153 spu_PutSubpicture(vout->p->spu, subpicture);
1156 static void ThreadFlushSubpicture(vout_thread_t *vout, int channel)
1158 spu_ClearChannel(vout->p->spu, channel);
1161 static void ThreadDisplayOsdTitle(vout_thread_t *vout, const char *string)
1163 if (!vout->p->title.show)
1166 vout_OSDText(vout, SPU_DEFAULT_CHANNEL,
1167 vout->p->title.position, INT64_C(1000) * vout->p->title.timeout,
1171 static void ThreadChangeSubSources(vout_thread_t *vout, const char *filters)
1173 spu_ChangeSources(vout->p->spu, filters);
1176 static void ThreadChangeSubFilters(vout_thread_t *vout, const char *filters)
1178 spu_ChangeFilters(vout->p->spu, filters);
1181 static void ThreadChangeSubMargin(vout_thread_t *vout, int margin)
1183 spu_ChangeMargin(vout->p->spu, margin);
1186 static void ThreadChangePause(vout_thread_t *vout, bool is_paused, mtime_t date)
1188 assert(!vout->p->pause.is_on || !is_paused);
1190 if (vout->p->pause.is_on) {
1191 const mtime_t duration = date - vout->p->pause.date;
1193 if (vout->p->step.timestamp > VLC_TS_INVALID)
1194 vout->p->step.timestamp += duration;
1195 if (vout->p->step.last > VLC_TS_INVALID)
1196 vout->p->step.last += duration;
1197 picture_fifo_OffsetDate(vout->p->decoder_fifo, duration);
1198 if (vout->p->displayed.decoded)
1199 vout->p->displayed.decoded->date += duration;
1200 spu_OffsetSubtitleDate(vout->p->spu, duration);
1202 ThreadFilterFlush(vout, false);
1204 vout->p->step.timestamp = VLC_TS_INVALID;
1205 vout->p->step.last = VLC_TS_INVALID;
1207 vout->p->pause.is_on = is_paused;
1208 vout->p->pause.date = date;
1211 static void ThreadFlush(vout_thread_t *vout, bool below, mtime_t date)
1213 vout->p->step.timestamp = VLC_TS_INVALID;
1214 vout->p->step.last = VLC_TS_INVALID;
1216 ThreadFilterFlush(vout, false); /* FIXME too much */
1218 picture_t *last = vout->p->displayed.decoded;
1220 if (( below && last->date <= date) ||
1221 (!below && last->date >= date)) {
1222 picture_Release(last);
1224 vout->p->displayed.decoded = NULL;
1225 vout->p->displayed.date = VLC_TS_INVALID;
1226 vout->p->displayed.timestamp = VLC_TS_INVALID;
1230 picture_fifo_Flush(vout->p->decoder_fifo, date, below);
1233 static void ThreadReset(vout_thread_t *vout)
1235 ThreadFlush(vout, true, INT64_MAX);
1236 if (vout->p->decoder_pool)
1237 picture_pool_NonEmpty(vout->p->decoder_pool, true);
1238 vout->p->pause.is_on = false;
1239 vout->p->pause.date = mdate();
1242 static void ThreadStep(vout_thread_t *vout, mtime_t *duration)
1246 if (vout->p->step.last <= VLC_TS_INVALID)
1247 vout->p->step.last = vout->p->displayed.timestamp;
1250 if (ThreadDisplayPicture(vout, true, &dummy))
1253 vout->p->step.timestamp = vout->p->displayed.timestamp;
1255 if (vout->p->step.last > VLC_TS_INVALID &&
1256 vout->p->step.timestamp > vout->p->step.last) {
1257 *duration = vout->p->step.timestamp - vout->p->step.last;
1258 vout->p->step.last = vout->p->step.timestamp;
1259 /* TODO advance subpicture by the duration ... */
1263 static void ThreadChangeFullscreen(vout_thread_t *vout, bool fullscreen)
1265 vout_SetDisplayFullscreen(vout->p->display.vd, fullscreen);
1268 static void ThreadChangeOnTop(vout_thread_t *vout, bool is_on_top)
1270 vout_SetWindowState(vout->p->display.vd,
1271 is_on_top ? VOUT_WINDOW_STATE_ABOVE :
1272 VOUT_WINDOW_STATE_NORMAL);
1275 static void ThreadChangeDisplayFilled(vout_thread_t *vout, bool is_filled)
1277 vout_SetDisplayFilled(vout->p->display.vd, is_filled);
1280 static void ThreadChangeZoom(vout_thread_t *vout, int num, int den)
1282 if (num * 10 < den) {
1285 } else if (num > den * 10) {
1289 vout_SetDisplayZoom(vout->p->display.vd, num, den);
1292 static void ThreadChangeAspectRatio(vout_thread_t *vout,
1293 unsigned num, unsigned den)
1295 vout_SetDisplayAspect(vout->p->display.vd, num, den);
1299 static void ThreadExecuteCropWindow(vout_thread_t *vout,
1300 unsigned x, unsigned y,
1301 unsigned width, unsigned height)
1303 vout_SetDisplayCrop(vout->p->display.vd, 0, 0,
1304 x, y, width, height);
1306 static void ThreadExecuteCropBorder(vout_thread_t *vout,
1307 unsigned left, unsigned top,
1308 unsigned right, unsigned bottom)
1310 msg_Err(vout, "ThreadExecuteCropBorder %d.%d %dx%d", left, top, right, bottom);
1311 vout_SetDisplayCrop(vout->p->display.vd, 0, 0,
1312 left, top, -(int)right, -(int)bottom);
1315 static void ThreadExecuteCropRatio(vout_thread_t *vout,
1316 unsigned num, unsigned den)
1318 vout_SetDisplayCrop(vout->p->display.vd, num, den,
1322 static int ThreadStart(vout_thread_t *vout, const vout_display_state_t *state)
1324 vlc_mouse_Init(&vout->p->mouse);
1325 vout->p->decoder_fifo = picture_fifo_New();
1326 vout->p->decoder_pool = NULL;
1327 vout->p->display_pool = NULL;
1328 vout->p->private_pool = NULL;
1330 vout->p->filter.configuration = NULL;
1331 video_format_Copy(&vout->p->filter.format, &vout->p->original);
1332 vout->p->filter.chain_static =
1333 filter_chain_New( vout, "video filter2", true,
1334 VoutVideoFilterStaticAllocationSetup, NULL, vout);
1335 vout->p->filter.chain_interactive =
1336 filter_chain_New( vout, "video filter2", true,
1337 VoutVideoFilterInteractiveAllocationSetup, NULL, vout);
1339 vout_display_state_t state_default;
1341 VoutGetDisplayCfg(vout, &state_default.cfg, vout->p->display.title);
1342 state_default.wm_state = var_CreateGetBool(vout, "video-on-top") ? VOUT_WINDOW_STATE_ABOVE :
1343 VOUT_WINDOW_STATE_NORMAL;
1344 state_default.sar.num = 0;
1345 state_default.sar.den = 0;
1347 state = &state_default;
1350 if (vout_OpenWrapper(vout, vout->p->splitter_name, state))
1351 return VLC_EGENERIC;
1352 if (vout_InitWrapper(vout))
1353 return VLC_EGENERIC;
1354 assert(vout->p->decoder_pool);
1356 vout->p->displayed.current = NULL;
1357 vout->p->displayed.next = NULL;
1358 vout->p->displayed.decoded = NULL;
1359 vout->p->displayed.date = VLC_TS_INVALID;
1360 vout->p->displayed.timestamp = VLC_TS_INVALID;
1361 vout->p->displayed.is_interlaced = false;
1363 vout->p->step.last = VLC_TS_INVALID;
1364 vout->p->step.timestamp = VLC_TS_INVALID;
1366 vout->p->spu_blend_chroma = 0;
1367 vout->p->spu_blend = NULL;
1369 video_format_Print(VLC_OBJECT(vout), "original format", &vout->p->original);
1373 static void ThreadStop(vout_thread_t *vout, vout_display_state_t *state)
1375 if (vout->p->spu_blend)
1376 filter_DeleteBlend(vout->p->spu_blend);
1378 /* Destroy translation tables */
1379 if (vout->p->display.vd) {
1380 if (vout->p->decoder_pool) {
1381 ThreadFlush(vout, true, INT64_MAX);
1382 vout_EndWrapper(vout);
1384 vout_CloseWrapper(vout, state);
1387 /* Destroy the video filters2 */
1388 filter_chain_Delete(vout->p->filter.chain_interactive);
1389 filter_chain_Delete(vout->p->filter.chain_static);
1390 video_format_Clean(&vout->p->filter.format);
1391 free(vout->p->filter.configuration);
1393 if (vout->p->decoder_fifo)
1394 picture_fifo_Delete(vout->p->decoder_fifo);
1395 assert(!vout->p->decoder_pool);
1398 static void ThreadInit(vout_thread_t *vout)
1400 vout->p->window.is_unused = true;
1401 vout->p->window.object = NULL;
1402 vout->p->dead = false;
1403 vout->p->is_late_dropped = var_InheritBool(vout, "drop-late-frames");
1404 vout->p->pause.is_on = false;
1405 vout->p->pause.date = VLC_TS_INVALID;
1407 vout_chrono_Init(&vout->p->render, 5, 10000); /* Arbitrary initial time */
1410 static void ThreadClean(vout_thread_t *vout)
1412 if (vout->p->window.object) {
1413 assert(vout->p->window.is_unused);
1414 vout_window_Delete(vout->p->window.object);
1416 vout_chrono_Clean(&vout->p->render);
1417 vout->p->dead = true;
1418 vout_control_Dead(&vout->p->control);
1421 static int ThreadReinit(vout_thread_t *vout,
1422 const vout_configuration_t *cfg)
1424 video_format_t original;
1425 if (VoutValidateFormat(&original, cfg->fmt)) {
1426 ThreadStop(vout, NULL);
1428 return VLC_EGENERIC;
1430 /* We ignore crop/ar changes at this point, they are dynamically supported */
1431 VideoFormatCopyCropAr(&vout->p->original, &original);
1432 if (video_format_IsSimilar(&original, &vout->p->original)) {
1433 if (cfg->dpb_size <= vout->p->dpb_size)
1435 msg_Warn(vout, "DPB need to be increased");
1438 vout_display_state_t state;
1439 memset(&state, 0, sizeof(state));
1441 ThreadStop(vout, &state);
1443 if (!state.cfg.is_fullscreen) {
1444 state.cfg.display.width = 0;
1445 state.cfg.display.height = 0;
1449 /* FIXME current vout "variables" are not in sync here anymore
1450 * and I am not sure what to do */
1452 vout->p->original = original;
1453 vout->p->dpb_size = cfg->dpb_size;
1454 if (ThreadStart(vout, &state)) {
1456 return VLC_EGENERIC;
1461 /*****************************************************************************
1462 * Thread: video output thread
1463 *****************************************************************************
1464 * Video output thread. This function does only returns when the thread is
1465 * terminated. It handles the pictures arriving in the video heap and the
1466 * display device events.
1467 *****************************************************************************/
1468 static void *Thread(void *object)
1470 vout_thread_t *vout = object;
1472 vout_interlacing_support_t interlacing = {
1473 .is_interlaced = false,
1477 mtime_t deadline = VLC_TS_INVALID;
1479 vout_control_cmd_t cmd;
1481 /* FIXME remove thoses ugly timeouts
1483 while (!vout_control_Pop(&vout->p->control, &cmd, deadline, 100000)) {
1485 case VOUT_CONTROL_INIT:
1487 if (ThreadStart(vout, NULL)) {
1488 ThreadStop(vout, NULL);
1493 case VOUT_CONTROL_CLEAN:
1494 ThreadStop(vout, NULL);
1497 case VOUT_CONTROL_REINIT:
1498 if (ThreadReinit(vout, cmd.u.cfg))
1501 case VOUT_CONTROL_SUBPICTURE:
1502 ThreadDisplaySubpicture(vout, cmd.u.subpicture);
1503 cmd.u.subpicture = NULL;
1505 case VOUT_CONTROL_FLUSH_SUBPICTURE:
1506 ThreadFlushSubpicture(vout, cmd.u.integer);
1508 case VOUT_CONTROL_OSD_TITLE:
1509 ThreadDisplayOsdTitle(vout, cmd.u.string);
1511 case VOUT_CONTROL_CHANGE_FILTERS:
1512 ThreadChangeFilters(vout, NULL, cmd.u.string, false);
1514 case VOUT_CONTROL_CHANGE_SUB_SOURCES:
1515 ThreadChangeSubSources(vout, cmd.u.string);
1517 case VOUT_CONTROL_CHANGE_SUB_FILTERS:
1518 ThreadChangeSubFilters(vout, cmd.u.string);
1520 case VOUT_CONTROL_CHANGE_SUB_MARGIN:
1521 ThreadChangeSubMargin(vout, cmd.u.integer);
1523 case VOUT_CONTROL_PAUSE:
1524 ThreadChangePause(vout, cmd.u.pause.is_on, cmd.u.pause.date);
1526 case VOUT_CONTROL_FLUSH:
1527 ThreadFlush(vout, false, cmd.u.time);
1529 case VOUT_CONTROL_RESET:
1532 case VOUT_CONTROL_STEP:
1533 ThreadStep(vout, cmd.u.time_ptr);
1535 case VOUT_CONTROL_FULLSCREEN:
1536 ThreadChangeFullscreen(vout, cmd.u.boolean);
1538 case VOUT_CONTROL_ON_TOP:
1539 ThreadChangeOnTop(vout, cmd.u.boolean);
1541 case VOUT_CONTROL_DISPLAY_FILLED:
1542 ThreadChangeDisplayFilled(vout, cmd.u.boolean);
1544 case VOUT_CONTROL_ZOOM:
1545 ThreadChangeZoom(vout, cmd.u.pair.a, cmd.u.pair.b);
1547 case VOUT_CONTROL_ASPECT_RATIO:
1548 ThreadChangeAspectRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
1550 case VOUT_CONTROL_CROP_RATIO:
1551 ThreadExecuteCropRatio(vout, cmd.u.pair.a, cmd.u.pair.b);
1553 case VOUT_CONTROL_CROP_WINDOW:
1554 ThreadExecuteCropWindow(vout,
1555 cmd.u.window.x, cmd.u.window.y,
1556 cmd.u.window.width, cmd.u.window.height);
1558 case VOUT_CONTROL_CROP_BORDER:
1559 ThreadExecuteCropBorder(vout,
1560 cmd.u.border.left, cmd.u.border.top,
1561 cmd.u.border.right, cmd.u.border.bottom);
1566 vout_control_cmd_Clean(&cmd);
1569 ThreadManage(vout, &deadline, &interlacing);