OpenCores
URL https://opencores.org/ocsvn/mb-jpeg/mb-jpeg/trunk

Subversion Repositories mb-jpeg

[/] [mb-jpeg/] [tags/] [STEP1_2/] [mb-bmp2jpg/] [ejpgl.h] - Blame information for rev 66

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 56 quickwayne
#ifndef _EJPGL_H
2
#define _EJPGL_H
3
 
4
#define MATRIX_SIZE 8
5
#define MACRO_BLOCK_SIZE 16
6
#define NUMBER_OF_PIXELS MATRIX_SIZE*MATRIX_SIZE
7
 
8
 
9
typedef struct {
10
   unsigned int size;               /* Header size in bytes      */
11
   int width,height;                /* Width and height of image */
12
   unsigned short int planes;       /* Number of colour planes   */
13
   unsigned short int bits;         /* Bits per pixel            */
14
   unsigned int compression;        /* Compression type          */
15
   unsigned int imagesize;          /* Image size in bytes       */
16
   int xresolution,yresolution;     /* Pixels per meter          */
17
   unsigned int ncolours;           /* Number of colours         */
18
   unsigned int importantcolours;   /* Important colours         */
19
   unsigned char palette[1024];      /* Storage for palette       */
20
} INFOHEADER;
21
 
22
typedef struct {
23
   int restofheader; //TODO
24
   INFOHEADER info;                 /* Information header        */
25
} BMPHEADER;
26
 
27
typedef struct {
28
   unsigned int row;     /* Width and height of image */
29
   unsigned int col;   /* Width and height of image */
30
} BLOCKINFO;
31
 
32
typedef struct {
33
        unsigned char QTMarker[2];
34
        unsigned char Length[2];
35
        unsigned char QTInfo[130]; //bit 0..3: number of QT (0..3, otherwise error)
36
                                //     bit 4..7: precision of QT, 0 = 8 bit, otherwise 16 bit
37
    //    unsigned char ValuesQT[]; //max 192 values. 64*(precision+1) bytes
38
} QTINFO;
39
 
40
typedef struct {
41
            unsigned char HTMarker[2];
42
            unsigned char Length[2];
43
            unsigned char HuffmanInfo[416]; //Array containing ALL huffman information
44
            //For each color component holds:
45
                    //First byte is used as info byte, followed by 16 bytes with values used
46
                    //for counting the different huffman codes, finally the corresponding
47
                    //huffman codes will follow. This sequence can repeat it self for
48
                    //different Huffman tables, both DC or AC tables.
49
 
50
                    //The structure of the information byte is as follows:
51
                    //bit 0..3 : number of HT (0..3, otherwise error)
52
                    //bit 4     : type of HT, 0 = DC table, 1 = AC table
53
                    //bit 5..7 : not used, must be 0 (Used for  progressive scan JPEG)
54
} HTINFO;
55
 
56
 
57
typedef struct {
58
            unsigned char APP0Marker[2];
59
            unsigned char Length[2];
60
            unsigned char Identifier[5];
61
            unsigned char Version[2];
62
            unsigned char Units;
63
            unsigned char XDensity[2];
64
            unsigned char YDensity[2];
65
            unsigned char ThumbWidth;
66
            unsigned char ThumbHeight;
67
} APP0INFO;
68
 
69
typedef struct {
70
            unsigned char SOF0Marker[2];
71
            unsigned char Length[2];
72
            unsigned char DataPrecision; //This is in bits/sample, usually 8 (12 and 16 not supported by most software).
73
            unsigned char ImageHeight[2];
74
            unsigned char ImageWidth[2];
75
            unsigned char Components; //Usually 1 = grey scaled, 3 = color YcbCr or YIQ 4 = color CMYK
76
            unsigned char ComponentInfo[3][3]; //Read each component data of 3 bytes. It contains,
77
                                       //(component Id(1byte)(1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q),
78
                                         //sampling factors (1byte) (bit 0-3 vertical., 4-7 horizontal.),
79
                                           //quantization table number (1 byte)).
80
} SOF0INFO;
81
 
82
typedef struct {
83
            unsigned char SOSMarker[2];
84
            unsigned char Length[2]; //This must be equal to 6+2*(number of components in scan).
85
            unsigned char ComponentCount; //This must be >= 1 and <=4 (otherwise error), usually 1 or 3
86
            unsigned char Component[3][2]; // For each component, read 2 bytes. It contains,
87
                                          //1 byte   Component Id (1=Y, 2=Cb, 3=Cr, 4=I, 5=Q),
88
                                            //1 byte   Huffman table to use :
89
                                              //bit 0..3 : AC table (0..3)
90
                                                //bit 4..7 : DC table (0..3)
91
            unsigned char Ignore[3]; //We have to skip 3 bytes
92
} SOSINFO;
93
 
94
typedef struct {
95
            unsigned char DRIMarker[2];
96
            unsigned char Length[2];
97
            unsigned char RestartInteral[2]; // Interval of the restart markers
98
} DRIINFO;
99
 
100
typedef struct {
101
            unsigned char SOIMarker[2]; //Start of image marker
102
            APP0INFO app0;
103
            QTINFO qt;
104
            SOF0INFO sof0;
105
            HTINFO ht;
106
//            DRIINFO dri;
107
            SOSINFO sos;
108
} JPEGHEADER;
109
 
110
 
111 57 quickwayne
int openBMPJPG(int argc, char* bmpfilename, char* jpgfilename);
112 56 quickwayne
int closeBMPJPG();
113
 
114
 
115
void    HuffmanEncodeFinishSend();
116
 
117
 
118
 
119
int idct8x8(int* fblock, char* sblock);
120
 
121
#endif
122
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.