initial commit
[goodguy/history.git] / cinelerra-5.0 / guicast / bccmodels.h
1 /*
2  * This library is free software; you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published
4  * by the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  * 
7  * This library is distributed in the hope that it will be useful, but
8  * WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10  * Lesser General Public License for more details.
11  * 
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 
15  * USA
16  */
17  
18  
19 #ifndef BCCMODELS_H
20 #define BCCMODELS_H
21
22 // Colormodels
23 // Must match colormodels.h in quicktime
24 #ifndef BC_TRANSPARENCY
25
26
27 #define BC_TRANSPARENCY 0
28 #define BC_COMPRESSED   1
29 #define BC_RGB8         2
30 #define BC_RGB565       3
31 #define BC_BGR565       4
32 #define BC_BGR888       5
33 #define BC_BGR8888      6
34 // Working bitmaps are packed to simplify processing
35 #define BC_RGB888       9
36 #define BC_RGBA8888     10
37 #define BC_ARGB8888     20
38 #define BC_ABGR8888     21
39 #define BC_RGB161616    11
40 #define BC_RGBA16161616 12
41 #define BC_YUV888       13
42 #define BC_YUVA8888     14
43 #define BC_YUV161616    15
44 #define BC_YUVA16161616 16
45 #define BC_YUV422       19
46 #define BC_A8           22
47 #define BC_A16          23
48 #define BC_A_FLOAT      31
49 #define BC_YUV101010    24
50 #define BC_VYU888       25
51 #define BC_UYVA8888     26
52 #define BC_RGB_FLOAT    29
53 #define BC_RGBA_FLOAT   30
54 // Planar
55 #define BC_YUV420P      7
56 #define BC_YUV422P      17
57 #define BC_YUV444P      27
58 #define BC_YUV411P      18
59 #define BC_YUV410P      28
60 #define BC_RGB_FLOATP   32
61 #define BC_RGBA_FLOATP  33
62
63 // Colormodels purely used by Quicktime are done in Quicktime.
64
65 // For communication with the X Server
66 #define FOURCC_YV12 0x32315659  /* YV12   YUV420P */
67 #define FOURCC_YUV2 0x32595559  /* YUV2   YUV422 */
68 #define FOURCC_I420 0x30323449  /* I420   Intel Indeo 4 */
69
70
71 #endif // !BC_TRANSPARENCY
72
73
74
75 // Access with BC_WindowBase::cmodels
76 class BC_CModels
77 {
78 public:
79         BC_CModels();
80
81         static int calculate_pixelsize(int colormodel);
82         static int calculate_datasize(int w, int h, int bytes_per_line, int color_model);
83         static int calculate_max(int colormodel);
84         static int components(int colormodel);
85         static int is_yuv(int colormodel);
86         static int has_alpha(int colormodel);
87         static int is_float(int colormodel);
88
89         // Tell when to use plane arguments or row pointer arguments to functions
90         static int is_planar(int color_model);
91         static void to_text(char *string, int cmodel);
92         static int from_text(const char *text);
93
94         static void transfer(unsigned char **output_rows, /* Leave NULL if non existent */
95                 unsigned char **input_rows,
96                 unsigned char *out_y_plane, /* Leave NULL if non existent */
97                 unsigned char *out_u_plane,
98                 unsigned char *out_v_plane,
99                 unsigned char *in_y_plane, /* Leave NULL if non existent */
100                 unsigned char *in_u_plane,
101                 unsigned char *in_v_plane,
102                 int in_x,        /* Dimensions to capture from input frame */
103                 int in_y, 
104                 int in_w, 
105                 int in_h,
106                 int out_x,       /* Dimensions to project on output frame */
107                 int out_y, 
108                 int out_w, 
109                 int out_h,
110                 int in_colormodel, 
111                 int out_colormodel,
112                 int bg_color,         /* When transfering BC_RGBA8888 to non-alpha this is the background color in 0xRRGGBB hex */
113                 int in_rowspan,       /* For planar use the luma rowspan */
114                 int out_rowspan);     /* For planar use the luma rowspan */
115
116 // ptrs are either row pointers (colormodel flat) or plane pointers (colormodel planar)
117         static void transfer(
118                 unsigned char **output_ptrs, int out_colormodel,
119                         int out_x, int out_y, int out_w, int out_h, int out_rowspan,
120                 unsigned char **input_ptrs, int in_colormodel,
121                         int in_x, int in_y, int in_w, int in_h, int in_rowspan,
122                 int bg_color);
123
124         static void init_yuv();
125         static int bc_to_x(int color_model);
126 };
127
128
129 #endif