1 |
#ifndef _CODEC_H_ |
#ifndef _CODEC_H_ |
2 |
#define _CODEC_H_ |
#define _CODEC_H_ |
3 |
|
|
|
#include <windows.h> |
|
4 |
#include <vfw.h> |
#include <vfw.h> |
|
#include <xvid.h> |
|
5 |
#include "config.h" |
#include "config.h" |
6 |
|
|
7 |
#if defined(_DEBUG) |
#define XVID_NAME_L L"XVID" |
8 |
#define DEBUG(X) OutputDebugString(X) |
#define XVID_DESC_L L"XviD MPEG-4 Codec" |
|
#define DEBUG1(X,A) { char tmp[120]; wsprintf(tmp, "%s %i", (X), (A)); OutputDebugString(tmp); } |
|
|
#define DEBUG2(X,A,B) { char tmp[120]; wsprintf(tmp, "%s %i %i", (X), (A), (B)); OutputDebugString(tmp); } |
|
|
#define DEBUG3(X,A,B,C) { char tmp[120]; wsprintf(tmp, "%s %i %i %i", (X), (A), (B), (C)); OutputDebugString(tmp); } |
|
|
#define DEBUG4(X,A,B,C,D) { char tmp[120]; wsprintf(tmp, "%s %i %i %i %i", (X), (A), (B), (C), (D)); OutputDebugString(tmp); } |
|
|
#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); } |
|
|
#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); } |
|
|
#else |
|
|
#define DEBUG(X) |
|
|
#define DEBUG1(X,A) { char tmp[120]; wsprintf(tmp, "%s %i", (X), (A)); OutputDebugString(tmp); } |
|
|
#define DEBUG2(X,A,B) |
|
|
#define DEBUG3(X,A,B,C) |
|
|
#define DEBUG4(X,A,B,C,D) |
|
|
#define DEBUG5(X,A,B,C,D,E) |
|
|
#define DEBUGFOURCC(X,Y) |
|
|
#endif |
|
|
|
|
|
|
|
|
#define DEBUGERR(X) OutputDebugString(X) |
|
|
#define DEBUG2P(X) OutputDebugString(X) |
|
|
#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); } |
|
|
#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); } |
|
|
|
|
9 |
|
|
10 |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
11 |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
12 |
#define FOURCC_DX50 mmioFOURCC('D','X','5','0') |
#define FOURCC_DX50 mmioFOURCC('D','X','5','0') |
|
//#define FOURCC_DIV3 mmioFOURCC('D','I','V','3') |
|
|
//#define FOURCC_DIV4 mmioFOURCC('D','I','V','4') |
|
|
|
|
13 |
/* yuyu 4:2:2 16bit, y-u-y-v, packed*/ |
/* yuyu 4:2:2 16bit, y-u-y-v, packed*/ |
14 |
#define FOURCC_YUYV mmioFOURCC('Y','U','Y','V') |
#define FOURCC_YUYV mmioFOURCC('Y','U','Y','V') |
15 |
#define FOURCC_YUY2 mmioFOURCC('Y','U','Y','2') |
#define FOURCC_YUY2 mmioFOURCC('Y','U','Y','2') |
|
|
|
16 |
/* yvyu 4:2:2 16bit, y-v-y-u, packed*/ |
/* yvyu 4:2:2 16bit, y-v-y-u, packed*/ |
17 |
#define FOURCC_YVYU mmioFOURCC('Y','V','Y','U') |
#define FOURCC_YVYU mmioFOURCC('Y','V','Y','U') |
|
|
|
18 |
/* uyvy 4:2:2 16bit, u-y-v-y, packed */ |
/* uyvy 4:2:2 16bit, u-y-v-y, packed */ |
19 |
#define FOURCC_UYVY mmioFOURCC('U','Y','V','Y') |
#define FOURCC_UYVY mmioFOURCC('U','Y','V','Y') |
|
|
|
20 |
/* i420 y-u-v, planar */ |
/* i420 y-u-v, planar */ |
21 |
#define FOURCC_I420 mmioFOURCC('I','4','2','0') |
#define FOURCC_I420 mmioFOURCC('I','4','2','0') |
22 |
#define FOURCC_IYUV mmioFOURCC('I','Y','U','V') |
#define FOURCC_IYUV mmioFOURCC('I','Y','U','V') |
|
|
|
23 |
/* yv12 y-v-u, planar */ |
/* yv12 y-v-u, planar */ |
24 |
#define FOURCC_YV12 mmioFOURCC('Y','V','1','2') |
#define FOURCC_YV12 mmioFOURCC('Y','V','1','2') |
25 |
|
|
26 |
|
|
|
|
|
|
#define XVID_NAME_L L"XVID" |
|
|
#define XVID_DESC_L L"XviD MPEG-4 Codec" |
|
|
|
|
|
|
|
|
#define NNSTATS_KEYFRAME (1<<31) |
|
|
#define NNSTATS_BFRAME (1<<30) |
|
|
|
|
|
typedef struct |
|
|
{ |
|
|
/* frame length (bytes) */ |
|
|
|
|
|
DWORD bytes; |
|
|
|
|
|
/* ignored & zero'd by gk |
|
|
xvid specific: dk_v = frame header bytes |
|
|
*/ |
|
|
|
|
|
int dk_v, dk_u, dk_y; |
|
|
int dd_v, dd_u, dd_y; |
|
|
int mk_u, mk_y; |
|
|
int md_u, md_y; |
|
|
|
|
|
/* q used for this frame |
|
|
set bit 31 for keyframe */ |
|
|
|
|
|
int quant; |
|
|
|
|
|
/* key, motion, not-coded macroblocks */ |
|
|
|
|
|
int kblk, mblk, ublk; |
|
|
|
|
|
/* lum_noise is actually a double (as 8 bytes) |
|
|
for some reason msvc6.0 stores doubles as 12 bytes!? |
|
|
lum_noise is not used so it doesnt matter */ |
|
|
|
|
|
float lum_noise[2]; |
|
|
} NNSTATS; |
|
|
|
|
|
|
|
27 |
typedef struct |
typedef struct |
28 |
{ |
{ |
|
HANDLE hints; |
|
|
HANDLE stats1; |
|
|
HANDLE stats2; |
|
|
|
|
|
void * hintstream; |
|
|
|
|
|
int bytes1; |
|
|
int bytes2; |
|
|
int desired_bytes2; |
|
|
|
|
|
int keyframe_locations[20480]; |
|
|
int max_framesize; |
|
|
int minbsize, minpsize, minisize; |
|
|
double movie_curve; |
|
|
double credits_start_curve; |
|
|
double credits_end_curve; |
|
|
|
|
|
double average_pframe; |
|
|
double average_bframe; |
|
|
double curve_comp_scale; |
|
|
double curve_bias_bonus; |
|
|
double alt_curve_low; |
|
|
double alt_curve_high; |
|
|
double alt_curve_low_diff; |
|
|
double alt_curve_high_diff; |
|
|
double alt_curve_mid_qual; |
|
|
double alt_curve_qual_dev; |
|
|
int overflow, KF_idx, KFoverflow, KFoverflow_partial; |
|
|
int quant_count[32]; |
|
|
|
|
|
NNSTATS nns1; |
|
|
NNSTATS nns2; |
|
|
|
|
|
NNSTATS* nns1_array; |
|
|
NNSTATS* nns2_array; |
|
|
int nns_array_size; |
|
|
int nns_array_length; |
|
|
int nns_array_pos; |
|
|
|
|
|
int nns_update_pos; /* codec_2pass_update() */ |
|
|
} TWOPASS; |
|
|
|
|
|
|
|
|
typedef struct |
|
|
{ |
|
|
// config |
|
29 |
CONFIG config; |
CONFIG config; |
30 |
|
|
31 |
// encore |
// decoder |
32 |
|
void * dhandle; |
33 |
|
|
34 |
|
// encoder |
35 |
void * ehandle; |
void * ehandle; |
36 |
int fincr; |
int fincr; |
37 |
int fbase; |
int fbase; |
38 |
|
|
39 |
|
// encoder min keyframe internal |
40 |
int framenum; |
int framenum; |
41 |
int keyspacing; |
int keyspacing; |
42 |
|
|
|
// encore 2pass |
|
|
TWOPASS twopass; |
|
|
|
|
|
// decore |
|
|
void * dhandle; |
|
|
int dopt; // DEC_OPT_DECODE, DEC_OPT_DECODE_MS |
|
43 |
} CODEC; |
} CODEC; |
44 |
|
|
45 |
|
|
59 |
LRESULT decompress_end(CODEC *); |
LRESULT decompress_end(CODEC *); |
60 |
LRESULT decompress(CODEC *, ICDECOMPRESS *); |
LRESULT decompress(CODEC *, ICDECOMPRESS *); |
61 |
|
|
|
int codec_get_quant(CODEC *, xvid_enc_frame_t *); |
|
|
int codec_is_in_credits(CONFIG *, int); |
|
|
int codec_get_vbr_quant(CONFIG *, int); |
|
|
|
|
|
// added by Koepi for greyscale credits |
|
|
int check_greyscale_mode(CONFIG *, xvid_enc_frame_t* , int); |
|
|
// end of koepi's additions |
|
|
|
|
62 |
#endif /* _CODEC_H_ */ |
#endif /* _CODEC_H_ */ |