no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / 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 enum BC_CModel {
27         BC_TRANSPARENCY = 0,
28         BC_COMPRESSED   = 1,
29         BC_RGB8         = 2,
30         BC_RGB565       = 3,
31         BC_BGR565       = 4,
32         BC_BGR888       = 5,
33         BC_BGR8888      = 6,
34 // Working bitmaps are packed to simplify processing
35         BC_RGB888       = 9,
36         BC_RGBA8888     = 10,
37         BC_ARGB8888     = 20,
38         BC_ABGR8888     = 21,
39         BC_RGB161616    = 11,
40         BC_RGBA16161616 = 12,
41         BC_YUV888       = 13,
42         BC_YUVA8888     = 14,
43         BC_YUV161616    = 15,
44         BC_YUVA16161616 = 16,
45         BC_UVY422       = 18,
46         BC_YUV422       = 19,
47         BC_A8           = 22,
48         BC_A16          = 23,
49         BC_A_FLOAT      = 31,
50         BC_YUV101010    = 24,
51         BC_VYU888       = 25,
52         BC_UYVA8888     = 26,
53         BC_RGB_FLOAT    = 29,
54         BC_RGBA_FLOAT   = 30,
55 // Planar
56         BC_YUV420P      = 7,
57         BC_YUV422P      = 8,
58         BC_YUV444P      = 27,
59         BC_YUV411P      = 17,
60         BC_YUV410P      = 28,
61         BC_RGB_FLOATP   = 32,
62         BC_RGBA_FLOATP  = 33,
63         BC_YUV420PI     = 34,
64         BC_GBRP         = 38,
65 // only used in intermediate ffmpeg xfers
66         BC_AYUV16161616 = 35,
67         BC_GREY8        = 36,
68         BC_GREY16       = 37,
69 //only used for chroma only xfers (transfer with bg_color = -1)
70         BC_RGBX8888     = 39,
71         BC_RGBX16161616 = 40,
72         BC_YUVX8888     = 41,
73         BC_YUVX16161616 = 42,
74         BC_RGBX_FLOAT   = 43,
75 };
76
77 // Colormodels purely used by Quicktime are done in Quicktime.
78
79 // For communication with the X Server
80 #define FOURCC_YV12 0x32315659  /* YV12   YUV420P */
81 #define FOURCC_YUV2 0x32595559  /* YUV2   YUV422 */
82 #define FOURCC_UYVY 0x59565955  /* UYVY   UVY422 */
83 #define FOURCC_I420 0x30323449  /* I420   Intel Indeo 4 */
84 #define BC_COLOR_ALIGN 64       /* overwrite padding, ssse3 */
85
86 #endif // !BC_TRANSPARENCY
87
88
89 // Access with BC_WindowBase::cmodels
90 class BC_CModels
91 {
92 public:
93         BC_CModels();
94
95         static int calculate_pixelsize(int colormodel);
96         static int calculate_datasize(int w, int h, int bytes_per_line, int color_model);
97         static int calculate_max(int colormodel);
98         static int components(int colormodel);
99         static int is_yuv(int colormodel);
100         static int has_alpha(int colormodel);
101         static int is_float(int colormodel);
102
103         // Tell when to use plane arguments or row pointer arguments to functions
104         static int is_planar(int color_model);
105         static void to_text(char *string, int cmodel);
106         static int from_text(const char *text);
107
108         static void transfer(unsigned char **output_rows, /* Leave NULL if non existent */
109                 unsigned char **input_rows,
110                 unsigned char *out_y_plane, /* Leave NULL if non existent */
111                 unsigned char *out_u_plane,
112                 unsigned char *out_v_plane,
113                 unsigned char *in_y_plane, /* Leave NULL if non existent */
114                 unsigned char *in_u_plane,
115                 unsigned char *in_v_plane,
116                 int in_x,        /* Dimensions to capture from input frame */
117                 int in_y,
118                 int in_w,
119                 int in_h,
120                 int out_x,       /* Dimensions to project on output frame */
121                 int out_y,
122                 int out_w,
123                 int out_h,
124                 int in_colormodel,
125                 int out_colormodel,
126                 int bg_color,         /* -1 for chroma only xfer, else bg color for BC_RGBA8888 to non-alpha */
127                 int in_rowspan,       /* For planar use the luma rowspan */
128                 int out_rowspan);     /* For planar use the luma rowspan */
129
130 // ptrs are either row pointers (colormodel flat) or plane pointers (colormodel planar)
131         static void transfer(
132                 unsigned char **output_ptrs, int out_colormodel,
133                         int out_x, int out_y, int out_w, int out_h, int out_rowspan,
134                 unsigned char **input_ptrs, int in_colormodel,
135                         int in_x, int in_y, int in_w, int in_h, int in_rowspan,
136                 int bg_color);
137 // paint buffer solid color
138         static int init_color(int color, int alpha,
139                 unsigned char **output_rows, int out_colormodel,
140                 unsigned char *out_yp, unsigned char *out_up, unsigned char *out_vp,
141                 int out_x, int out_y, int out_w, int out_h, int out_rowspan);
142
143         static int bc_to_x(int color_model);
144         static void bcxfer_stop_slicers();
145 };
146
147
148 #endif