IOSurfaces - Artefacts in video and unable to grab video surfaces

后端 未结 1 1817
逝去的感伤
逝去的感伤 2020-12-13 16:39

This is a 2-part Question. I have the following code working which grabs the current display surface and creates a video out of the surfaces (everything happens in the backg

相关标签:
1条回答
  • 2020-12-13 17:18

    I did a bit of experimentation and concluded that the screen surface from which the content is copied is changing even before the transfer of contents is complete (call to IOSurfaceAcceleratorTransferSurface() ). I am using a lock (tried both asynchronous and read-only) but it is being overridden by the iOS. I changed the code between the lock/unlock part to the following minimal:

    IOSurfaceLock(screenSurface, kIOSurfaceLockReadOnly, &aseed);
    aseed1 = IOSurfaceGetSeed(screenSurface);
    IOSurfaceAcceleratorTransferSurface(outAcc, screenSurface, destSurf, dict, NULL);
    aseed2 = IOSurfaceGetSeed(screenSurface);
    IOSurfaceUnlock(screenSurface, kIOSurfaceLockReadOnly, &aseed);
    

    The GetSeed function tells if the contents of the surface have changed. And, I logged a count indicating the number of frames for which the seed changes. The count was non-zero. So, the following code resolved the problem:

    if(aseed1 != aseed2){
    //Release the created surface
    continue; //Do not use this surface/frame since it has artefacts
    }
    

    This however does affect performance since many frames/surfaces are rejected due to artefacts. Any additions/corrections to this will be helpful.

    0 讨论(0)
提交回复
热议问题