-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode.h
More file actions
72 lines (62 loc) · 1.45 KB
/
encode.h
File metadata and controls
72 lines (62 loc) · 1.45 KB
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
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <errno.h>
typedef struct _Picture
{
int x;
int y;
unsigned char *r;
unsigned char *g;
unsigned char *b;
unsigned char *a;
}Picture;
void check_error(int n, const char* p);
void check_error(char* n, const char* p);
void check_error(FILE* n, const char* p);
class Jpegencoder {
public:
Jpegencoder(char input[64], char output[64]) {
check_error(strcpy(input_path_, input), "input_path_ strcpy");
check_error(strcpy(output_path_, output), "output_path_, strcpy");
check_error((input_fp_ = fopen(input_path_, "rb")), "input_fp_ fopen");
check_error((output_fp_ = fopen(output_path_, "wb")), "output_fp_ fopen");
count_ = 0;
}
~Jpegencoder() {
fclose(input_fp_);
fclose(output_fp_);
}
void inputPpm();
void makeHeader();
void convertYCbCr();
void freeYCbCr();
void DCTconvert();
void freeDCT();
void quantization();
void huffman();
void endHeader();
/* debug section */
void printQuant();
void printPic();
private:
char input_path_[64];
char output_path_[64];
FILE* input_fp_;
FILE* output_fp_;
int x_size_, y_size_;
Picture *pPic_;
int *col_y_;
int *col_cb_;
int *col_cr_;
int fixed_x_, fixed_y_;
int *dct_y_;
int *dct_cr_;
int *dct_cb_;
int count_;
unsigned int str_[128];
int digit(int x);
void outstream(unsigned int size, unsigned int x);
int bit_inv(int size, int x);
};