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
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.
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.
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 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
30 #include <math.h> /* exp(), pow() */
31 #include <errno.h> /* ENOMEM */
32 #include <stdlib.h> /* free() */
33 #include <string.h> /* strerror() */
41 #include "video_output.h"
42 #include "video_yuv.h"
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 )
56 typedef void ( yuv_getplugin_t ) ( vout_thread_t * p_vout );
59 /* Get a suitable YUV plugin */
60 for( i_index = 0 ; i_index < p_main->p_bank->i_plugin_count ; i_index++ )
62 /* If there's a plugin in p_info ... */
63 if( p_main->p_bank->p_info[ i_index ] != NULL )
65 /* ... and if this plugin provides the functions we want ... */
66 if( p_main->p_bank->p_info[ i_index ]->yuv_GetPlugin != NULL )
68 /* ... then get these functions */
70 p_main->p_bank->p_info[ i_index ]->yuv_GetPlugin )( p_vout );
75 return p_vout->p_yuv_init( p_vout );
78 /*****************************************************************************
79 * vout_ResetYUV: re-initialize translation tables
80 *****************************************************************************
81 * This function will initialize the tables allocated by vout_InitYUV and
82 * set functions pointers.
83 *****************************************************************************/
84 int vout_ResetYUV( vout_thread_t *p_vout )
86 p_vout->p_yuv_end( p_vout );
87 return( p_vout->p_yuv_init( p_vout ) );
90 /*****************************************************************************
91 * vout_EndYUV: destroy translation tables
92 *****************************************************************************
93 * Free memory allocated by vout_InitYUV
94 *****************************************************************************/
95 void vout_EndYUV( vout_thread_t *p_vout )
97 p_vout->p_yuv_end( p_vout );