void init() { #ifndef SIMU TRISBbits.TRISB5 = 0;//output LATBbits.LATB5 = 1; /*TRISBbits.TRISB3 = 0;//output LATBbits.LATB3 = 1;//valeur de la sortie TRISBbits.TRISB2 = 0;//output LATBbits.LATB2 = 0;//valeur de la sortie*/ #endif init_osc(); UART_init(); my_malloc_init(); }
int main() { my_malloc_init(12 * MiB); void *b1 = my_malloc(2 * MiB); assert(b1); void *b2 = my_malloc(2 * MiB); assert(b2); void *b3 = my_malloc(1 * MiB); assert(b3); void *b4 = my_malloc(2 * MiB); assert(b4); my_free(b2); void *b5 = my_malloc(1 * MiB); assert(b5); my_free(b1); void *b6 = my_malloc(1 * MiB); printf("HEAP (1)\n"); my_dump_mem(stdout); printf("Address of p5 is %" PRIu64 "\n", my_address(b5)); printf("Address of p6 is %" PRIu64 "\n", my_address(b6)); my_free(b3); my_free(b5); my_free(b6); void *b7 = my_malloc(2 * MiB); assert(b7); void *b8 = my_malloc(3 * MiB); assert(b8); printf("HEAP (2)\n"); my_dump_mem(stdout); return 0; }
int main(void) { unsigned char *mp4_buffer = NULL; unsigned char *in_buffer = NULL; unsigned char *out_buffer = NULL; int status; long frame_type; long m4v_size; /***************************************************************************** * Arguments checking ****************************************************************************/ if (XDIM <= 0 || XDIM >= 2048 || YDIM <=0 || YDIM >= 2048 ) { my_printf("Trying to retreive width and height from PGM header\n"); } my_malloc_init(); // initial memory allocation. by gary input_file(); // it give input address,or open input file. by gary output_file(); // it give output address, or open output file . by gary /* now we know the sizes, so allocate memory */ in_buffer = (unsigned char *) my_malloc(IMAGE_SIZE(XDIM,YDIM)); if (!in_buffer) goto free_all_memory; /* this should really be enough memory ! */ mp4_buffer = (unsigned char *) my_malloc(IMAGE_SIZE(XDIM,YDIM)*2); if (!mp4_buffer) goto free_all_memory; clock_gettime(CLOCK_REALTIME, &start_time); /***************************************************************************** * XviD PART Start ****************************************************************************/ status = enc_init(); if (status) { my_printf("Encore INIT problem, return value %d\n", status); goto release_all; } /***************************************************************************** * Encoding loop ****************************************************************************/ do { /* read raw data (YUV-format) */ my_read(in_buffer, 1, IMAGE_SIZE(XDIM, YDIM), input_add); input_add = input_add + IMAGE_SIZE(XDIM, YDIM); /***************************************************************************** * Encode and decode this frame ****************************************************************************/ status = enc_main(in_buffer, mp4_buffer, &m4v_size, &frame_type); output_size += m4v_size; my_printf("Frame %5d: intra %1d, size=%6dbytes\n", (int)filenr, (int)frame_type, (int)m4v_size); /***************************************************************************** * Save stream to file ****************************************************************************/ /* Write mp4 data */ my_write(mp4_buffer, m4v_size, 1, output_add_temp); output_add_temp = output_add_temp + m4v_size; filenr++; } while ( filenr < ARG_FRAMENO ); /***************************************************************************** * Calculate totals and averages for output, print results ****************************************************************************/ clock_gettime(CLOCK_REALTIME, &end_time); printf("sizeof(start_time.tv_sec):%d, sizeof(start_time.tv_nsec):%d\n", sizeof(start_time.tv_sec), sizeof(start_time.tv_nsec)); printf("s_time.tv_sec:%d, s_time.tv_nsec:%d\n", start_time.tv_sec, start_time.tv_nsec); printf("e_time.tv_sec:%d, e_time.tv_nsec:%d\n", end_time.tv_sec, end_time.tv_nsec); double execution_time = (double)end_time.tv_sec + (double)end_time.tv_nsec/1000000000.0 - (double)start_time.tv_sec - (double)start_time.tv_nsec/1000000000.0; printf("diff_time:%.4f(s)\n", execution_time); my_memcpy(output_add,&output_size,4); finish_file(); output_size /= filenr; my_printf("Avg: filesize %7d bytes\n",(int)output_size); /***************************************************************************** * XviD PART Stop ****************************************************************************/ release_all: if (enc_handle) { status = enc_stop(); if (status) my_printf("Encore RELEASE problem return value %d\n", status); } free_all_memory: my_free(mp4_buffer); my_free(in_buffer); return 0; }