コード例 #1
0
ファイル: p3.c プロジェクト: Achal-Aggarwal/entire-src
void sender3(void)
{
  seq_nr next_frame_to_send;	/* seq number of next outgoing frame */
  frame s;		/* scratch variable */
  packet buffer;	/* buffer for an outbound packet */
  event_type event;

  next_frame_to_send = 0;	/* initialize outbound sequence numbers */
  from_network_layer(&buffer);	/* fetch first packet */
  while (true) {
        init_frame(&s);
        s.info = buffer;	/* construct a frame for transmission */
        s.seq = next_frame_to_send;	/* insert sequence number in frame */
        to_physical_layer(&s);	/* send it on its way */
        start_timer(s.seq);	/* if answer takes too long, time out */
        wait_for_event(&event);	/* frame_arrival, cksum_err, timeout */
        if (event == frame_arrival) {
                from_physical_layer(&s);	/* get the acknowledgement */
                if (s.ack == next_frame_to_send) {
                        from_network_layer(&buffer);	/* get the next one to send */
                        inc(next_frame_to_send);	/* invert next_frame_to_send */
                }
        }
  }
}
コード例 #2
0
    int AudioEncoder::encodeAudio (unsigned char* inBuffer, int nSamples, AVPacket* pkt) 
    {
        AVFrame *frame;
        init_frame(&frame);

        return 0;
    }
コード例 #3
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_continuation(InputIterator begin, InputIterator end, int length,
     MaskKey mask = nothing{})
 {
   init_frame(length, 0x0, mask);
   bool result = generate(begin, end);
   body[0] = 0x0; //no fin bit
   return result;
 }
コード例 #4
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_text_fragment(InputIterator begin, InputIterator end, int length,
     MaskKey mask = nothing{})
 {
   init_frame(length, 0x1, mask);
   bool result = generate(begin, end);
   body[0] = 0x1; //no fin bit
   return result;
 }
コード例 #5
0
/*
 * Locate the physical frame number for the given vaddr using the page table.
 *
 * If the entry is invalid and not on swap, then this is the first reference 
 * to the page and a (simulated) physical frame should be allocated and 
 * initialized (using init_frame).  
 *
 * If the entry is invalid and on swap, then a (simulated) physical frame
 * should be allocated and filled by reading the page data from swap.
 *
 * Counters for hit, miss and reference events should be incremented in
 * this function.
 */
char *find_physpage(addr_t vaddr, char type) {
	pgtbl_entry_t *p=NULL; // pointer to the full page table entry for vaddr
	unsigned idx = PGDIR_INDEX(vaddr); // get index into page directory

	// IMPLEMENTATION NEEDED
	// Use top-level page directory to get pointer to 2nd-level page table
	if (!(pgdir[idx].pde & PG_VALID)){
		pgdir[idx] = init_second_level();
	}

	// Use vaddr to get index into 2nd-level page table and initialize 'p'
	uintptr_t ptr_table = PAGE_MASK & pgdir[idx].pde;
	p = (pgtbl_entry_t*)(ptr_table) + PGTBL_INDEX(vaddr);

	// Check if p is valid or not, on swap or not, and handle appropriately
	
	// Page is present in the memory
	if (p->frame & PG_VALID){
		hit_count++;

	// Page is not present in the memory
	} else {
		miss_count++;
		ref_count++;
		int frame = allocate_frame(p);

		// Page on disk.
		if (p->frame & PG_ONSWAP){
			swap_pagein(frame, p->swap_off);
			p->frame = frame << PAGE_SHIFT;
			p->frame = p->frame | PG_VALID;

		// Page not on disk, first time access the page	
		} else {
			init_frame(frame, vaddr);
			p->frame = frame << PAGE_SHIFT;
			p->frame = p->frame | PG_DIRTY;			
		}
	}

	// Make sure that p is marked valid. Also mark it dirty
	// if the access type indicates that the page will be written to
	p->frame = p->frame | PG_VALID;

	if(type == 'S' || type == 'M'){
		p->frame = p->frame | PG_DIRTY;
	}

	// Call replacement algorithm's ref_fcn for this page
	ref_fcn(p);

	// p is marked referenced.
	p->frame = p->frame | PG_REF;
	
	// Return pointer into (simulated) physical memory at start of frame
	return  &physmem[(p->frame >> PAGE_SHIFT)*SIMPAGESIZE];
}
コード例 #6
0
ファイル: protocol.c プロジェクト: Pinois/reseaux_octobre
void init_window(window * window)
{
  int i;
  for (i = 0; i < MAX_WINDOW_SIZE; i++)
  {
    init_frame(&window[i].frame);
    init_timer(&window[i].timer);
  }
}
コード例 #7
0
/*!
 ************************************************************************
 * \brief
 *    Encodes one frame
 ************************************************************************
 */
void encode_one_frame ()
//int encode_one_frame ()
{
//MSG(Start_encode_one_frame);
//printf("Start_encode_one_frame\n");
  init_frame ();
  //FrameNumberInFile = CalculateFrameNumber();
//  FrameNumberInFile = IMG_NUMBER;
  
  /*printf("\n\n\n*********************************\n");
  printf("*         Frame #%02d             *\n", FrameNumberInFile);
  printf("*********************************\n");*/
  
  // Rate Control
  // initialize variables and get a new quantization parameter
  //if(input.RCEnable)
  //{
  //  rc_init_pict();
  //  if (img.number % 2  == 0 ) //jykim
  //  {
  //  	img.qp = updateQuantizationParameter();
  //  }
  //}
  //enable_slice_mode
  //writeout_picture (frame_pic);		// write IDR-TYPE NALU header
  frame_picture();
  //printf(">>>>> frame encoded <<<<<\n");

//  if (frame_pic)
//#ifdef OR1200
//    free_slice_list(frame_pic);
//#endif

  // Rate control
  // update quadratic model parameter.
    //if (input.RCEnable) {
    //        img.NumberofHeaderBits = FR_HEADER_BITS;
    //        img.NumberofTextureBits = FR_TEXTURE_BITS;

    //        rc_update_pict_frame(bits_per_frame);
    //        rc_update_pict(bits_per_frame);

    //        // update the parameters of quadratic R-D model
    //        if (img.type == P_SLICE)
    //                updateRCModel();

    //        //printf("img.qp = %d, %d bits/frame, MAD[%f]\n", img.qp, bits_per_frame, CurrentFrameMAD);
    //}


//  if (IMG_NUMBER == 0)
//    return 0;
//  else
//    return 1;
}
コード例 #8
0
ファイル: frame.c プロジェクト: JeffAbrahamson/ratpoison-dev
rp_frame *
frame_new (rp_screen *s)
{
    rp_frame *f;

    f = xmalloc (sizeof (rp_frame));
    init_frame(f);
    f->number = numset_request (s->frames_numset);

    return f;
}
コード例 #9
0
    int AudioDecoder::decodeAudio(AVPacket& input_packet, AVPacket& outPacket)    {
        ELOG_DEBUG("decoding input packet, size %d", input_packet.size);
        
        AVFrame* input_frame;
        init_frame(&input_frame);

        int data_present;
        int error = avcodec_decode_audio4(input_codec_context, input_frame, &data_present,&input_packet);

        if (error < 0)
        {
            ELOG_DEBUG("decoding error %s", get_error_text(error));
            return error;
        }

        if (data_present <= 0)
        {
            ELOG_DEBUG("data not present");
            return 0;
        }

        // resample

        /** Initialize the temporary storage for the converted input samples. */
        uint8_t **converted_input_samples = NULL;
        if (init_converted_samples(&converted_input_samples, output_codec_context, input_frame->nb_samples))
        {
            ELOG_DEBUG("init_converted_samples fails");
            return 0;
        }

        /**
         * Convert the input samples to the desired output sample format.
         * This requires a temporary storage provided by converted_input_samples
         */
        if (convert_samples((const uint8_t**)input_frame->extended_data, converted_input_samples,input_frame->nb_samples, resample_context))
        {
            ELOG_WARN("convert_samples failed!!");
            return 0;
        }

        /** Add converted input samples to the FIFO buffer for later processing. */
        if (add_samples_to_fifo(fifo, converted_input_samples,
                    input_frame->nb_samples))
        {
            ELOG_WARN("add_samples to fifo failed !!");
        }

        outPacket.pts = input_packet.pts;

        // meanwhile, encode; package
        return load_encode(outPacket);
    }
コード例 #10
0
ファイル: main.c プロジェクト: taisukef/IchigoDot
boolean load() {
	fr = (struct Frame*)(data + 8);
	loadFlash(data, LEN_DATA);
	if (startsWith(data, "MATLED00")) {
		println("MATLED00");
		if (fr->waitms[0] == 0)
			return false;
		return true;
	}
	memcpy(data, "MATLED00", 8);
	init_frame();
	return false;
}
コード例 #11
0
ファイル: mainloop.cpp プロジェクト: mkoloberdin/unrealspeccy
void spectrum_frame()
{
   if (!temp.inputblock || input.keymode != K_INPUT::KM_DEFAULT)
      input.make_matrix();

   init_snd_frame();
   init_frame();

   if(cpu.dbgchk)
   {
       cpu.SetDbgMemIf();
       z80dbg::z80loop();
   }
   else
   {
       cpu.SetFastMemIf();
       z80fast::z80loop();
   }
   if (modem.open_port)
       modem.io();

   flush_snd_frame();
   flush_frame();
   showleds();

   if (!cpu.iff1 || // int disabled in CPU
        ((conf.mem_model == MM_ATM710 || conf.mem_model == MM_ATM3) && !(comp.pFF77 & 0x20))) // int disabled by ATM hardware
   {
      unsigned char *mp = am_r(cpu.pc);
      if (cpu.halted)
      {
          strcpy(statusline, "CPU HALTED");
          statcnt = 10;
      }
      if (*(unsigned short*)mp == WORD2(0x18,0xFE) ||
          ((*mp == 0xC3) && *(unsigned short*)(mp+1) == (unsigned short)cpu.pc))
      {
         strcpy(statusline, "CPU STOPPED");
         statcnt = 10;
      }
   }

   comp.t_states += conf.frame;
   cpu.t -= conf.frame;
   cpu.eipos -= conf.frame;
   comp.frame_counter++;
}
コード例 #12
0
ファイル: protocol.c プロジェクト: Pinois/reseaux_octobre
void clean_send_window(uint8_t seq, window* to_clean, window* removed, int* len)
{
  seq = get_seq(seq);
  int i = 0;
  while (i < MAX_WINDOW_SIZE)
  {
    if (!is_empty_frame(to_clean[i].frame) && seq == to_clean[i].frame.seq)
    {
      memcpy(&removed[*len], &to_clean[i], sizeof(window));
      init_frame(&to_clean[i].frame);
      init_timer(&to_clean[i].timer);
      (*len)++;
      clean_send_window(get_seq(seq-1), to_clean, removed, len);
    }
    i++;
  }
}
コード例 #13
0
void Playback3D::clear_output_sync(Playback3DCommand *command)
{
	command->canvas->lock_canvas("Playback3D::clear_output_sync");
	if(command->canvas->get_canvas())
	{
		command->canvas->get_canvas()->lock_window("Playback3D::clear_output_sync");
// If we get here, the virtual console is being used.
		command->canvas->get_canvas()->enable_opengl();

// Using pbuffer for refresh frame.
		if(command->frame)
		{
			command->frame->enable_opengl();
		}	


		init_frame(command);
		command->canvas->get_canvas()->unlock_window();
	}
	command->canvas->unlock_canvas();
}
コード例 #14
0
ファイル: p3.c プロジェクト: Achal-Aggarwal/entire-src
void receiver3(void)
{
  seq_nr frame_expected;
  frame r, s;
  event_type event;

  frame_expected = 0;
  while (true) {
        wait_for_event(&event);	/* possibilities: frame_arrival, cksum_err */
        if (event == frame_arrival) {
                /* A valid frame has arrived. */
                from_physical_layer(&r);	/* go get the newly arrived frame */
                if (r.seq == frame_expected) {
                        /* This is what we have been waiting for. */
                        to_network_layer(&r.info);	/* pass the data to the network layer */
                        inc(frame_expected);	/* next time expect the other sequence nr */
                }
                init_frame(&s);
                s.ack = 1 - frame_expected;	/* tell which frame is being acked */
                to_physical_layer(&s);	/* only the ack field is use */
        }
  }
}
コード例 #15
0
ファイル: capture.c プロジェクト: robhemsley/libdc1394
dc1394error_t
dc1394_juju_capture_setup(platform_camera_t *craw, uint32_t num_dma_buffers,
        uint32_t flags)
{
    struct fw_cdev_create_iso_context create;
    struct fw_cdev_start_iso start_iso;
    dc1394error_t err;
    dc1394video_frame_t proto;
    int i, j, retval;
    dc1394camera_t * camera = craw->camera;

    if (flags & DC1394_CAPTURE_FLAGS_DEFAULT)
        flags = DC1394_CAPTURE_FLAGS_CHANNEL_ALLOC |
            DC1394_CAPTURE_FLAGS_BANDWIDTH_ALLOC;

    craw->flags = flags;

    // if capture is already set, abort
    if (craw->capture_is_set>0)
        return DC1394_CAPTURE_IS_RUNNING;

    // if auto iso is requested, stop ISO (if necessary)
    if (flags & DC1394_CAPTURE_FLAGS_AUTO_ISO) {
        dc1394switch_t is_iso_on;
        dc1394_video_get_transmission(camera, &is_iso_on);
        if (is_iso_on == DC1394_ON) {
            err=dc1394_video_set_transmission(camera, DC1394_OFF);
            DC1394_ERR_RTN(err,"Could not stop ISO!");
        }
    }

    if (capture_basic_setup(camera, &proto) != DC1394_SUCCESS) {
        dc1394_log_error("basic setup failed");
        return DC1394_FAILURE;
    }

    if (flags & (DC1394_CAPTURE_FLAGS_CHANNEL_ALLOC |
                DC1394_CAPTURE_FLAGS_BANDWIDTH_ALLOC)) {
        uint64_t channels_allowed = 0;
        unsigned int bandwidth_units = 0;
        int channel;
        if (flags & DC1394_CAPTURE_FLAGS_CHANNEL_ALLOC)
            channels_allowed = 0xffff;
        if (flags & DC1394_CAPTURE_FLAGS_BANDWIDTH_ALLOC)
            dc1394_video_get_bandwidth_usage (camera, &bandwidth_units);
        err = juju_iso_allocate (craw, channels_allowed,
                bandwidth_units, &craw->capture_iso_resource);
        if (err == DC1394_SUCCESS) {
            channel = craw->capture_iso_resource->channel;
        } else if (err == DC1394_FUNCTION_NOT_SUPPORTED) {
            channel = craw->node_id & 0x3f;
            dc1394_log_warning ("iso allocation not available in this kernel, "
                    "using channel %d...", channel);
        } else {
            dc1394_log_error ("juju: Failed to allocate iso resources");
            return err;
        }

        if (dc1394_video_set_iso_channel (camera, channel) != DC1394_SUCCESS)
            return DC1394_NO_ISO_CHANNEL;
    }

    if (dc1394_video_get_iso_channel (camera, &craw->iso_channel)
            != DC1394_SUCCESS)
        return DC1394_FAILURE;
    dc1394_log_debug ("juju: Receiving from iso channel %d", craw->iso_channel);

    craw->iso_fd = open(craw->filename, O_RDWR);
    if (craw->iso_fd < 0) {
        dc1394_log_error("error opening file: %s", strerror (errno));
        return DC1394_FAILURE;
    }

    create.type = FW_CDEV_ISO_CONTEXT_RECEIVE;
    create.header_size = craw->header_size;
    create.channel = craw->iso_channel;
    create.speed = SCODE_400;
    err = DC1394_IOCTL_FAILURE;
    if (ioctl(craw->iso_fd, FW_CDEV_IOC_CREATE_ISO_CONTEXT, &create) < 0) {
        dc1394_log_error("failed to create iso context");
        goto error_fd;
    }

    craw->iso_handle = create.handle;

    craw->num_frames = num_dma_buffers;
    craw->current = -1;
    craw->buffer_size = proto.total_bytes * num_dma_buffers;
    craw->buffer =
        mmap(NULL, craw->buffer_size, PROT_READ | PROT_WRITE , MAP_SHARED, craw->iso_fd, 0);
    err = DC1394_IOCTL_FAILURE;
    if (craw->buffer == MAP_FAILED)
        goto error_fd;

    err = DC1394_MEMORY_ALLOCATION_FAILURE;
    craw->frames = malloc (num_dma_buffers * sizeof *craw->frames);
    if (craw->frames == NULL)
        goto error_mmap;

    for (i = 0; i < num_dma_buffers; i++) {
        err = init_frame(craw, i, &proto);
        if (err != DC1394_SUCCESS) {
            dc1394_log_error("error initing frames");
            break;
        }
    }
    if (err != DC1394_SUCCESS) {
        for (j = 0; j < i; j++)
            release_frame(craw, j);
        goto error_mmap;
    }

    for (i = 0; i < num_dma_buffers; i++) {
        err = queue_frame(craw, i);
        if (err != DC1394_SUCCESS) {
            dc1394_log_error("error queuing");
            goto error_frames;
        }
    }

    // starting from here we use the ISO channel so we set the flag in
    // the camera struct:
    craw->capture_is_set = 1;

    start_iso.cycle   = -1;
    start_iso.tags = FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS;
    start_iso.sync = 1;
    start_iso.handle = craw->iso_handle;
    retval = ioctl(craw->iso_fd, FW_CDEV_IOC_START_ISO, &start_iso);
    err = DC1394_IOCTL_FAILURE;
    if (retval < 0) {
        dc1394_log_error("error starting iso");
        goto error_frames;
    }

    // if auto iso is requested, start ISO
    if (flags & DC1394_CAPTURE_FLAGS_AUTO_ISO) {
        err=dc1394_video_set_transmission(camera, DC1394_ON);
        DC1394_ERR_RTN(err,"Could not start ISO!");
        craw->iso_auto_started=1;
    }

    return DC1394_SUCCESS;

error_frames:
    for (i = 0; i < num_dma_buffers; i++)
        release_frame(craw, i);
error_mmap:
    munmap(craw->buffer, craw->buffer_size);
error_fd:
    close(craw->iso_fd);

    return err;
}
コード例 #16
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_pong()
 {
   init_frame(0, 0xA);
   return generate();
 }
