1 | /********************************************************************** <BR>
|
---|
2 | This file is part of Crack dot Com's free source code release of
|
---|
3 | Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
|
---|
4 | information about compiling & licensing issues visit this URL</a>
|
---|
5 | <PRE> If that doesn't help, contact Jonathan Clark at
|
---|
6 | golgotha_source@usa.net (Subject should have "GOLG" in it)
|
---|
7 | ***********************************************************************/
|
---|
8 |
|
---|
9 | #ifndef MIP_AVERAGE_HH
|
---|
10 | #define MIP_AVERAGE_HH
|
---|
11 |
|
---|
12 | struct i4_pixel_format;
|
---|
13 | #include "math/num_type.hh"
|
---|
14 | #include "time/profile.hh"
|
---|
15 |
|
---|
16 | //regular shifting info
|
---|
17 | extern w32 mip_r_and; extern w8 mip_r_shift; //r and g shifts are to the left
|
---|
18 | extern w32 mip_g_and; extern w8 mip_g_shift;
|
---|
19 | extern w32 mip_b_and; extern w8 mip_b_shift; //b shift is to the right
|
---|
20 |
|
---|
21 | //chroma-key shifting info
|
---|
22 | extern w32 mip_c_r_and; extern w8 mip_c_r_shift; //r and g shifts are to the left
|
---|
23 | extern w32 mip_c_g_and; extern w8 mip_c_g_shift;
|
---|
24 | extern w32 mip_c_b_and; extern w8 mip_c_b_shift; //b shift is to the right
|
---|
25 | extern w32 mip_c_a_and; extern w8 mip_c_a_shift; //a shift is to the left
|
---|
26 |
|
---|
27 | //alpha texture shifting info
|
---|
28 | extern w32 mip_a_r_and; extern w8 mip_a_r_shift; //r and g shifts are to the left
|
---|
29 | extern w32 mip_a_g_and; extern w8 mip_a_g_shift;
|
---|
30 | extern w32 mip_a_b_and; extern w8 mip_a_b_shift; //b shift is to the right
|
---|
31 | extern w32 mip_a_a_and; extern w8 mip_a_a_shift; //a shift is to the left
|
---|
32 |
|
---|
33 | extern w8 mip_chroma_red,mip_chroma_green,mip_chroma_blue;
|
---|
34 |
|
---|
35 | extern i4_profile_class pf_make_next_mip;
|
---|
36 | extern i4_profile_class pf_mip_24_to_16;
|
---|
37 |
|
---|
38 | void setup_pixel_formats(i4_pixel_format ®_fmt,
|
---|
39 | i4_pixel_format &chroma_fmt,
|
---|
40 | i4_pixel_format &alpha_fmt,
|
---|
41 | w32 chroma_color);
|
---|
42 |
|
---|
43 | inline void remap_pixel(w16 *&dst, w8 *&src)
|
---|
44 | {
|
---|
45 | //convert 24bit RGB to 16bit RGB
|
---|
46 |
|
---|
47 | //shifts must go first, ands last
|
---|
48 | *dst = (((w16)src[0] << mip_r_shift) & mip_r_and) |
|
---|
49 | (((w16)src[1] << mip_g_shift) & mip_g_and) |
|
---|
50 | (((w16)src[2] >> mip_b_shift) & mip_b_and);
|
---|
51 | }
|
---|
52 |
|
---|
53 | inline void chroma_remap_pixel(w16 *&dst, w8 *&src)
|
---|
54 | {
|
---|
55 | //convert 24bit RGB to argb
|
---|
56 |
|
---|
57 | if (src[0]==mip_chroma_red && src[1]==mip_chroma_green && src[2]==mip_chroma_blue)
|
---|
58 | {
|
---|
59 | *dst = 0;
|
---|
60 | }
|
---|
61 | else
|
---|
62 | {
|
---|
63 | //alpha bit(s) is set if its not transparent
|
---|
64 | *dst = (((w16)src[0] << mip_c_r_shift) & mip_c_r_and) |
|
---|
65 | (((w16)src[1] << mip_c_g_shift) & mip_c_g_and) |
|
---|
66 | (((w16)src[2] >> mip_c_b_shift) & mip_c_b_and) |
|
---|
67 | ((0xFFFFFFFF << mip_c_a_shift) & mip_c_a_and);
|
---|
68 | }
|
---|
69 | }
|
---|
70 |
|
---|
71 | inline void alpha_remap_pixel(w16 *&dst, w8 *&src)
|
---|
72 | {
|
---|
73 | //convert 32bit ARGB to 16bit ARGB
|
---|
74 |
|
---|
75 | //alpha bit(s) is set if its not transparent
|
---|
76 | *dst = (((w16)src[1] << mip_a_r_shift) & mip_a_r_and) |
|
---|
77 | (((w16)src[2] << mip_a_g_shift) & mip_a_g_and) |
|
---|
78 | (((w16)src[3] >> mip_a_b_shift) & mip_a_b_and) |
|
---|
79 | (((w16)src[0] << mip_a_a_shift) & mip_a_a_and);
|
---|
80 | }
|
---|
81 |
|
---|
82 | void r1_dos_paths(char *src);
|
---|
83 |
|
---|
84 | void r1_unix_paths(char *src);
|
---|
85 |
|
---|
86 | char *r1_remove_paths(char *src);
|
---|
87 |
|
---|
88 | void r1_remove_extention(char *src);
|
---|
89 |
|
---|
90 | void r1_concatenate_path(char *src, char *path);
|
---|
91 |
|
---|
92 | void chroma_process(w8 *&p, float &r, float &g, float &b, sw8 &num_regular, sw8 &num_chroma);
|
---|
93 |
|
---|
94 | void average_4x4_chroma(w16 *&dst, w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
|
---|
95 |
|
---|
96 | void average_4x4_chroma(w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
|
---|
97 |
|
---|
98 | void average_4x4_alpha(w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
|
---|
99 |
|
---|
100 | void average_4x4_alpha(w16 *dst, w8 *dst_24, w8 *&p0, w8 *p1, w8 *p2, w8 *p3);
|
---|
101 |
|
---|
102 | void average_4x4_normal(w16 *dst, w8 *dst_24, w8 *p0, w32 bpl);
|
---|
103 |
|
---|
104 | void average_4x4_normal(w8 *dst_24, w8 *p0, w32 bpl);
|
---|
105 |
|
---|
106 | void mip_24_to_16(w8 *mip24, w16 *mip16, sw32 &width,
|
---|
107 | sw32 &height, sw32 &base_width, w8 &flags);
|
---|
108 |
|
---|
109 | void make_next_mip(w8 *mip24, w16 *mip16, sw32 &width, sw32 &height,
|
---|
110 | sw32 &base_width, w8 &flags);
|
---|
111 |
|
---|
112 | void make_square(w8 *mip24, w8 *square_mip24, w8 base_pixel_size, sw32 base_width,
|
---|
113 | sw32 base_height, sw32 new_dimention);
|
---|
114 |
|
---|
115 | void generate_mip_offsets(sw32 base_width,sw32 base_height,
|
---|
116 | sw32 num_to_copy,
|
---|
117 | sw32 *offsets, sw32 pixel_size);
|
---|
118 |
|
---|
119 | #endif
|
---|