Skip to content

Commit 50222f3

Browse files
author
Clement Champetier
committed
Transcoder: refactore process
* Clean indentation. * Avoid while( 1 ). * Suppress warning of getTotalDurationFromProcessMethod: add default case in switch.
1 parent cfb3669 commit 50222f3

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,17 @@ void Transcoder::init()
252252
bool Transcoder::processFrame()
253253
{
254254
if( _streamTranscoders.size() == 0 )
255-
{
256255
return false;
257-
}
258256

259257
if( _verbose )
260258
std::cout << "process frame" << std::endl;
259+
261260
for( size_t streamIndex = 0; streamIndex < _streamTranscoders.size(); ++streamIndex )
262261
{
263262
if( _verbose )
264263
std::cout << "process stream " << streamIndex << "/" << _streamTranscoders.size() - 1 << std::endl;
265264

266265
bool streamProcessStatus = _streamTranscoders.at( streamIndex )->processFrame();
267-
268266
if( ! streamProcessStatus )
269267
{
270268
_streamTranscoders.clear();
@@ -276,37 +274,31 @@ bool Transcoder::processFrame()
276274

277275
void Transcoder::process( IProgress& progress )
278276
{
279-
size_t frame = 0;
280-
281-
if( ! _streamTranscoders.size() )
282-
{
277+
if( _streamTranscoders.size() == 0 )
283278
throw std::runtime_error( "missing input streams in transcoder" );
284-
}
285279

286280
if( _verbose )
287281
std::cout << "begin transcoding" << std::endl;
288282
init();
289283

290284
_outputFile.beginWrap();
291285

292-
double totalDuration = getTotalDurationFromProcessMethod();
293-
294286
if( _verbose )
295287
av_log_set_level( AV_LOG_DEBUG );
296288

297-
while( 1 )
289+
double totalDuration = getTotalDurationFromProcessMethod();
290+
291+
size_t frame = 0;
292+
bool frameProcessed = true;
293+
while( frameProcessed )
298294
{
299295
if( _verbose )
300296
std::cout << "process frame " << frame << std::endl;
301297

302-
bool frameProcessed = processFrame();
303-
if( ! frameProcessed )
304-
break;
298+
frameProcessed = processFrame();
305299

306300
if( progress.progress( _outputFile.getProgressDuration(), totalDuration ) == eJobStatusCancel )
307-
{
308301
break;
309-
}
310302

311303
++frame;
312304
}
@@ -526,6 +518,8 @@ double Transcoder::getTotalDurationFromProcessMethod() const
526518
return getStreamDuration( _mainStreamIndex );
527519
case eProcessMethodInfinity :
528520
return std::numeric_limits<double>::max();
521+
default:
522+
return getMaxTotalDuration();
529523
}
530524
}
531525

src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ enum EProcessMethod
4343
class AvExport Transcoder
4444
{
4545
public:
46-
4746
Transcoder( OutputFile& outputFile );
4847

4948
~Transcoder();
@@ -139,7 +138,6 @@ class AvExport Transcoder
139138
void setVerbose( bool verbose = true );
140139

141140
private:
142-
143141
void addRewrapStream( const std::string& filename, const size_t streamIndex );
144142

145143
void addTranscodeStream( const std::string& filename, const size_t streamIndex, const size_t subStreamIndex, const size_t offset ); ///< Get profile from input

0 commit comments

Comments
 (0)