Example #1
0
void *read_msgs( void *param)
{
	int thread_id = (int) param;
	int e;
	unsigned int count = 0U;
	unsigned int int_data;
	unsigned char data[MAX_QUEUE_DATA_SIZE];
	size_t data_size;
	queue_t *queue = &readers[thread_id].queue;
	file_info_t *file = &readers[thread_id].file;

	printf( "thread %d created\n", thread_id);

	e = init_queue( queue, MAX_QUEUE_SIZE);
	if (e < 0) {
		fprintf( stderr, "init_queue() failed\n");
		return NULL;
	}

	e = init_file( file, thread_id);
	if (e < 0) {
		fprintf( stderr, "init_file() failed\n");
		return NULL;
	}

	while (should_thread_keep_alive() && (count < MAX_QUEUE_SIZE)) {
		e = get_queue_data( queue, data, &data_size);
		if (e < 0) {
			fprintf( stderr, "get_queue_data() failed\n");
			continue;
		} else {
			if (data_size == 0) {
				continue;
			}
		}

		memcpy( &int_data, data, data_size);
		printf( "[thread %d] data=%u, data_size=%zu\n", thread_id, int_data, data_size);

		fprintf( file->fp, "data=%d\n", int_data);
		count++;
		printf( "[thread %d] count=%u\n", thread_id, count);
	}

	finish_file( file->fp);

	return NULL;
}
Example #2
0
void
cluster_helper_c::split(packet_cptr &packet) {
  render();

  m->num_cue_elements = 0;

  bool create_new_file       = m->current_split_point->m_create_new_file;
  bool previously_discarding = m->discarding;

  mxdebug_if(m->debug_splitting, boost::format("Splitting: splitpoint %1% reached before timecode %2%, create new? %3%.\n") % m->current_split_point->str() % format_timecode(packet->assigned_timecode) % create_new_file);

  finish_file(false, create_new_file, previously_discarding);

  if (m->current_split_point->m_use_once) {
    if (   m->current_split_point->m_discard
        && (   (split_point_c::parts             == m->current_split_point->m_type)
            || (split_point_c::parts_frame_field == m->current_split_point->m_type))
        && (m->split_points.end() == (m->current_split_point + 1))) {
      mxdebug_if(m->debug_splitting, boost::format("Splitting: Last part in 'parts:' splitting mode finished\n"));
      m->splitting_and_processed_fully = true;
    }

    m->discarding = m->current_split_point->m_discard;
    ++m->current_split_point;
  }

  if (create_new_file) {
    create_next_output_file();
    if (g_no_linking) {
      m->previous_cluster_tc = -1;
      m->timecode_offset = g_video_packetizer ? m->max_video_timecode_rendered : packet->assigned_timecode;
    }

    m->bytes_in_file          =  0;
    m->first_timecode_in_file = -1;
    m->max_timecode_in_file   = -1;
    m->min_timecode_in_file.reset();
  }

  m->first_timecode_in_part = -1;

  handle_discarded_duration(create_new_file, previously_discarding);

  prepare_new_cluster();
}
Example #3
0
void PROCout( Procedure p ) {
    prep_file();
    PROC_out( p, 0 );
    finish_file();
}
Example #4
0
void RULEout( Rule r ) {
    prep_file();
    RULE_out( r, 0 );
    finish_file();
}
Example #5
0
void SCHEMAref_out( Schema s ) {
    prep_file();
    REFout( s->u.schema->usedict, s->u.schema->use_schemas, "USE", 0 );
    REFout( s->u.schema->refdict, s->u.schema->ref_schemas, "REFERENCE", 0 );
    finish_file();
}
Example #6
0
void STMTout( Statement s ) {
    prep_file();
    STMT_out( s, 0 );
    finish_file();
}
Example #7
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;

}