コード例 #17
0
ファイル: evaluate.c プロジェクト: co2meal/SNSD_Compiler
void evaluate(Node* pNode, Value* pValue) {
  if (return_count != top_of_frame_stack) return;
  print_node(pNode);
  switch(pNode->type) {
    case NTINTEGER:
      // printf("pNode->value.type: %d\n", (int)pNode->value.type);
      // printf("pNode->value.intValue: %d\n", pNode->value.intValue);
      *pValue = pNode->value;
      break;

    case NTDOUBLE:
      *pValue = pNode->value;
      break;

    case NTIDENTIFIER:
      *pValue = get_variable(pNode->name);
      break;

    case NTASSIGNMENT:
      {
        Value rhs;
        evaluate(pNode->child_nodes[1], &rhs);
        set_variable(pNode->child_nodes[0]->name, rhs);
        *pValue = rhs;
      }
      break;

    case NTUNARYOPERATOR :
    {
        Value a;
        evaluate(pNode->child_nodes[0], &a);
        cal_uminus (pValue, a);
    }
    break;

    case NTBINARYOPERATOR:
      {
        Value a, b;
        evaluate(pNode->child_nodes[0], &a);
        evaluate(pNode->child_nodes[1], &b);
        cal_value(pValue, a, b,pNode->op_token);
      }
      break;

    case NTSTATEMENTLIST:
      {
        int i;
        Value temp;
        for(i = 0; i < pNode->n_of_child_nodes; i++) {
          evaluate(pNode->child_nodes[i], &temp);
        }
      }
      break;

    case NTSTATEMENT:
      {
        Value temp;

        if (pNode->n_of_child_nodes > 0) {
          evaluate(pNode->child_nodes[0], &temp);
          *pValue = temp;
        } else {
          pValue->type = STATEMENTVALUE;
          pValue->statementValue = "empty statement";
        }
      }
      break;

    case NTIFSTATEMENT:
      {
        Value test, temp;
        evaluate(pNode->child_nodes[0], &temp);
        test_value(&test, temp);

        if ( (test.type == INTVALUE) && (test.intValue == 1) ) {
          evaluate(pNode->child_nodes[1], &temp);
        } else if (pNode->n_of_child_nodes == 3) {
          evaluate(pNode->child_nodes[2], &temp);
        }

        pValue->type = STATEMENTVALUE;
        pValue->statementValue = "if";
      }
      break;

    case NTWHILESTATEMENT:
      {
        Value test, temp;

        while (1) {
          evaluate(pNode->child_nodes[0], &temp);
          test_value(&test, temp);

          if (!(test.type == INTVALUE && test.intValue)) break;

          // printf("AAAA  - %d\n", test.intValue);
          evaluate(pNode->child_nodes[1], &temp);
        }

        pValue->type = STATEMENTVALUE;
        pValue->statementValue = "while";
      }
      break;

    case  NTFUNCDECLARE:
      {
        Function* pFn;
        Value value;
        create_function(&pFn, pNode->child_nodes[1], pNode->child_nodes[2]);
        value.type = FUNCTIONVALUE;
        value.functionValue = pFn;

        set_variable(pNode->child_nodes[0]->name, value);
        pValue->type = STATEMENTVALUE;
        pValue->statementValue = "a function is defined.";
      }
      break;

    case NTRETURNSTATEMENT:

      {
        evaluate(pNode->child_nodes[0], frame_stack[top_of_frame_stack].pReturnValue);
        return_count --;
      }
      break;

    case NTLOCALSTATEMENT:
      {
        int i;
        Node* parameter_list = pNode->child_nodes[0];

        for(i=0;i<parameter_list->n_of_child_nodes;i++) {
          char* identifier = parameter_list->child_nodes[i]->name;
          register_local_frame(&frame_stack[top_of_frame_stack], identifier);
        }
        pValue->type = STATEMENTVALUE;
        pValue->statementValue = "local variables are defined.";

      }
      break;

    case NTFUNCCALL:
      {
        int i;
        Value value;
        Function* pFn;
        Node* expression_list;
        Node* statement_list;
        value = get_variable(pNode->child_nodes[0]->name);
        expression_list = pNode->child_nodes[1];

        if (value.type != FUNCTIONVALUE) {
          pValue->type = ERRORVALUE;
          pValue->errorValue = "no function name error";
        } else {
          Value temp;
          pFn = value.functionValue;
          statement_list = pFn->statement_list;

          pValue->type = ERRORVALUE;
          pValue->errorValue = "nothing is returned";

          top_of_frame_stack ++;
          return_count ++;
          init_frame(&frame_stack[top_of_frame_stack], pValue, pFn, expression_list);
          if (pValue->type != ERRORVALUE) {
            evaluate(statement_list, &temp);
          }
          top_of_frame_stack --;
          return_count = top_of_frame_stack;
        }
      }
      break;

    default:
      // printf("not evaluated...\n");
      break;
  }
}
コード例 #18
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_final_continuation(InputIterator begin, InputIterator end, int length,
     MaskKey mask = nothing{})
 {
   init_frame(length, 0x0, mask);
   return generate(begin, end);
 }
