]> git.sesse.net Git - vlc/blob - src/video_output/video_yuv.c
* Mandatory step for video output IV and the audio output quality
[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.48 2001/05/01 04:18:18 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 /*****************************************************************************
49  * vout_InitYUV: allocate and initialize translation tables
50  *****************************************************************************
51  * This function will allocate memory to store translation tables, depending
52  * on the screen depth.
53  *****************************************************************************/
54 int vout_InitYUV( vout_thread_t *p_vout )
55 {
56     /* Choose the best module */
57     p_vout->yuv.p_module = module_Need( MODULE_CAPABILITY_YUV, NULL );
58
59     if( p_vout->yuv.p_module == NULL )
60     {
61         intf_ErrMsg( "vout error: no suitable yuv module" );
62         return( -1 );
63     }
64
65 #define yuv_functions p_vout->yuv.p_module->p_functions->yuv.functions.yuv
66     p_vout->yuv.pf_init       = yuv_functions.pf_init;
67     p_vout->yuv.pf_reset      = yuv_functions.pf_reset;
68     p_vout->yuv.pf_end        = yuv_functions.pf_end;
69 #undef yuv_functions
70
71     return( p_vout->yuv.pf_init( p_vout ) );
72 }
73
74 /*****************************************************************************
75  * vout_ResetYUV: re-initialize translation tables
76  *****************************************************************************
77  * This function will initialize the tables allocated by vout_InitYUV and
78  * set functions pointers.
79  *****************************************************************************/
80 int vout_ResetYUV( vout_thread_t *p_vout )
81 {
82     p_vout->yuv.pf_end( p_vout );
83     return( p_vout->yuv.pf_init( p_vout ) );
84 }
85
86 /*****************************************************************************
87  * vout_EndYUV: destroy translation tables
88  *****************************************************************************
89  * Free memory allocated by vout_InitYUV
90  *****************************************************************************/
91 void vout_EndYUV( vout_thread_t *p_vout )
92 {
93     p_vout->yuv.pf_end( p_vout );
94     module_Unneed( p_vout->yuv.p_module );
95 }
96