diff --git a/camlibs/gsmart300/gsmart300-jpeg-header.h b/camlibs/gsmart300/gsmart300-jpeg-header.h index 5541e8f96..150241322 100644 --- a/camlibs/gsmart300/gsmart300-jpeg-header.h +++ b/camlibs/gsmart300/gsmart300-jpeg-header.h @@ -1,18 +1,18 @@ #ifndef __GSMART_300_JPEG_HEADER_H #define __GSMART_300_JPEG_HEADER_H -/* +/* * Start from 0 -> 588 * 7 - 70 : Quantization Table[0] * 72 - 135 : Quantization Table[1] * 561 - 562 : Image Height(H Byte,L Byte) * 563 - 564 : Image Width(H Byte,L Byte) - */ + */ #define GSMART_JPG_DEFAULT_HEADER_LENGTH 589 uint8_t Gsmart_300_JPGDefaultHeader[GSMART_JPG_DEFAULT_HEADER_LENGTH] = { - //SOI(Start of Image) + /* SOI(Start of Image) */ 0xFF,0xD8, - //DQT(Define Quantization Table) + /* DQT(Define Quantization Table) */ 0xFF,0xDB, 0x00,0x84, 0x00, @@ -25,7 +25,7 @@ uint8_t Gsmart_300_JPGDefaultHeader[GSMART_JPG_DEFAULT_HEADER_LENGTH] = { 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, 0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22, - //DHT(Define Huffman Table) + /* DHT(Define Huffman Table) */ 0xFF,0xC4, 0x01,0xA2, 0x00,0x00,0x01,0x05,0x01,0x01,0x01,0x01,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00, @@ -54,11 +54,11 @@ uint8_t Gsmart_300_JPGDefaultHeader[GSMART_JPG_DEFAULT_HEADER_LENGTH] = { 0xA8,0xA9,0xAA,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xC2,0xC3,0xC4,0xC5, 0xC6,0xC7,0xC8,0xC9,0xCA,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xE2,0xE3, 0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA, - //SOFn(Start of Frame) + /* SOFn(Start of Frame) */ 0xFF,0xC0, 0x00,0x11, 0x08,0x00,0x78,0x00,0xA0,0x03,0x01,0x21,0x00,0x02,0x11,0x01,0x03,0x11,0x01, - //SOS(Start of Scan) + /* SOS(Start of Scan) */ 0xFF,0xDA, 0x00,0x0C, 0x03,0x01,0x00,0x02,0x11,0x03,0x11,0x00,0x3F,0x00 @@ -67,7 +67,7 @@ uint8_t Gsmart_300_JPGDefaultHeader[GSMART_JPG_DEFAULT_HEADER_LENGTH] = { /* Quantization tables for GSmart300 */ uint8_t Gsmart_300_QTable[10][64]= { - // index 0, Q85 + /* index 0, Q85 */ { 5, 3, 4, 4, 4, 3, 5, 4, 4, 4, 5, 5, 5, 6, 7, 12, 8, 7, 7, 7, 7, 15, 11, 11, 9, 12, 17, 15, 18, 18, 17, 15, 17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26, @@ -77,7 +77,7 @@ uint8_t Gsmart_300_QTable[10][64]= 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, - // index 1, Q85 + /* index 1, Q85 */ { 5, 3, 4, 4, 4, 3, 5, 4, 4, 4, 5, 5, 5, 6, 7, 12, 8, 7, 7, 7, 7, 15, 11, 11, 9, 12, 17, 15, 18, 18, 17, 15, 17, 17, 19, 22, 28, 23, 19, 20, 26, 21, 17, 17, 24, 33, 24, 26, @@ -87,7 +87,7 @@ uint8_t Gsmart_300_QTable[10][64]= 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30 }, - // index 2, Q80 + /* index 2, Q80 */ { 6, 4, 5, 6, 5, 4, 6, 6, 5, 6, 7, 7, 6, 8, 10, 16, 10, 10, 9, 9, 10, 20, 14, 15, 12, 16, 23, 20, 24, 24, 23, 20, 22, 22, 26, 29, 37, 31, 26, 27, 35, 28, 22, 22, 32, 44, 32, 35, @@ -97,7 +97,7 @@ uint8_t Gsmart_300_QTable[10][64]= 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40 }, - // index 3, Q25 + /* index 3, Q25 */ { 32, 22, 24, 28, 24, 20, 32, 28, 26, 28, 36, 34, 32, 38, 48, 80, 52, 48, 44, 44, 48, 98, 70, 74, 58, 80,116,102,122,120,114,102, 112,110,128,144,184,156,128,136,174,138,110,112,160,218,162,174, @@ -107,7 +107,7 @@ uint8_t Gsmart_300_QTable[10][64]= 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198, 198,198,198,198,198,198,198,198,198,198,198,198,198,198,198,198 }, - // index 4, Q70 + /* index 4, Q70 */ { 10, 7, 7, 8, 7, 6, 10, 8, 8, 8, 11, 10, 10, 11, 14, 24, 16, 14, 13, 13, 14, 29, 21, 22, 17, 24, 35, 31, 37, 36, 34, 31, 34, 33, 38, 43, 55, 47, 38, 41, 52, 41, 33, 34, 48, 65, 49, 52, @@ -117,4 +117,5 @@ uint8_t Gsmart_300_QTable[10][64]= 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59 }, }; + #endif /* __GSMART_300_JPEG_HEADER_H */ diff --git a/camlibs/gsmart300/gsmart300.c b/camlibs/gsmart300/gsmart300.c index 1be4019ce..c76e672d4 100644 --- a/camlibs/gsmart300/gsmart300.c +++ b/camlibs/gsmart300/gsmart300.c @@ -56,8 +56,8 @@ #endif #define GP_MODULE "gsmart300" -static int gsmart300_download_data (CameraPrivateLibrary * lib, - int data_type, uint16_t index, unsigned int size, +static int gsmart300_download_data (CameraPrivateLibrary * lib, + int data_type, uint16_t index, unsigned int size, uint8_t * buf); static int gsmart300_get_FATs (CameraPrivateLibrary * lib); static int yuv2rgb (int y, int u, int v, int *r, int *g, int *b); @@ -91,7 +91,7 @@ gsmart300_delete_file (CameraPrivateLibrary * lib, unsigned int index) fat_index = 0x1FFF - index; - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, fat_index, 0x0003, + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, fat_index, 0x0003, NULL, 0)); sleep (1); @@ -105,7 +105,7 @@ gsmart300_delete_file (CameraPrivateLibrary * lib, unsigned int index) int gsmart300_delete_all (CameraPrivateLibrary * lib) { - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x0000, 0x0004, + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x0000, 0x0004, NULL, 0)); sleep (3); @@ -133,8 +133,8 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, /* decode the image size */ flash_size = (p[6] * 0x100 + p[5])*0x200; - data_size = (p[13] & 0xff) * 0x10000 - + (p[12] & 0xff) * 0x100 + data_size = (p[13] & 0xff) * 0x10000 + + (p[12] & 0xff) * 0x100 + (p[11] & 0xff); qIndex = p[7] & 0x07; @@ -145,7 +145,7 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, if (!mybuf) return GP_ERROR_NO_MEMORY; - CHECK (gsmart300_download_data (lib, __GS300_PIC, g_file->index, + CHECK (gsmart300_download_data (lib, __GS300_PIC, g_file->index, flash_size, mybuf)); /* now build a jpeg */ @@ -155,7 +155,7 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, start_of_file = lp_jpg; /* copy the header from the template */ - memcpy (lp_jpg, Gsmart_300_JPGDefaultHeader, + memcpy (lp_jpg, Gsmart_300_JPGDefaultHeader, GSMART_JPG_DEFAULT_HEADER_LENGTH); /* modify quantization table */ @@ -164,13 +164,13 @@ gsmart300_request_file (CameraPrivateLibrary * lib, uint8_t ** buf, /* modify the image width, height */ - /* NOTE : the picture width and height written on flash is either + /* NOTE : the picture width and height written on flash is either * 640x480 or 320x240, but the real size id 640x480 for ALL pictures */ - *(lp_jpg + 564) = (640) & 0xFF; //Image width low byte - *(lp_jpg + 563) = (640 >> 8) & 0xFF; //Image width high byte - *(lp_jpg + 562) = (480) & 0xFF; //Image height low byte - *(lp_jpg + 561) = (480 >> 8) & 0xFF; //Image height high byte + *(lp_jpg + 564) = (640) & 0xFF; /* Image width low byte */ + *(lp_jpg + 563) = (640 >> 8) & 0xFF; /* Image width high byte */ + *(lp_jpg + 562) = (480) & 0xFF; /* Image height low byte */ + *(lp_jpg + 561) = (480 >> 8) & 0xFF; /* Image height high byte */ /* point to real JPG compress data start position and copy */ lp_jpg += GSMART_JPG_DEFAULT_HEADER_LENGTH; @@ -231,14 +231,14 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, t_width = 80; t_height = 60; - snprintf (pbm_header, sizeof (pbm_header), "P6 %d %d 255\n", + snprintf (pbm_header, sizeof (pbm_header), "P6 %d %d 255\n", t_width, t_height); /* size needed for download */ size = 9728; mybuf = malloc (size); - CHECK (gsmart300_download_data (lib, __GS300_THUMB, g_file->index, + CHECK (gsmart300_download_data (lib, __GS300_THUMB, g_file->index, size, mybuf)); /* effective size of file */ @@ -288,7 +288,7 @@ gsmart300_get_info (CameraPrivateLibrary * lib) CHECK (gsmart300_get_file_count (lib)); if (lib->num_files > 0) { CHECK (gsmart300_get_FATs (lib)); - } + } lib->dirty = 0; @@ -309,7 +309,7 @@ int gsmart300_reset (CameraPrivateLibrary * lib) { GP_DEBUG ("* gsmart300_reset"); - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x0000, 0x0003, + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x0000, 0x0003, NULL, 0)); sleep (1.5); return GP_OK; @@ -325,19 +325,19 @@ static int gsmart300_download_data (CameraPrivateLibrary * lib, int data_type, uint16_t fat_index = 0x1fff - index; int i; - if (data_type == __GS300_FAT) - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, + if (data_type == __GS300_FAT) + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, fat_index, 0x0000, NULL, 0)); - if (data_type == __GS300_THUMB) - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x0a, + if (data_type == __GS300_THUMB) + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x0a, fat_index, 0x0003, NULL, 0)); - if (data_type == __GS300_PIC) - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, + if (data_type == __GS300_PIC) + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x03, fat_index, 0x0008, NULL, 0)); if (data_type == __GS300_INIT ) { - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x00, + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x02, 0x00, 0x0007, NULL, 0)); - CHECK (gp_port_usb_msg_write (lib->gpdev, 0x0a, 0x00, + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x0a, 0x00, 0x0001, NULL, 0)); } @@ -369,14 +369,14 @@ gsmart300_get_FATs (CameraPrivateLibrary * lib) p = lib->fats; while (index < lib->num_files) { - CHECK (gsmart300_download_data (lib, __GS300_FAT, index, + CHECK (gsmart300_download_data (lib, __GS300_FAT, index, FLASH_PAGE_SIZE_300, p)); if (p[0] == 0xFF) break; type = p[0]; if (type == 0x00) { snprintf (buf, 13, "Image%03d.jpg", index + 1); - lib->files[file_index].mime_type = + lib->files[file_index].mime_type = GSMART_FILE_TYPE_IMAGE; lib->files[file_index].index = index; lib->files[file_index].fat = p;