Now when we don't use SwapFrame consistently anymore, we need to recycle allocations with a buffer pool instead. This CL adds a buffer pool class, and updates the vp8 decoder to use it. If this CL lands successfully I will update the other video producers as well. BUG=1128 R=stefan@webrtc.org, tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41189004 Cr-Commit-Position: refs/heads/master@{#8748} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8748 4adac7df-926f-26a2-2b94-8c16560cd09d
41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_COMMON_VIDEO_INTERFACE_I420_BUFFER_POOL_H_
|
|
#define WEBRTC_COMMON_VIDEO_INTERFACE_I420_BUFFER_POOL_H_
|
|
|
|
#include <list>
|
|
|
|
#include "webrtc/base/thread_checker.h"
|
|
#include "webrtc/common_video/interface/video_frame_buffer.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Simple buffer pool to avoid unnecessary allocations of I420Buffer objects.
|
|
// The pool manages the memory of the I420Buffer returned from CreateBuffer.
|
|
// When the I420Buffer is destructed, the memory is returned to the pool for use
|
|
// by subsequent calls to CreateBuffer. If the resolution passed to CreateBuffer
|
|
// changes, old buffers will be purged from the pool.
|
|
class I420BufferPool {
|
|
public:
|
|
I420BufferPool();
|
|
// Returns a buffer from the pool, or creates a new buffer if no suitable
|
|
// buffer exists in the pool.
|
|
rtc::scoped_refptr<VideoFrameBuffer> CreateBuffer(int width, int height);
|
|
|
|
private:
|
|
rtc::ThreadChecker thread_checker_;
|
|
std::list<rtc::scoped_refptr<I420Buffer>> buffers_;
|
|
};
|
|
|
|
} // namespace webrtc
|
|
|
|
#endif // WEBRTC_COMMON_VIDEO_INTERFACE_I420_BUFFER_POOL_H_
|