Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit30be155

Browse files
committed
Transcoder: refactoring of the wrapping status support
Fix the processed frames counterFix the process progress check depending on the wrapping status
1 parent33253f7 commit30be155

File tree

4 files changed

+102
-71
lines changed

4 files changed

+102
-71
lines changed

‎src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ void StreamTranscoder::preProcessCodecLatency()
597597
_currentDecoder =NULL;
598598
}
599599

600-
boolStreamTranscoder::processFrame()
600+
IOutputStream::EWrappingStatusStreamTranscoder::processFrame()
601601
{
602602
std::string msg ="Current process case of the stream is a";
603603
switch(getProcessCase())
@@ -677,7 +677,7 @@ bool StreamTranscoder::processFrame()
677677
returnprocessTranscode();
678678
}
679679

680-
boolStreamTranscoder::processRewrap()
680+
IOutputStream::EWrappingStatusStreamTranscoder::processRewrap()
681681
{
682682
assert(_inputStreams.size() ==1);
683683
assert(_outputStream !=NULL);
@@ -692,25 +692,13 @@ bool StreamTranscoder::processRewrap()
692692
switchToGeneratorDecoder();
693693
returnprocessTranscode();
694694
}
695-
returnfalse;
695+
returnIOutputStream::eWrappingError;
696696
}
697697

698-
const IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap(data);
699-
switch(wrappingStatus)
700-
{
701-
case IOutputStream::eWrappingSuccess:
702-
returntrue;
703-
case IOutputStream::eWrappingWaitingForData:
704-
// the wrapper needs more data to write the current packet
705-
returnprocessFrame();
706-
case IOutputStream::eWrappingError:
707-
returnfalse;
708-
}
709-
710-
returntrue;
698+
return _outputStream->wrap(data);
711699
}
712700

713-
boolStreamTranscoder::processTranscode()
701+
IOutputStream::EWrappingStatusStreamTranscoder::processTranscode()
714702
{
715703
assert(_outputStream !=NULL);
716704
assert(_currentDecoder !=NULL);
@@ -840,25 +828,13 @@ bool StreamTranscoder::processTranscode()
840828
}
841829
returnprocessTranscode();
842830
}
843-
returnfalse;
831+
returnIOutputStream::eWrappingError;
844832
}
845833
}
846834

847835
// Wrap
848836
LOG_DEBUG("wrap (" << data.getSize() <<" bytes)")
849-
const IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap(data);
850-
switch(wrappingStatus)
851-
{
852-
case IOutputStream::eWrappingSuccess:
853-
returntrue;
854-
case IOutputStream::eWrappingWaitingForData:
855-
// the wrapper needs more data to write the current packet
856-
returnprocessFrame();
857-
case IOutputStream::eWrappingError:
858-
returnfalse;
859-
}
860-
861-
returntrue;
837+
return _outputStream->wrap(data);
862838
}
863839

864840
voidStreamTranscoder::switchToGeneratorDecoder()

‎src/AvTranscoder/transcoder/StreamTranscoder.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AvExport StreamTranscoder
6969
* @brief process a single frame for the current stream
7070
* @return the process status result
7171
*/
72-
boolprocessFrame();
72+
IOutputStream::EWrappingStatusprocessFrame();
7373

7474
//@{
7575
// Switch current decoder.
@@ -139,8 +139,8 @@ class AvExport StreamTranscoder
139139
voidaddDecoder(const InputStreamDesc& inputStreamDesc, IInputStream& inputStream);
140140
voidaddGenerator(const InputStreamDesc& inputStreamDesc,const ProfileLoader::Profile& profile);
141141

142-
boolprocessRewrap();
143-
boolprocessTranscode();
142+
IOutputStream::EWrappingStatusprocessRewrap();
143+
IOutputStream::EWrappingStatusprocessTranscode();
144144

145145
private:
146146
std::vector<InputStreamDesc> _inputStreamDesc;///< Description of the data to extract from the input stream.

‎src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Transcoder::Transcoder(IOutputFile& outputFile)
1919
, _profileLoader(true)
2020
, _eProcessMethod(eProcessMethodLongest)
2121
, _mainStreamIndex(0)
22+
, _processedFrames(0)
2223
, _outputDuration(0)
2324
{
2425
}
@@ -159,27 +160,86 @@ void Transcoder::preProcessCodecLatency()
159160
}
160161

161162
boolTranscoder::processFrame()
163+
{
164+
NoDisplayProgress progress;
165+
returnprocessFrame(progress);
166+
}
167+
168+
boolTranscoder::processFrame(IProgress& progress)
162169
{
163170
if(_streamTranscoders.size() ==0)
164171
returnfalse;
165172

166173
// For each stream, process a frame
174+
bool result =true;
167175
for(size_t streamIndex =0; streamIndex < _streamTranscoders.size(); ++streamIndex)
168176
{
169-
LOG_DEBUG("Process stream" << streamIndex +1 <<"/" << _streamTranscoders.size())
177+
if(!processFrame(progress, streamIndex))
178+
result =false;
179+
}
180+
return result;
181+
}
170182

