Skip to content

Commit 630915d

Browse files
author
Clement Champetier
committed
clean: add const when it's possible
1 parent 075e2f9 commit 630915d

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

src/AvTranscoder/codec/ICodec.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void ICodec::openCodec()
5656
if( ! _avCodecContext )
5757
throw std::runtime_error( "unable to open a codec with no codec context" );
5858

59-
int ret = avcodec_open2( _avCodecContext, _avCodec, NULL );
59+
const int ret = avcodec_open2( _avCodecContext, _avCodec, NULL );
6060
if( ret < 0 )
6161
{
6262
std::string msg = "unable open codec: ";

src/AvTranscoder/file/InputFile.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ bool InputFile::readNextPacket( CodedData& data, const size_t streamIndex )
6060
bool nextPacketFound = false;
6161
while( ! nextPacketFound )
6262
{
63-
int ret = av_read_frame( &_formatContext.getAVFormatContext(), &data.getAVPacket() );
63+
const int ret = av_read_frame( &_formatContext.getAVFormatContext(), &data.getAVPacket() );
6464
if( ret < 0 ) // error or end of file
6565
{
6666
return false;
6767
}
6868

6969
// if the packet stream is the expected one
7070
// return the packet data
71-
int packetStreamIndex = data.getAVPacket().stream_index;
71+
const int packetStreamIndex = data.getAVPacket().stream_index;
7272
if( packetStreamIndex == (int)streamIndex )
7373
{
7474
nextPacketFound = true;
@@ -85,13 +85,13 @@ bool InputFile::readNextPacket( CodedData& data, const size_t streamIndex )
8585

8686
bool InputFile::seekAtFrame( const size_t frame, const int flag )
8787
{
88-
uint64_t position = frame / getFps() * AV_TIME_BASE;
88+
const uint64_t position = frame / getFps() * AV_TIME_BASE;
8989
return _formatContext.seek( position, flag );
9090
}
9191

9292
bool InputFile::seekAtTime( const double time, const int flag )
9393
{
94-
uint64_t position = time * AV_TIME_BASE;
94+
const uint64_t position = time * AV_TIME_BASE;
9595
return _formatContext.seek( position, flag );
9696
}
9797

src/AvTranscoder/stream/OutputStream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ float OutputStream::getStreamDuration() const
3535

3636
size_t OutputStream::getNbFrames() const
3737
{
38-
AVStream& outputStream = _outputFile->getFormatContext().getAVStream( _streamIndex );
38+
const AVStream& outputStream = _outputFile->getFormatContext().getAVStream( _streamIndex );
3939
return outputStream.nb_frames;
4040
}
4141

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ bool StreamTranscoder::processFrame()
326326
// Manage offset
327327
if( _offset > 0 )
328328
{
329-
bool endOfOffset = _outputStream->getStreamDuration() >= _offset;
329+
const bool endOfOffset = _outputStream->getStreamDuration() >= _offset;
330330
if( endOfOffset )
331331
{
332332
LOG_INFO( "End of positive offset" )
@@ -349,7 +349,7 @@ bool StreamTranscoder::processFrame()
349349
}
350350
else if( _offset < 0 )
351351
{
352-
bool endOfStream = _outputStream->getStreamDuration() >= ( _inputStream->getDuration() + _offset );
352+
const bool endOfStream = _outputStream->getStreamDuration() >= ( _inputStream->getDuration() + _offset );
353353
if( endOfStream )
354354
{
355355
LOG_INFO( "End of negative offset" )
@@ -392,8 +392,7 @@ bool StreamTranscoder::processRewrap()
392392
}
393393

394394
LOG_DEBUG( "wrap (" << data.getSize() << " bytes)" )
395-
IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
396-
395+
const IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
397396
switch( wrappingStatus )
398397
{
399398
case IOutputStream::eWrappingSuccess:
@@ -450,8 +449,7 @@ bool StreamTranscoder::processTranscode( const int subStreamIndex )
450449
}
451450

452451
LOG_DEBUG( "wrap (" << data.getSize() << " bytes)" )
453-
IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
454-
452+
const IOutputStream::EWrappingStatus wrappingStatus = _outputStream->wrap( data );
455453
switch( wrappingStatus )
456454
{
457455
case IOutputStream::eWrappingSuccess:

src/AvTranscoder/transcoder/Transcoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ ProcessStat Transcoder::process( IProgress& progress )
248248
bool frameProcessed = true;
249249
while( frameProcessed )
250250
{
251-
double progressDuration = _outputFile.getStream( 0 ).getStreamDuration();
251+
const double progressDuration = _outputFile.getStream( 0 ).getStreamDuration();
252252

253253
// check if JobStatusCancel
254254
if( progress.progress( ( progressDuration > outputDuration ) ? outputDuration : progressDuration, outputDuration ) == eJobStatusCancel )

0 commit comments

Comments
 (0)