summaryrefslogtreecommitdiffstats
path: root/tkmpeg/ezmpeg.h
blob: 47a5599ca77df59bd30cf957e88c0ec63766bdc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//This file is part of ezMPEG

//Copyright (C)2002 Ingo Oppermann ( ingo_opp@users.sourceforge.net / http://sourceforge.net/projects/ezmpeg/ )

//

//This program is free software; you can redistribute it and/or

//modify it under the terms of the GNU General Public License

//as published by the Free Software Foundation; either

//version 2 of the License, or (at your option) any later version.

//

//This program is distributed in the hope that it will be useful,

//but WITHOUT ANY WARRANTY; without even the implied warranty of

//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

//GNU General Public License for more details.


// Version 0.1


typedef struct ezMPEGStream {
	char *outfile;
	FILE *out;
	int hsize;
	int vsize;
	int picture_rate;
	int gop_size;
	int dc_prev[3];
	double q_scale;

	int picture_count;
	int buffersize;
	int buffercount;
	char *buffer;
	int buf;
	int pos;

	short error_code;
	char error_msg[256];
} ezMPEGStream;

typedef struct Block {
	float a[64];
} Block;

typedef struct Macroblock {
	Block lum[4];
	Block chrom[2];
} Macroblock;

// Prototypes

// 'sichtbare' Funktionen. Nur diese 5 Funktionen werden direkt benutzt

int ezMPEG_Init(ezMPEGStream *ms, const char *outfile, int hsize, int vsize, int picture_rate, int gop_size, int q_scale);
int ezMPEG_Start(ezMPEGStream *ms);
int ezMPEG_Add(ezMPEGStream *ms, unsigned char *picture);
int ezMPEG_Finalize(ezMPEGStream *ms);
void ezMPEG_Resize(ezMPEGStream *ms, unsigned char *outbild, unsigned char *inbild, int x, int y, int u, int v);
char *ezMPEG_GetLastError(ezMPEGStream *ms);

// 'unsichtbare' Funktionen

void ezMPEG_InitBitBuffer(ezMPEGStream *ms);
void ezMPEG_ByteAlign(ezMPEGStream *ms);
int ezMPEG_WriteBits(ezMPEGStream *ms, unsigned int value, int length);

void ezMPEG_WriteSequenceHeader(ezMPEGStream *ms);
void ezMPEG_WriteGOPHeader(ezMPEGStream *ms);
void ezMPEG_WritePictureHeader(ezMPEGStream *ms);

Macroblock ezMPEG_GetMacroblock(ezMPEGStream *ms, unsigned char *picture, int number);
Macroblock ezMPEG_QuantizeMacroblock(ezMPEGStream *ms, Macroblock mb);
void ezMPEG_WriteMacroblock(ezMPEGStream *ms, Macroblock mb);

float ezMPEG_1DFDCT(float *v, int i);

void ezMPEG_EncodeDC(ezMPEGStream *ms, int dc_diff, int type);
void ezMPEG_EncodeAC(ezMPEGStream *ms, int runlength, int level);

void ezMPEG_FlushBuffer(ezMPEGStream *ms);
void ezMPEG_SetError(ezMPEGStream *ms, const char *error_msg);