1 |
|
/***************************************************************************** |
2 |
|
* |
3 |
|
* XVID MPEG-4 VIDEO CODEC |
4 |
|
* - VFW codec header - |
5 |
|
* |
6 |
|
* Copyright(C) 2002-2003 Anonymous <xvid-devel@xvid.org> |
7 |
|
* |
8 |
|
* This program is free software ; you can redistribute it and/or modify |
9 |
|
* it under the terms of the GNU General Public License as published by |
10 |
|
* the Free Software Foundation ; either version 2 of the License, or |
11 |
|
* (at your option) any later version. |
12 |
|
* |
13 |
|
* This program is distributed in the hope that it will be useful, |
14 |
|
* but WITHOUT ANY WARRANTY ; without even the implied warranty of |
15 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
|
* GNU General Public License for more details. |
17 |
|
* |
18 |
|
* You should have received a copy of the GNU General Public License |
19 |
|
* along with this program ; if not, write to the Free Software |
20 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 |
|
* |
22 |
|
* $Id: codec.h,v 1.1.2.4 2003-06-09 13:55:56 edgomez Exp $ |
23 |
|
* |
24 |
|
****************************************************************************/ |
25 |
#ifndef _CODEC_H_ |
#ifndef _CODEC_H_ |
26 |
#define _CODEC_H_ |
#define _CODEC_H_ |
27 |
|
|
|
#include <windows.h> |
|
28 |
#include <vfw.h> |
#include <vfw.h> |
|
#include <xvid.h> |
|
29 |
#include "config.h" |
#include "config.h" |
30 |
|
|
31 |
#if defined(_DEBUG) |
#define XVID_NAME_L L"XVID" |
32 |
#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); } |
|
|
|
|
33 |
|
|
34 |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
#define FOURCC_XVID mmioFOURCC('X','V','I','D') |
35 |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
#define FOURCC_DIVX mmioFOURCC('D','I','V','X') |
36 |
#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') |
|
|
|
|
37 |
/* yuyu 4:2:2 16bit, y-u-y-v, packed*/ |
/* yuyu 4:2:2 16bit, y-u-y-v, packed*/ |
38 |
#define FOURCC_YUYV mmioFOURCC('Y','U','Y','V') |
#define FOURCC_YUYV mmioFOURCC('Y','U','Y','V') |
39 |
#define FOURCC_YUY2 mmioFOURCC('Y','U','Y','2') |
#define FOURCC_YUY2 mmioFOURCC('Y','U','Y','2') |
|
|
|
40 |
/* yvyu 4:2:2 16bit, y-v-y-u, packed*/ |
/* yvyu 4:2:2 16bit, y-v-y-u, packed*/ |
41 |
#define FOURCC_YVYU mmioFOURCC('Y','V','Y','U') |
#define FOURCC_YVYU mmioFOURCC('Y','V','Y','U') |
|
|
|
42 |
/* uyvy 4:2:2 16bit, u-y-v-y, packed */ |
/* uyvy 4:2:2 16bit, u-y-v-y, packed */ |
43 |
#define FOURCC_UYVY mmioFOURCC('U','Y','V','Y') |
#define FOURCC_UYVY mmioFOURCC('U','Y','V','Y') |
|
|
|
44 |
/* i420 y-u-v, planar */ |
/* i420 y-u-v, planar */ |
45 |
#define FOURCC_I420 mmioFOURCC('I','4','2','0') |
#define FOURCC_I420 mmioFOURCC('I','4','2','0') |
46 |
#define FOURCC_IYUV mmioFOURCC('I','Y','U','V') |
#define FOURCC_IYUV mmioFOURCC('I','Y','U','V') |
|
|
|
47 |
/* yv12 y-v-u, planar */ |
/* yv12 y-v-u, planar */ |
48 |
#define FOURCC_YV12 mmioFOURCC('Y','V','1','2') |
#define FOURCC_YV12 mmioFOURCC('Y','V','1','2') |
49 |
|
|
50 |
|
|
|
|
|
|
#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; |
|
|
|
|
|
|
|
51 |
typedef struct |
typedef struct |
52 |
{ |
{ |
|
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 |
|
53 |
CONFIG config; |
CONFIG config; |
54 |
|
|
55 |
// encore |
// decoder |
56 |
|
void * dhandle; |
57 |
|
|
58 |
|
// encoder |
59 |
void * ehandle; |
void * ehandle; |
60 |
int fincr; |
int fincr; |
61 |
int fbase; |
int fbase; |
62 |
|
|
63 |
|
/* encoder min keyframe internal */ |
64 |
int framenum; |
int framenum; |
65 |
int keyspacing; |
int keyspacing; |
66 |
|
|
|
// encore 2pass |
|
|
TWOPASS twopass; |
|
|
|
|
|
// decore |
|
|
void * dhandle; |
|
|
int dopt; // DEC_OPT_DECODE, DEC_OPT_DECODE_MS |
|
67 |
} CODEC; |
} CODEC; |
68 |
|
|
69 |
|
|
83 |
LRESULT decompress_end(CODEC *); |
LRESULT decompress_end(CODEC *); |
84 |
LRESULT decompress(CODEC *, ICDECOMPRESS *); |
LRESULT decompress(CODEC *, ICDECOMPRESS *); |
85 |
|
|
|
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 |
|
|
|
|
86 |
#endif /* _CODEC_H_ */ |
#endif /* _CODEC_H_ */ |