]> git.sesse.net Git - vlc/blob - src/video_output/video_yuv.c
3b125eb28f7d70a361888eb159f3b911c91d92de
[vlc] / src / video_output / video_yuv.c
1 /*****************************************************************************
2  * video_yuv.c: YUV transformation functions
3  * These functions set up YUV tables for colorspace conversion
4  *****************************************************************************
5  * Copyright (C) 1999, 2000 VideoLAN
6  *
7  * Authors: Vincent Seguin <seguin@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 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 GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public
20  * License along with this program; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <math.h>                                            /* exp(), pow() */
31 #include <errno.h>                                                 /* ENOMEM */
32 #include <stdlib.h>                                                /* free() */
33 #include <string.h>                                            /* strerror() */
34
35 #include "config.h"
36 #include "common.h"
37 #include "threads.h"
38 #include "mtime.h"
39 #include "modules.h"
40
41 #include "video.h"
42 #include "video_output.h"
43 #include "video_yuv.h"
44
45 #include "intf_msg.h"
46
47 #include "main.h"
48
49 /*****************************************************************************
50  * vout_InitYUV: allocate and initialize translation tables
51  *****************************************************************************
52  * This function will allocate memory to store translation tables, depending
53  * on the screen depth.
54  *****************************************************************************/
55 int vout_InitYUV( vout_thread_t *p_vout )
56 {
57     /* Choose the best module */
58     p_vout->yuv.p_module = module_Need( p_main->p_bank,
59                                         MODULE_CAPABILITY_YUV, NULL );
60
61     if( p_vout->yuv.p_module == NULL )
62     {
63         intf_ErrMsg( "vout error: no suitable yuv module" );
64         return( -1 );
65     }
66
67 #define yuv_functions p_vout->yuv.p_module->p_functions->yuv.functions.yuv
68     p_vout->yuv.pf_init       = yuv_functions.pf_init;
69     p_vout->yuv.pf_reset      = yuv_functions.pf_reset;
70     p_vout->yuv.pf_end        = yuv_functions.pf_end;
71 #undef yuv_functions
72
73     return( p_vout->yuv.pf_init( p_vout ) );
74 }
75
76 /*****************************************************************************
77  * vout_ResetYUV: re-initialize translation tables
78  *****************************************************************************
79  * This function will initialize the tables allocated by vout_InitYUV and
80  * set functions pointers.
81  *****************************************************************************/
82 int vout_ResetYUV( vout_thread_t *p_vout )
83 {
84     p_vout->yuv.pf_end( p_vout );
85     return( p_vout->yuv.pf_init( p_vout ) );
86 }
87
88 /*****************************************************************************
89  * vout_EndYUV: destroy translation tables
90  *****************************************************************************
91  * Free memory allocated by vout_InitYUV
92  *****************************************************************************/
93 void vout_EndYUV( vout_thread_t *p_vout )
94 {
95     p_vout->yuv.pf_end( p_vout );
96     module_Unneed( p_main->p_bank, p_vout->yuv.p_module );
97 }
98