Skip to content

Commit a3c8209

Browse files
author
Clement Champetier
committed
VideoProperties: refactored the methods that use gop_size
* Use VideoProperties::getGopSize() instead. * Add doc to this method.
1 parent 718b855 commit a3c8209

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/AvTranscoder/properties/VideoProperties.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ size_t VideoProperties::getBitRate() const
340340
avcodec_open2(_codecContext, _codec, NULL);
341341

342342
int gotFrame = 0;
343-
int count = 0;
343+
size_t count = 0;
344344
int gopFramesSize = 0;
345345

346346
while(!av_read_frame(const_cast<AVFormatContext*>(_formatContext), &pkt))
@@ -359,12 +359,12 @@ size_t VideoProperties::getBitRate() const
359359
}
360360
}
361361
av_free_packet(&pkt);
362-
if(_codecContext->gop_size == count)
362+
if(getGopSize() == count)
363363
break;
364364
}
365365

366366
int bitsPerByte = 8;
367-
return (gopFramesSize / _codecContext->gop_size) * bitsPerByte * getFps();
367+
return (gopFramesSize / getGopSize()) * bitsPerByte * getFps();
368368
}
369369

370370
size_t VideoProperties::getMaxBitRate() const
@@ -484,7 +484,7 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
484484
avcodec_open2(_codecContext, _codec, NULL);
485485

486486
Frame frame;
487-
int count = 0;
487+
size_t count = 0;
488488
int gotFrame = 0;
489489
bool stopAnalyse = false;
490490

@@ -501,14 +501,14 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
501501
_isInterlaced = avFrame.interlaced_frame;
502502
_isTopFieldFirst = avFrame.top_field_first;
503503
++count;
504-
if(progress.progress(count, _codecContext->gop_size) == eJobStatusCancel)
504+
if(progress.progress(count, getGopSize()) == eJobStatusCancel)
505505
stopAnalyse = true;
506506
}
507507
}
508508

509509
av_free_packet(&pkt);
510510

511-
if(_codecContext->gop_size == count)
511+
if(getGopSize() == count)
512512
{
513513
stopAnalyse = true;
514514
}

src/AvTranscoder/properties/VideoProperties.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ class AvExport VideoProperties : public StreamProperties
4747
size_t getTicksPerFrame() const;
4848
size_t getWidth() const;
4949
size_t getHeight() const;
50+
51+
/**
52+
* @return the distance between two nearest I frame
53+
* @note it returns 0 for intra_only
54+
*/
5055
size_t getGopSize() const;
56+
5157
size_t getDtgActiveFormat() const;
5258
size_t getReferencesFrames() const;
5359
int getProfile() const;

0 commit comments

Comments
 (0)