コード例 #1
0
ファイル: Fifo.c プロジェクト: aCayF/dmai_1_21_00_10
/******************************************************************************
 * Fifo_create
 ******************************************************************************/
Fifo_Handle Fifo_create(Fifo_Attrs *attrs)
{
    Fifo_Handle hFifo;
    BUF_Attrs bAttrs = BUF_ATTRS;

    if (attrs == NULL) {
        return NULL;
    }
    
    hFifo = MEM_calloc(Dmai_Bios_segid, sizeof(Fifo_Object), 0);

    if (hFifo == NULL) {
        Dmai_err0("Failed to allocate space for Fifo Object\n");
        return NULL;
    }
    
    /* Allocate a buffer pool for messages */
    bAttrs.segid = Dmai_Bios_segid;
    hFifo->hBufPool = BUF_create(attrs->maxElems, sizeof(Fifo_Elem), 0, &bAttrs);
    if (hFifo->hBufPool == NULL) {
        Dmai_err0("Failed to allocate space for buffer pool\n");
        MEM_free(Dmai_Bios_segid, hFifo, sizeof(Fifo_Object));
        return NULL;
    }
    
    /* initialize the object */
    QUE_new(&hFifo->queue);
    SEM_new(&hFifo->sem, 0);
    SEM_new(&hFifo->mutex, 1);

    return hFifo;
}
コード例 #2
0
PathSegment *raster_make_segment(Raster *raster, short eid, short v1, short h1, short h2, short v2) {
	PathSegment *s = MEM_calloc(sizeof(*s));

	s->head.eid = eid;
	s->head.type = PATH_SEGMENT;

	s->v1 = (void*)hashtable_get(&raster->verts, v1);
	s->h1 = (void*)hashtable_get(&raster->verts, h1);
	s->h2 = (void*)hashtable_get(&raster->verts, h2);
	s->v2 = (void*)hashtable_get(&raster->verts, v2);
	
	if (!s->v1) {
		fprintf(stderr, "failed to find vert with id %d\n", v1);
		return NULL;
	}
	if (!s->h1) {
		fprintf(stderr, "failed to find vert with id %d\n", h1);
		return NULL;
	}
	if (!s->h2) {
		fprintf(stderr, "failed to find vert with id %d\n", h2);
		return NULL;
	}
	if (!s->v2) {
		fprintf(stderr, "failed to find vert with id %d\n", v2);
		return NULL;
	}

	hashtable_set(&raster->segments, eid, (intptr_t)s);
	hashtable_set(&raster->master, eid, (intptr_t)s);

	return s;
}
コード例 #3
0
ファイル: object.c プロジェクト: joeedh/FunLittleProject
val_t SVM_MakeObject(SimpleVM *vm, int type) {
  SVMObject *ob = MEM_calloc(sizeof(*ob));
  LinkNode *node = MEM_malloc(sizeof(*node));
  
  ob->type = TYPE_OBJECT;
  node->value = ob;
  List_Append(&vm->objects, node);
  
  return SVM_Obj2Val(ob);
}
コード例 #4
0
_DSKT2_PERMUTE_EnumerationHandle _DSKT2_Permute_createHandle()
{
#ifdef _RTSMODE_
    _DSKT2_PERMUTE_EnumerationHandle h = (_DSKT2_PERMUTE_Enumeration *)
            malloc(sizeof(_DSKT2_PERMUTE_Enumeration));
#else
    _DSKT2_PERMUTE_EnumerationHandle h = (_DSKT2_PERMUTE_Enumeration *)
            MEM_calloc(_DSKT2_HEAP, sizeof(_DSKT2_PERMUTE_Enumeration),0);
#endif
    return h;
}
コード例 #5
0
ファイル: dio.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== tskMkPort ========
 *  Creates a DIO object and binds the controller.
 */
