1 |
|
#ifndef _CODEC_H_ |
2 |
|
#define _CODEC_H_ |
3 |
|
|
4 |
|
#include <windows.h> |
5 |
|
#include <vfw.h> |
6 |
|
#include <xvid.h> |
7 |
|
#include "config.h" |
8 |
|
|
9 |
|
#if defined(_DEBUG) |
10 |
|
#define DEBUG(X) OutputDebugString(X) |
11 |
|
#define DEBUG1(X,A) { char tmp[120]; wsprintf(tmp, "%s %i", (X), (A)); OutputDebugString(tmp); } |
12 |
|
#define DEBUG2(X,A,B) { char tmp[120]; wsprintf(tmp, "%s %i %i", (X), (A), (B)); OutputDebugString(tmp); } |
13 |
|
#define DEBUG3(X,A,B,C) { char tmp[120]; wsprintf(tmp, "%s %i %i %i", (X), (A), (B), (C)); OutputDebugString(tmp); } |
14 |
|
#define DEBUG4(X,A,B,C,D) { char tmp[120]; wsprintf(tmp, "%s %i %i %i %i", (X), (A), (B), (C), (D)); OutputDebugString(tmp); } |
15 |
|
#define DEBUG5(X,A,B,C,D,E) { char tmp[120]; wsprintf(tmp, "%s %i %i %i %i %i", (X), (A), (B), (C), (D), (E)); OutputDebugString(tmp); } |
16 |
|
#define DEBUGFOURCC(X,Y) { char tmp[120]; wsprintf(tmp, "%s %c %c %c %c", (X), (Y)&0xff, ((Y)>>8)&0xff, ((Y)>>16)&0xff, ((Y)>>24)&0xff); OutputDebugString(tmp); } |
17 |
|
#else |
18 |
|
#define DEBUG(X) |
19 |
|
#define DEBUG1(X,A) { char tmp[120]; wsprintf(tmp, "%s %i", (X), (A)); OutputDebugString(tmp); } |
20 |
|
#define DEBUG2(X,A,B) |
21 |
|
#define DEBUG3(X,A,B,C) |
22 |
|
#define DEBUG4(X,A,B,C,D) |
23 |
|
#define DEBUG5(X,A,B,C,D,E) |
24 |
|
#define DEBUGFOURCC(X,Y) |
25 |
|
#endif |
26 |
|
|
27 |
|
|
28 |
|
#define DEBUGERR(X) OutputDebugString(X) |
29 |
|
#define DEBUG2P(X) OutputDebugString(X) |
30 |
|
#define DEBUG1ST(A,B,C,D,E,F,G) { char tmp[140]; wsprintf(tmp, "1st-pass: size:%d total-kbytes:%d %s quant:%d %s kblocks:%d mblocks:%d", (A), (B), (C), (D), (E), (F), (G)); OutputDebugString(tmp); } |
31 |
|
#define DEBUG2ND(A,B,C,D,E,F,G,H) { char tmp[140]; wsprintf(tmp, "2nd-pass: quant:%d %s %s stats1:%d scaled:%d actual:%d overflow:%d %s", (A), (B), (C), (D), (E), (F), (G), (H) ? "credits" : "movie"); OutputDebugString(tmp); } |
32 |
|
|
33 |
|
|
34 |
|
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
35 |
|
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
36 |
|
#define FOURCC_DX50 mmioFOURCC('D','X','5','0') |
37 |
|
//#define FOURCC_DIV3 mmioFOURCC('D','I','V','3') |
38 |
|
//#define FOURCC_DIV4 mmioFOURCC('D','I','V','4') |
39 |
|
|
40 |
|
/* yuyu 4:2:2 16bit, y-u-y-v, packed*/ |
41 |
|
#define FOURCC_YUYV mmioFOURCC('Y','U','Y','V') |
42 |
|
#define FOURCC_YUY2 mmioFOURCC('Y','U','Y','2') |
43 |
|
|
44 |
|
/* yvyu 4:2:2 16bit, y-v-y-u, packed*/ |
45 |
|
#define FOURCC_YVYU mmioFOURCC('Y','V','Y','U') |
46 |
|
|
47 |
|
/* uyvy 4:2:2 16bit, u-y-v-y, packed */ |
48 |
|
#define FOURCC_UYVY mmioFOURCC('U','Y','V','Y') |
49 |
|
|
50 |
|
/* i420 y-u-v, planar */ |
51 |
|
#define FOURCC_I420 mmioFOURCC('I','4','2','0') |
52 |
|
#define FOURCC_IYUV mmioFOURCC('I','Y','U','V') |
53 |
|
|
54 |
|
/* yv12 y-v-u, planar */ |
55 |
|
#define FOURCC_YV12 mmioFOURCC('Y','V','1','2') |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
#define XVID_NAME_L L"XVID" |
60 |
|
#define XVID_DESC_L L"XviD MPEG-4 Codec" |
61 |
|
|
62 |
|
|
63 |
|
#define NNSTATS_KEYFRAME (1<<31) |
64 |
|
#define NNSTATS_BFRAME (1<<30) |
65 |
|
|
66 |
|
typedef struct |
67 |
|
{ |
68 |
|
/* frame length (bytes) */ |
69 |
|
|
70 |
|
DWORD bytes; |
71 |
|
|
72 |
|
/* ignored & zero'd by gk |
73 |
|
xvid specific: dk_v = frame header bytes |
74 |
|
*/ |
75 |
|
|
76 |
|
int dk_v, dk_u, dk_y; |
77 |
|
int dd_v, dd_u, dd_y; |
78 |
|
int mk_u, mk_y; |
79 |
|
int md_u, md_y; |
80 |
|
|
81 |
|
/* q used for this frame |
82 |
|
set bit 31 for keyframe */ |
83 |
|
|
84 |
|
int quant; |
85 |
|
|
86 |
|
/* key, motion, not-coded macroblocks */ |
87 |
|
|
88 |
|
int kblk, mblk, ublk; |
89 |
|
|
90 |
|
/* lum_noise is actually a double (as 8 bytes) |
91 |
|
for some reason msvc6.0 stores doubles as 12 bytes!? |
92 |
|
lum_noise is not used so it doesnt matter */ |
93 |
|
|
94 |
|
float lum_noise[2]; |
95 |
|
} NNSTATS; |
96 |
|
|
97 |
|
|
98 |
|
typedef struct |
99 |
|
{ |
100 |
|
HANDLE hints; |
101 |
|
HANDLE stats1; |
102 |
|
HANDLE stats2; |
103 |
|
|
104 |
|
void * hintstream; |
105 |
|
|
106 |
|
int bytes1; |
107 |
|
int bytes2; |
108 |
|
int desired_bytes2; |
109 |
|
|
110 |
|
int keyframe_locations[20480]; |
111 |
|
int max_framesize; |
112 |
|
int minbsize, minpsize, minisize; |
113 |
|
double movie_curve; |
114 |
|
double credits_start_curve; |
115 |
|
double credits_end_curve; |
116 |
|
|
117 |
|
double average_pframe; |
118 |
|
double average_bframe; |
119 |
|
double curve_comp_scale; |
120 |
|
double curve_bias_bonus; |
121 |
|
double alt_curve_low; |
122 |
|
double alt_curve_high; |
123 |
|
double alt_curve_low_diff; |
124 |
|
double alt_curve_high_diff; |
125 |
|
double alt_curve_mid_qual; |
126 |
|
double alt_curve_qual_dev; |
127 |
|
int overflow, KF_idx, KFoverflow, KFoverflow_partial; |
128 |
|
int quant_count[32]; |
129 |
|
|
130 |
|
NNSTATS nns1; |
131 |
|
NNSTATS nns2; |
132 |
|
|
133 |
|
NNSTATS* nns1_array; |
134 |
|
NNSTATS* nns2_array; |
135 |
|
int nns_array_size; |
136 |
|
int nns_array_length; |
137 |
|
int nns_array_pos; |
138 |
|
|
139 |
|
int nns_update_pos; /* codec_2pass_update() */ |
140 |
|
} TWOPASS; |
141 |
|
|
142 |
|
|
143 |
|
typedef struct |
144 |
|
{ |
145 |
|
// config |
146 |
|
CONFIG config; |
147 |
|
|
148 |
|
// encore |
149 |
|
void * ehandle; |
150 |
|
int fincr; |
151 |
|
int fbase; |
152 |
|
int framenum; |
153 |
|
int keyspacing; |
154 |
|
|
155 |
|
// encore 2pass |
156 |
|
TWOPASS twopass; |
157 |
|
|
158 |
|
// decore |
159 |
|
void * dhandle; |
160 |
|
int dopt; // DEC_OPT_DECODE, DEC_OPT_DECODE_MS |
161 |
|
} CODEC; |
162 |
|
|
163 |
|
|
164 |
|
int get_colorspace(BITMAPINFOHEADER *); |
165 |
|
|
166 |
|
LRESULT compress_query(CODEC *, BITMAPINFO *, BITMAPINFO *); |
167 |
|
LRESULT compress_get_format(CODEC *, BITMAPINFO *, BITMAPINFO *); |
168 |
|
LRESULT compress_get_size(CODEC *, BITMAPINFO *, BITMAPINFO *); |
169 |
|
LRESULT compress_frames_info(CODEC *, ICCOMPRESSFRAMES *); |
170 |
|
LRESULT compress_begin(CODEC *, BITMAPINFO *, BITMAPINFO *); |
171 |
|
LRESULT compress_end(CODEC *); |
172 |
|
LRESULT compress(CODEC *, ICCOMPRESS *); |
173 |
|
|
174 |
|
LRESULT decompress_query(CODEC *, BITMAPINFO *, BITMAPINFO *); |
175 |
|
LRESULT decompress_get_format(CODEC *, BITMAPINFO *, BITMAPINFO *); |
176 |
|
LRESULT decompress_begin(CODEC *, BITMAPINFO *, BITMAPINFO *); |
177 |
|
LRESULT decompress_end(CODEC *); |
178 |
|
LRESULT decompress(CODEC *, ICDECOMPRESS *); |
179 |
|
|
180 |
|
int codec_get_quant(CODEC *, xvid_enc_frame_t *); |
181 |
|
int codec_is_in_credits(CONFIG *, int); |
182 |
|
int codec_get_vbr_quant(CONFIG *, int); |
183 |
|
|
184 |
|
// added by Koepi for greyscale credits |
185 |
|
int check_greyscale_mode(CONFIG *, xvid_enc_frame_t* , int); |
186 |
|
// end of koepi's additions |
187 |
|
|
188 |
|
#endif /* _CODEC_H_ */ |