Пример #1
0
static int extract_archive(struct vt_options* opt, vaht_archive* archive, char* out)
{
    uint16_t resource_types_count = vaht_archive_get_resource_types(archive);
    unsigned int t;
    for (t = 0; t < resource_types_count; t++)
    {
        const char* type = vaht_archive_get_resource_type(archive, t);
        
        /* check if we pass the type filter */
        if (opt->filter_type != NULL && strcmp(opt->filter_type, type) != 0)
        {
            /* we have failed the type filter! */
            continue;
        }

        /* if we're converting, but there's no extension for this type,
         * skip it
         */
        if (opt->convert && get_ext(opt, type) == NULL)
            continue;
        
        char* newdir = path_join(out, type);
        if (create_directory(opt, newdir))
        {
            free(newdir);
            return 1;
        }
        
        free(newdir);
        
        vaht_resource** resources = vaht_resources_open(archive, type);
        
        unsigned int r;
        for (r = 0; resources[r] != NULL; r++)
        {
            /* check if we pass the id filter */
            if (opt->filter_id != -1 && opt->filter_id != vaht_resource_id(resources[r]))
            {
                /* we failed the resource id filter! */
                continue;
            }
            
            char* ext = get_ext(opt, type);
            char* path = construct_path(resources[r], out, ext);
            
            if (write_resource(opt, resources[r], path))
            {
                vaht_resources_close(resources);
                free(path);
                return 1;
            }
            
            free(path);
        }
        
        vaht_resources_close(resources);
    }
    
    return 0;
}
Пример #2
0
int main(int argc, char *argv[])
{
    if ((argc < 5) || (argc > 7)) {
        printf("Usage: janus_enroll sdk_path data_path metadata_file gallery_file [[algorithm] verbose]\n");
        return 1;
    }

    const char *ext1 = get_ext(argv[3]);
    const char *ext2 = get_ext(argv[4]);

    if (strcmp(ext1, "csv") != 0) {
    	printf("metadata_file must be \".csv\" format.\n");
    	return 1;
    }

    if (strcmp(ext2, "gal") != 0) {
    	printf("gallery_file must be \".gal\" format. \n");
    	return 1;
    }

    JANUS_ASSERT(janus_initialize(argv[1], argc >= 6 ? argv[5] : ""))
    JANUS_ASSERT(janus_create_gallery(argv[2], argv[3], argv[4], argc >= 7 ? atoi(argv[6]) : 0))
    JANUS_ASSERT(janus_finalize())

    janus_print_metrics(janus_get_metrics());
    return EXIT_SUCCESS;
}
Пример #3
0
/*
 *   Get 'targetobj' from the frame 
 */
void CVmObjFrameRef::get_targobj(VMG_ vm_val_t *result)
{
    /* get 'targetobj' from the frame, if active, or our snapshot */
    result->set_obj_or_nil(
        get_ext()->fp != 0
        ? G_interpreter->get_orig_target_obj_from_frame(vmg_ get_ext()->fp)
        : get_ext()->targobj);
}
Пример #4
0
/*
 *   Get 'definingobj' from the frame 
 */
void CVmObjFrameRef::get_defobj(VMG_ vm_val_t *result)
{
    /* get it from the active frame, or our snapshot if the frame has exited */
    result->set_obj_or_nil(
        get_ext()->fp != 0
        ? G_interpreter->get_defining_obj_from_frame(vmg_ get_ext()->fp)
        : get_ext()->defobj);
}
Пример #5
0
/*
 *   Get 'invokee' from the frame 
 */
void CVmObjFrameRef::get_invokee(VMG_ vm_val_t *result)
{
    /* get 'invokee' from the frame, if active, or our snapshot */
    *result =
        get_ext()->fp != 0
        ? *G_interpreter->get_invokee_from_frame(vmg_ get_ext()->fp)
        : get_ext()->invokee;
}
static void
multi_upload_setup (perf_test_t *test)
{
   multi_upload_test_t *upload_test;
   multi_upload_thread_context_t *ctx;
   mongoc_uri_t *uri;
   char *data_dir;
   DIR *dirp;
   struct dirent *dp;
   int i;

   perf_test_setup (test);

   upload_test = (multi_upload_test_t *) test;

   uri = mongoc_uri_new (NULL);
   upload_test->pool = mongoc_client_pool_new (uri);

   data_dir = bson_strdup_printf ("%s/%s", g_test_dir, test->data_path);
   dirp = opendir(data_dir);
   if (!dirp) {
      perror ("opening data path");
      abort ();
   }

   i = 0;

   while ((dp = readdir(dirp)) != NULL) {
      if (!strcmp (get_ext (dp->d_name), "txt")) {
         ++i;
      }
   }

   upload_test->cnt = i;
   upload_test->contexts = (multi_upload_thread_context_t *) bson_malloc0 (
      i * sizeof (multi_upload_thread_context_t));

   rewinddir (dirp);
   i = 0;

   while ((dp = readdir (dirp)) != NULL) {
      if (!strcmp (get_ext (dp->d_name), "txt")) {
         ctx = &upload_test->contexts[i];
         ctx->filename = bson_strdup (dp->d_name);
         ctx->path = bson_strdup_printf (
            "%s/%s/%s", g_test_dir, test->data_path, dp->d_name);

         ++i;
      }
   }

   assert (i == upload_test->cnt);

   closedir (dirp);
   bson_free (data_dir);
   mongoc_uri_destroy (uri);
}
Пример #7
0
/*
 *   Invalidate the frame.  The VM calls this just before our frame exits.
 *   We make a snapshot of the local variables in the frame, then we set our
 *   frame pointer to null to indicate that we no longer have an active frame
 *   in the stack.  
 */
void CVmObjFrameRef::inval_frame(VMG0_)
{
    if (ext_ != 0 && get_ext()->fp != 0)
    {
        /* make a snapshot of the frame */
        make_snapshot(vmg0_);
        
        /* forget our frame pointer */
        get_ext()->fp = 0;
    }
}
Пример #8
0
/*
 *   Get 'self' from the frame 
 */
void CVmObjFrameRef::get_self(VMG_ vm_val_t *result)
{
    /* return the 'self' value from the frame, if active, or our snapshot */
    if (get_ext()->fp != 0)
        *result = *G_interpreter->get_self_val_from_frame(vmg_ get_ext()->fp);
    else
        *result = get_ext()->self;

    /* if the return value is an invalid object ID, return nil */
    if (result->typ == VM_OBJ && result->val.obj == VM_INVALID_OBJ)
        result->set_nil();
}
Пример #9
0
int main(int argc, char *argv[])
{
    int requiredArgs = 6;

    if ((argc < requiredArgs) || (argc > 9)) {
        printUsage();
        return 1;
    }

    const char *ext1 = get_ext(argv[4]);
    const char *ext2 = get_ext(argv[5]);
    if (strcmp(ext1, "csv") != 0) {
        printf("metadata_file must be \".csv\" format.\n");
        return 1;
    } else if (strcmp(ext2, "gal") != 0) {
        printf("gallery_file must be \".gal\" format. \n");
        return 1;
    }

    char *algorithm = NULL;
    int verbose = 0;

    for (int i=0; i<argc-requiredArgs; i++)
        if (strcmp(argv[requiredArgs+i],"-algorithm") == 0)
            algorithm = argv[requiredArgs+(++i)];
        else if (strcmp(argv[requiredArgs+i],"-verbose") == 0)
            verbose = 1;
        else {
            fprintf(stderr, "Unrecognized flag: %s\n", argv[requiredArgs+i]);
            return 1;
        }

    JANUS_ASSERT(janus_initialize(argv[1], argv[2], algorithm))

    janus_gallery gallery;
    JANUS_ASSERT(janus_allocate_gallery(&gallery))

    JANUS_ASSERT(janus_create_gallery(argv[3], argv[4], gallery, verbose))

    janus_metrics metrics = janus_get_metrics();
    size_t size = metrics.janus_initialize_template_speed.count;
    janus_flat_gallery flat_gallery = new janus_data[size*janus_max_template_size()];
    size_t bytes;
    JANUS_ASSERT(janus_flatten_gallery(gallery, flat_gallery, &bytes))
    std::ofstream file;
    file.open(argv[5], std::ios::out | std::ios::binary);
    file.write((char*)flat_gallery, bytes);
    file.close();
    JANUS_ASSERT(janus_finalize())

    janus_print_metrics(metrics);
    return EXIT_SUCCESS;
}
Пример #10
0
/*
 *   Get 'targetprop' from the frame 
 */
void CVmObjFrameRef::get_targprop(VMG_ vm_val_t *result)
{
    /* get 'targetobj' from the frame, if active, or our snapshot */
    vm_prop_id_t prop =
        get_ext()->fp != 0
        ? G_interpreter->get_target_prop_from_frame(vmg_ get_ext()->fp)
        : get_ext()->targprop;

    /* set the return value to the property, or nil if there isn't one */
    if (prop != VM_INVALID_PROP)
        result->set_propid(prop);
    else
        result->set_nil();
}
Пример #11
0
/*
 *   Get the value of a local given the variable descriptor 
 */
void CVmObjFrameRef::get_local_val(VMG_ vm_val_t *result,
                                   const CVmDbgFrameSymPtr *sym)
{
    /* 
     *   if we have an active stack frame, get the value from the frame;
     *   otherwise get the value from our local snapshot 
     */
    vm_frameref_ext *ext = get_ext();
    if (ext->fp != 0)
    {
        /* we have a frame - get the value from the frame */
        G_interpreter->get_local_from_frame(vmg_ result, ext->fp, sym);
    }
    else
    {
        /* 
         *   There's no frame, so we must retrieve the value from the
         *   snapshot.  First, get the value of the local or parameter.  Our
         *   snapshot array consists of all of the locals followed by all of
         *   the parameters, so local N is at vars[N] and parameter N is at
         *   vars[nlocals + N].  
         */
        vm_val_t *v = &ext->vars[sym->get_var_num()
                                 + (sym->is_param() ? ext->nlocals : 0)];

        /* 
         *   If it's a context local, index the local by the context index.
         *   Otherwise the value is simply the value in the snapshot array.  
         */
        if (sym->is_ctx_local())
            v->ll_index(vmg_ result, sym->get_ctx_arr_idx());
        else
            *result = *v;
    }
}
Пример #12
0
/**
 * \brief CGI request search engine.
 *
 * \param name CGI request name.
 * \param table CGI handler table.
 *
 * \return A valid function handler for the specified CGI request, NULL
 * otherwise.
 */