171-
// if a stream failed to process
172-
if(!_streamTranscoders.at(streamIndex)->processFrame())
173-
{
183+
boolTranscoder::processFrame(IProgress& progress,constsize_t& streamIndex)
184+
{
185+
LOG_DEBUG("Process stream" << streamIndex +1 <<"/" << _streamTranscoders.size())
186+
187+
IOutputStream::EWrappingStatus status = _streamTranscoders.at(streamIndex)->processFrame();
188+
switch(status)
189+
{
190+
case IOutputStream::eWrappingSuccess:
191+
if(streamIndex ==0)
192+
_processedFrames++;
193+
194+
if(!continueProcess(progress))
195+
returnfalse;
196+
returntrue;
197+
198+
case IOutputStream::eWrappingWaitingForData:
199+
// the wrapper needs more data to write the current packet
200+
if(streamIndex ==0)
201+
_processedFrames++;
202+
203+
if(!continueProcess(progress))
204+
returnfalse;
205+
206+
returnprocessFrame(progress, streamIndex);
207+
208+
case IOutputStream::eWrappingSkip:
209+
returntrue;
210+
211+
case IOutputStream::eWrappingError:
212+
// if a stream failed to process
174213
LOG_WARN("Failed to process the stream transcoder at index" << streamIndex)
175214

176215
// if this is the end of the main stream
177-
if(streamIndex == _mainStreamIndex) {
216+
if(streamIndex == _mainStreamIndex)
178217
LOG_INFO("End of process because the main stream at index" << _mainStreamIndex <<" failed to process a new frame.")
179-
returnfalse;
180-
}
181-
}
218+
219+
returnfalse;
182220
}
221+
}
222+
223+
boolTranscoder::continueProcess(IProgress& progress) {
224+
constfloat expectedOutputDuration =getExpectedOutputDuration();
225+
constfloat progressDuration =getCurrentOutputDuration();
226+
227+
// check if JobStatusCancel
228+
if(progress.progress((progressDuration > expectedOutputDuration) ? expectedOutputDuration : progressDuration,
229+
expectedOutputDuration) == eJobStatusCancel)
230+
{
231+
LOG_INFO("End of process because the job was canceled.")
232+
returnfalse;
233+
}
234+
235+
// check progressDuration
236+
if(_eProcessMethod == eProcessMethodBasedOnDuration && progressDuration >= expectedOutputDuration)
237+
{
238+
LOG_INFO("End of process because the output program duration ("
239+
<< progressDuration <<"s) is equal or upper than" << expectedOutputDuration <<"s.")
240+
returnfalse;
241+
}
242+
183243
returntrue;
184244
}
185245

@@ -205,36 +265,15 @@ ProcessStat Transcoder::process(IProgress& progress)
205265
constfloat expectedOutputDuration =getExpectedOutputDuration();
206266
LOG_INFO("The expected output duration of the program will be" << expectedOutputDuration <<"s.")
207267

208-
size_t frame =0;
209268
bool frameProcessed =true;
210269
while(frameProcessed)
211270
{
212-
LOG_DEBUG("Process frame" << frame)
213-
frameProcessed =processFrame();
214-
++frame;
215-
216-
constfloat progressDuration =getCurrentOutputDuration();
217-
218-
// check if JobStatusCancel
219-
if(progress.progress((progressDuration > expectedOutputDuration) ? expectedOutputDuration : progressDuration,
220-
expectedOutputDuration) == eJobStatusCancel)
221-
{
222-
LOG_INFO("End of process because the job was canceled.")
223-
break;
224-
}
225-
226-
// check progressDuration
227-
if(_eProcessMethod == eProcessMethodBasedOnDuration && progressDuration >= expectedOutputDuration)
228-
{
229-
LOG_INFO("End of process because the output program duration ("
230-
<< progressDuration <<"s) is equal or upper than" << expectedOutputDuration <<"s.")
231-
break;
232-
}
271+
LOG_INFO("Process frame" << _processedFrames);
272+
frameProcessed =processFrame(progress);
233273
}
234274

235275
_outputFile.endWrap();
236-
237-
LOG_INFO("End of process:" << ++frame <<" frames processed")
276+
LOG_INFO("End of process:" << ++_processedFrames <<" frames processed")
238277

239278
LOG_INFO("Get process statistics")
240279
ProcessStat processStat;

‎src/AvTranscoder/transcoder/Transcoder.hpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ class AvExport Transcoder
9595

9696
/**
9797
* @brief Process the next frame of all streams.
98+
* @param progress: choose a progress, or create your own in C++ or in bindings by inherit IProgress class.
9899
* @return if a frame was processed or not.
99100
*/
100-
boolprocessFrame();
101+
boolprocessFrame(IProgress& progress);
102+
boolprocessFrame();///< Call processFrame with no display of progression
101103

102104
/**
103105
* @brief Process all the streams, and ended the process depending on the transcode politic.
@@ -190,6 +192,19 @@ class AvExport Transcoder
190192
*/
191193
voidmanageSwitchToGenerator();
192194

195+
/**
196+
* @brief Process the next frame of the specified stream.
197+
* @return whether a frame was processed or not.
198+
*/
199+
boolprocessFrame(IProgress& progress,constsize_t& streamIndex);
200+
201+
/**
202+
* @brief Check whether the process is canceled or not, and whether the process reached the ending condition.
203+
* @note The progress is updated in this function.
204+
* @return whether the process must continue or stop.
205+
*/
206+
boolcontinueProcess(IProgress& progress);
207+
193208
/**
194209
* @brief Fill the given ProcessStat to summarize the process.
195210
*/
@@ -205,10 +220,11 @@ class AvExport Transcoder
205220
ProfileLoader _profileLoader;///< Objet to get existing profiles, and add new ones for the Transcoder.
206221

207222
EProcessMethod _eProcessMethod;///< Processing policy
208-
size_t
209-
_mainStreamIndex;///< Index of stream used to stop the process.
210-
float _outputDuration;///< Duration of output media used to stop the process of transcode in case of
211-
/// eProcessMethodBasedOnDuration.
223+
224+
size_t _mainStreamIndex;///< Index of stream used to stop the process.
225+
size_t _processedFrames;///< Counter for the number of processed frames.
226+
227+
float _outputDuration;///< Duration of output media used to stop the process of transcode in case of eProcessMethodBasedOnDuration.
212228
};
213229
}
214230

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp