Skip to content

Commit 2c9198f

Browse files
committed
Merge pull request #200 from cchampet/dev_ProcessStat
Dev process stat
2 parents 1668097 + e3944f4 commit 2c9198f

27 files changed

+426
-235
lines changed

app/avPlay/AvReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ AvReader::AvReader( const std::string& filename )
1717
_inputFile.activateStream( _videoStream );
1818

1919
_inputVideo = new avtranscoder::VideoDecoder( _inputFile.getStream( _videoStream ) );
20-
_inputVideo->setup();
20+
_inputVideo->setupDecoder();
2121

2222
_sourceImage = new avtranscoder::VideoFrame( _inputFile.getStream( _videoStream ).getVideoCodec().getVideoFrameDesc() );
2323

src/AvTranscoder/avTranscoder.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
%include "AvTranscoder/encoder/encoder.i"
3737
%include "AvTranscoder/transform/transform.i"
3838
%include "AvTranscoder/file/file.i"
39+
%include "AvTranscoder/stat/stat.i"
3940
%include "AvTranscoder/transcoder/transcoder.i"

src/AvTranscoder/decoder/AudioDecoder.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,39 @@ AudioDecoder::~AudioDecoder()
5050
}
5151

5252

53-
void AudioDecoder::setup()
53+
void AudioDecoder::setupDecoder( const ProfileLoader::Profile& profile )
5454
{
55+
LOG_DEBUG( "Set profile of audio decoder with:\n" << profile )
56+
57+
AudioCodec& codec = _inputStream->getAudioCodec();
58+
59+
// set threads before any other options
60+
if( profile.count( constants::avProfileThreads ) )
61+
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
62+
else
63+
codec.getOption( constants::avProfileThreads ).setString( "auto" );
64+
65+
// set decoder options
66+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
67+
{
68+
if( (*it).first == constants::avProfileIdentificator ||
69+
(*it).first == constants::avProfileIdentificatorHuman ||
70+
(*it).first == constants::avProfileType ||
71+
(*it).first == constants::avProfileThreads )
72+
continue;
73+
74+
try
75+
{
76+
Option& decodeOption = codec.getOption( (*it).first );
77+
decodeOption.setString( (*it).second );
78+
}
79+
catch( std::exception& e )
80+
{
81+
LOG_WARN( "AudioDecoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
82+
}
83+
}
84+
85+
// open decoder
5586
_inputStream->getAudioCodec().openCodec();
5687
}
5788

@@ -145,37 +176,4 @@ bool AudioDecoder::decodeNextFrame()
145176
return true;
146177
}
147178

148-
void AudioDecoder::setProfile( const ProfileLoader::Profile& profile )
149-
{
150-
LOG_DEBUG( "Set profile of audio decoder with:\n" << profile )
151-
152-
AudioCodec& codec = _inputStream->getAudioCodec();
153-
154-
// set threads before any other options
155-
if( profile.count( constants::avProfileThreads ) )
156-
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
157-
else
158-
codec.getOption( constants::avProfileThreads ).setString( "auto" );
159-
160-
// set decoder options
161-
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
162-
{
163-
if( (*it).first == constants::avProfileIdentificator ||
164-
(*it).first == constants::avProfileIdentificatorHuman ||
165-
(*it).first == constants::avProfileType ||
166-
(*it).first == constants::avProfileThreads )
167-
continue;
168-
169-
try
170-
{
171-
Option& decodeOption = codec.getOption( (*it).first );
172-
decodeOption.setString( (*it).second );
173-
}
174-
catch( std::exception& e )
175-
{
176-
LOG_WARN( "AudioDecoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
177-
}
178-
}
179-
}
180-
181179
}

src/AvTranscoder/decoder/AudioDecoder.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define _AV_TRANSCODER_ESSENCE_STREAM_AV_INPUT_AUDIO_HPP_
33

44
#include "IDecoder.hpp"
5-
#include <AvTranscoder/profile/ProfileLoader.hpp>
65

76
struct AVFrame;
87

@@ -17,13 +16,11 @@ class AvExport AudioDecoder : public IDecoder
1716
AudioDecoder( InputStream& inputStream );
1817
~AudioDecoder();
1918

20-
void setup();
19+
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() );
2120

2221
bool decodeNextFrame( Frame& frameBuffer );
2322
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2423

25-
void setProfile( const ProfileLoader::Profile& profile );
26-
2724
private:
2825
bool decodeNextFrame();
2926

src/AvTranscoder/decoder/AudioGenerator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AvExport AudioGenerator : public IDecoder
1616

1717
~AudioGenerator();
1818

19-
void setup() {}
19+
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) {}
2020

2121
bool decodeNextFrame( Frame& frameBuffer );
2222
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );

src/AvTranscoder/decoder/IDecoder.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <AvTranscoder/common.hpp>
55
#include <AvTranscoder/frame/Frame.hpp>
6+
#include <AvTranscoder/profile/ProfileLoader.hpp>
67

78
namespace avtranscoder
89
{
@@ -13,9 +14,11 @@ class AvExport IDecoder
1314
virtual ~IDecoder() {};
1415

1516
/**
16-
* @brief Open the decoder
17+
* @brief Setup the decoder
18+
* @param profile: set decoder parameters from the given profile
19+
* @note Open the decoder.
1720
*/
18-
virtual void setup() = 0;
21+
virtual void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) = 0;
1922

2023
/**
2124
* @brief Decode next frame

src/AvTranscoder/decoder/VideoDecoder.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,39 @@ VideoDecoder::~VideoDecoder()
4848
}
4949
}
5050

51-
void VideoDecoder::setup()
51+
void VideoDecoder::setupDecoder( const ProfileLoader::Profile& profile )
5252
{
53+
LOG_DEBUG( "Set profile of video decoder with:\n" << profile )
54+
55+
VideoCodec& codec = _inputStream->getVideoCodec();
56+
57+
// set threads before any other options
58+
if( profile.count( constants::avProfileThreads ) )
59+
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
60+
else
61+
codec.getOption( constants::avProfileThreads ).setString( "auto" );
62+
63+
// set decoder options
64+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
65+
{
66+
if( (*it).first == constants::avProfileIdentificator ||
67+
(*it).first == constants::avProfileIdentificatorHuman ||
68+
(*it).first == constants::avProfileType ||
69+
(*it).first == constants::avProfileThreads )
70+
continue;
71+
72+
try
73+
{
74+
Option& decodeOption = codec.getOption( (*it).first );
75+
decodeOption.setString( (*it).second );
76+
}
77+
catch( std::exception& e )
78+
{
79+
LOG_WARN( "VideoDecoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
80+
}
81+
}
82+
83+
// open decoder
5384
_inputStream->getVideoCodec().openCodec();
5485
}
5586

@@ -104,37 +135,4 @@ void VideoDecoder::flushDecoder()
104135
avcodec_flush_buffers( &_inputStream->getVideoCodec().getAVCodecContext() );
105136
}
106137

107-
void VideoDecoder::setProfile( const ProfileLoader::Profile& profile )
108-
{
109-
LOG_DEBUG( "Set profile of video decoder with:\n" << profile )
110-
111-
VideoCodec& codec = _inputStream->getVideoCodec();
112-
113-
// set threads before any other options
114-
if( profile.count( constants::avProfileThreads ) )
115-
codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
116-
else
117-
codec.getOption( constants::avProfileThreads ).setString( "auto" );
118-
119-
// set decoder options
120-
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
121-
{
122-
if( (*it).first == constants::avProfileIdentificator ||
123-
(*it).first == constants::avProfileIdentificatorHuman ||
124-
(*it).first == constants::avProfileType ||
125-
(*it).first == constants::avProfileThreads )
126-
continue;
127-
128-
try
129-
{
130-
Option& decodeOption = codec.getOption( (*it).first );
131-
decodeOption.setString( (*it).second );
132-
}
133-
catch( std::exception& e )
134-
{
135-
LOG_WARN( "VideoDecoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
136-
}
137-
}
138-
}
139-
140138
}

src/AvTranscoder/decoder/VideoDecoder.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#define _AV_TRANSCODER_DECODER_VIDEO_DECODER_HPP_
33

44
#include "IDecoder.hpp"
5-
#include <AvTranscoder/profile/ProfileLoader.hpp>
65

76
struct AVFrame;
87

@@ -16,16 +15,14 @@ class AvExport VideoDecoder : public IDecoder
1615
public:
1716
VideoDecoder( InputStream& inputStream );
1817
~VideoDecoder();
19-
20-
void setup();
18+
19+
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() );
2120

2221
bool decodeNextFrame( Frame& frameBuffer );
2322
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );
2423

2524
void flushDecoder();
26-
27-
void setProfile( const ProfileLoader::Profile& profile );
28-
25+
2926
private:
3027
bool decodeNextFrame();
3128

src/AvTranscoder/decoder/VideoGenerator.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AvExport VideoGenerator : public IDecoder
1616

1717
~VideoGenerator();
1818

19-
void setup() {}
19+
void setupDecoder( const ProfileLoader::Profile& profile = ProfileLoader::Profile() ) {}
2020

2121
bool decodeNextFrame( Frame& frameBuffer );
2222
bool decodeNextFrame( Frame& frameBuffer, const size_t subStreamIndex );

src/AvTranscoder/encoder/AudioEncoder.cpp

Lines changed: 61 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,69 @@ AudioEncoder::~AudioEncoder()
3535
#endif
3636
}
3737

38-
void AudioEncoder::setup()
38+
void AudioEncoder::setupAudioEncoder( const AudioFrameDesc& frameDesc, const ProfileLoader::Profile& profile )
3939
{
40+
LOG_DEBUG( "Set profile of audio encoder with:\n" << profile )
41+
42+
// set sampleRate, number of channels, sample format
43+
_codec.setAudioParameters( frameDesc );
44+
45+
// setup encoder
46+
setupEncoder( profile );
47+
}
48+
49+
void AudioEncoder::setupEncoder( const ProfileLoader::Profile& profile )
50+
{
51+
// set threads before any other options
52+
if( profile.count( constants::avProfileThreads ) )
53+
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
54+
else
55+
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
56+
57+
58+
// set encoder options
59+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
60+
{
61+
if( (*it).first == constants::avProfileIdentificator ||
62+
(*it).first == constants::avProfileIdentificatorHuman ||
63+
(*it).first == constants::avProfileType ||
64+
(*it).first == constants::avProfileCodec ||
65+
(*it).first == constants::avProfileSampleFormat ||
66+
(*it).first == constants::avProfileThreads )
67+
continue;
68+
69+
try
70+
{
71+
Option& encodeOption = _codec.getOption( (*it).first );
72+
encodeOption.setString( (*it).second );
73+
}
74+
catch( std::exception& e )
75+
{}
76+
}
77+
78+
// open encoder
4079
_codec.openCodec();
80+
81+
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
82+
{
83+
if( (*it).first == constants::avProfileIdentificator ||
84+
(*it).first == constants::avProfileIdentificatorHuman ||
85+
(*it).first == constants::avProfileType ||
86+
(*it).first == constants::avProfileCodec ||
87+
(*it).first == constants::avProfileSampleFormat ||
88+
(*it).first == constants::avProfileThreads )
89+
continue;
90+
91+
try
92+
{
93+
Option& encodeOption = _codec.getOption( (*it).first );
94+
encodeOption.setString( (*it).second );
95+
}
96+
catch( std::exception& e )
97+
{
98+
LOG_WARN( "AudioEncoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
99+
}
100+
}
41101
}
42102

43103
bool AudioEncoder::encodeFrame( const Frame& sourceFrame, Frame& codedFrame )
@@ -133,63 +193,5 @@ bool AudioEncoder::encodeFrame( Frame& codedFrame )
133193
#endif
134194
}
135195

136-
void AudioEncoder::setProfile( const ProfileLoader::Profile& profile, const AudioFrameDesc& frameDesc )
137-
{
138-
LOG_DEBUG( "Set profile of audio encoder with:\n" << profile )
139-
140-
// set sampleRate, number of channels, sample format
141-
_codec.setAudioParameters( frameDesc );
142-
143-
// set threads before any other options
144-
if( profile.count( constants::avProfileThreads ) )
145-
_codec.getOption( constants::avProfileThreads ).setString( profile.at( constants::avProfileThreads ) );
146-
else
147-
_codec.getOption( constants::avProfileThreads ).setString( "auto" );
148-
149-
150-
// set encoder options
151-
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
152-
{
153-
if( (*it).first == constants::avProfileIdentificator ||
154-
(*it).first == constants::avProfileIdentificatorHuman ||
155-
(*it).first == constants::avProfileType ||
156-
(*it).first == constants::avProfileCodec ||
157-
(*it).first == constants::avProfileSampleFormat ||
158-
(*it).first == constants::avProfileThreads )
159-
continue;
160-
161-
try
162-
{
163-
Option& encodeOption = _codec.getOption( (*it).first );
164-
encodeOption.setString( (*it).second );
165-
}
166-
catch( std::exception& e )
167-
{}
168-
}
169-
170-
setup();
171-
172-
for( ProfileLoader::Profile::const_iterator it = profile.begin(); it != profile.end(); ++it )
173-
{
174-
if( (*it).first == constants::avProfileIdentificator ||
175-
(*it).first == constants::avProfileIdentificatorHuman ||
176-
(*it).first == constants::avProfileType ||
177-
(*it).first == constants::avProfileCodec ||
178-
(*it).first == constants::avProfileSampleFormat ||
179-
(*it).first == constants::avProfileThreads )
180-
continue;
181-
182-
try
183-
{
184-
Option& encodeOption = _codec.getOption( (*it).first );
185-
encodeOption.setString( (*it).second );
186-
}
187-
catch( std::exception& e )
188-
{
189-
LOG_WARN( "AudioEncoder - can't set option " << (*it).first << " to " << (*it).second << ": " << e.what() )
190-
}
191-
}
192-
}
193-
194196
}
195197

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