Skip to content

AvInputStream: use std::queue instead of std::vector for stream cache #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/AvTranscoder/codedStream/AvInputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bool AvInputStream::readNextPacket( CodedData& data )
if( ! _streamCache.empty() )
{
_streamCache.front().getBuffer().swap( data.getBuffer() );
_streamCache.erase( _streamCache.begin() );
_streamCache.pop();
}
// else read next packet
else
Expand All @@ -94,7 +94,7 @@ void AvInputStream::addPacket( AVPacket& packet )
return;

CodedData data;
_streamCache.push_back( data );
_streamCache.push( data );
_streamCache.back().getBuffer().resize( packet.size );
if( packet.size != 0 )
memcpy( _streamCache.back().getPtr(), packet.data, packet.size );
Expand Down Expand Up @@ -148,7 +148,7 @@ double AvInputStream::getDuration() const

void AvInputStream::clearBuffering()
{
_streamCache.clear();
_streamCache = std::queue<CodedData>();
}

AVStream* AvInputStream::getAVStream() const
Expand Down
4 changes: 3 additions & 1 deletion src/AvTranscoder/codedStream/AvInputStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "IInputStream.hpp"

#include <queue>

struct AVStream;

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

std::vector<CodedData> _streamCache;
std::queue<CodedData> _streamCache;

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