]> git.sesse.net Git - vlc/blob - modules/video_output/vdummy.c
flac: don't overwrite bitspersample
[vlc] / modules / video_output / vdummy.c
1 /*****************************************************************************
2  * vdummy.c: Dummy video output display method for testing purposes
3  *****************************************************************************
4  * Copyright (C) 2000-2009 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_vout_display.h>
35
36 #define CHROMA_TEXT N_("Dummy image chroma format")
37 #define CHROMA_LONGTEXT N_( \
38     "Force the dummy video output to create images using a specific chroma " \
39     "format instead of trying to improve performances by using the most " \
40     "efficient one.")
41
42 static int OpenDummy( vlc_object_t * );
43 static int OpenStats( vlc_object_t * );
44 static void Close( vlc_object_t * );
45
46 vlc_module_begin ()
47     set_shortname( N_("Dummy") )
48     set_description( N_("Dummy video output") )
49     set_capability( "vout display", 0 )
50     set_callbacks( OpenDummy, Close )
51     add_shortcut( "dummy" )
52
53     set_category( CAT_VIDEO )
54     set_subcategory( SUBCAT_VIDEO_VOUT )
55     add_string( "dummy-chroma", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
56
57     add_submodule ()
58     set_description( N_("Statistics video output") )
59     set_capability( "vout display", 0 )
60     add_shortcut( "stats" )
61     set_callbacks( OpenStats, Close )
62 vlc_module_end ()
63
64
65 /*****************************************************************************
66  * Local prototypes
67  *****************************************************************************/
68 struct vout_display_sys_t {
69     picture_pool_t *pool;
70 };
71 static picture_pool_t *Pool(vout_display_t *, unsigned count);
72 static void            Display(vout_display_t *, picture_t *, subpicture_t *);
73 static void            DisplayStat(vout_display_t *, picture_t *, subpicture_t *);
74 static int             Control(vout_display_t *, int, va_list);
75
76 /*****************************************************************************
77  * OpenVideo: activates dummy vout display method
78  *****************************************************************************/
79 static int Open(vlc_object_t *object,
80                 void (*display)(vout_display_t *, picture_t *, subpicture_t *))
81 {
82     vout_display_t *vd = (vout_display_t *)object;
83     vout_display_sys_t *sys;
84
85     vd->sys = sys = calloc(1, sizeof(*sys));
86     if (!sys)
87         return VLC_EGENERIC;
88     sys->pool = NULL;
89
90     /* p_vd->info is not modified */
91
92     char *chroma = var_InheritString(vd, "dummy-chroma");
93     if (chroma) {
94         vlc_fourcc_t fcc = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
95         if (fcc != 0) {
96             msg_Dbg(vd, "forcing chroma 0x%.8x (%4.4s)", fcc, (char*)&fcc);
97             vd->fmt.i_chroma = fcc;
98         }
99         free(chroma);
100     }
101     vd->pool    = Pool;
102     vd->prepare = NULL;
103     vd->display = display;
104     vd->control = Control;
105     vd->manage  = NULL;
106
107     return VLC_SUCCESS;
108 }
109
110 static int OpenDummy(vlc_object_t *object)
111 {
112     return Open(object, Display);
113 }
114
115 static int OpenStats(vlc_object_t *object)
116 {
117     return Open(object, DisplayStat);
118 }
119
120 static void Close(vlc_object_t *object)
121 {
122     vout_display_t *vd = (vout_display_t *)object;
123     vout_display_sys_t *sys = vd->sys;
124
125     if (sys->pool)
126         picture_pool_Delete(sys->pool);
127     free(sys);
128 }
129
130 static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
131 {
132     vout_display_sys_t *sys = vd->sys;
133     if (!sys->pool)
134         sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
135     return sys->pool;
136 }
137
138 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
139 {
140     VLC_UNUSED(vd);
141     VLC_UNUSED(subpicture);
142     picture_Release(picture);
143 }
144
145 static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
146 {
147     VLC_UNUSED(vd);
148     VLC_UNUSED(subpicture);
149     if (vd->fmt.i_width*vd->fmt.i_height >= sizeof(mtime_t)) {
150         mtime_t date;
151         memcpy(&date, picture->p->p_pixels, sizeof(date));
152         msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
153                 (mdate() - date) / 1000 );
154     }
155     picture_Release(picture);
156 }
157
158 static int Control(vout_display_t *vd, int query, va_list args)
159 {
160     VLC_UNUSED(vd);
161     VLC_UNUSED(query);
162     VLC_UNUSED(args);
163     return VLC_SUCCESS;
164 }