Пример #1
0
arxstatus_t ImageBuffer::allocate()
{
    ARX_PRINT(ARX_ZONE_API, "%s\n", __FUNCTION__);

    if (mRemote) {
        ARX_PRINT(ARX_ZONE_ERROR, "%s: trying to allocate remote image!\n", __FUNCTION__);
        return INVALID_STATE;
    }

    if (mAnw != NULL) {
        uint8_t *ptrs[3] = {NULL, NULL, NULL};
        int32_t stride = 0;
        if (!anativewindow_acquire(mAnw, &(mImage.reserved), ptrs, &stride)) {
            ARX_PRINT(ARX_ZONE_ERROR, "failed allocating native window buffer!\n");
            return NO_MEMORY;
        }
        mImage.y_stride = stride;
        mImage.pBuffer[0] = mImage.pData[0] = ptrs[0];
        if (mImage.color == FOURCC_NV12) {
            mImage.pBuffer[1] = mImage.pData[1] = &ptrs[0][mImage.y_stride*mImage.bufHeight];
        }
        return NOERROR;
    }

    bool ret = DVP_Image_Alloc(mDvp, &mImage, static_cast<DVP_MemType_e>(mImage.memType));
    return ret ? NOERROR : FAILED;
}
Пример #2
0
void CreateMatrix(DVP_Handle handle, DVP_Image_t* mat, int type, int width, int height, char val)
{
	if (mat == 0)
		return;

        DVP_Image_Init(mat, width, height, type);
        if (DVP_Image_Alloc(handle, mat, DVP_MTYPE_DEFAULT) == DVP_FALSE) 
	{
		fprintf(stderr,"could not allocate buffer\n");
		exit(1);
	}
	for (int j = mat->y_start; j < mat->height; j++ )
	   for (int i = mat->x_start; i < mat->width; i++)
              mat->pData[0][j*mat->y_stride + i*mat->x_stride] = val;
}
Пример #3
0
int main(int argc, char *argv[])
{
	int width = 320;
	int height = 240;
	int numNodes = 3;
   DVP_Handle hDVP = 0;
   DVP_KernelNode_t *pNodes = NULL;

   struct timespec stop,start;

   hDVP = DVP_KernelGraph_Init();

   DVP_Image_t input;
   width  = 11;
   height = sizeof(packedfield) / width;
   DVP_Image_Init(&input, width, height, FOURCC_Y800);
   if (DVP_Image_Alloc(hDVP, &input, DVP_MTYPE_DEFAULT) == DVP_FALSE) 
   {
		fprintf(stderr,"could not allocate buffer\n");
		exit(1);
   }
   unsigned char* ptr = packedfield;
   for (int j = input.y_start; j < input.height; j++ )
      for (int i = input.x_start; i < input.width; i++)
        input.pData[0][j*input.y_stride + i*input.x_stride] = *ptr++;
   PrintMatrix("Input",&input);

   // Create the output buffer
   DVP_Image_t output;
   CreateMatrix(hDVP, &output, FOURCC_Y800, width, height, 0x66);

   // setupt the parameters
   pNodes = DVP_KernelGraph_Alloc(hDVP, numNodes);
   if (pNodes)
   {
            DVP_U32            orders[] = {0,0,0};
            DVP_KernelGraphSection_t sections[] = 
	    {
                {&pNodes[0], 1, DVP_PERF_INIT, DVP_CORE_LOAD_INIT, DVP_TRUE},
            };
            DVP_KernelGraph_t graph = 
	    {
                sections, 
                1,
                orders,
                DVP_PERF_INIT,
            };

	   pNodes[0].affinity = DVP_CORE_DSP;
	   pNodes[0].kernel = DVP_KN_HP_UNPACK;
	   pNodes[0].data.io.input = input;
	   pNodes[0].data.io.output = output;


         // Call the graph 
	 sections[0].skipSection = DVP_FALSE;
	 clock_gettime(CLOCK_REALTIME, &start);
         int ret = DVP_KernelGraphs(hDVP, &graph, (void*)0x01, tellMe);
	 clock_gettime(CLOCK_REALTIME, &stop);
	 double fstart, fstop;
	 fstart = (double)start.tv_sec + ((double)start.tv_nsec / 1000000000.0);
	 fstop  = (double)stop.tv_sec  + ((double)stop.tv_nsec / 1000000000.0);
	 printf("time %gms\n", (fstop-fstart)*1000.0);
	 sections[0].skipSection = DVP_TRUE;

         // Print the results
         PrintMatrix("Output",&output);
         DVP_PrintPerformanceGraph(hDVP, &graph);

         DVP_KernelGraph_Free(hDVP, pNodes, numNodes);
   }
   else fprintf(stderr,"could not allocate nodes\n");

   // free the image memory
   DVP_Image_Free(hDVP, &input);
   DVP_Image_Free(hDVP, &output);

    // tear down the graph resources
    DVP_KernelGraph_Deinit(hDVP);

   return 0;
}