예제 #1
0
파일: libgme.c 프로젝트: DeHackEd/FFmpeg
static int read_header_gme(AVFormatContext *s)
{
    AVStream *st;
    AVIOContext *pb = s->pb;
    GMEContext *gme = s->priv_data;
    int64_t sz = avio_size(pb);
    char *buf;
    char dummy;

    if (sz < 0) {
        av_log(s, AV_LOG_WARNING, "Could not determine file size\n");
        sz = gme->max_size;
    } else if (gme->max_size && sz > gme->max_size) {
        sz = gme->max_size;
    }

    buf = av_malloc(sz);
    if (!buf)
        return AVERROR(ENOMEM);
    sz = avio_read(pb, buf, sz);

    // Data left means our buffer (the max_size option) is too small
    if (avio_read(pb, &dummy, 1) == 1) {
        av_log(s, AV_LOG_ERROR, "File size is larger than max_size option "
               "value %"PRIi64", consider increasing the max_size option\n",
               gme->max_size);
        return AVERROR_BUFFER_TOO_SMALL;
    }

    if (gme_open_data(buf, sz, &gme->music_emu, gme->sample_rate)) {
        av_freep(&buf);
        return AVERROR_INVALIDDATA;
    }
    av_freep(&buf);

    if (gme_track_info(gme->music_emu, &gme->info, gme->track_index))
        return AVERROR_STREAM_NOT_FOUND;

    if (gme_start_track(gme->music_emu, gme->track_index))
        return AVERROR_UNKNOWN;

    load_metadata(s);

    st = avformat_new_stream(s, NULL);
    if (!st)
        return AVERROR(ENOMEM);
    avpriv_set_pts_info(st, 64, 1, 1000);
    if (st->duration > 0)
        st->duration = gme->info->length;
    st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
    st->codecpar->codec_id    = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE);
    st->codecpar->channels    = 2;
    st->codecpar->sample_rate = gme->sample_rate;

    return 0;
}
예제 #2
0
			void  OntologyBase::fill_missing_data(){
				std::cerr << "entering fill missign data" << std::endl;
				std::vector<OntologyBase::MetaDataStruct> * metaData = load_metadata();

						   if (this->get_acronym() == NULL)
						   {
							   for (std::vector<OntologyBase::MetaDataStruct>::iterator it=metaData->begin();it!=metaData->end();++it){
								   if (this->get_name()==static_cast<OntologyBase::MetaDataStruct>((*it)).name){
									   this->set_acronym(static_cast<OntologyBase::MetaDataStruct>((*it)).acronym);
								   }
							   }
						   }

						   if (this->get_name() == NULL)
						   {
							   for (std::vector<OntologyBase::MetaDataStruct>::iterator it=metaData->begin();it!=metaData->end();++it){
								   if (this->get_acronym()==static_cast<OntologyBase::MetaDataStruct>((*it)).acronym){
									   this->set_name(static_cast<OntologyBase::MetaDataStruct>((*it)).name);
								   }
							   }
						   }

						   if (this->get_url() == NULL)
						   {
							   for (std::vector<OntologyBase::MetaDataStruct>::iterator it=metaData->begin();it!=metaData->end();++it){
								   if (this->get_acronym()==static_cast<OntologyBase::MetaDataStruct>((*it)).acronym && this->get_name()==static_cast<OntologyBase::MetaDataStruct>((*it)).name){
									   this->set_url(static_cast<OntologyBase::MetaDataStruct>((*it)).url);
								   }
							   }
						   }

						   if (this->ontologyURL == NULL)
						   {
							   for (std::vector<OntologyBase::MetaDataStruct>::iterator it=metaData->begin();it!=metaData->end();++it){
								   if (this->get_acronym()==static_cast<OntologyBase::MetaDataStruct>((*it)).acronym && this->get_name()==static_cast<OntologyBase::MetaDataStruct>((*it)).name){
									   this->set_ontologyURL(static_cast<OntologyBase::MetaDataStruct>((*it)).ontologyURL);
								   }
							   }
						   }

						   if (this->version == NULL)
						   {
							   for (std::vector<OntologyBase::MetaDataStruct>::iterator it=metaData->begin();it!=metaData->end();++it){
								   if (this->get_acronym()==static_cast<OntologyBase::MetaDataStruct>((*it)).acronym && this->get_name()==static_cast<OntologyBase::MetaDataStruct>((*it)).name){
									   this->set_version(static_cast<OntologyBase::MetaDataStruct>((*it)).version);
								   }
							   }
						   }

			}
