Switch frame list implementation to std::map.

This reduces the complexity of insert and find (by timestamp) from linear to logarithmic, which has a big impact on large frame lists.

BUG=1726
TEST=trybots, vie_auto_test --automated
R=mikhal@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/1561005

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4127 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
stefan@webrtc.org
2013-05-29 07:41:48 +00:00
parent f791b1cebf
commit ace7ad2302
2 changed files with 65 additions and 79 deletions

View File

@ -11,7 +11,7 @@
#ifndef WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_
#define WEBRTC_MODULES_VIDEO_CODING_MAIN_SOURCE_JITTER_BUFFER_H_
#include <list>
#include <map>
#include <set>
#include <vector>
@ -47,11 +47,22 @@ struct VCMJitterSample {
int64_t latest_packet_time;
};
class FrameList : public std::list<VCMFrameBuffer*> {
class TimestampLessThan {
public:
bool operator() (const uint32_t& timestamp1,
const uint32_t& timestamp2) const {
return IsNewerTimestamp(timestamp2, timestamp1);
}
};
class FrameList :
public std::map<uint32_t, VCMFrameBuffer*, TimestampLessThan> {
public:
void InsertFrame(VCMFrameBuffer* frame);
VCMFrameBuffer* FindFrame(uint32_t timestamp) const;
VCMFrameBuffer* PopFrame(uint32_t timestamp);
VCMFrameBuffer* Front() const;
VCMFrameBuffer* Back() const;
int RecycleFramesUntilKeyFrame(FrameList::iterator* key_frame_it);
int CleanUpOldOrEmptyFrames(VCMDecodingState* decoding_state);
};