コード例 #19
0
ファイル: pagetable.c プロジェクト: tienchil/os_projects
/*
 * Locate the physical frame number for the given vaddr using the page table.
 *
 * If the entry is invalid and not on swap, then this is the first reference 
 * to the page and a (simulated) physical frame should be allocated and 
 * initialized (using init_frame).  
 *
 * If the entry is invalid and on swap, then a (simulated) physical frame
 * should be allocated and filled by reading the page data from swap.
 *
 * Counters for hit, miss and reference events should be incremented in
 * this function.
 */
char *find_physpage(addr_t vaddr, char type) {

	pgtbl_entry_t *p=NULL; // pointer to the full page table entry for vaddr
	unsigned idx = PGDIR_INDEX(vaddr); // get index into page directory

	// IMPLEMENTATION NEEDED
	// Use top-level page directory to get pointer to 2nd-level page table

	// Check if it's valid
	unsigned int valid_pde = pgdir[idx].pde & PG_VALID;

	// Not Valid, initialize a 2nd pagetable
	if (!valid_pde) {

		pgdir[idx] = init_second_level();

	}

	// Use vaddr to get index into 2nd-level page table and initialize 'p'
	unsigned pgtbl_index =  PGTBL_INDEX(vaddr);
	p = (pgtbl_entry_t *) (pgdir[idx].pde & PAGE_MASK);
	p = p + pgtbl_index;

	// Check if p is valid or not, on swap or not, and handle appropriately
	// Find the valid bit and the on-swap bit
	unsigned int valid = p->frame & PG_VALID;
	unsigned int on_swap = p->frame & PG_ONSWAP;

	// Check if it's valid
	if (!valid) {

		// Allocate a frame for p
		int frame = allocate_frame(p);

		// Update fields for OPT
		coremap[frame].pgtbl_idx = (int) pgtbl_index;
		coremap[frame].pgdir_idx = (int) idx;

		// On swap
		if (on_swap) {
			// Read the page from swap
			int success = swap_pagein(frame, p->swap_off);
			assert(success == 0);

		}
 
		// Not on swap
		if (!on_swap) { 
			// Initialize the frame
			init_frame(frame, vaddr);

			// Mark it as dirty
			p->frame = p->frame | PG_DIRTY;

		}

		// Not Valid, so increment miss
		miss_count++;
	
	} 


	// Make sure that p is marked valid and referenced. Also mark it
	// dirty if the access type indicates that the page will be written to.

	// Mark p as valid and referenced
	p->frame = p->frame | PG_VALID;
	p->frame = p->frame | PG_REF;

	unsigned int check =  p->frame & PG_VALID;
	assert(check);

	// Check the access type
	if ((type == 'S') || (type == 'M')) {

		// Set the dirty bit
		p->frame = p->frame | PG_DIRTY;

	} 

	// Increment ref, hit
	if (valid) {
		hit_count++;
	}

	ref_count++;


	// Call replacement algorithm's ref_fcn for this page
	ref_fcn(p);

	// Return pointer into (simulated) physical memory at start of frame
	return  &physmem[(p->frame >> PAGE_SHIFT)*SIMPAGESIZE];
}
コード例 #20
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_binary(InputIterator begin, InputIterator end, int length, MaskKey mask = nothing{})
 {
   init_frame(length, 0x2, mask);
   return generate(begin, end);
 }
コード例 #21
0
ファイル: main.c プロジェクト: nikolawhallon/nviz-project
// main
int main(int argc, char * argv[])
{
	// command line input
	if (argc != 3)
	{
		fprintf(stderr, "ERROR - wrong number of arguments\n");
		fprintf(stderr, "usage: %s in_file_path out_file_path\n", argv[0]);

		return 1;
	}

	sprintf(g_nframe_file_path, argv[1]);
	sprintf(g_bmp_file_path, argv[2]);

	// characters
	init_characters();

	// nframe
	if (init_frame())
	{
		fprintf(stderr, "ERROR - could not open %s\n", g_nframe_file_path);

		return 1;
	}

	// bmp
	g_px_w = g_nframe_col * CURSOR_W;
	g_px_h = g_nframe_row * CURSOR_H;

	// bitmap file header
	uint16_t BM = 0x4d42;
	uint32_t file_size = 54 + g_px_w * g_px_h * 3;
	uint16_t reserve1 = 8;
	uint16_t reserve2 = 8;
	uint32_t pixel_array_start = 54;

	// bitmap information header
	uint32_t bm_info_size = 40;
	int32_t pixel_wd = g_px_w;
	int32_t pixel_ht = g_px_h;
	uint16_t color_planes = 1;
	uint16_t bits_per_pixel = 24;
	uint32_t compression = 0;
	uint32_t image_size = g_px_w * g_px_h * 3;
	int32_t hor_res = g_px_w;
	int32_t ver_res = g_px_h;
	uint32_t palette_colors = 0;
	uint32_t important_colors = 0;

	// declare and open the bmp file
	FILE * bmp_file = fopen(g_bmp_file_path, "wb");

	// write out the bitmap file header
	fwrite(&BM, 2, 1, bmp_file);
	fwrite(&file_size, 4, 1, bmp_file);
	fwrite(&reserve1, 2, 1, bmp_file);
	fwrite(&reserve2, 2, 1, bmp_file);
	fwrite(&pixel_array_start, 4, 1, bmp_file);

	// write out the bitmap information header
	fwrite(&bm_info_size, 4, 1, bmp_file);
	fwrite(&pixel_wd, 4, 1, bmp_file);
	fwrite(&pixel_ht, 4, 1, bmp_file);
	fwrite(&color_planes, 2, 1, bmp_file);
	fwrite(&bits_per_pixel, 2, 1, bmp_file);
	fwrite(&compression, 4, 1, bmp_file);
	fwrite(&image_size, 4, 1, bmp_file);
	fwrite(&hor_res, 4, 1, bmp_file);
	fwrite(&ver_res, 4, 1, bmp_file);
	fwrite(&palette_colors, 4, 1, bmp_file);
	fwrite(&important_colors, 4, 1, bmp_file);

	// bmp pixel array
	char clr;
	char chr;

	uint8_t red;
	uint8_t green;
	uint8_t blue;

	int c;
	int r;
	int w;
	int h;
	for (r = 0; r < g_nframe_row; r++)
	{
		for (h = 0; h < CURSOR_H; h++)
		{
			for (c = 0; c < g_nframe_col; c++)
			{
				for (w = 0; w < CURSOR_W; w++)
				{
					int index = CH_BYTS * ((g_nframe_row - r - 1) * g_nframe_col + c);

					clr = g_frame[index];
					chr = g_frame[index + 1];

					if (g_character_array[chr - 32].pxl[(CURSOR_H - h - 1) * CURSOR_W + w])
					{
						switch (clr)
						{
							case 1:
								red = 0;
								green = 0;
								blue = 255;
								break;
							case 2:
								red = 0;
								green = 255;
								blue = 0;
								break;
							case 3:
								red = 0;
								green = 255;
								blue = 255;
								break;
							case 4:
								red = 255;
								green = 0;
								blue = 0;
								break;
							case 5:
								red = 255;
								green = 0;
								blue = 255;
								break;
							case 6:
								red = 255;
								green = 255;
								blue = 0;
								break;
							case 7:
								red = 255;
								green = 255;
								blue = 255;
								break;
							default:
								red = 0;
								green = 0;
								blue = 0;
								break;
						}

						fwrite(&blue, 1, 1, bmp_file);
						fwrite(&green, 1, 1, bmp_file);
						fwrite(&red, 1, 1, bmp_file);
					}
					else
					{
						red = 0;
						green = 0;
						blue = 0;

						fwrite(&blue, 1, 1, bmp_file);
						fwrite(&green, 1, 1, bmp_file);
						fwrite(&red, 1, 1, bmp_file);
					}
				}
			}
		}
	}

	// close the bmp file
	fclose(bmp_file);

	return 0;
}
コード例 #22
0
ファイル: main.c プロジェクト: taisukef/IchigoDot
void uart() {
#define SIZE_BUF 128
	
	char buf[SIZE_BUF];
	int nbuf = 0;
	for (int i = 0; i < SIZE_BUF; i++)
		buf[i] = 0;
	
//	init_frame();
//	load(); // 初回はデータクリアいるかも?
	int mode = 1;
	
	unsigned char data[8];
	for (int i = 0; i < 8; i++)
		data[i] = 0;
	
	int n = 0;
	int cnt = 0;
	int nframe = 0;
	for (int i = 0;; i++) {
		while (uart0_test()) {
			int c = uart0_getc();
//			println(buf);
			if (c == '\n') {
				buf[nbuf] = '\0';
				if (startsWith(buf, "MATLED SHOW ")) {
					decode(buf + (9 + 3), data);
					println("SHOW");
				} else if (startsWith(buf, "MATLED SET ")) {
					char* pbuf = buf + 11;
					int nf = parseInt(pbuf);
					if (nf >= 0 && nf <= N_FRAME) {
						int n = indexOf(pbuf, ' ');
						if (n >= 0) {
							pbuf += n + 1;
//							println(pbuf);
							decode(pbuf, fr->frame[nf]);
							decode(pbuf, data); // 停止時の画面にも表示
							n = indexOf(pbuf, ' ');
							int nw = 100;
							if (n >= 0) {
								pbuf += n + 1;
								nw = parseInt(pbuf);
							}
							fr->waitms[nf] = nw;
						}
					}
				} else if (startsWith(buf, "MATLED CLEAR")) {
					mode = 0;
					init_frame();
				} else if (startsWith(buf, "MATLED RUN")) {
					mode = 1;
					println("RUN");
				} else if (startsWith(buf, "MATLED STOP")) {
					mode = 0;
					println("STOP");
				} else if (startsWith(buf, "MATLED SAVE")) {
					save();
					println("SAVE");
				} else if (startsWith(buf, "MATLED LOAD")) {
					load();
					println("LOAD");
				}
				nbuf = 0;
				continue;
			} else if (c == '\r') {
			} else {
				if (nbuf < SIZE_BUF - 1)
					buf[nbuf++] = c;
			}
		}
		if (mode == 0) {
			setMatrix(data);
		} else {
			setMatrix(fr->frame[nframe]);
			
			cnt++;
			if (cnt >= fr->waitms[nframe]) {
				cnt = 0;
				int bknframe = nframe;
				for (;;) {
					nframe++;
					if (nframe == N_FRAME)
						nframe = 0;
					if (fr->waitms[nframe])
						break;
					if (bknframe == nframe) {
						mode = 0;
						break;
					}
				}
			}
		}
	}
}
コード例 #23
0
ファイル: window.c プロジェクト: ashmew2/kolibriosSVN
window_t *create_window(char *caption, int style, int x, int y,
                        int w, int h, handler_t handler)
{
    char proc_info[1024];
    int stride;

//    __asm__ __volatile__("int3");


//    ctx_t *ctx = &Window.client_ctx;

    if(handler==0) return 0;

    BeginDraw();
    DrawWindow(x, y, w, h,
               NULL,0,0x41);
    EndDraw();

    get_proc_info(proc_info);

    x = *(uint32_t*)(proc_info+34);
    y = *(uint32_t*)(proc_info+38);
    w = *(uint32_t*)(proc_info+42)+1;
    h = *(uint32_t*)(proc_info+46)+1;

    Window.handler = handler;
//   Window.ctx = ctx;

    list_initialize(&Window.link);
    list_initialize(&Window.child);


//    Window.bitmap.width  = 1920;
//    Window.bitmap.height = 1080;
//    Window.bitmap.flags  = 0;

//   if( create_bitmap(&Window.bitmap) )
//   {
//       printf("not enough memory for window bitmap\n");
//       return 0;
    //  }

//   ctx->pixmap   = &Window.bitmap;
//   ctx->offset_x = 0;
//   ctx->offset_y = 0;

    Window.rc.l = x;
    Window.rc.t = y;
    Window.rc.r = x + w;
    Window.rc.b = y + h;

    Window.w = w;
    Window.h = h;

    Window.caption_txt = caption;
    Window.style = style;

    Window.child_over  = NULL;
    Window.child_focus = NULL;

    init_caption(&Window);
    init_panel(&Window);
    init_frame(&Window);
    send_message((ctrl_t*)&Window, MSG_SIZE, 0, 0);
    return &Window;
};
コード例 #24
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_ping()
 {
   init_frame(0, 0x9);
   return generate();
 }
コード例 #25
0
void Playback3D::draw_output(Playback3DCommand *command)
{
#ifdef HAVE_GL
	int texture_id = command->frame->get_texture_id();
	BC_WindowBase *window = command->canvas->get_canvas();

// printf("Playback3D::draw_output 1 texture_id=%d window=%p\n", 
// texture_id,
// command->canvas->get_canvas());




// If virtual console is being used, everything in this function has
// already been done except the page flip.
	if(texture_id >= 0)
	{
		canvas_w = window->get_w();
		canvas_h = window->get_h();
		VFrame::init_screen(canvas_w, canvas_h);

		if(!command->is_cleared)
		{
// If we get here, the virtual console was not used.
			init_frame(command);
		}

// Texture
// Undo any previous shader settings
		command->frame->bind_texture(0);




// Convert colormodel
		unsigned int frag_shader = 0;
		switch(command->frame->get_color_model())
		{
			case BC_YUV888:
			case BC_YUVA8888:
				frag_shader = VFrame::make_shader(0,
					yuv_to_rgb_frag,
					0);
				break;
		}


		if(frag_shader > 0) 
		{
			glUseProgram(frag_shader);
			int variable = glGetUniformLocation(frag_shader, "tex");
// Set texture unit of the texture
			glUniform1i(variable, 0);
		}

		if(BC_CModels::components(command->frame->get_color_model()) == 4)
		{
			glEnable(GL_BLEND);
			glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		}

		command->frame->draw_texture(command->in_x1, 
			command->in_y1,
			command->in_x2,
			command->in_y2,
			command->out_x1,
			command->out_y1,
			command->out_x2,
			command->out_y2,
			1);


// printf("Playback3D::draw_output 2 %f,%f %f,%f -> %f,%f %f,%f\n",
// command->in_x1,
// command->in_y1,
// command->in_x2,
// command->in_y2,
// command->out_x1,
// command->out_y1,
// command->out_x2,
// command->out_y2);

		glUseProgram(0);

		command->canvas->get_canvas()->flip_opengl();
		
	}
#endif
}
コード例 #26
0
ファイル: MessageGenerator.hpp プロジェクト: ricejasonf/nbdl
 bool generate_close()
 {
   init_frame(0, 0x8);
   return generate();
 }
コード例 #27
0
ファイル: unit_arp.c プロジェクト: AustinHunting/picotcp
END_TEST

START_TEST(tc_pico_arp_queue)
{
    struct pico_ip4 addr = {
        .addr = 0xaabbccdd
    };
    int i;
    struct pico_frame *f = pico_frame_alloc(sizeof(struct pico_ipv4_hdr));
    struct pico_ipv4_hdr *h = (struct pico_ipv4_hdr *) f->buffer;
    fail_if(!f);
    f->net_hdr = h;
    h->dst.addr = addr.addr;

    for (i = 0; i < PICO_ND_MAX_FRAMES_QUEUED; i++) {
        fail_if(frames_queued[i] != NULL);
    }
    pico_arp_unreachable(&addr);
    for (i = 0; i < PICO_ND_MAX_FRAMES_QUEUED; i++) {
        fail_if(frames_queued[i] != NULL);
    }
    pico_arp_postpone(f);
    fail_if(frames_queued[0]->buffer != f->buffer);
    pico_arp_unreachable(&addr);
    for (i = 0; i < PICO_ND_MAX_FRAMES_QUEUED; i++) {
        fail_if(frames_queued[i] != NULL);
    }
    PICO_FREE(f);
}
END_TEST