static DIO_Handle tskMkPort(DEV_Handle device, String name)
{
    DIO_Params *params = (DIO_Params *)device->params;
    DIO_Handle dio;
    DEV_Device  *entry;
    Uns         mode;
    Int         status;

    /* params should contain name of mini-driver */
    if (params == NULL) {
        return (NULL);
    }
    
    /*
     * check to see that name of mini-driver matches one in the device table
     * and its type is of DEV_IOMTYPE.
     */
    (void)DEV_match(params->name, &entry);
    if (entry == NULL || entry->type != DEV_IOMTYPE) {
        return (NULL);
    }

    /* allocate 0-initialized dio object */
    if ((dio = MEM_calloc(0, sizeof(DIO_Obj), 0)) == MEM_ILLEGAL) {
        return (NULL);
    }

    /*
     * Tasks will pend on dio->complete if there are no available frames on
     * the fromdevice queue.
     */
    dio->context.sems.complete = SEM_create(0, NULL);

    /* make sure SEM_create() succeeded ... */
    if (dio->context.sems.complete == NULL) {
        MEM_free(0, dio, sizeof(DIO_Obj));     /* free dio object */
        return (NULL);
    }

    dio->fxns = (IOM_Fxns *)entry->fxns;

    mode = (device->mode == DEV_INPUT) ? IOM_INPUT : IOM_OUTPUT;

    /* create a channel from the mini-driver */
    status = dio->fxns->mdCreateChan(&dio->chanp, entry->devp, name, mode,
                params->chanParams, DIO_tskCallback, device); 

    if (status != IOM_COMPLETED) {
        tskRmPort(dio);
        return (NULL);
    }

    return (dio);
}
コード例 #6
0
ファイル: dio.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== cbMkPort ========
 *  Creates a DIO object and binds the controller.
 */
static DIO_Handle cbMkPort(DEV_Handle device, String name)
{
    DIO_Params *params = (DIO_Params *)device->params;
    DEV_Callback  *callback = (DEV_Callback *)device->callback;
    DIO_Handle dio;
    DEV_Device  *entry;
    Uns         mode;
    Int         status;

    /* callback must not be NULL if using this version of DIO */
    if (callback == NULL) {
        return (NULL);
    }
    
    /* params must contain name of mini-driver */
    if (params == NULL) {
        return (NULL);
    }
    
    /*
     * check to see that name of mini-driver matches one in the device table
     * and its type is of DEV_IOMTYPE.
     */
    (void)DEV_match(params->name, &entry);
    if (entry == NULL || entry->type != DEV_IOMTYPE) {
        return (NULL);
    }

    /* allocate 0-initialized dio object */
    if ((dio = MEM_calloc(0, sizeof(DIO_Obj), 0)) == MEM_ILLEGAL) {
        return (NULL);
    }

    /* initialize the DIO callback values */
    dio->context.cb = *callback;

    dio->fxns = (IOM_Fxns *)entry->fxns;

    mode = (device->mode == DEV_INPUT) ? IOM_INPUT : IOM_OUTPUT;

    /* create a channel from the mini-driver */
    status = dio->fxns->mdCreateChan(&dio->chanp, entry->devp, name, mode,
                params->chanParams, DIO_cbCallback, device); 

    if (status != IOM_COMPLETED) {
        cbRmPort(dio);
        return (NULL);
    }

    return (dio);
}
コード例 #7
0
Path *raster_make_path(Raster *raster, short eid, short style) {
	Path *p = MEM_calloc(sizeof(*p));

	p->head.eid = eid;
	p->head.type = PATH_PATH;
	p->style = style;

	hashtable_set(&raster->paths, eid, (intptr_t)p);
	hashtable_set(&raster->master, eid, (intptr_t)p);

	list_append(&raster->renderlist, p);

	return p;
}
コード例 #8
0
PathVertex *raster_make_vertex(Raster *raster, short eid, short x, short y) {
	PathVertex *v = MEM_calloc(sizeof(*v));
	
	v->head.eid = eid;
	v->head.type = PATH_VERTEX;

	v->x = x;
	v->y = y;

	hashtable_set(&raster->verts, eid, (intptr_t)v);
	hashtable_set(&raster->master, eid, (intptr_t)v);

	return v;
}
コード例 #9
0
Raster *raster_new(int width, int height) {
	Raster *raster = MEM_calloc(sizeof(*raster));

	hashtable_init(&raster->verts);
	hashtable_init(&raster->segments);
	hashtable_init(&raster->paths);
	hashtable_init(&raster->styles);
	hashtable_init(&raster->textures);
	hashtable_init(&raster->master);

	raster->size[0] = width;
	raster->size[1] = height;
	raster->buffer = MEM_malloc(width*height*4);
	memset(raster->buffer, 255, width*height*4); //initialize to white

	return raster;
}
コード例 #10
0
ファイル: Cpu.c プロジェクト: Soorma07/dvsdk-dmai
/******************************************************************************
 * Cpu_create
 ******************************************************************************/
Cpu_Handle Cpu_create(Cpu_Attrs *attrs)
{
    Cpu_Handle hCpu;
    
    hCpu = MEM_calloc(Dmai_Bios_segid, sizeof(Cpu_Object), 0);

    if (hCpu == NULL) {
        Dmai_err0("Failed to allocate space for Cpu Object\n");
        return NULL;
    }

    /* Determine type of device */
    if (getDevice(&hCpu->device) < 0) {
        Dmai_err0("Failed to get device type\n");
        MEM_free(Dmai_Bios_segid, hCpu, sizeof(Cpu_Object));
        return NULL;
    }

    return hCpu;
}
コード例 #11
0
ファイル: requestlib.c プロジェクト: joeedh/cserver
HandlerInfo *HL_New(ReqInfo *req)
{
  HandlerInfo *hl = (HandlerInfo*) MEM_calloc(sizeof(HandlerInfo), "HandlerInfo");
  char *buf;

  hl->docroot = s_dup(docroot);
  hl->servroot = s_dup(servroot);
  hl->req = req;

  RQ_SplitQuery(req->path, NULL, &buf, NULL);
  hl->query = RQ_ParseQuery(buf);
  s_free(buf);

  if (!strcncmp(req->method, "POST", 5, 5) && req->body != NULL) {
    char *encoding = RQ_GetHeader(req, "Content-Type");

    if (encoding && s_find(encoding, "urlencoded") >= 0) {
      //turn binary body data into 0-terminated C string
      array_append(req->body, 0);
      hl->query2 = RQ_ParseQuery(req->body);
    }
  }
  return hl;
}
コード例 #12
0
ファイル: dev.c プロジェクト: andreimironenko/bios
/*
 * DEV_createDevice creates device(DEV_Device) entry in the OBJ table
 * if device by that name do not exist in the system.
 * This API is not reentrant
 */
Int DEV_createDevice (String name, Void *fxns,   Fxn initFxn,
        DEV_Attrs *attrs)
{
    DEV_TableElem *objDevHead = (DEV_TableElem*) &DEV_table;
    DEV_TableElem *objDev, *objEntry;
    DEV_Device *dptr, *entry;
    IOM_Fxns *iomfxns;
    Int status;
    Uns key;

    /*
     * Crate a device entry, if not successful return
     * SYS_EALLOC. 
     */

    objEntry = MEM_calloc(0, sizeof(DEV_TableElem), 0);

    if (objEntry == NULL) {
        return(SYS_EALLOC);
    }

    TSK_disable();


    /*
     * Check if device already exists in the Device table, if yes return
     * SYS_EINVAL
     */
    DEV_find(name, &entry);

    if (entry != NULL) {
        TSK_enable();
        MEM_free(0, objEntry, sizeof(DEV_TableElem));
        SYS_error("DEV", SYS_EINVAL);
        return(SYS_EINVAL);
    }

    /*
     * Initialize new device entry(DEV_Device) in the OBJ table with
     * the parameters passed to API
     */
    entry = &objEntry->device;
    entry->name = name;
    entry->fxns = fxns;

    if (attrs == NULL) {
        attrs = &DEV_ATTRS;
    }
    entry->devid  = attrs->devid;
    entry->params = attrs->params;
    entry->type   = attrs->type;
    entry->devp   = attrs->devp;

    /*
     * Call the Device init function if its not NULL, with interrupts
     * disabled.
     */
    if (initFxn != NULL) {
        key = HWI_disable();
        (*initFxn)();
        HWI_restore(key);
    }

    /*
     * If device created is of type IOM then call mini driver function
     * mdBindDev with interrupts disabled.
     */
    if (entry->type == DEV_IOMTYPE) {
        iomfxns = (IOM_Fxns *) entry->fxns;

        key = HWI_disable();
        status = iomfxns->mdBindDev(&entry->devp, entry->devid,
                                     entry->params);
        HWI_restore(key);

        if (status != IOM_COMPLETED) {
            
            TSK_enable();

            /* Delete the just created device entry in device table */
            MEM_free(0, objEntry, sizeof(DEV_TableElem));

            SYS_error("DEV", SYS_EBADIO);

            return(status);
        }

    }

    /*
     * Device is ready for addition into OBJ_Table. Check new device
     * name length against existing device name lengths. If length of
     * new device is greater than one in OBJ_table, mark the location
     * and insert device ahead of device whose name length is shorter
     * else add it to the end.
     *
     * This will keep all the devices sorted in descending order, which is
     * required to pass additional parameters along with device name in 
     * DEV_open()
     */

    objDev = (DEV_TableElem *)QUE_next((Ptr)objDevHead);
    while (objDev != objDevHead) {
        dptr = &objDev->device;
        if (strlen(name) > strlen(dptr->name)) {
            break;
        }
        objDev = (DEV_TableElem *)QUE_next((Ptr)objDev);
    }

    /* Insert objEntry ahead of objDev */
    QUE_insert(objDev, objEntry);

    TSK_enable();

    return(SYS_OK);
}
コード例 #13
0
ファイル: task.c プロジェクト: Imara90/ESLab
Int Task_create (Task_TransferInfo ** infoPtr)
{
    Int status    = SYS_OK ;
    Task_TransferInfo * info = NULL ;

    /* Allocate Task_TransferInfo structure that will be initialized
     * and passed to other phases of the application */
    if (status == SYS_OK) 
	{
        *infoPtr = MEM_calloc (DSPLINK_SEGID,
                               sizeof (Task_TransferInfo),
                               0) ; /* No alignment restriction */
        if (*infoPtr == NULL) 
		{
            status = SYS_EALLOC ;
        }
        else 
		{
            info = *infoPtr ;
        }
    }

    /* Fill up the transfer info structure */
    if (status == SYS_OK) 
	{
        info->dataBuf       = NULL ; /* Set through notification callback. */
        info->bufferSize    = MPCSXFER_BufferSize ;
        SEM_new (&(info->notifySemObj), 0) ;
    }

    /*
     *  Register notification for the event callback to get control and data
     *  buffer pointers from the GPP-side.
     */
    if (status == SYS_OK) 
	{
        status = NOTIFY_register (ID_GPP,
                                  MPCSXFER_IPS_ID,
                                  MPCSXFER_IPS_EVENTNO,
                                  (FnNotifyCbck) Task_notify,
                                  info) ;
        if (status != SYS_OK) 
		{
            return status;
        }
    }

    /*
     *  Send notification to the GPP-side that the application has completed its
     *  setup and is ready for further execution.
     */
    if (status == SYS_OK) 
	{
        status = NOTIFY_notify (ID_GPP,
                                MPCSXFER_IPS_ID,
                                MPCSXFER_IPS_EVENTNO,
                                (Uint32) 0) ; /* No payload to be sent. */
        if (status != SYS_OK) 
		{
            return status;
        }
    }

    /*
     *  Wait for the event callback from the GPP-side to post the semaphore
     *  indicating receipt of the data buffer pointer and image width and height.
     */
    SEM_pend (&(info->notifySemObj), SYS_FOREVER) ;
    SEM_pend (&(info->notifySemObj), SYS_FOREVER) ;

    return status ;
}
コード例 #14
0
ファイル: gio.c プロジェクト: CheredHerry/ti-bios
/*
 *  ======== GIO_create ========
 */
GIO_Handle GIO_create(String name, Int mode, Int *status, Ptr optArgs, \
        GIO_Attrs *attrs)
{
    GIO_Handle  gioChan;
    IOM_Packet  *packet;
    DEV_Device  *entry;
    Int         i;
    Int         tmpStat;

    if (attrs == NULL) {
        attrs = &GIO_ATTRS;
    }

    /*
     * status param is used to pass additional device status back to caller.
     */
    if (status == NULL) {
        status = &tmpStat;    /* no longer need to check if status valid ptr */
    }

    *status = IOM_COMPLETED;
    
    /*
     *  Find device structure in device table for device with name 'name'.
     *  DEV_match() returns the remaining name string for use by the
     *  mini-driver's create() function.
     */
    name = DEV_match(name, &entry);
    if (entry == NULL) {
        SYS_error(name, SYS_ENODEV); /* sys error - no device found */

        return (NULL);
    }
    
    if (entry->type != DEV_IOMTYPE) {
        SYS_error("IOM", SYS_EINVAL); /* sys error - invalid device parameter */

        return (NULL);
    }

    /*  allocate and 0-fill IOM object */
    gioChan = MEM_calloc(0, sizeof(GIO_Obj), 0);
    if (gioChan == NULL) {
        *status = IOM_EALLOC;  
       
        return (NULL);
    }

    /* initialize queue structures */
    QUE_new(&gioChan->freeList);

    /*
     * Allocate packets for asynch I/O.
     */
    for (i=0; i < attrs->nPackets; i++) {

        packet = _GIO_mkPacket();

        if (packet == NULL) {
           
            *status = IOM_EALLOC;

            GIO_delete(gioChan);
            return (NULL);
        }

        QUE_put(&gioChan->freeList, packet);
    }

    /*
     * Create semaphore or other synchronization object.  'gioChan->syncObj' is
     * used to wait for I/O to complete when GIO_submit() is called with
     * NULL *appCallback parameter. 
     */
    gioChan->syncObj = GIO->SEMCREATE(0, NULL);

    if (gioChan->syncObj == NULL) {

        *status = IOM_EALLOC;
 
        GIO_delete(gioChan);
        return (NULL);
    }

    gioChan->fxns = (IOM_Fxns *)entry->fxns;
    gioChan->mode = mode;
    gioChan->timeout = attrs->timeout;

    *status = gioChan->fxns->mdCreateChan(&gioChan->mdChan, entry->devp,
            name, mode, optArgs, _GIO_iomCallback, gioChan);

    if (gioChan->mdChan == NULL) {
        
        GIO_delete(gioChan);
        return (NULL);
    }

    return (gioChan);
}
コード例 #15
0
/** ============================================================================
 *  @func   SWIRGB2YCBCR_DSP_create
 *
 *  @desc   Create phase of SWISWIRGB2YCBCR_DSP application. It allocates
 *          SWISWIRGB2YCBCR_DSP_TransferInfo structure and intializes it with configured
 *          values.
 *
 *  @modif  None.
 *  ============================================================================
 */