예제 #3
0
파일: ftl.c 프로젝트: ClydeProjects/OpenSSD
void ftl_open(void)
{
    // debugging example 1 - use breakpoint statement!
    /* *(UINT32*)0xFFFFFFFE = 10; */

    /* UINT32 volatile g_break = 0; */
    /* while (g_break == 0); */

	led(0);
    sanity_check();
    //----------------------------------------
    // read scan lists from NAND flash
    // and build bitmap of bad blocks
    //----------------------------------------
	build_bad_blk_list();

    //----------------------------------------
	// If necessary, do low-level format
	// format() should be called after loading scan lists, because format() calls is_bad_block().
    //----------------------------------------
/* 	if (check_format_mark() == FALSE) */
	if (TRUE)
	{
        uart_print("do format");
		format();
        uart_print("end format");
	}
    // load FTL metadata
    else
    {
        load_metadata();
    }
	g_ftl_read_buf_id = 0;
	g_ftl_write_buf_id = 0;

    // This example FTL can handle runtime bad block interrupts and read fail (uncorrectable bit errors) interrupts
    flash_clear_irq();

    SETREG(INTR_MASK, FIRQ_DATA_CORRUPT | FIRQ_BADBLK_L | FIRQ_BADBLK_H);
	SETREG(FCONF_PAUSE, FIRQ_DATA_CORRUPT | FIRQ_BADBLK_L | FIRQ_BADBLK_H);

	enable_irq();
}
예제 #4
0
int main(){
	
	//union
	
	FILE *arq, *arq2; //Ponteiros para arquivos
	int valor_reg, tam_registro, pos_inicial_regis;
	pos_inicial_regis = valor_reg = tam_registro = 0;
	
	tp_buffer *bufferpoll = (tp_buffer*)malloc(sizeof(tp_buffer)*PAGES);
	
	initbuffer(bufferpoll);
	
	arq = fopen("file/meta.dat", "r");
	if(arq == NULL){	
		printf("Read Error\n");
		return 0;
	}
	fread(&valor_reg, sizeof(int), 1, arq);
	tp_table *s = (tp_table*)malloc(sizeof(tp_table)*valor_reg); //Aloca um vetor com o numero de colunas da tupla
	tam_registro = load_metadata(arq, s, valor_reg);
	fclose(arq);
	
	arq2 = fopen("file/data.dat", "r");
	if(arq2 == NULL){
		printf("Read Error\n");
		return 0;
	}
	load_data(arq2, bufferpoll, tam_registro);
	fclose(arq2);
	
	//para imprimir
	
	//printbufferpoll(bufferpoll, s, 0, valor_reg); //Parametros são: buffer, estrutura dos meta dados, página a ser impressa e quantos campos tem a "tabela"
	
	cabecalho(s, valor_reg);
	pos_inicial_regis = 1 * tam_registro;
	drawline(bufferpoll, s, valor_reg, &pos_inicial_regis, 0); // (buffer, meta, numero de campos, posicao inicial, pagina)
	printf("\n");
	free(s);
	free(bufferpoll);
	return 0;
}
예제 #5
0
QImage MainWindow::fetch_image(QString absolute_file_name, QSize max_size, PhotoMetaData &pmd)
{
    pmd = load_metadata(absolute_file_name);//The preview image needs this returned
    QImageReader qir(absolute_file_name);
    QSize orig = qir.size();
    float ratio, rw, rh , width, height;
    if(pmd.rotation_angle==0 || pmd.rotation_angle==180) {
        width = orig.width();
        height = orig.height();
    } else {
        height = orig.width();
        width = orig.height();
    }
    rw = (float)max_size.width()/width;
    rh = (float)max_size.height()/height;
    if( rw > rh)
        ratio = rh;
    else
        ratio = rw;
    qir.setScaledSize(ratio*orig);
    return rotate(pmd.rotation_angle, qir.read());
}
예제 #6
0
파일: webfs.c 프로젝트: Hexasoft/WebFS
int main(int argc, char *argv[])
{
    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
    int res, nb, fd;
    FILE *f;


    /* initialise cache system */
    if (!wget_init()) {
      fprintf(stderr, "Failed to initialize CURL library. Abort.\n");
      exit(3);
    }
    if (!cache_init()) {
      fprintf(stderr, "Failed to initialize cache system. Abort.\n");
      exit(3);
    }

    res = fuse_opt_parse(&args, &mo, rofs_opts, rofs_parse_opt);
    if (res != 0)
    {
        fprintf(stderr, "Invalid arguments\n");
        fprintf(stderr, "see `%s -h' for usage\n", argv[0]);
        exit(1);
    }

    /* copy args in local */
    if (mo.path == NULL) {
        fprintf(stderr, "Missing URL. See -h for help.\n");
        exit(1);
    }

    /* if mo.metadata == NULL, keep default value */
    url_path = strdup(mo.path);
    if (mo.metadata != NULL)
      url_metadata = strdup(mo.metadata);
    if ((url_path == NULL)||(url_metadata == NULL)) {
        fprintf(stderr, "Internal error while copying options. Abort.\n");
        exit(1);
    }

    if ((mo.chunks > 0)&&(mo.chunks <= CACHE_MAX_CHUNK)) {
      cache_chunks = mo.chunks;
    } else {
      if ((mo.chunks < 0)&&(mo.chunks > CACHE_MAX_CHUNK)) {
        fprintf(stderr, "Invalid number of chunks '%d' (allowed: 1-%d)\n",
	    mo.chunks, CACHE_MAX_CHUNK);
	exit(1);
      }
    }

    if (mo.chunksize >= 512) {
      cache_chunksize = mo.chunksize;
    } else {
      if (mo.chunksize > 0) {
        fprintf(stderr, "Chunk size '%d' too small (min: 512).\n", mo.chunksize);
 	exit(1);
      }
    }

    /* check: if using a updater program for metadata file,
       this one must be set with --metafile */
    if ((url_metadata[0] == '@')&&(mo.metafile == NULL)) {
      fprintf(stderr, "Problem: you set a updater program name, but you\n"
      "did not set a name for the local metafil (--metafile option), so\n"
      "you program has no way to know which file to update.\n"
      "Abort.\n");
      exit(8);
    }

    /* temp file to get the metadata for filesystem */
    /* does user gives a metafile name? */
    tpl[0] = '\0';
    if (mo.metafile != NULL) {
      strcat(tpl, mo.metafile);
    } else {
      strcat(tpl, "/tmp/webfsdesc.XXXXXX");
      fd = mkstemp(tpl);
      if (fd < 0) {
	fprintf(stderr, "Failed to create temporaty file.\n");
	exit(5);
      }
      close(fd); /* we use a FILE, not a fd */
    }
    
    /* build URL of metadata */
    metaurl[0] = '\0';
    /* special case: if url_metadata starts by @ it is the
       name of the program to use to update the code */
    if (url_metadata[0] == '@') {
      strcat(metaurl, url_metadata);
    } else {
      strcat(metaurl, wget_encode(url_path, url_metadata));
    }
    if (!load_metadata()) {
      fprintf(stderr, "Failed to download metadata file.\n");
      exit(5);
    }

    /* load metadata to create FS tree */
    f = fopen(tpl, "r");
    if (f == NULL) {
        fprintf(stderr, "Failed to open description file. Abort.\n");
	exit(9);
    }
    nb = tree_create(f);
    if (nb <= 0) {
        /* this is an error */
	fprintf(stderr, "Error while loading filesystem description. Abort.\n");
	exit(1);
    }
    printf("%d entries added in FS tree.\n", nb);
    tree_print();
    fclose(f);
    update_ok = UP_OK;
    update_nbent = nb;

    printf("Info: chunksize: %d, #chunks: %d\n", cache_chunksize, cache_chunks);

    /* only for fuse 26. else remove the final NULL */
    fuse_main(args.argc, args.argv, &callback_oper, NULL);


    /* terminate everythings */
    tree_free();
    cache_fini();
    wget_fini();
    
    /* remove temp file */
    if (url_metadata[0] != '@') /* do not remove in this case */
      unlink((const char *)tpl);
    
    return(0);
}
예제 #7
0
파일: webfs.c 프로젝트: Hexasoft/WebFS
/* this function:
  - checks if we dl metadata file for too long
  - if yes, re-download metadata file
  - if ok, check for timestamp in it
  - if more recent than current tree, update it
*/
int update_meta_if_needed() {
  unsigned int cur, act;
  int nb;
  FILE *f;


mylog("::update_meta_if_meeded()\n");
  cur = (unsigned int)time(NULL);
  if (cur < last_dl + intv_dl) {
    set_message(NULL);
    return(0);  /* too recent */
  }

  /* re-get the file */
  if (!load_metadata()) {
    /* eeek! */
    return(0);  /* how to tell to user? */
    /* done with /.status */
  }
  /* update dl time */
  last_dl = cur;
  
  /* check for timestamp in it */
  f = fopen(tpl, "r");
  if (f == NULL) {
    update_ok = UP_INT;
    set_message("Failed to open local metadata file (check /tmp).");
    return(0);
  }
  if (fscanf(f, "%u", &act) < 1) {
    fclose(f);
    update_ok = UP_INT;
    set_message("Failed to find timestamp in metadata file (bad format?).");
    return(0);
  }
  fclose(f);
  
  /* if older or same, do nothing */
  if (act <= update) {
    set_message(NULL);
    return(0);
  }
  
  /* ok, so it is newer. we need to rebuild the FS tree.
     but before we need to destroy the cache data that
     should point to current node elements
  */

mylog("::update_meta_if_meeded: timestamp newer: updating tree\n");
  cache_destroy_all();
  
  /* re-load tree */
  f = fopen(tpl, "r");
  if (f == NULL) {
    update_ok = UP_INT;
    set_message("Failed to open local metadata file (check /tmp).");
    return(0);
  }
  /* destroy & recreate */
  tree_free();
  nb = tree_create(f);
  if (nb <= 0) {
    /* this is a very bad error */
    update_ok = UP_TREE;
    set_message("Failed to read metadata file (bad format?).");
    return(0);
  }
  update_ok = UP_OK;
  update_nbent = nb;
  fclose(f);
  set_message(NULL);

  return(1);
}