/** * @brief Main decoder function. It all starts here. * Input parameters: * 1) input JPEG 2000 image * * @return 0 on success */ int main(int argc, char **argv) { // println_start(INFO); type_image *img = (type_image *)malloc(sizeof(type_image)); memset(img, 0, sizeof(type_image)); if((parse_args(argc, argv, img) == ERROR) || (check_args_dec(img) == ERROR)) { fprintf(stderr, "Error occurred while parsing arguments.\n"); fprintf(stdout, "%s", help); return 1; } type_parameters *param = (type_parameters*)malloc(sizeof(type_parameters)); if((parse_config(img->conf_file, param) == ERROR) || (check_config(param) == ERROR)) { fprintf(stderr, "Error occurred while parsing configuration file.\n"); fprintf(stdout, "%s", help); return 1; } init_device(param); FILE *fsrc = fopen(img->in_file, "rb"); if (!fsrc) { fprintf(stderr, "Error, failed to open %s for reading\n", img->in_file); return 1; } type_tile *tile; int i; if(strstr(img->in_file, ".jp2") != NULL) { println(INFO, "It's a JP2 file"); //parse the JP2 boxes jp2_parse_boxes(fsrc, img); fclose(fsrc); // Do decoding for all tiles for(i = 0; i < img->num_tiles; i++) { tile = &(img->tile[i]); /* Decode data */ decode_tile(tile); /* Dequantize data */ dequantize_tile(tile); /* Do inverse wavelet transform */ iwt(tile); } if(img->use_mct == 1) { // lossless decoder if(img->wavelet_type == 0) { color_decoder_lossless(img); } else { //lossy decoder color_decoder_lossy(img); } } else if (img->use_part2_mct == 1) { decode_klt(img); } else { if(img->sign == UNSIGNED) { idc_level_shifting(img); } } } else {//It is not a JP2 file. type_buffer *src_buff = (type_buffer *) malloc(sizeof(type_buffer)); init_dec_buffer(fsrc, src_buff); fclose(fsrc); decode_codestream(src_buff, img); // get_next_box(fsrc); // Do decoding for all tiles for(i = 0; i < img->num_tiles; i++) { tile = &(img->tile[i]); /* Decode data */ decode_tile(tile); /* Dequantize data */ dequantize_tile(tile); /* Do inverse wavelet transform */ iwt(tile); } if(img->use_mct == 1) { // lossless decoder if(img->wavelet_type == 0) { color_decoder_lossless(img); } else { //lossy decoder color_decoder_lossy(img); } } else if (img->use_part2_mct == 1) { decode_klt(img); } else { if(img->sign == UNSIGNED) { idc_level_shifting(img); } } } save_image(img); }
size_t Print::println(int num, int base) { size_t n = print(num, base); n += println(); return n; }
size_t Print::println(double num, int digits) { size_t n = print(num, digits); n += println(); return n; }
/* * Application entry point. */ int main(void) { unsigned i; gptcnt_t interval, threshold, worst; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Prepares the Serial driver 2 and GPT drivers 1 and 2. */ sdStart(&SD1, NULL); /* Default is 38400-8-N-1.*/ gptStart(&GPTD1, &gpt1cfg); gptStart(&GPTD2, &gpt2cfg); /* * Initializes the mailboxes and creates the worker threads. */ for (i = 0; i < NUM_THREADS; i++) { chMBInit(&mb[i], b[i], MAILBOX_SIZE); chThdCreateStatic(waWorkerThread[i], sizeof waWorkerThread[i], NORMALPRIO - 20, WorkerThread, (void *)i); } /* * Test procedure. */ println(""); println("*** ChibiOS/RT IRQ-STORM long duration test"); println("***"); print("*** Kernel: "); println(CH_KERNEL_VERSION); #ifdef CH_COMPILER_NAME print("*** Compiler: "); println(CH_COMPILER_NAME); #endif print("*** Architecture: "); println(CH_ARCHITECTURE_NAME); #ifdef CH_CORE_VARIANT_NAME print("*** Core Variant: "); println(CH_CORE_VARIANT_NAME); #endif #ifdef CH_PORT_INFO print("*** Port Info: "); println(CH_PORT_INFO); #endif #ifdef PLATFORM_NAME print("*** Platform: "); println(PLATFORM_NAME); #endif #ifdef BOARD_NAME print("*** Test Board: "); println(BOARD_NAME); #endif println("***"); print("*** System Clock: "); printn(LPC11xx_SYSCLK); println(""); print("*** Iterations: "); printn(ITERATIONS); println(""); print("*** Randomize: "); printn(RANDOMIZE); println(""); print("*** Threads: "); printn(NUM_THREADS); println(""); print("*** Mailbox size: "); printn(MAILBOX_SIZE); println(""); println(""); worst = 0; for (i = 1; i <= ITERATIONS; i++){ print("Iteration "); printn(i); println(""); saturated = FALSE; threshold = 0; for (interval = 2000; interval >= 20; interval -= interval / 10) { gptStartContinuous(&GPTD1, interval - 1); /* Slightly out of phase.*/ gptStartContinuous(&GPTD2, interval + 1); /* Slightly out of phase.*/ chThdSleepMilliseconds(1000); gptStopTimer(&GPTD1); gptStopTimer(&GPTD2); if (!saturated) print("."); else { print("#"); if (threshold == 0) threshold = interval; } } /* Gives the worker threads a chance to empty the mailboxes before next cycle.*/ chThdSleepMilliseconds(20); println(""); print("Saturated at "); printn(threshold); println(" uS"); println(""); if (threshold > worst) worst = threshold; } gptStopTimer(&GPTD1); gptStopTimer(&GPTD2); print("Worst case at "); printn(worst); println(" uS"); println(""); println("Test Complete"); /* * Normal main() thread activity, nothing in this test. */ while (TRUE) { chThdSleepMilliseconds(5000); } return 0; }
size_t Print::println(char c) { size_t n = print(c); n += println(); return n; }
//************************************************************************ void Print::println(int n, int base) { print(n, base); println(); }
//************************************************************************ void Print::println(unsigned long n, int base) { print(n, base); println(); }
static void show_usage(const char *command) { println("Usage: %s [option]", command); println("-H, -h, --help\t\t\t%s", cavan_help_message_help); println("-V, -v, --version\t\t%s", cavan_help_message_version); println("-I, -i, --ip IP\t\t\t%s", cavan_help_message_ip); println("--host [HOSTNAME]\t\t%s", cavan_help_message_hostname); println("-L, ---locall\t\t\t%s", cavan_help_message_local); println("-p, --port PORT\t\t\t%s", cavan_help_message_port); println("-A, -a, --adb\t\t\t%s", cavan_help_message_adb); println("--udp\t\t\t\t%s", cavan_help_message_udp); println("--unix, --unix-tcp [PATHNAME]\t%s", cavan_help_message_unix_tcp); println("--unix-udp [PATHNAME]\t\t%s", cavan_help_message_unix_udp); println("-P, --pt, --protocol PROTOCOL\t%s", cavan_help_message_protocol); println("-U, -u, --url [URL]\t\t%s", cavan_help_message_url); println("--na, --noack\t\t\texit don't need ack"); println("-c, --cmdline\t\t\t%s", cavan_help_message_cmdline); println("--loop\t\t\t\tcycle to execute the command"); println("--aloop\t\t\t\tuse adb and cycle to execute the command"); }
void Adafruit_ESP8266::closeAP(void) { println(F("AT+CWQAP")); // Quit access point find(); // Purge 'OK' }
void serial::printlnX(int z) { ino(z); println(); return; }
void serial::writeX(int z,char *p) { ino(z); println(p); return; }
void serial::printlnX(int z, String s) { ino(z); println(s); return; }
void serial::printlnX(int z,const char *p) { ino(z); println(p); return; }
void serial::printlnX(int z,int x) { ino(z); println(x); return; }
//************************************************************************ void Print::println(char c, int base) { print(c, base); println(); }
void Adafruit_ESP8266::closeTCP(void) { println(F("AT+CIPCLOSE")); find(F("Unlink\r\n")); }
//************************************************************************ void Print::println(unsigned char b, int base) { print(b, base); println(); }
/* * Application entry point. */ int main(void) { msg_t status = MSG_OK; systime_t tmo = MS2ST(4); /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); chSysInit(); /* * Starts I2C */ i2cStart(&I2CD2, &i2cfg2); /* * Prepares the Serial driver 2 */ sdStart(&SD2, NULL); /* Default is 38400-8-N-1.*/ palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); /** * Prepares the accelerometer */ txbuf[0] = ACCEL_CTRL_REG1; /* register address */ txbuf[1] = 0x1; i2cAcquireBus(&I2CD2); status = i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 2, rxbuf, 0, tmo); i2cReleaseBus(&I2CD2); if (status != MSG_OK){ errors = i2cGetErrors(&I2CD2); } /* * Normal main() thread activity, nothing in this test. */ while (TRUE) { palTogglePad(GPIOB, GPIOB_LED_B); chThdSleepMilliseconds(100); txbuf[0] = ACCEL_OUT_DATA; /* register address */ i2cAcquireBus(&I2CD2); status = i2cMasterTransmitTimeout(&I2CD2, mma8451_addr, txbuf, 1, rxbuf, 6, tmo); i2cReleaseBus(&I2CD2); if (status != MSG_OK){ errors = i2cGetErrors(&I2CD2); } acceleration_x = complement2signed(rxbuf[0], rxbuf[1]); acceleration_y = complement2signed(rxbuf[2], rxbuf[3]); acceleration_z = complement2signed(rxbuf[4], rxbuf[5]); print("x: "); printn(acceleration_x); print(" y: "); printn(acceleration_y); print(" z: "); printn(acceleration_z); println(""); } }
//************************************************************************ void Print::println(long n, int base) { print(n, base); println(); }
void BetterStream::println_P(const char *s) { print_P(s); println(); }
//************************************************************************ void Print::println(double n, int digits) { print(n, digits); println(); }
size_t Print::println(const __FlashStringHelper *ifsh) { size_t n = print(ifsh); n += println(); return n; }
size_t Print::println(const char c[]) { size_t n = print(c); n += println(); return n; }
size_t Print::println(const String &s) { size_t n = print(s); n += println(); return n; }
size_t Print::println(unsigned char b, int base) { size_t n = print(b, base); n += println(); return n; }
static void show_usage(void) { println("Usage:"); println("usb_dd -w if=local_file of=remote_file"); println("usb_dd -r if=remote_file of=local_file"); }
size_t Print::println(unsigned long num, int base) { size_t n = print(num, base); n += println(); return n; }
//************************************************************************ void Print::println(const char c[]) { print(c); println(); }
size_t Print::println(const Printable& x) { size_t n = print(x); n += println(); return n; }
void mp3_c(u8 c){ int i; static int over=0; if (cur_song.content_length == 0 || cur_song.content_remain == -1){ print_c(c); if (c != '\n'){ if (cur_song.buffer_idx < sizeof(cur_song.buffer)){ cur_song.buffer[cur_song.buffer_idx++] = c; } }else{ char * s = cur_song.buffer; if (s[0] == 'C' && s[1] == 'o' && s[2] == 'n' && s[3] == 't' && s[4] == 'e' && s[5] == 'n' && s[6] == 't' && s[7] == '-' && s[8] == 'L' && s[9] == 'e' && s[10]== 'n' && s[11]== 'g' && s[12]== 't' && s[13]== 'h' && s[14]== ':'){ i = 16; while (i < 50 && s[i] >= '0' && s[i] <= '9'){ cur_song.content_length = cur_song.content_length * 10 + (s[i] - '0'); i++; } printf("-----content_length: %d\r\n",cur_song.content_length); } if (s[0]='\r' && cur_song.buffer_idx ==1 && cur_song.content_length > 0){ cur_song.content_remain = cur_song.content_length; println("content_start"); } cur_song.buffer_idx = 0; } }else{ if (cur_song.content_remain > 0){ // printf("%d\r\n",cur_song.content_remain); cur_song.content_remain--; cur_song.buffer[cur_song.buffer_idx++] = c; if (cur_song.content_length_without_id3v2 == 0 && cur_song.buffer_idx > 9){ if (cur_song.buffer[0] == 0x49 && cur_song.buffer[1] == 0x44 && cur_song.buffer[2] == 0x33 ){ cur_song.content_length_without_id3v2 = cur_song.content_length - ((cur_song.buffer[6]&0x7F)*0x200000+(cur_song.buffer[7]&0x7F)*0x4000+(cur_song.buffer[8]&0x7F)*0x80+(cur_song.buffer[9]&0x7F) + 10); }else{ cur_song.content_length_without_id3v2 = cur_song.content_length; cur_song.first_head[0] = cur_song.buffer[0]; cur_song.first_head[1] = cur_song.buffer[1]; cur_song.first_head[2] = cur_song.buffer[2]; cur_song.first_head[3] = cur_song.buffer[3]; cur_song.headed = 4; } } if (cur_song.headed < 4 && cur_song.content_length_without_id3v2 > cur_song.content_remain ){ cur_song.first_head[cur_song.headed++] = c; } if (cur_song.headed >= 4 && cur_song.frame_size == 0){ for(i=0;i<4;i++) printf("0x%02x ",cur_song.first_head[i]); cur_song.frame_size = calc_frame_size(cur_song.first_head); printf("frame_size: %d\r\n",cur_song.frame_size); } }else{ println("shot over"); printf("content_over %d\r\n",over++); } } }