]> git.sesse.net Git - vlc/blob - plugins/yuvmmx/video_yuv.h
3d7feffc9a34cc123798d025ef18a8a562c6f294
[vlc] / plugins / yuvmmx / video_yuv.h
1 /*****************************************************************************
2  * video_yuv.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  *
9  * Authors:
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this program; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24  * Boston, MA 02111-1307, USA.
25  *****************************************************************************/
26
27 /*****************************************************************************
28  * Constants
29  *****************************************************************************/
30
31 /* Margins and offsets in conversion tables - Margins are used in case a RGB
32  * RGB conversion would give a value outside the 0-255 range. Offsets have been
33  * calculated to avoid using the same cache line for 2 tables. conversion tables
34  * are 2*MARGIN + 256 long and stores pixels.*/
35 #define RED_MARGIN      178
36 #define GREEN_MARGIN    135
37 #define BLUE_MARGIN     224
38 #define RED_OFFSET      1501                                 /* 1323 to 1935 */
39 #define GREEN_OFFSET    135                                      /* 0 to 526 */
40 #define BLUE_OFFSET     818                                   /* 594 to 1298 */
41 #define RGB_TABLE_SIZE  1935                             /* total table size */
42
43 #define GRAY_MARGIN     384
44 #define GRAY_TABLE_SIZE 1024                             /* total table size */
45
46 #define PALETTE_TABLE_SIZE 2176          /* YUV -> 8bpp palette lookup table */
47
48 /* macros used for YUV pixel conversions */
49 #define SHIFT 20
50 #define U_GREEN_COEF    ((int)(-0.391 * (1<<SHIFT) / 1.164))
51 #define U_BLUE_COEF     ((int)(2.018 * (1<<SHIFT) / 1.164))
52 #define V_RED_COEF      ((int)(1.596 * (1<<SHIFT) / 1.164))
53 #define V_GREEN_COEF    ((int)(-0.813 * (1<<SHIFT) / 1.164))
54
55 /* argument lists for YUV functions */
56 #define YUV_ARGS_8BPP p_vout_thread_t p_vout, u8 *p_pic, yuv_data_t *p_y, \
57 yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
58 int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
59
60 #define YUV_ARGS_16BPP p_vout_thread_t p_vout, u16 *p_pic, yuv_data_t *p_y, \
61 yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
62 int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
63
64 #define YUV_ARGS_24BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
65 yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
66 int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
67
68 #define YUV_ARGS_32BPP p_vout_thread_t p_vout, u32 *p_pic, yuv_data_t *p_y, \
69 yuv_data_t *p_u, yuv_data_t *p_v, int i_width, int i_height, int i_pic_width, \
70 int i_pic_height, int i_pic_line_width, int i_matrix_coefficients
71
72 /*****************************************************************************
73  * Local prototypes
74  *****************************************************************************/
75 void SetGammaTable        ( int *pi_table, double f_gamma );
76 void SetYUV               ( vout_thread_t *p_vout );
77 void SetOffset            ( int i_width, int i_height, int i_pic_width,
78                             int i_pic_height, boolean_t *pb_h_scaling,
79                             int *pi_v_scaling, int *p_offset );
80
81 void ConvertY4Gray8       ( YUV_ARGS_8BPP );
82 void ConvertYUV420RGB8    ( YUV_ARGS_8BPP );
83 void ConvertYUV422RGB8    ( YUV_ARGS_8BPP );
84 void ConvertYUV444RGB8    ( YUV_ARGS_8BPP );
85
86 void ConvertY4Gray16      ( YUV_ARGS_16BPP );
87 void ConvertYUV420RGB16   ( YUV_ARGS_16BPP );
88 void ConvertYUV422RGB16   ( YUV_ARGS_16BPP );
89 void ConvertYUV444RGB16   ( YUV_ARGS_16BPP );
90
91 void ConvertY4Gray24      ( YUV_ARGS_24BPP );
92 void ConvertYUV420RGB24   ( YUV_ARGS_24BPP );
93 void ConvertYUV422RGB24   ( YUV_ARGS_24BPP );
94 void ConvertYUV444RGB24   ( YUV_ARGS_24BPP );
95
96 void ConvertY4Gray32      ( YUV_ARGS_32BPP );
97 void ConvertYUV420RGB32   ( YUV_ARGS_32BPP );
98 void ConvertYUV422RGB32   ( YUV_ARGS_32BPP );
99 void ConvertYUV444RGB32   ( YUV_ARGS_32BPP );
100