START_TEST (arp_receive_test)
{
    struct mock_device *mock;
    struct pico_frame *f = NULL;
    struct pico_arp_hdr *ah = NULL;
    struct pico_eth_hdr *eh = NULL;
    uint8_t macaddr1[6] = {
        0, 0, 0, 0xa, 0xb, 0xf
    };
    uint8_t macaddr2[6] = {
        0, 0, 0, 0xc, 0xd, 0xf
    };
    struct pico_ip4 netmask = {
        .addr = long_be(0xffffff00)
    };
    struct pico_ip4 ip1 = {
        .addr = long_be(0x0A28000A)
    };
    struct pico_ip4 ip2 = {
        .addr = long_be(0x0A28000B)
    };

    pico_stack_init();

    /* Create mock device */
    mock = pico_mock_create(macaddr1);
    fail_if(!mock, "MOCK DEVICE creation failed");
    fail_if(pico_ipv4_link_add(mock->dev, ip1, netmask), "add link to mock device failed");

    /* Normal ARP request */
    f = init_frame(mock->dev);
    fail_if(!f, "FRAME INIT failed");
    eh = (struct pico_eth_hdr *) f->datalink_hdr;
    ah = (struct pico_arp_hdr *) f->net_hdr;

    memcpy(eh->saddr, macaddr2, PICO_SIZE_ETH);
    memcpy(eh->daddr, PICO_ETHADDR_ALL, PICO_SIZE_ETH);
    eh->proto = PICO_IDETH_ARP;

    ah->htype  = PICO_ARP_HTYPE_ETH;
    ah->ptype  = PICO_IDETH_IPV4;
    ah->hsize  = PICO_SIZE_ETH;
    ah->psize  = PICO_SIZE_IP4;
    ah->opcode = PICO_ARP_REQUEST;
    memcpy(ah->s_mac, macaddr2, PICO_SIZE_ETH);
    ah->src.addr = ip2.addr;
    ah->dst.addr = ip1.addr;
    fail_unless(pico_arp_receive(f) == 0);

    /* net_hdr is a nullpointer */
    f = init_frame(mock->dev);
    fail_if(!f, "FRAME INIT failed");
    f->net_hdr = NULL;
    fail_unless(pico_arp_receive(f) == -1);

    /* wrong hardware type */
    f = init_frame(mock->dev);
    fail_if(!f, "FRAME INIT failed");
    ah = (struct pico_arp_hdr *) f->net_hdr;
    ah->htype = 0;
    fail_unless(pico_arp_receive(f) == -1);

    /* wrong protocol type */
    f = init_frame(mock->dev);
    fail_if(!f, "FRAME INIT failed");
    ah = (struct pico_arp_hdr *) f->net_hdr;
    ah->ptype = 0;
    fail_unless(pico_arp_receive(f) == -1);

    /* source mac address is multicast */
    f = init_frame(mock->dev);
    fail_if(!f, "FRAME INIT failed");
    ah = (struct pico_arp_hdr *) f->net_hdr;
    ah->s_mac[0] = 0x01;
    fail_unless(pico_arp_receive(f) == -1);
}
END_TEST

