VideoFrame VideoFrame::newVideoFrame(ofFbo & videoFrame){ VideoFormat format(videoFrame); poolMutex.lock(); if(!pool[format].empty()){ VideoFrame frame; //cout << "returning frame from pool" << endl; frame.data = pool[format].back(); pool[format].pop_back(); poolMutex.unlock(); frame.refreshTimestamp(); frame.getFboRef(); frame.data->updateTexture(videoFrame); frame.data->pixelsChanged = false; frame.data->createdTexPixels = false; return frame; }else{ poolMutex.unlock(); return VideoFrame(videoFrame); } }
VideoFrame VideoFrame::newVideoFrame(const ofPixels & videoFrame){ VideoFormat format(videoFrame); poolMutex.lock(); if(!pool[format].empty()){ VideoFrame frame; //cout << "returning frame from pool" << endl; // A pool is a map in which the videoformat is the 'key' // and the value is vector of data. frame.data = pool[format].back(); pool[format].pop_back(); poolMutex.unlock(); frame.refreshTimestamp(); frame.data->pixels = videoFrame; frame.data->pixelsChanged = true; frame.data->createdTexPixels = true; return frame; }else{ poolMutex.unlock(); return VideoFrame(videoFrame); } }