コード例 #1
0
ファイル: enc.c プロジェクト: Alexlcb/rt-thread
int32_t encode_test(void *arg)
{
    struct codec_control *codecctrl;
    int32_t file_in, file_out;

    uint8_t in_enc_file[] = "raw_yv12.yuv";
    uint8_t out_enc_file[] = "out.264";

    codecctrl = (struct codec_control *)calloc(1, sizeof(struct codec_control));
    if (codecctrl == NULL) {
        err_msg("Failed to allocate command structure\n");
        return -1;
    }

    if ((file_in = Fopen(in_enc_file, (uint8_t *) "r")) < 0) {
        printf("Can't open the file: %s !\n", in_enc_file);
        goto err2;
    }

    if ((file_out = Fopen(out_enc_file, (uint8_t *) "w")) < 0) {
        printf("Can't open the file: %s !\n", out_enc_file);
        goto err1;
    }

    /*now enable the INTERRUPT mode of usdhc */
    set_card_access_mode(1, 0);
    
    memset((void *)&g_bs_memory, 0, sizeof(bs_mem_t));
    codecctrl->input = file_in; /* Input file name */
    codecctrl->output = file_out;   /* Output file name */
    codecctrl->format = STD_AVC;
    codecctrl->src_scheme = PATH_FILE;
    codecctrl->dst_scheme = PATH_FILE;
    codecctrl->dering_en = 0;
    codecctrl->deblock_en = 0;
    codecctrl->chromaInterleave = 0;    //partial interleaved mode
    codecctrl->mapType = LINEAR_FRAME_MAP;
    codecctrl->bs_mode = 0;     /*disable pre-scan */
    codecctrl->fps = 24;
    codecctrl->enc_width = 320;
    codecctrl->enc_height = 240;
    codecctrl->width = 320;
    codecctrl->height = 240;
    codecctrl->gop = 0;
    codecctrl->read_mode = 0;
    encoder_setup(codecctrl);

  err1:
    Fclose(file_out);

  err2:
    Fclose(file_in);

    return 0;
}
コード例 #2
0
ファイル: driver.c プロジェクト: terurin/MDU_COMMON
bool driver_setup(){
    
    //クロック確認
#if !defined(IS_SLIM)
    while (OSCCONbits.LOCK != 1);//PLL Lock
#endif
    //周辺機器(優先度高)
    ports_setup();
    //システム(優先度高)
    eeprom_setup();
    //周辺機器
    pwm_setup();
    encoder_setup();
    
    uart_setup();
    
    
    pwm_shutdown(false);
    
    
    return false;
}
コード例 #3
0
ファイル: main.c プロジェクト: alexpriem/avr
int main(void)
{
    int j=0, vol_l, vol_r,d;
	
	
	uart_init();
	uart_puts ("\r\nreset -- init2\r\n");
	//void lcd_setup (uint8_t rs, uint8_t rw, uint8_t enable,
	//			uint8_t db0, uint8_t db1, uint8_t db2, uint8_t db3 ) 
	/* lcd_setup (0, P_PC2, P_PC4, P_PC6, P_PC0,
			  P_PC1, P_PC3, P_PC5, P_PC7);	 */
	// lcd_setup  (uint8_t chip,  uint8_t strobe, uint8_t clock, uint8_t io)
	lcd_setup (0, P_PA2, P_PA4, P_PA0);
	lcd_setup_info (0, HD44780, 20, 2);

	//a2311_setup (uint8_t chip, uint8_t zcen, uint8_t cs, uint8_t sdi, uint8_t clk, uint8_t mute)	
	/* pga2311_setup (0, P_PA0, P_PA1, P_PA2, P_PA3, P_PA4);
	pga2311_init (0); */
	lcd_init (0, LCD_DISP_ON_CURSOR_BLINK);
	
//	lcd_puts (0,"abcdef\n1234");
	//lcd_clrscr(0);
	lcd_puts (0,"abcdefghijklmnopqrstuvwxyz");
	lcd_puts (0,"\nok");
	/*
	lcd_puts (0, "xbcde 1");
	lcd_puts (0, "\nfghij 2");
	lcd_puts (0, "\nklmno 3");
	lcd_puts (0, "\npqrst 4");
	lcd_puts (0, "\nuvw 5");
	lcd_puts (0, "\nzAB 6");
	lcd_puts (0, "\nEFG 7");
	lcd_puts (0, "\nKLM 8");
	lcd_puts (0, "\n# 9"); */
	
	/*
	lcd_puts (0, "##234567890abcdefghijklmno##rstuvwxyz\n");
	lcd_puts (0, "12##$567890abcdefghijklmnopq##tuvwxyz\n");
	lcd_puts (0, "12345##7890abcdefghijklmnopqs##vwxyz\n");
	lcd_puts (0, "1234567##90abcdefghijklmnopqrstu##yz\n");
	*/
	
	
	/*
	lcd_init (1, LCD_DISP_ON_CURSOR_BLINK);
	lcd_puts (1, "regel 1");
	lcd_puts (1, "\nregel 2");
	lcd_puts (1, "\nregel 3");
	lcd_puts (1, "\nregel 4");
	lcd_puts (1, "\nregel 5");
	lcd_puts (1, "\nregel 6");
	lcd_puts (1, "\nregel 7");
	*/
	j=0;
	
	vol_l=128;
	vol_r=128;
	encoder_setup (0,P_PD2, P_PD3);
	encoder_setup (1,P_PD4, P_PD5);
	
	for (;;) {
		d=encoder_poll (0);
		if (d>0) {
			vol_l++; vol_r--;
			}
		if (d<0) {
			vol_l--; vol_r--;
		}
		
		pga2311_set_gain (0, vol_l, vol_r);
		}
 return 0;
}
コード例 #4
0
ファイル: motor.cpp プロジェクト: ziyan/amos
void Motor::setup()
{
    encoder_setup();
    victor_setup();
    timer_setup();
}
コード例 #5
0
void dc_electronic_load_setup() {
  setCurrentMilliamps = 0;
  readCurrentMilliamps = 0;
  readMilliVolts = 0;
  setRateIndex = 0;
  readCurrentMilliampsDisplay = DISPLAY_MILLI;
  gfxState = GFX_STATE_MEASURE;

  dma_ring_buffer_init(&g_debugUsartDmaInputRingBuffer, DEBUG_USART_RX_DMA_CH, g_debugUsartRxBuffer, DEBUG_USART_RX_BUFFER_SIZE);

  debug_setup();
  debug_write_line("?BEGIN setup");

  process_init();
  process_start(&etimer_process, NULL);

  process_start(&debug_process, NULL);
#ifdef DISP6800_ENABLE
  process_start(&gfx_update_process, NULL);
  process_poll(&gfx_update_process);
#endif

  spi_setup();

#ifdef DISP6800_ENABLE
  disp6800_setup();
  gfx_setup();
#endif

#ifdef ENCODER_ENABLE
  encoder_setup();
#endif

#ifdef FLASH_ENABLE
  flashsst25_setup();
#endif

#ifdef MAC_ENABLE
  mac25aa02e48_setup();
  mac25aa02e48_read_eui48();
#endif

#ifdef ADC_ENABLE
  adc_setup();
#endif

#ifdef DAC_ENABLE
  dac_setup();
  dac_set(0);
#endif

#ifdef NETWORK_ENABLE
  network_setup(EUI48);
#endif

#ifdef FAN_ENABLE
  fan_setup();
#endif

#ifdef BUTTONS_ENABLE
  buttons_setup();
#endif

  time_setup();
  recorder_setup();

  debug_write_line("?END setup");
}
コード例 #6
0
ファイル: ltcgen.c プロジェクト: x42/ltc-tools
int main (int argc, char **argv) {
  int c;

  program_name = argv[0];
  long long int msec = 0;// start timecode in ms from 00:00:00.00
  long int date = 0;// bcd: 201012 = 20 Oct 2012
  long int tzoff = 0;// time-zone in minuteswest
  int custom_user_bits = 0;

  while ((c = getopt_long (argc, argv,
	   "h"	/* help */
	   "f:"	/* fps */
	   "d:"	/* date */
	   "g:"	/* gain^wvolume */
	   "l:"	/* duration */
	   "r"	/* reverse */
	   "s:"	/* samplerate */
	   "t:"	/* timecode */
	   "z:"	/* timezone */
	   "m:"	/* timezone */
	   "u:" /* free format user bits */
	   "V",	/* version */
	   long_options, (int *) 0)) != EOF)
  {
      switch (c) {
	case 'V':
	  printf ("%s %s\n\n",basename(argv[0]), VERSION);
	  printf (
		  "Copyright (C) 2012 Robin Gareus <*****@*****.**>\n"
		  "This is free software; see the source for copying conditions.  There is NO\n"
		  "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
		  );
	  exit (0);

	case 'h':
	  usage (0);

	case 'f':
	  parse_fps(optarg);
	  break;

	case 'd':
	  {
	    date=atoi(optarg);
	    char *tmp = optarg;
	    if (tmp && (tmp = strchr(tmp, '/'))) date=date*100+(atoi(++tmp)*10000);
	    if (tmp) {
	      if ((tmp = strchr(tmp, '/'))) date+=atoi(++tmp);
	      else date+=12;// 2012
	    }
	  }
	  break;

	case 'g':
	  volume_dbfs = atof(optarg);
	  if (volume_dbfs > 0) volume_dbfs=0;
	  if (volume_dbfs < -96.0) volume_dbfs=-96.0;
	  printf("Output volume %.2f dBfs\n", volume_dbfs);
	  break;

	case 'm':
	  tzoff=atoi(optarg); //minuteswest
	  break;

	case 'r':
	  reverse = 1;
	  break;

	case 's':
	  samplerate=atoi(optarg);
	  break;

	case 'z':
	  {
	    int hh = atoi(optarg)/100;
	    tzoff= 60*hh + ((atoi(optarg)-(100*hh))%60); // HHMM
	  }
	  break;

	case 'l':
	  {
	    int bcd[SMPTE_LAST];
	    parse_string(rint(fps_num/(double)fps_den), bcd, optarg);
	    duration = bcdarray_to_framecnt(bcd) * 1000.0 / (((double)fps_num)/(double)fps_den);
	  }
	  break;

	case 't':
	  {
	    sync_now=0;
	    int bcd[SMPTE_LAST];
	    parse_string(rint(fps_num/(double)fps_den), bcd, optarg);
	    msec = bcdarray_to_framecnt(bcd) * 1000.0 / (((double)fps_num)/(double)fps_den);
	  }
	  break;

	case 'u':
	  {
	    custom_user_bits = 1;
	    parse_user_bits(user_bit_array, optarg);
	    /* Free format user bits, so reset any date/timezone settings. */
	    date = 0;
	    tzoff = 0;
	  }
	  break;

	default:
	  usage (EXIT_FAILURE);
      }
  }

  if (optind >= argc) {
    usage (EXIT_FAILURE);
  }

  fps_sanity_checks();

  {
    SF_INFO sfnfo;
    memset(&sfnfo, 0, sizeof(SF_INFO));
    sfnfo.samplerate = samplerate;
    sfnfo.channels = 1;
    sfnfo.format = SF_FORMAT_WAV | sf_format;
    sf = sf_open(argv[optind], SFM_WRITE, &sfnfo);
    if (!sf) {
      fprintf(stderr, "cannot open output file '%s'\n", argv[optind]);
      return 1;
    }
  }
  printf("writing to '%s'\n", argv[optind]);
  printf("samplerate: %d, duration %.1f ms\n", samplerate, duration);

  encoder_setup(fps_num, fps_den, ltc_tv, samplerate,
      ((date != 0) ? LTC_USE_DATE : 0) | ((sync_now) ? (LTC_USE_DATE|LTC_TC_CLOCK) : 0)
      );

  if (sync_now==0) {
#if 0 // DEBUG
    printf("date: %06ld (DDMMYY)\n", date);
    printf("time: %lldms\n", msec);
    printf("zone: %c%02d%02d = %ld minutes west\n", tzoff<0?'-':'+', abs(tzoff/60),abs(tzoff%60), tzoff);
#endif
    set_encoder_time(1000.0*msec, date, tzoff, fps_num, fps_den, 1);
  } else {
    struct timespec t;
    long int sync_msec;
    my_clock_gettime(&t);
    sync_msec = (t.tv_sec%86400)*1000 + (t.tv_nsec/1000000);

    time_t now = t.tv_sec;
    struct tm gm;
    long int sync_date = 0;
    if (gmtime_r(&now, &gm))
      sync_date = gm.tm_mday*10000 + (gm.tm_mon + 1)*100 + (gm.tm_year % 100);
    sync_msec += 1000.0 * ltc_frame_alignment(samplerate * fps_den / (double) fps_num, ltc_tv) / samplerate;
    set_encoder_time(1000.0*sync_msec, custom_user_bits ? 0 : sync_date, 0, fps_num, fps_den, 1);
  }

  if (custom_user_bits)
    set_user_bits(user_bit_array);

  signal(SIGINT, endnow);

  if (reverse)
    main_loop_reverse();
  else
    main_loop();

  if (sf) sf_close(sf);
  if (enc_buf) free(enc_buf);
  if (encoder) ltc_encoder_free(encoder);
  return(0);
}