Int SWIRGB2YCBCR_DSP_create (SWIRGB2YCBCR_DSP_TransferInfo ** infoPtr)
{
    Int                     status      = SYS_OK ;
    SWI_Attrs               swiAttrs    = SWI_ATTRS ;
    SWIRGB2YCBCR_DSP_TransferInfo *  info;
#if  defined (DSP_BOOTMODE_NOBOOT)
    POOL_Obj                poolObj ;

    {
        while (DSPLINK_initFlag != 0xC0C0BABA) ;
    }
    /* Initialize DSP/BIOS LINK. */
    DSPLINK_init () ;
    smaPoolObj.poolId        = 0;
    smaPoolObj.exactMatchReq = TRUE ;
    poolObj.initFxn          = SMAPOOL_init ;
    poolObj.fxns             = (POOL_Fxns *) &SMAPOOL_FXNS ;
    poolObj.params           = &(smaPoolObj) ;
    poolObj.object           = NULL ;

    status = POOL_open (0, &poolObj) ;

    /* Create IOM driver dynamically */
    status = DEV_createDevice("/dsplink", &ZCPYDATA_FXNS, (Fxn) &ZCPYDATA_init, &devAttrs) ;

    /* Create DIO adapter dynamically */
    status = DEV_createDevice("/dio_dsplink", &DIO_tskDynamicFxns, NULL, &dioDevAttrs);
#endif

    /* Allocate SWIRGB2YCBCR_DSP_TransferInfo structure */
    *infoPtr = MEM_calloc (DSPLINK_SEGID,
                           sizeof (SWIRGB2YCBCR_DSP_TransferInfo),
                           DSPLINK_BUF_ALIGN) ;
    if (*infoPtr == NULL) {
        status = SYS_EALLOC ;
        SET_FAILURE_REASON (status) ;
    }
    else {
        info = *infoPtr ;
    }

    /* Initialize SWIRGB2YCBCR_DSP_TransferInfo structure */
    if (status == SYS_OK) {
        info->bufferSize = xferBufSize ;
        (info->appReadCb).fxn  = readFinishCb ;
        (info->appReadCb).arg  = (Ptr) info ;
        (info->appWriteCb).fxn = writeFinishCb ;
        (info->appWriteCb).arg = (Ptr) info ;
    }

    /* Create channel handles */
    if (status == SYS_OK) {
        GIO_Attrs gioAttrs  = GIO_ATTRS ;
        info->gioInputChan  = GIO_create (INPUT_CHANNEL,
                                          IOM_INPUT,
                                          NULL,
                                          NULL,
                                          &gioAttrs) ;
        info->gioOutputChan = GIO_create (OUTPUT_CHANNEL,
                                          IOM_OUTPUT,
                                          NULL,
                                          NULL,
                                          &gioAttrs) ;
        if (   (info->gioInputChan  == NULL)
            || (info->gioOutputChan == NULL)) {
            status = SYS_EALLOC ;
            SET_FAILURE_REASON (status) ;
        }
    }

    /* Create SWI for sending and receiving data */
    if (status == SYS_OK) {
        swiAttrs.fxn     = rgb2ycbcr_dspSWI ;
        swiAttrs.arg0    = (Arg) info ;
        swiAttrs.mailbox = INITIAL_MAILBOX_VAL ;
        info->swi = SWI_create (&swiAttrs) ;
        if (info->swi == NULL) {
            status = SYS_EALLOC ;
            SET_FAILURE_REASON (status) ;
        }
    }

    /* Allocate input and output buffers */
    if (status == SYS_OK) {
        status = POOL_alloc (SAMPLE_POOL_ID,
                             (Ptr *) &(info->inputBuffer),
                             info->bufferSize) ;
        if (status == SYS_OK) {
            status = POOL_alloc (SAMPLE_POOL_ID,
                                 (Ptr *) &(info->outputBuffer),
                                 info->bufferSize) ;
            if (status != SYS_OK) {
                SET_FAILURE_REASON (status) ;
            }
        }
        else {
            SET_FAILURE_REASON (status) ;
        }
    }

    return status ;
}
コード例 #16
0
/*
 *  ======== SCALESOCKET_TI_create ========
 */
