]> git.sesse.net Git - vlc/blob - plugins/yuv/video_common.h
* Header cleaning: filled all empty authors fields, added CVS $Id stuff.
[vlc] / plugins / yuv / video_common.h
1 /*****************************************************************************
2  * video_common.h: YUV transformation functions
3  * Provides functions to perform the YUV conversion. The functions provided here
4  * are a complete and portable C implementation, and may be replaced in certain
5  * case by optimized functions.
6  *****************************************************************************
7  * Copyright (C) 1999, 2000 VideoLAN
8  * $Id: video_common.h,v 1.3 2001/03/21 13:42:34 sam Exp $
9  *
10  * Authors: Vincent Seguin <seguin@via.ecp.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public
23  * License along with this program; if not, write to the
24  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25  * Boston, MA 02111-1307, USA.
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * Constants
30  *****************************************************************************/
31
32 /* Margins and offsets in conversion tables - Margins are used in case a RGB
33  * RGB conversion would give a value outside the 0-255 range. Offsets have been
34  * calculated to avoid using the same cache line for 2 tables. conversion tables
35  * are 2*MARGIN + 256 long and stores pixels.*/
36 #define RED_MARGIN      178
37 #define GREEN_MARGIN    135
38 #define BLUE_MARGIN     224
39 #define RED_OFFSET      1501                                 /* 1323 to 1935 */
40 #define GREEN_OFFSET    135                                      /* 0 to 526 */
41 #define BLUE_OFFSET     818                                   /* 594 to 1298 */
42 #define RGB_TABLE_SIZE  1935                             /* total table size */
43
44 #define GRAY_MARGIN     384
45 #define GRAY_TABLE_SIZE 1024                             /* total table size */
46
47 #define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
48
49 /* macros used for YUV pixel conversions */
50 #define SHIFT 20
51 #define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
52 #define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
53 #define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
54 #define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
55
56 /* argument lists for YUV functions */
57 #define YUV_ARGS( word_size ) p_vout_thread_t p_vout, word_size *p_pic, \
58 yuv_data_t *p_y, yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, \
59 int i_pic_width, int i_pic_height, int i_pic_line_width, \
60 int i_matrix_coefficients
61
62 #define YUV_ARGS_8BPP    YUV_ARGS( u8 )
63 #define YUV_ARGS_16BPP   YUV_ARGS( u16 )
64 #define YUV_ARGS_24BPP   YUV_ARGS( u32 )
65 #define YUV_ARGS_32BPP   YUV_ARGS( u32 )
66
67 /*****************************************************************************
68  * Extern prototypes
69  *****************************************************************************/
70
71 void SetOffset( int i_width, int i_height, int i_pic_width, int i_pic_height,
72                 boolean_t *pb_h_scaling, int *pi_v_scaling,
73                 int *p_offset, boolean_t b_double );
74
75 void ConvertY4Gray8       ( YUV_ARGS_8BPP );
76 void ConvertYUV420RGB8    ( YUV_ARGS_8BPP );
77 void ConvertYUV422RGB8    ( YUV_ARGS_8BPP );
78 void ConvertYUV444RGB8    ( YUV_ARGS_8BPP );
79
80 void ConvertY4Gray16      ( YUV_ARGS_16BPP );
81 void ConvertYUV420RGB16   ( YUV_ARGS_16BPP );
82 void ConvertYUV422RGB16   ( YUV_ARGS_16BPP );
83 void ConvertYUV444RGB16   ( YUV_ARGS_16BPP );
84
85 void ConvertY4Gray24      ( YUV_ARGS_24BPP );
86 void ConvertYUV420RGB24   ( YUV_ARGS_24BPP );
87 void ConvertYUV422RGB24   ( YUV_ARGS_24BPP );
88 void ConvertYUV444RGB24   ( YUV_ARGS_24BPP );
89
90 void ConvertY4Gray32      ( YUV_ARGS_32BPP );
91 void ConvertYUV420RGB32   ( YUV_ARGS_32BPP );
92 void ConvertYUV422RGB32   ( YUV_ARGS_32BPP );
93 void ConvertYUV444RGB32   ( YUV_ARGS_32BPP );
94
95 void ConvertYUV420YCbr8    ( YUV_ARGS_8BPP );
96 void ConvertYUV422YCbr8    ( YUV_ARGS_8BPP );
97 void ConvertYUV444YCbr8    ( YUV_ARGS_8BPP );
98
99 void ConvertYUV420YCbr16    ( YUV_ARGS_16BPP );
100 void ConvertYUV422YCbr16    ( YUV_ARGS_16BPP );
101 void ConvertYUV444YCbr16    ( YUV_ARGS_16BPP );
102
103 void ConvertYUV420YCbr24    ( YUV_ARGS_24BPP );
104 void ConvertYUV422YCbr24    ( YUV_ARGS_24BPP );
105 void ConvertYUV444YCbr24    ( YUV_ARGS_24BPP );
106
107 void ConvertYUV420YCbr32    ( YUV_ARGS_32BPP );
108 void ConvertYUV422YCbr32    ( YUV_ARGS_32BPP );
109 void ConvertYUV444YCbr32    ( YUV_ARGS_32BPP );
110
111