Don't overwrite VideoSurface data while it is still needed for OutputSurface

We use hardware overlays instead of copying the VideoSurface to the
OutputSurface, so the VideoSurface must not be overwritten while it
is still used for an OutputSurface. This is now ensured by reference
counting and allocating new memory if the old is still in use, which
might not be the best way to solve this, but the performance impact
is negligible for now.