RMS_STATUS SCALESOCKET_TI_create(Int argLength, Char * argData,
    IALG_Fxns *algFxns, Int numInStreams, RMS_WORD inDef[], Int numOutStreams,
    RMS_WORD outDef[], NODE_EnvPtr node)
{
    struct SSKT_Obj *dataPtr;
    Int nodePriority;
    Int segId;

    /* Using bitwise OR to prevent compiler warning */
    argLength |= argLength;
    *argData |= *argData;
    numInStreams |= numInStreams;
    numOutStreams |= numOutStreams;

    /* Get the node's external heap segment Id, if it exists */
    segId = NODE_getHeapSeg(node);

    if (segId < 0) {
        /*
         *  Use heap 0 to allocate the node object if no external heap
         *  was defined for the node.
         */
        segId = 0;
    }


    if ((dataPtr = MEM_calloc(segId, sizeof(SSKT_Obj), 0)) != MEM_ILLEGAL) {

        /* attach socket's context structure to the node environment */
        node->moreEnv = dataPtr;

        /* Save the external heap segment for delete phase. */
        dataPtr->segId = segId;


        /* parse stream definition params, create input stream */
        dataPtr->inStream = _createStream((RMS_StrmDef *)inDef[0],
            STRM_INPUT, &dataPtr->inSize, segId);


        /* parse stream definition params, create output stream */
        dataPtr->outStream = _createStream((RMS_StrmDef *)outDef[0],
            STRM_OUTPUT, &dataPtr->outSize, segId);

        /* check for stream creation failure */
        if((dataPtr->inStream == NULL) || (dataPtr->outStream == NULL)) {
            return (RMS_ESTREAM);
        }


        /* allocate data buffers */
        dataPtr->inBuf = STRM_allocateBuffer(dataPtr->inStream,
            dataPtr->inSize);
        dataPtr->outBuf = STRM_allocateBuffer(dataPtr->outStream,
            dataPtr->outSize);

        /* check for buffer allocation failure */
        if((dataPtr->inBuf == NULL) || (dataPtr->outBuf == NULL)) {
            return (RMS_EOUTOFMEMORY);
        }


        /* create an algorithm instance object */
        nodePriority = NODE_getPri(node);

        if (segId > 0) {
            dataPtr->algHandle = DSKT2_createAlg2(nodePriority,
                    (IALG_Fxns *)algFxns, (IALG_Handle)NULL,
                    (IALG_Params *)NULL, segId);
        }
        else {
            dataPtr->algHandle = DSKT2_createAlg(nodePriority,
                    (IALG_Fxns *)algFxns, (IALG_Handle)NULL,
                    (IALG_Params *)NULL);
        }

        /* check for algorithm instance creation failure */
        if (dataPtr->algHandle == NULL) {
            return (RMS_EOUTOFMEMORY);
        }

        /* activation done during exec phase */
        // dataPtr->algHandle->fxns->algActivate(dataPtr->algHandle);

        return (RMS_EOK);
    }
    else {
        return (RMS_EOUTOFMEMORY);
    }
}
コード例 #17
0
// Called by plugin
void my_plugin_init(void)
{
	// Init variables
	//ppz2gst.pitch = 0;
	//ppz2gst.roll = 0;
	gray_frame = (unsigned char *)MEM_calloc(segid,imgWidth*imgHeight*sizeof(unsigned char),0);
	prev_frame = (unsigned char *)MEM_calloc(segid,imgWidth*imgHeight*2*sizeof(unsigned char),0);
	old_img_init = 1;

	old_pitch = 0;
	old_roll = 0;
	old_alt = 0;
	opt_trans_x = 0;
	opt_trans_y = 0;

	opt_angle_x_raw = 0;
	opt_angle_y_raw = 0;

	//gst2ppz.counter = 0;

	mark_points = 0;

	x = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	new_x = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	y = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	new_y = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	status = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	dx = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	dy = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	dx_scaled = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	dy_scaled = (short *) MEM_calloc(segid,MAX_COUNT*sizeof(short),0);
	n_inlier_minu = (int *) MEM_calloc(segid,sizeof(int),0);
	n_inlier_minv = (int *) MEM_calloc(segid,sizeof(int),0);
	
	flow_points = (flowPoint*)MEM_calloc(segid,MAX_COUNT*sizeof(flowPoint),0);
	detected_points = (detectedPoint*)MEM_calloc(segid,MAX_COUNT*sizeof(detectedPoint),0);
}
コード例 #18
0
ファイル: cnxdiag.c プロジェクト: OpenUAS/userspace-dspbridge
/*
 *  ======== cnxdiagCreate ========
 */
