URL
https://opencores.org/ocsvn/mb-jpeg/mb-jpeg/trunk
Subversion Repositories mb-jpeg
Compare Revisions
- This comparison shows the changes necessary to convert path
/
- from Rev 38 to Rev 39
- ↔ Reverse comparison
Rev 38 → Rev 39
/trunk/bmp2jpg_mb/bmp2jpg_mb.c
72,7 → 72,19
|
} |
|
unsigned long htonl(unsigned long x) { |
|
return ((((x)&0xff000000)>>24) | (((x)&0x00ff0000)>>8) | (((x)&0x0000ff00)<<8) | (((x)&0x000000ff)<<24)); |
|
} |
|
unsigned short hton(unsigned short x) { |
|
return ((((x) & 0xff00)>>8) | (((x) &0x00ff)<<8)); |
|
} |
|
|
int main() |
{ |
SYSACE_FILE* outfile2; |
100,12 → 112,12
ejpgl_error(eLARGE_INPUTFILE, 0); |
} |
|
if ((outfile2 = sysace_fopen("image01b.bmp", "w")) == NULL) { // see if the BMP file is correctly read into memory |
/* if ((outfile2 = sysace_fopen("image01b.bmp", "w")) == NULL) { // see if the BMP file is correctly read into memory |
ejpgl_error(eOPENOUTPUT_FILE, 0); |
} |
|
sysace_fwrite(bmpimage, 1, bmpsize, outfile2); |
sysace_fclose(outfile2); |
sysace_fclose(outfile2); */ |
|
if (getbmpheader(infile,bmpheader) == 0) { //File is a valid BMP |
ejpgl_error(eINVALID_BMP, 0); |
/trunk/bmp2jpg_mb/mb.h
37,6 → 37,7
#define eINVALID_BMP 3 |
#define eLARGE_INPUTFILE 4 |
|
#if 0 |
#ifndef htonl |
#define htonl(x) ((((x)&0xff000000)>>24) | (((x)&0x00ff0000)>>8) | (((x)&0x0000ff00)<<8) | (((x)&0x000000ff)<<24)) |
#endif |
44,6 → 45,7
#ifndef hton |
#define hton(x) ((((x) & 0xff00)>>8) | (((x) &0x00ff)<<8)) |
#endif |
#endif |
|
#endif |
|
/trunk/bmp2jpg_mb/huffman.c
58,8 → 58,29
|
#endif |
|
static unsigned char convertDCMagnitudeCLengthTable[16] = { |
0x02, 0x02, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
0x08, 0x09, 0x0a, 0x0b, 0x00, 0x00, 0x00, 0x00 |
}; |
|
static unsigned short convertDCMagnitudeCOutTable[16] = { |
0x0000, 0x0001, 0x0002, 0x0006, 0x000e, 0x001e, 0x003e, 0x007e, |
0x00fe, 0x01fe, 0x03fe, 0x07fe, 0x0000, 0x0000, 0x0000, 0x0000 |
}; |
|
void ConvertDCMagnitudeC(unsigned char magnitude,unsigned short int *out, unsigned short int *lenght) |
{ |
unsigned char len; |
|
if ((magnitude>16) || ((len=convertDCMagnitudeCLengthTable[magnitude])==0)) { |
#ifndef __MICROBLAZE |
printf("WAARDE STAAT NIET IN TABEL!!!!!!!!!!!!!!!!!!!!\n"); |
#endif |
} |
*lenght = len; |
*out = convertDCMagnitudeCOutTable[magnitude]; |
|
#if 0 |
switch (magnitude) { |
case 0x00 : *out=0x0000; *lenght=2; break; |
case 0x01 : *out=0x0001; *lenght=2; break; |
74,11 → 95,63
case 0x0a : *out=0x03fe; *lenght=10; break; |
case 0x0b : *out=0x07fe; *lenght=11; break; |
} |
#endif |
|
} |
|
static unsigned char convertACMagnitudeCLengthTable[256] = { |
0x02, 0x02, 0x03, 0x04, 0x05, 0x05, 0x06, 0x07, 0x09, 0x0a, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, // 00 - 0f |
0x00, 0x04, 0x06, 0x08, 0x09, 0x0b, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 10 - 1f |
0x00, 0x05, 0x08, 0x0a, 0x0c, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 - 2f |
0x00, 0x05, 0x08, 0x0a, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 30 - 3f |
0x00, 0x06, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 40 - 4f |
0x00, 0x06, 0x0a, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 5f |
0x00, 0x07, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 6f |
0x00, 0x07, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 7f |
0x00, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 8f |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 9f |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // a0 - af |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // b0 - bf |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // c0 - cf |
0x00, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // d0 - df |
0x00, 0x0e, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // e0 - ef |
0x0a, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 |
}; |
|
static unsigned short convertACMagnitudeCOutTable[256] = { |
0x0000, 0x0001, 0x0004, 0x000a, 0x0018, 0x0019, 0x0038, 0x0078, 0x01f4, 0x03f6, 0x0ff4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 00 - 0f |
0x0000, 0x000b, 0x0039, 0x00f6, 0x01f5, 0x07f6, 0x0ff5, 0xff88, 0xff89, 0xff8a, 0xff8b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 10 - 1f |
0x0000, 0x001a, 0x00f7, 0x03f7, 0x0ff6, 0x7fc2, 0xff8c, 0xff8d, 0xff8e, 0xff8f, 0xff90, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 20 - 2f |
0x0000, 0x001b, 0x00f8, 0x03f8, 0x0ff7, 0xff91, 0xff92, 0xff93, 0xff94, 0xff95, 0xff96, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 30 - 3f |
0x0000, 0x003a, 0x01f6, 0xff97, 0xff98, 0xff99, 0xff9a, 0xff9b, 0xff9c, 0xff9d, 0xff9e, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 40 - 4f |
0x0000, 0x003b, 0x03f9, 0xff9f, 0xffa0, 0xffa1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0xFFA6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50 - 5f |
0x0000, 0x0079, 0x07f7, 0xffa7, 0xffa8, 0xffa9, 0xffaa, 0xffab, 0xFFAc, 0xFFAf, 0xFFAe, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 60 - 6f |
0x0000, 0x007a, 0x07f8, 0xffaf, 0xffb0, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0xFFB6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 70 - 7f |
0x0000, 0x00f9, 0xffb7, 0xFFB8, 0xFFB9, 0xFFBa, 0xFFBb, 0xFFBc, 0xFFBd, 0xFFBe, 0xFFBf, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 80 - 8f |
0x0000, 0x01f7, 0xffc0, 0xffc1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0xFFC7, 0xFFC8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 90 - 9f |
0x0000, 0x01f8, 0xffc9, 0xFFCa, 0xFFCb, 0xFFCc, 0xFFCd, 0xFFCe, 0xFFCf, 0xFFd0, 0xFFd1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // a0 - af |
0x0000, 0x01f9, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7, 0xFFD8, 0xFFD9, 0xFFDa, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // b0 - bf |
0x0000, 0x01fa, 0xFFDb, 0xFFDc, 0xFFDd, 0xFFDe, 0xFFDf, 0xFFe0, 0xFFe1, 0xFFe2, 0xFFe3, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // c0 - cf |
0x0000, 0x07f9, 0xFFE4, 0xFFE5, 0xFFE6, 0xFFE7, 0xFFE8, 0xFFE9, 0xFFEa, 0xFFEb, 0xFFEc, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // d0 - df |
0x0000, 0x3fe0, 0xffed, 0xFFEe, 0xFFEf, 0xFFf0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0xFFF5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // e0 - ef |
0x03fa, 0x7fc3, 0xFFF6, 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 |
}; |
|
//=========================================================================== |
void ConvertACMagnitudeC(unsigned char magnitude,unsigned short int *out, unsigned short int *lenght) |
{ |
unsigned char len; |
|
len = convertACMagnitudeCLengthTable[magnitude]; |
if (!len) { |
#ifndef __MICROBLAZE |
printf("WAARDE STAAT NIET IN TABEL!!!!!!!!!!!!!!!!!!!!\n"); |
#endif |
} |
*lenght = len; |
*out = convertACMagnitudeCOutTable[magnitude]; |
|
#if 0 |
switch (magnitude) { |
case 0x00 : *lenght=0x02; *out=0x0000; break; //1010 |
case 0x01 : *lenght=0x02; *out=0x0001; break; //00 |
248,10 → 321,34
} |
// printf("magnitude= %x out= %x lenght= %d \n",magnitude,*out,*lenght); |
return; |
#endif |
|
|
} |
|
static unsigned char convertDCMagnitudeYLengthTable[16] = { |
0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05, |
0x06, 0x07, 0x08, 0x09, 0x00, 0x00, 0x00, 0x00 |
}; |
|
static unsigned short convertDCMagnitudeYOutTable[16] = { |
0x0000, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x000e, 0x001e, |
0x003e, 0x007e, 0x00fe, 0x01fe, 0x0000, 0x0000, 0x0000, 0x0000 |
}; |
|
//=========================================================================== |
void ConvertDCMagnitudeY(unsigned char magnitude,unsigned short int *out, unsigned short int *lenght) |
{ |
unsigned char len; |
|
if ((magnitude>16) || ((len=convertDCMagnitudeYLengthTable[magnitude])==0)) { |
#ifndef __MICROBLAZE |
printf("WAARDE STAAT NIET IN TABEL!!!!!!!!!!!!!!!!!!!!\n"); |
#endif |
} |
*lenght = len; |
*out = convertDCMagnitudeYOutTable[magnitude]; |
#if 0 |
switch (magnitude) { |
case 0x00 : *out=0x0000; *lenght=2; break; |
case 0x01 : *out=0x0002; *lenght=3; break; |
266,10 → 363,62
case 0x0a : *out=0x00fe; *lenght=8; break; |
case 0x0b : *out=0x01fe; *lenght=9; break; |
} |
#endif |
} |
|
static unsigned char convertACMagnitudeYLength[256] = { |
0x04, 0x02, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x0a, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 00 - 0f |
0x00, 0x04, 0x05, 0x07, 0x09, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 10 - 1f |
0x00, 0x05, 0x08, 0x0a, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 20 - 2f |
0x00, 0x06, 0x09, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 30 - 3f |
0x00, 0x06, 0x0a, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 40 - 4f |
0x00, 0x07, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 50 - 5f |
0x00, 0x07, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 60 - 6f |
0x00, 0x08, 0x0c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 70 - 7f |
0x00, 0x09, 0x0f, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 80 - 8f |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // 90 - 9f |
0x00, 0x09, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // a0 - af |
0x00, 0x0a, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // b0 - bf |
0x00, 0x0a, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // c0 - cf |
0x00, 0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // d0 - df |
0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // e0 - ef |
0x0b, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00 |
}; |
|
static unsigned short convertACMagnitudeYOut[256] = { |
0xFFFA, 0xFFF0, 0xFFF1, 0xFFF4, 0xFFFB, 0xFFFA, 0xFFF8, 0xFFF8, 0xFFF6, 0xFF82, 0xFF83, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 00 - 0f |
0x0000, 0xFFFC, 0xFFFB, 0xFFF9, 0xFFF6, 0xFFF6, 0xFF84, 0xFF85, 0xFF86, 0xFF87, 0xFF88, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 10 - 1f |
0x0000, 0xFFFC, 0xFFF9, 0xFFF7, 0xFFF4, 0xFF89, 0xFF8A, 0xFF8B, 0xFF8C, 0xFF8D, 0xFF8E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 20 - 2f |
0x0000, 0xFFFA, 0xFFF7, 0xFFF5, 0xFF8F, 0xFF90, 0xFF91, 0xFF92, 0xFF93, 0xFF94, 0xFF95, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 30 - 3f |
0x0000, 0xFFFB, 0xFFF8, 0xFF96, 0xFF97, 0xFF98, 0xFF99, 0xFF9A, 0xFF9B, 0xFF9C, 0xFF9D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 40 - 4f |
0x0000, 0xFFFA, 0xFFF7, 0xFF9E, 0xFF9F, 0xFFA0, 0xFFA1, 0xFFA2, 0xFFA3, 0xFFA4, 0xFFA5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50 - 5f |
0x0000, 0xFFFB, 0xFFF6, 0xFFA6, 0xFFA7, 0xFFA8, 0xFFA9, 0xFFAA, 0xFFAB, 0xFFAC, 0xFFAD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 60 - 6f |
0x0000, 0xFFFA, 0xFFF7, 0xFFAE, 0xFFAF, 0xFFB0, 0xFFB1, 0xFFB2, 0xFFB3, 0xFFB4, 0xFFB5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 70 - 7f |
0x0000, 0xFFF8, 0xFFC0, 0xFFB6, 0xFFB7, 0xFFB8, 0xFFB9, 0xFFBA, 0xFFBB, 0xFFBC, 0xFFBD, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 80 - 8f |
0x0000, 0xFFF9, 0xFFBE, 0xFFBF, 0xFFC0, 0xFFC1, 0xFFC2, 0xFFC3, 0xFFC4, 0xFFC5, 0xFFC6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 90 - 9f |
0x0000, 0xFFFA, 0xFFC7, 0xFFC8, 0xFFC9, 0xFFCA, 0xFFCB, 0xFFCC, 0xFFCD, 0xFFCE, 0xFFCF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // a0 - af |
0x0000, 0xFFF9, 0xFFD0, 0xFFD1, 0xFFD2, 0xFFD3, 0xFFD4, 0xFFD5, 0xFFD6, 0xFFD7, 0xFFD8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // b0 - bf |
0x0000, 0xFFFA, 0xFFD9, 0xFFDA, 0xFFDB, 0xFFDC, 0xFFDD, 0xFFDE, 0xFFDF, 0xFFE0, 0xFFE1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // c0 - cf |
0x0000, 0xFFF8, 0xFFE2, 0xFFE3, 0xFFE4, 0xFFE5, 0xFFE6, 0xFFE7, 0xFFE8, 0xFFE9, 0xFFEA, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // d0 - df |
0x0000, 0xFFEB, 0xFFEC, 0xFFED, 0xFFEE, 0xFFEF, 0xFFF0, 0xFFF1, 0xFFF2, 0xFFF3, 0xFFF4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // e0 - ef |
0xFFF9, 0xFFF5, 0xFFF6, 0xFFF7, 0xFFF8, 0xFFF9, 0xFFFA, 0xFFFB, 0xFFFC, 0xFFFD, 0xFFFE, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 |
}; |
|
//=========================================================================== |
void ConvertACMagnitudeY(unsigned char magnitude,unsigned short int *out, unsigned short int *lenght) |
{ |
unsigned char len; |
|
len = convertACMagnitudeYLength[magnitude]; |
if (!len) { |
#ifndef __MICROBLAZE |
printf("WAARDE STAAT NIET IN TABEL!!!!!!!!!!!!!!!!!!!!\n"); |
#endif |
} |
*lenght = len; |
*out = convertACMagnitudeYOut[magnitude]; |
|
#if 0 |
switch (magnitude) { |
case 0x00 : *lenght=4; *out=0xFFFA; break; //1010 |
case 0x01 : *lenght=2; *out=0xFFF0; break; //00 |
439,6 → 588,8
} |
// printf("magnitude= %x out= %x lenght= %d \n",magnitude,*out,*lenght); |
return; |
#endif |
|
} |
//=========================================================================== |
char Extend (char additional, unsigned char magnitude) |