Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Unified Diff: media/base/video_frame_pool.h

Issue 101623006: Created VideoFramePool to avoid unnecessary VideoFrame alloc/free. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change SimpleFormatChange test so it can pass on Android. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/video_frame.cc ('k') | media/base/video_frame_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/video_frame_pool.h
diff --git a/media/base/video_frame_pool.h b/media/base/video_frame_pool.h
new file mode 100644
index 0000000000000000000000000000000000000000..76b309196a4745aab96dd8ecdf11182a773531e9
--- /dev/null
+++ b/media/base/video_frame_pool.h
@@ -0,0 +1,50 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_BASE_VIDEO_FRAME_POOL_H_
+#define MEDIA_BASE_VIDEO_FRAME_POOL_H_
+
+#include "media/base/media_export.h"
+#include "media/base/video_frame.h"
+
+namespace media {
+
+// Simple VideoFrame pool used to avoid unnecessarily allocating and destroying
+// VideoFrame objects. The pool manages the memory for the VideoFrame
+// returned by CreateFrame(). When one of these VideoFrames is destroyed,
+// the memory is returned to the pool for use by a subsequent CreateFrame()
+// call. The memory in the pool is retained for the life of the
+// VideoFramePool object. If the parameters passed to CreateFrame() change
+// during the life of this object, then the memory used by frames with the old
+// parameter values will be purged from the pool.
+class MEDIA_EXPORT VideoFramePool {
+ public:
+ VideoFramePool();
+ ~VideoFramePool();
+
+ // Returns a frame from the pool that matches the specified
+ // parameters or creates a new frame if no suitable frame exists in
+ // the pool.
+ scoped_refptr<VideoFrame> CreateFrame(VideoFrame::Format format,
+ const gfx::Size& coded_size,
+ const gfx::Rect& visible_rect,
+ const gfx::Size& natural_size,
+ base::TimeDelta timestamp);
+
+protected:
+ friend class VideoFramePoolTest;
+
+ // Returns the number of frames in the pool for testing purposes.
+ size_t GetPoolSizeForTesting() const;
+
+ private:
+ class PoolImpl;
+ scoped_refptr<PoolImpl> pool_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoFramePool);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_VIDEO_FRAME_POOL_H_
« no previous file with comments | « media/base/video_frame.cc ('k') | media/base/video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698