RMS_STATUS cnxdiagCreate(Int argLength, Char * argData, Int numInStreams,
    RMS_WORD inDef[], Int numOutStreams, RMS_WORD outDef[],
    NODE_EnvPtr  node)
{
    RMS_StrmDef     * streamAttrs;
    STRM_Attrs      attrs = STRM_ATTRS;
    CnxdiagObj      * pCopyObj;
    RMS_STATUS      cResult = RMS_EOK;

    /* Allocate context structure for this instance of the siocopy object. */
    if ((pCopyObj = MEM_calloc(0, sizeof(CnxdiagObj), 0)) != NULL) {
        streamAttrs = (RMS_StrmDef *)outDef[0];

        attrs.nbufs = streamAttrs->nbufs;
        attrs.segid = streamAttrs->segid;
        attrs.align = streamAttrs->align;
        attrs.timeout = streamAttrs->timeout;
        /* Initialize remainder of context structure. */
        pCopyObj->uSegid = streamAttrs->segid;
        pCopyObj->nBufsize = streamAttrs->bufsize;

        SYS_printf("cnxdiagCreate: output stream = %s\n", streamAttrs->name);
        SYS_printf("  bufsize 0x%x, nbufs %d, segid %d, timeout %d\n",
            streamAttrs->bufsize, streamAttrs->nbufs, streamAttrs->segid,
            streamAttrs->timeout);

        pCopyObj->outStream = STRM_create(streamAttrs->name, STRM_OUTPUT,
            streamAttrs->bufsize, &attrs);

        if(pCopyObj->outStream == NULL) {
            SYS_printf("cnxdiagCreate: Failed to Create the Stream\n");
            return(RMS_ESTREAM);
        }
        pCopyObj->pBuf = STRM_allocateBuffer(pCopyObj->outStream, \
            streamAttrs->bufsize);

        /* Verify allocations; if failure, free all allocated objects. */
        if (pCopyObj->pBuf != MEM_ILLEGAL){
       /*
        * Return pointer to siocopy context structure for use in execute
        * and delete phases.
        */
            node->moreEnv = (Ptr)pCopyObj;
        }
        else {
            /* Free all allocated objects. */
            SYS_printf("cnxdiagCreate: Failed to Allocate Stream Buffer\n");
            if (pCopyObj->outStream != NULL) {
                STRM_delete(pCopyObj->outStream);
            }
            cResult = RMS_EOUTOFMEMORY;
        }
    }
    else {
        /* If unable to allocate object, return RMS_E_OUTOFMEMORY. */
        cResult = RMS_EOUTOFMEMORY;
        SYS_printf("cnxdiagCreate: Failed to Allocate Context structure\n");
    }

    return (cResult);
}
コード例 #19
0
void init_default_styles() {
	/*
	unsigned char code[] = {
		MOV_RC, OUTR, FCONST(1.0f),
		MOV_RC, OUTG, FCONST(0.5f),
		MOV_RC, OUTB, FCONST(0.0f),
		MOV_RC, OUTA, FCONST(0.8f),

		//let's make a little triangle wave corner gradient
		MUL_RR, OUTR, INU,
		MUL_RR, OUTR, INV,
		MUL_RC, OUTR, FCONST(5.0f),
		FRC_RR, OUTR, OUTR,
		END
	};
	//*/

	unsigned char fallback_code[] = {
		MOV_RR, 0x5, 0x7f,
		MOV_RR, 0xf, 0x7d,
		MUL_RR, 0x5, 0xf,
		MOV_RR, 0x75, 0x5,
		MOV_RR, 0x5, 0x7d,
		MOV_RR, 0xf, 0x7d,
		MOV_RR, 0x10, 0x7c,
		MOV_RR, 0x11, 0x7c,
		MUL_RR, 0x10, 0x11,
		ADD_RR, 0xf, 0x10,
		MUL_RR, 0x5, 0xf,
		MOV_RC, 0xf, 0x99, 0x49,
		MUL_RR, 0x5, 0xf,
		FRC_RR, 0x5, 0x5,
		MOV_RR, 0x73, 0x5,
		MOV_RR, 0x5, 0x7e,
		MOV_RR, 0xf, 0x7c,
		MUL_RR, 0x5, 0xf,
		MOV_RR, 0x74, 0x5,
	};

#if 0
	char *script = 
		"float tent(float f) {\n"
		"	return 1.0 - abs(fract(f)-0.5)*2.0;\n"
		"}\n"

		"\n"

		"r = u;\n"
		"g = v;\n"
		"b = tent((u*u + v*v)*11.2);\n";
#elif 1
	char *script = 
		"r = 0.0;\n"
		"g = 0.1;\n"
		//"b = 1.0 - abs(fract(v * 10.159149 + 1.570796) - 0.500000)*2.0;\n"
		"b = sin((u*u + v*v)*11.2);\n"
		//"b = 0.0;\n"
	;
#endif

	int codelen=0;
	unsigned char *code = compilestyle(script, strlen(script), &codelen);

	if (!code) {
		code = fallback_code;
		codelen = sizeof(fallback_code);
	}

	Style *style = MEM_calloc(sizeof(*style));

	style->codelen = codelen;
	style->code = MEM_malloc(codelen);
	style->ccode = NULL;

	memcpy(style->code, code, codelen);
	_redstyle = style;
}