Skip to content

Commit 5d74dc7

Browse files
committed
Merge pull request #187 from mikrosimage/dev_fileProperties_streams_map
FileProperties: StreamProperties stored by streamIndex into a map
2 parents 67eb60a + 2e7d791 commit 5d74dc7

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/AvTranscoder/mediaProperty/FileProperties.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,22 +82,22 @@ void FileProperties::extractStreamProperties( IProgress& progress, const EAnalys
8282

8383
// once the streams vectors are filled, add their references the base streams vector
8484
for( size_t streamIndex = 0; streamIndex < _videoStreams.size(); ++streamIndex )
85-
_streams.push_back( &_videoStreams.at( streamIndex ) );
85+
_streams[ _videoStreams.at( streamIndex ).getStreamIndex() ] = &_videoStreams.at( streamIndex );
8686

8787
for( size_t streamIndex = 0; streamIndex < _audioStreams.size(); ++ streamIndex )
88-
_streams.push_back( &_audioStreams.at(streamIndex) );
88+
_streams[ _audioStreams.at(streamIndex).getStreamIndex() ] = &_audioStreams.at(streamIndex);
8989

9090
for( size_t streamIndex = 0; streamIndex < _dataStreams.size(); ++ streamIndex )
91-
_streams.push_back( &_dataStreams.at(streamIndex) );
91+
_streams[ _dataStreams.at(streamIndex).getStreamIndex() ] = &_dataStreams.at(streamIndex);
9292

9393
for( size_t streamIndex = 0; streamIndex < _subtitleStreams.size(); ++ streamIndex )
94-
_streams.push_back( &_subtitleStreams.at(streamIndex) );
94+
_streams[ _subtitleStreams.at(streamIndex).getStreamIndex() ] = &_subtitleStreams.at(streamIndex);
9595

9696
for( size_t streamIndex = 0; streamIndex < _attachementStreams.size(); ++ streamIndex )
97-
_streams.push_back( &_attachementStreams.at(streamIndex) );
97+
_streams[ _attachementStreams.at(streamIndex).getStreamIndex() ] = &_attachementStreams.at(streamIndex);
9898

9999
for( size_t streamIndex = 0; streamIndex < _unknownStreams.size(); ++ streamIndex )
100-
_streams.push_back( &_unknownStreams.at(streamIndex) );
100+
_streams[ _unknownStreams.at(streamIndex).getStreamIndex() ] = &_unknownStreams.at(streamIndex);
101101

102102
// if the analysis level has decoded some streams parts, return at the beginning
103103
if( level > eAnalyseLevelHeader )
@@ -162,11 +162,9 @@ size_t FileProperties::getPacketSize() const
162162

163163
const avtranscoder::StreamProperties& FileProperties::getStreamPropertiesWithIndex( const size_t streamIndex ) const
164164
{
165-
for( std::vector< StreamProperties* >::const_iterator it = _streams.begin(); it != _streams.end(); ++it )
166-
{
167-
if( (*it)->getStreamIndex() == streamIndex )
168-
return *(*it);
169-
}
165+
avtranscoder::StreamProperties* properties = _streams.find( streamIndex )->second;
166+
if( properties )
167+
return *properties;
170168
std::stringstream os;
171169
os << "No stream properties correspond to stream at index ";
172170
os << streamIndex;

src/AvTranscoder/mediaProperty/FileProperties.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <string>
1818
#include <vector>
19+
#include <map>
1920

2021
namespace avtranscoder
2122
{
@@ -61,6 +62,7 @@ class AvExport FileProperties
6162

6263
//@{
6364
// @brief Get the properties at the indicated stream index
65+
// @throws A runtime error if the streamIndex does not match any stream
6466
const avtranscoder::StreamProperties& getStreamPropertiesWithIndex( const size_t streamIndex ) const;
6567
//@}
6668

@@ -102,7 +104,8 @@ class AvExport FileProperties
102104
const FormatContext* _formatContext; ///< Has link (no ownership)
103105
const AVFormatContext* _avFormatContext; ///< Has link (no ownership)
104106

105-
std::vector< StreamProperties* > _streams; ///< Array of properties per stream (of all types) - only references to the following properties
107+
std::map< size_t, StreamProperties* > _streams; ///< Map of properties per stream index (of all types) - only references to the following properties
108+
106109
std::vector< VideoProperties > _videoStreams; ///< Array of properties per video stream
107110
std::vector< AudioProperties > _audioStreams; ///< Array of properties per audio stream
108111
std::vector< DataProperties > _dataStreams; ///< Array of properties per data stream

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy