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