Skip to content

Commit f5a1b3f

Browse files
author
Valentin Noel
committed
AvInputStream: use std::queue instead of std::vector for stream cache
1 parent 1a51ae4 commit f5a1b3f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/AvTranscoder/codedStream/AvInputStream.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool AvInputStream::readNextPacket( CodedData& data )
7676
if( ! _streamCache.empty() )
7777
{
7878
_streamCache.front().getBuffer().swap( data.getBuffer() );
79-
_streamCache.erase( _streamCache.begin() );
79+
_streamCache.pop();
8080
}
8181
// else read next packet
8282
else
@@ -94,7 +94,7 @@ void AvInputStream::addPacket( AVPacket& packet )
9494
return;
9595

9696
CodedData data;
97-
_streamCache.push_back( data );
97+
_streamCache.push( data );
9898
_streamCache.back().getBuffer().resize( packet.size );
9999
if( packet.size != 0 )
100100
memcpy( _streamCache.back().getPtr(), packet.data, packet.size );
@@ -148,7 +148,7 @@ double AvInputStream::getDuration() const
148148

149149
void AvInputStream::clearBuffering()
150150
{
151-
_streamCache.clear();
151+
_streamCache = std::queue<CodedData>();
152152
}
153153

154154
AVStream* AvInputStream::getAVStream() const

src/AvTranscoder/codedStream/AvInputStream.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "IInputStream.hpp"
55

6+
#include <queue>
7+
68
struct AVStream;
79

810
namespace avtranscoder
@@ -45,7 +47,7 @@ class AvExport AvInputStream : public IInputStream
4547
InputFile* _inputFile; ///< Has link (no ownership)
4648
ICodec* _codec; ///< Has ownership
4749

48-
std::vector<CodedData> _streamCache;
50+
std::queue<CodedData> _streamCache;
4951

5052
size_t _streamIndex; ///< Index of the stream in the input file
5153
bool _bufferized; ///< If the stream is bufferized

0 commit comments

Comments
 (0)