After OpenVX data structures creation, initialization and graph construction, you can perform data processing in Process plugin method. No need for OpenVX data structures creation, graph construction and verification now. You lock Intel® Media Server Studio frame input and output surfaces and update OpenVX graph input and output image data pointers for each incoming frame. No any explicit data copies exist beyond that.

Notice that it is not direct data sharing between Intel® Media Server Studio and OpenVX. Rather, the Intel® Media Server Studio surface is always locked and resulting pointer used for the most effective data exchange on the current OpenVX and Intel® Media Server Studio API level. The following code snippets illustrate this process.

//Lock MSS input frame.  
mfxFrameSurface1 *frame_in;   //Input MSS surface.
mfxFrameAllocator* pAlloc = &m_mfxCore.FrameAllocator();    
pAlloc->Lock(pAlloc->pthis, frame_in->Data.MemId, &frame_in->Data); 
//Lock MSS output frame.  
mfxFrameSurface1 *frame_out;   //Output MSS surface.
mfxFrameAllocator* pAlloc = &m_mfxCore.FrameAllocator();    
pAlloc->Lock(pAlloc->pthis, frame_out->Data.MemId, &frame_out->Data);  

//Use locked MSS surface pointers. No copy.
//Two pointers for NV12: Y plane and UV plane.
void *in_ptrs[] = { frame_in->Data.Y, frame_in->Data.UV };
void *out_ptrs[] = { frame_out->Data.Y, frame_out->Data.UV };
//Update input image data pointers.
vxSwapImageHandle(inputNV12_image, (void** const)&in_ptrs[0], NULL, 2 );
vxSwapImageHandle(outputNV12_image, (void** const)&out_ptrs[0], NULL, 2 );

//Process OpenVX graph.

You can retrieve the result after OpenVX graph processing. The output image planes are mapped to guarantee that output Intel® Media Server Studio surface pointers contains valid data.

//Prepare to result data mapping. 
vx_map_id map_out_id[2];
vx_imagepatch_addressing_t out_imagepatchNV12[2];
vx_rectangle_t rectFullImage;
rectFullImage.start_x = rectFullImage.start_y = 0;
rectFullImage.end_x = w;
rectFullImage.end_y = h;

//Map output OpenVX image to the host. 
vxMapImagePatch(outputNV12_image, &rectFullImage, 0, &map_out_id[0], &out_imagepatchNV12[0], (void**)&out_ptrs[0], VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);
vxMapImagePatch(outputNV12_image, &rectFullImage, 1, &map_out_id[1], &out_imagepatchNV12[1], (void**)&out_ptrs[1], VX_READ_ONLY, VX_MEMORY_TYPE_HOST, 0);

//Unlock MSS input frame surfaces.
pAlloc->Unlock(pAlloc->pthis, frame_in->Data.MemId, &frame_in->Data);
pAlloc->Unlock(pAlloc->pthis, frame_out->Data.MemId, &frame_out->Data);

//UnMap output OpenVX image. 
vxUnmapImagePatch(outputNV12_image, map_out_id[0]);
vxUnmapImagePatch(outputNV12_image, map_out_id[1]);

The output Intel Media Server Studio data surface containы processed data with NV12 original Y channel replaced with Canny edges image, after this OpenVX plugin processing. You can always check the plugin processing result in the output encoded file produced by the Intel Media Server Studio encoder or transcoder sample, which invokes this Intel Media Server Studio – OpenVX interoperability plugin.

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.