START_TEST (arp_get_test)
{
    struct pico_frame *f = NULL;
    struct mock_device *mock;
    struct pico_ipv4_hdr *hdr = NULL;
    struct pico_eth *eth = NULL;
    uint8_t macaddr[6] = {
        0, 0, 0, 0xa, 0xb, 0xf
    };
    struct pico_ip4 netmask = {
        .addr = long_be(0xffffff00)
    };
    struct pico_ip4 ip = {
        .addr = long_be(0x0A28000A)
    };

    mock = pico_mock_create(macaddr);
    fail_if(!mock, "MOCK DEVICE creation failed");
    fail_if(pico_ipv4_link_add(mock->dev, ip, netmask), "add link to mock device failed");

    f = pico_frame_alloc(PICO_SIZE_ETHHDR + sizeof(struct pico_ipv4_hdr));
    f->net_hdr = f->start + PICO_SIZE_ETHHDR;
    f->datalink_hdr = f->start;
    f->dev = mock->dev;

    hdr = (struct pico_ipv4_hdr *) f->net_hdr;
    hdr->dst.addr = ip.addr;
    eth = pico_arp_get(f);
    fail_unless(eth == &mock->dev->eth->mac);
}
END_TEST
コード例 #28
0
ファイル: frame.c プロジェクト: JeffAbrahamson/ratpoison-dev
rp_frame *
frame_read (char *str, rp_screen *screen)
{
    Window w = 0L;
    rp_window *win;
    rp_frame *f;
    char *tmp, *d;
    int s_width = -1;
    int s_height = -1;

    /* Create a blank frame. */
    f = xmalloc (sizeof (rp_frame));
    init_frame(f);

    PRINT_DEBUG(("parsing '%s'\n", str));

    d = xstrdup(str);
    tmp = strtok_ws (d);

    /* Verify it starts with '(frame ' */
    if (strcmp(tmp, "(frame"))
    {
        PRINT_DEBUG(("Doesn't start with '(frame '\n"));
        free (d);
        free (f);
        return NULL;
    }
    /* NOTE: there is no check to make sure each field was filled in. */
    tmp = strtok_ws(NULL);
    while (tmp)
    {
        if (!strcmp(tmp, ":number"))
            read_slot(f->number);
        else if (!strcmp(tmp, ":x"))
            read_slot(f->x);
        else if (!strcmp(tmp, ":y"))
            read_slot(f->y);
        else if (!strcmp(tmp, ":width"))
            read_slot(f->width);
        else if (!strcmp(tmp, ":height"))
            read_slot(f->height);
        else if (!strcmp(tmp, ":screenw"))
            read_slot(s_width);
        else if (!strcmp(tmp, ":screenh"))
            read_slot(s_height);
        else if (!strcmp(tmp, ":window"))
            read_slot(w);
        else if (!strcmp(tmp, ":last-access"))
            read_slot(f->last_access);
        else if (!strcmp(tmp, ":dedicated")) {
            /* f->dedicated is unsigned, so read into local variable. */
            long dedicated;

            read_slot(dedicated);
            if (dedicated <= 0)
                f->dedicated = 0;
            else
                f->dedicated = 1;
        }
        else if (!strcmp(tmp, ")"))
            break;
        else
            PRINT_ERROR(("Unknown slot %s\n", tmp));
        /* Read the next token. */
        tmp = strtok_ws(NULL);
    }
    if (tmp)
        PRINT_ERROR(("Frame has trailing garbage\n"));
    free (d);

    /* adjust x, y, width and height to a possible screen size change */
    if (s_width > 0)
    {
        f->x = (f->x*screen->width)/s_width;
        f->width = (f->width*screen->width)/s_width;
    }
    if (s_height > 0)
    {
        f->y = (f->y*screen->height)/s_height;
        f->height = (f->height*screen->height)/s_height;
    }

    /* Perform some integrity checks on what we got and fix any
       problems. */
    if (f->number <= 0)
        f->number = 0;
    if (f->x <= 0)
        f->x = 0;
    if (f->y <= 0)
        f->y = 0;
    if (f->width <= defaults.window_border_width*2)
        f->width = defaults.window_border_width*2 + 1;
    if (f->height <= defaults.window_border_width*2)
        f->height = defaults.window_border_width*2 + 1;
    if (f->last_access < 0)
        f->last_access = 0;

    /* Find the window with the X11 window ID. */
    win = find_window_in_list (w, &rp_mapped_window);
    if (win)
        f->win_number = win->number;
    else
        f->win_number = EMPTY;

    return f;
}
コード例 #29
0
ファイル: main.c プロジェクト: RajasekharBhumi/L4Re
int main(int argc,char **argv) {
	INFO(char *dbg="Main(init): ");

	native_startup(argc, argv);

	/*** init modules ***/

	INFO(printf("%sSharedMemory\n",dbg));
	init_sharedmem(&dope);

	INFO(printf("%sTimer\n",dbg));
	init_timer(&dope);

	INFO(printf("%sTick\n",dbg));
	init_tick(&dope);

	INFO(printf("%sRelax\n",dbg));
	init_relax(&dope);

	INFO(printf("%sKeymap\n",dbg));
	init_keymap(&dope);

	INFO(printf("%sThread\n",dbg));
	init_thread(&dope);

	INFO(printf("%sCache\n",dbg));
	init_cache(&dope);

	INFO(printf("%sHashTable\n",dbg));
	init_hashtable(&dope);

	INFO(printf("%sApplication Manager\n",dbg));
	init_appman(&dope);

	INFO(printf("%sTokenizer\n",dbg));
	init_tokenizer(&dope);

	INFO(printf("%sMessenger\n",dbg));
	init_messenger(&dope);

	INFO(printf("%sScript\n",dbg));
	init_script(&dope);

	INFO(printf("%sClipping\n",dbg));
	init_clipping(&dope);

	INFO(printf("%sScreen Driver\n",dbg));
	init_scrdrv(&dope);

	INFO(printf("%sInput\n",dbg));
	init_input(&dope);

	INFO(printf("%sViewManager\n",dbg));
	init_viewman(&dope);

	INFO(printf("%sConvertFNT\n",dbg));
	init_conv_fnt(&dope);

	INFO(printf("%sFontManager\n",dbg));
	init_fontman(&dope);

	INFO(printf("%sGfxScreen16\n",dbg));
	init_gfxscr16(&dope);

	INFO(printf("%sGfxImage16\n",dbg));
	init_gfximg16(&dope);

	INFO(printf("%sGfxImage32\n",dbg));
	init_gfximg32(&dope);

	INFO(printf("%sGfxImageYUV420\n",dbg));
	init_gfximgyuv420(&dope);

	INFO(printf("%sGfx\n",dbg));
	init_gfx(&dope);

	INFO(printf("%sRedrawManager\n",dbg));
	init_redraw(&dope);

	INFO(printf("%sUserState\n",dbg));
	init_userstate(&dope);

	INFO(printf("%sWidgetManager\n",dbg));
	init_widman(&dope);

	INFO(printf("%sScope\n",dbg));
	init_scope(&dope);

	INFO(printf("%sButton\n",dbg));
	init_button(&dope);

	INFO(printf("%sEntry\n",dbg));
	init_entry(&dope);

	INFO(printf("%sVariable\n",dbg));
	init_variable(&dope);

	INFO(printf("%sLabel\n",dbg));
	init_label(&dope);

	INFO(printf("%sLoadDisplay\n",dbg));
	init_loaddisplay(&dope);

	INFO(printf("%sBackground\n",dbg));
	init_background(&dope);

	INFO(printf("%sScrollbar\n",dbg));
	init_scrollbar(&dope);

	INFO(printf("%sScale\n",dbg));
	init_scale(&dope);

	INFO(printf("%sFrame\n",dbg));
	init_frame(&dope);

	INFO(printf("%sContainer\n",dbg));
	init_container(&dope);

	INFO(printf("%sGrid\n",dbg));
	init_grid(&dope);

	INFO(printf("%sWinLayout\n",dbg));
	init_winlayout(&dope);

	INFO(printf("%sWindow\n",dbg));
	init_window(&dope);

	INFO(printf("%sScreen\n",dbg));
	init_screen(&dope);

	INFO(printf("%sScheduler\n",dbg));
	if (config_don_scheduler)
        {
	//	init_don_scheduler(&dope);
          printf("NOOOOOOOOOOOOOOOOOOO\n");
        }
	else
		init_simple_scheduler(&dope);

	INFO(printf("%sVScreenServer\n",dbg));
	init_vscr_server(&dope);

	INFO(printf("%sVScreen\n",dbg));
	init_vscreen(&dope);
	
	INFO(printf("%sVTextScreen\n",dbg));
	init_vtextscreen(&dope);

	INFO(printf("%sServer\n",dbg));
	init_server(&dope);

	INFO(printf("%screate screen\n",dbg));
	{
		static GFX_CONTAINER *scr_ds;
		gfx       = pool_get("Gfx 1.0");
		screen    = pool_get("Screen 1.0");
		userstate = pool_get("UserState 1.0");

		scr_ds = gfx->alloc_scr("default");
		curr_scr = screen->create();
		curr_scr->scr->set_gfx(curr_scr, scr_ds);
		userstate->set_max_mx(gfx->get_width(scr_ds));
		userstate->set_max_my(gfx->get_height(scr_ds));
	}
	
	INFO(printf("%sstarting server\n",dbg));
	if ((server = pool_get("Server 1.0")))
		server->start();
	
	INFO(printf("%sstarting scheduler\n",dbg));
	if ((sched  = pool_get("Scheduler 1.0")))
		sched->process_mainloop();

	return 0;
}
コード例 #30
0
ファイル: player4.c プロジェクト: pkuembedded/player
int main(int argc, char **argv)
{
/*    PacketQueue *a = av_mallocz(sizeof(PacketQueue));
      AVPacket *p = av_mallocz(sizeof(AVPacket));
      AVPacket *b = av_mallocz(sizeof(AVPacket));
      add_to_queue(a, p);
      add_to_queue(a, p);
      add_to_queue(a, p);
      add_to_queue(a, p);
      get_from_queue(a, b);
      add_to_queue(a, p);

      get_from_queue(a, b);
      get_from_queue(a, b);
      get_from_queue(a, b);
      get_from_queue(a, b);
      av_free(a);
      av_free(p);
*/
    

    FileState *file = av_mallocz(sizeof(FileState));
    VideoState *video = av_mallocz(sizeof(VideoState));
    AudioState *audio = av_mallocz(sizeof(AudioState));
    State *state = av_mallocz(sizeof(State));
    SDL_Thread *video_decode_tid;
    SDL_Thread *read_pkt_tid;
    SDL_Thread *play_tid;
    state->file = file;
    state->video = video;
    state->audio = audio;
    
    if(argc < 2) {
	fprintf(stderr, "Usage : play <file>\n");
	exit(1);
    }
    av_register_all();
    if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER)) {
	fprintf(stderr, "Could not initialize SDL - %s\n", SDL_GetError());
	exit(1);
    }
    av_strlcpy(file->fileName, argv[1], sizeof(file->fileName));
    video->vFrameqMutex = SDL_CreateMutex();
    video->vFrameqCond = SDL_CreateCond();
    get_file_info(file);
    find_av_streams(file, video, audio);
    
    //find_audio_decoder(audio);
    init_screen(video);

    read_pkt_tid = SDL_CreateThread(queue_av_pkt, state);
    init_frame(video);

    video_decode_tid = SDL_CreateThread(decode_video, video);
/*
    video->frame_timer = (double)av_gettime() / 1000000.0;
    video->frame_last_delay = 40e-3;

    video->pCodecCtx->get_buffer = our_get_buffer;
    video->pCodecCtx->release_buffer = our_release_buffer;*/
//    play_tid = SDL_CreateThread(play_video, video);
    while(true) {
//	decode_video(video);
	play_video(video);	
    }
	

    sleep(10);
    if(!video_decode_tid) {
	av_free(video_decode_tid);
	return -1;
    }
    if(!read_pkt_tid) {
	av_free(read_pkt_tid);
	return -1;
    }
    return 0;
}