http_handler_t cgi_search(const char *name, HttpCGI *table)
{
	if (!table) {
		return NULL;
	}

	int i = 0;
	const char *ext = get_ext(name);

	while (table[i].name) {
		if (ext && table[i].type == CGI_MATCH_EXT) {
			if (!strcmp(table[i].name, ext)) {
				break;
			}
		} else if (table[i].type == CGI_MATCH_NAME) {
			if (strstr(name, table[i].name) != NULL) {
				break;
			}
		} else { /* (table[i].type == CGI_MATCH_WORD) */
			if (!strcmp(table[i].name, name)) {
				break;
			}
		}

		i++;
	}

	return table[i].handler;
}
Пример #13
0
ST struct plugins *parse_plugin(const char *rcline)
{
    struct plugins *q = (struct plugins*)c_alloc(sizeof(*q) + strlen(rcline));

    if ('#' == *rcline || 0 == *rcline)
        q->is_comment = true;
    else
    if ('!' == *rcline)
        while (' '== *++rcline);
    else
        q->enabled = true;

    if ('&' == *rcline)
    {
        q->useslit = true;
        while (' '== *++rcline);
    }

    char *s = strcpy(q->fullpath, rcline);
    if (false == q->is_comment)
    {
        s = strcpy(q->name, get_file(s)); // copy name
        *(char*)get_ext(s) = 0; // strip ".dll"

        // accept BBSlit and BBSlitX
        q->is_slit = 0 == memicmp(s, "BBSlit", 6) && (s[6] == 0 || s[7] == 0);

        // lookup for duplicates
        int n = 0; int l = strlen(s); struct plugins *q2;
        dolist (q2, bbplugins)
        {
            char *p = q2->name;
            if (0 == memicmp(p, s, l) && (0 == *(p+=l) || '/' == *p))
                if (0 == n++) strcpy(p, "/1");
        }
Пример #14
0
int cmus_is_supported(const char *filename)
{
	const char *ext = get_ext(filename);

	return ext && (str_in_array(ext, (const char * const *)playable_exts) ||
			str_in_array(ext, playlist_exts));
}
Пример #15
0
/* 
 *   notify of deletion 
 */
void CVmObjHTTPServer::notify_delete(VMG_ int /*in_root_set*/)
{
    /* free our additional data, if we have any */
    vm_httpsrv_ext *ext = get_ext();
    if (ext != 0)
    {
        /* shut down the listener */
        if (ext->l != 0)
        {
            /* tell it to terminate */
            ext->l->shutdown();

            /* 
             *   Notify the listener thread that we're being deleted, so that
             *   it can drop its reference on us.  The listener thread object
             *   keeps a reference on us, but it isn't itself a
             *   garbage-collected object, so its reference on us won't
             *   prevent us from being deleted.  We therefore need to
             *   manually remove its reference on us when we're about to be
             *   deleted.  
             */
            ((TadsHttpListenerThread *)ext->l->get_thread())
                ->detach_server_obj();
            
            /* we're done with the listener object */
            ext->l->release_ref();
        }

        /* delete our address string */
        lib_free_str(ext->addr);

        /* delete the extension */
        G_mem->get_var_heap()->free_mem(ext_);
    }
}
Пример #16
0
/*
 *   mark references
 */
void CVmObjFrameRef::mark_refs(VMG_ uint state)
{
    /* get the extension */
    vm_frameref_ext *ext = get_ext();

    /* mark the function */
    if (ext->entry.typ == VM_OBJ)
        G_obj_table->mark_all_refs(ext->entry.val.obj, state);

    /* mark the method context objects */
    if (ext->self.typ == VM_OBJ)
        G_obj_table->mark_all_refs(ext->self.val.obj, state);
    if (ext->defobj != VM_INVALID_OBJ)
        G_obj_table->mark_all_refs(ext->defobj, state);
    if (ext->targobj != VM_INVALID_OBJ)
        G_obj_table->mark_all_refs(ext->targobj, state);

    /* mark the invokee */
    if (ext->invokee.typ == VM_OBJ)
        G_obj_table->mark_all_refs(ext->invokee.val.obj, state);

    /* mark each snapshot variable */
    int i;
    const vm_val_t *v;
    for (i = ext->nlocals + ext->nparams, v = ext->vars ; i > 0 ; --i, ++v)
    {
        if (v->typ == VM_OBJ)
            G_obj_table->mark_all_refs(v->val.obj, state);
    }
}
Пример #17
0
/*
 *   Create a method context object 
 */
void CVmObjFrameRef::create_loadctx_obj(VMG_ vm_val_t *result)
{
    vm_frameref_ext *ext = get_ext();
    vm_val_t *fp = ext->fp;
    vm_obj_id_t self, defobj, targobj;
    vm_prop_id_t targprop;

    /* retrieve the method context elements */
    if (fp != 0)
    {
        /* get the context elements from the live stack frame */
        self = G_interpreter->get_self_from_frame(vmg_ fp);
        defobj = G_interpreter->get_defining_obj_from_frame(vmg_ fp);
        targobj = G_interpreter->get_orig_target_obj_from_frame(vmg_ fp);
        targprop = G_interpreter->get_target_prop_from_frame(vmg_ fp);
    }
    else
    {
        /* the stack frame has exited, so use our snapshot */
        self = (ext->self.typ == VM_OBJ ? ext->self.val.obj : VM_INVALID_OBJ);
        defobj = ext->defobj;
        targobj = ext->targobj;
        targprop = ext->targprop;
    }

    /* create the context object */
    CVmRun::create_loadctx_obj(vmg_ result, self, defobj, targobj, targprop);
}
Пример #18
0
/**
 * \brief CGI request search engine.
 *
 * \param name CGI request name.
 * \param table CGI handler table.
 * \return A valid function handler for the specified CGI request, NULL otherwise.
 */
http_handler_t cgi_search(const char *name, HttpCGI *table)
{
	/* Allocate the CGI semaphore. */
	/* This is necessary to avoid race conditions on tx_buf.*/
	if (!sys_sem_valid(&cgi_sem)) {
		sys_sem_new(&cgi_sem, 1);
	}

	if (!table) {
		return NULL;
	}

	int i = 0;
	const char *ext = get_ext(name);

	while (table[i].name) {
		if (ext && table[i].type == CGI_MATCH_EXT) {
			if (!strcmp(table[i].name, ext)) {
				break;
			}
		} else if (table[i].type == CGI_MATCH_NAME) {
			if (strstr(name, table[i].name) != NULL) {
				break;
			}
		} else { /* (table[i].type == CGI_MATCH_WORD) */
			if (!strcmp(table[i].name, name)) {
				break;
			}
		}

		i++;
	}

	return table[i].handler;
}
Пример #19
0
/*
 *   mark references for garbage collection
 */
void CVmObjClass::mark_refs(VMG_ uint state)
{
    /* if we have an object in our class state value, mark it */
    vm_intcls_ext *ext = get_ext();
    if (ext->class_state.typ == VM_OBJ)
        G_obj_table->mark_all_refs(ext->class_state.val.obj, state);
}
Пример #20
0
static int tris(httrackp * opt, char *buffer) {
  char catbuff[CATBUFF_SIZE];

  //
  // Java
  if ((buffer[0] == '[') && buffer[1] == 'L' && (!strstr(buffer, "java/")))
    return 2;
  if (strstr(buffer, ".gif") || strstr(buffer, ".jpg")
      || strstr(buffer, ".jpeg") || strstr(buffer, ".au"))
    return 1;
  // Ajouts R.X: test type
  // Autres fichiers
  {
    char type[256];

    type[0] = '\0';
    get_httptype(opt, type, buffer, 0);
    if (strnotempty(type))      // type reconnu!
      return 1;
    // ajout RX 05/2001
    else if (is_dyntype(get_ext(catbuff, sizeof(catbuff), buffer)))      // asp,cgi...
      return 1;
  }
  return 0;
}
Пример #21
0
/*
 *   mark references
 */
void CVmObjFrameDesc::mark_refs(VMG_ uint state)
{
    /* get the extension */
    vm_framedesc_ext *ext = get_ext();

    /* mark our frame ref object */
    G_obj_table->mark_all_refs(ext->fref, state);
}
Пример #22
0
/*
 *   After loading, resolve the entry pointer.  We need to wait until loading
 *   is complete to do this, since the entry pointer might refer to another
 *   object, in which case the other object needs to be loaded before we can
 *   resolve a pointer to it.  
 */
void CVmObjFrameRef::post_load_init(VMG_ vm_obj_id_t self)
{
    /* get our extension */
    vm_frameref_ext *ext = get_ext();

    /* resolve the entry pointer */
    CVmFuncPtr f(vmg_ &ext->entry);
    ext->entryp = f.get();
}
Пример #23
0
/*
 *   restore 
 */
void CVmObjFrameRef::restore_from_file(VMG_ vm_obj_id_t self,
                                       class CVmFile *fp,
                                       class CVmObjFixup *fixups)
{
    char buf[VMB_DATAHOLDER];
    
    /* read the variables counts */
    int nlocals = fp->read_int2();
    int nparams = fp->read_int2();

    /* allocate the extension */
    vm_frameref_ext *ext = alloc_ext(vmg_ nlocals, nparams);

    /* 
     *   Since stack frames are inherently transient, a saved frame ref
     *   object can't point back to a live stack frame, so on restore we have
     *   to assume that our stack frame is inactive. 
     */
    get_ext()->fp = 0;

    /* load the entry pointer */
    fp->read_bytes(buf, VMB_DATAHOLDER);
    fixups->fix_dh(vmg_ buf);
    vmb_get_dh(buf, &ext->entry);

    /* after other objects are loaded, resolve the entry pointer */
    G_obj_table->request_post_load_init(self);

    /* restore the method context values */
    fp->read_bytes(buf, VMB_DATAHOLDER);
    fixups->fix_dh(vmg_ buf);
    vmb_get_dh(buf, &ext->self);

    ext->defobj = (vm_obj_id_t)fp->read_uint4();
    if (ext->defobj != VM_INVALID_OBJ)
        ext->defobj = fixups->get_new_id(vmg_ ext->defobj);
    
    ext->targobj = (vm_obj_id_t)fp->read_uint4();
    if (ext->targobj != VM_INVALID_OBJ)
        ext->targobj = fixups->get_new_id(vmg_ ext->targobj);
    
    ext->targprop = (vm_prop_id_t)fp->read_uint2();

    fp->read_bytes(buf, VMB_DATAHOLDER);
    fixups->fix_dh(vmg_ buf);
    vmb_get_dh(buf, &ext->invokee);

    /* load the snapshot values */
    int i;
    vm_val_t *v;
    for (i = nlocals + nparams, v = ext->vars ; i > 0 ; --i, ++v)
    {
        fp->read_bytes(buf, VMB_DATAHOLDER);
        fixups->fix_dh(vmg_ buf);
        vmb_get_dh(buf, v);
    }
}
Пример #24
0
/*
 *   Find a symbol.  If we find the name, we fill in 'symp' with the
 *   description of the variable and return true; otherwise we return false.
 */
int CVmObjFrameDesc::find_local(VMG_ const textchar_t *name, size_t namelen,
                                CVmDbgFrameSymPtr *symp)
{

    /* get our extension and the underlying frame's extension */
    vm_framedesc_ext *ext = get_ext();
    vm_frameref_ext *fext = get_frame_ref(vmg0_)->get_ext();

    /* if the caller doesn't care about the symbol information, use a local */
    CVmDbgFrameSymPtr oursym;
    if (symp == 0)
        symp = &oursym;

    /* if there's no frame, there are no locals */
    if (ext->frame_idx == 0)
        return FALSE;

    /* set up pointer to this method's debug records */
    CVmDbgTablePtr dp;
    if (!dp.set(fext->entryp))
        return FALSE;

    /* set up a pointer to our frame */
    CVmDbgFramePtr dfp;
    dp.set_frame_ptr(vmg_ &dfp, ext->frame_idx);

    /* walk up the list of frames from innermost to outermost */
    for (;;)
    {
        /* set up a pointer to the first symbol */
        dfp.set_first_sym_ptr(vmg_ symp);

        /* scan this frame's local symbol list */
        int sym_cnt = dfp.get_sym_count();
        for (int i = 0 ; i < sym_cnt ; ++i, symp->inc(vmg0_))
        {
            /* check for a match */
            if (symp->get_sym_len(vmg0_) == namelen
                && memcmp(symp->get_sym(vmg0_), name, namelen) == 0)
            {
                /* this is it - return with symp pointing to the symbol */
                return TRUE;
            }
        }

        /* didn't find it - move up to the enclosing frame */
        int parent = dfp.get_enclosing_frame();
        if (parent == 0)
            break;

        /* set up dfp to point to the parent fraem */
        dp.set_frame_ptr(vmg_ &dfp, parent);
    }

    /* we didn't find the symbol */
    return FALSE;
}
Пример #25
0
/* 
 *   assign an indexed value: this sets a variable's value by index
 */
int CVmObjFrameRef::set_index_val_q(VMG_ vm_val_t *new_container,
                                    vm_obj_id_t self,
                                    const vm_val_t *index_val,
                                    const vm_val_t *new_val)
{
    /* get our extension */
    vm_frameref_ext *ext = get_ext();

    /* check the type */
    if (index_val->typ == VM_INT)
    {
        /* 
         *   It's a direct index into the frame.  Make sure the value is in
         *   range.  
         */
        int n = index_val->val.intval;
        if (n < 0 || n >= ext->nlocals + ext->nparams)
            err_throw(VMERR_INDEX_OUT_OF_RANGE);

        /*  
         *   If we have an active stack frame, read the value from the stack;
         *   otherwise read it from the snapshot array.  
         */
        if (ext->fp != 0)
        {
            /* get it from the stack frame */
            if (n < ext->nlocals)
            {
                /* it's in the local variable range */
                *G_interpreter->get_local_from_frame(vmg_ ext->fp, n) =
                    *new_val;
            }
            else
            {
                /* it's in the parameter range */
                *G_interpreter->get_param_from_frame(
                    vmg_ ext->fp, n - ext->nlocals) = *new_val;
            }
        }
        else
        {
            /* there's no frame - get it from the snapshot array */
            ext->vars[n] = *new_val;
        }
    }
    else
    {
        /* invalid index type */
        err_throw(VMERR_INDEX_OUT_OF_RANGE);
    }

    /* the container doesn't change */
    new_container->set_obj(self);

    /* handled */
    return TRUE;
}
Пример #26
0
bool
AUDIO_DECODERS::open(
		AVCodecContext *codec_ctx,
		const char *filepath,
		AVIOContext* io_ctx )
{
#if _USE_SCE_DECODERS
	if (codec_ctx==NULL)
	{
		if (sceWma_open(filepath, io_ctx))
			audio_dec = &sceAsfWma;
	}
	else
	{
		switch (codec_ctx->codec_id)
		{
			case CODEC_ID_MP2:
			case CODEC_ID_MP3: // NOTE: this may also be the codec ID for mpeg 1 and 2
				if (sceMp3Aac_open(codec_ctx, PSP_CODEC_MP3))
					audio_dec = &sceMp3Aac;
				break;
			case CODEC_ID_AAC:
				if (sceMp3Aac_open(codec_ctx, PSP_CODEC_AAC|((strcasecmp(get_ext(filepath), "aac")==0)?AAC_IS_ADTS:0)))
					audio_dec = &sceMp3Aac;
				break;
			case CODEC_ID_ATRAC3:
				if (sceAtrac3_open(codec_ctx))
					audio_dec = &sceAtrac3;
				break;
			case CODEC_ID_ATRAC3P:
				if (sceAtrac3p_open(codec_ctx))
					audio_dec = &sceAtrac3p;
				break;
			default:
				break;
		}
	}
#endif //_USE_SCE_DECODERS
	
	if ( !audio_dec )
	{
		if ( codec_ctx!=NULL && ffmpegAdec_open(codec_ctx) )
			audio_dec = &ffmpegAudio;
	// no need to allocate buffers without an open decoder
		else return false;
	}
	
	// sceAsfParser needs 64byte alignment
	tmpbuf = (short*)memalign(64, C_AUDIOBUF_MAX_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
	if (tmpbuf) return true;
	
	printf("failed allocating tmp buffer\n");
	this->close(codec_ctx);
	
	return false;
}
Пример #27
0
const Cooker * CookerRegistry::find_cooker_from_cooked(const ChefString & cookedPath)
{
    // find our cooker
    ChefString ext = get_ext(cookedPath.c_str());
    auto it = sCookedExtToCooker.find(ext);
    if (it == sCookedExtToCooker.end())
        return nullptr;
    const Cooker * pCooker = it->second;
    return pCooker;
}
Пример #28
0
/*
 *   save
 */
void CVmObjFrameDesc::save_to_file(VMG_ class CVmFile *fp)
{
    /* get our extension */
    vm_framedesc_ext *ext = get_ext();

    /* save our extension data */
    fp->write_uint4(ext->fref);
    fp->write_uint2(ext->frame_idx);
    fp->write_uint2(ext->ret_ofs);
}
Пример #29
0
/* 
 *   save to a file 
 */
void CVmObjClass::save_to_file(VMG_ class CVmFile *fp)
{
    /* write our data: data size, meta table index, mod ID, class state */
    vm_intcls_ext *ext = get_ext();
    fp->write_uint2(2 + 2 + 4 + VMB_DATAHOLDER);
    fp->write_uint2(ext->meta_idx);
    fp->write_uint4(ext->mod_obj);

    char buf[VMB_DATAHOLDER];
    vmb_put_dh(buf, &ext->class_state);
    fp->write_bytes(buf, VMB_DATAHOLDER);
}
Пример #30
0
action_result grinder_intro_action() {
    grinder_branch_extension & ext = get_ext();
    state & s                      = curr_state();
    expr const & target            = s.get_target();
    expr const & f                 = get_app_fn(target);
    if (!is_constant(f))
        return action_result::failed();
    list<gexpr> const * lemmas = ext.m_intro_lemmas.find(head_index(f));
    if (!lemmas)
        return action_result::failed();
    return backward_cut_action(*lemmas);
}