Skip to content

Commit 4c82c58

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 7aa1179 commit 4c82c58

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
@@ -343,7 +343,7 @@ size_t VideoProperties::getBitRate() const
343343
avcodec_open2(_codecContext, _codec, NULL);
344344

345345
int gotFrame = 0;
346-
int count = 0;
346+
size_t count = 0;
347347
int gopFramesSize = 0;
348348

349349
while(!av_read_frame(const_cast<AVFormatContext*>(_formatContext), &pkt))
@@ -362,12 +362,12 @@ size_t VideoProperties::getBitRate() const
362362
}
363363
}
364364
av_free_packet(&pkt);
365-
if(_codecContext->gop_size == count)
365+
if(getGopSize() == count)
366366
break;
367367
}
368368

369369
int bitsPerByte = 8;
370-
return (gopFramesSize / _codecContext->gop_size) * bitsPerByte * getFps();
370+
return (gopFramesSize / getGopSize()) * bitsPerByte * getFps();
371371
}
372372

373373
size_t VideoProperties::getMaxBitRate() const
@@ -487,7 +487,7 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
487487
avcodec_open2(_codecContext, _codec, NULL);
488488

489489
Frame frame;
490-
int count = 0;
490+
size_t count = 0;
491491
int gotFrame = 0;
492492
bool stopAnalyse = false;
493493

@@ -504,14 +504,14 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
504504
_isInterlaced = avFrame.interlaced_frame;
505505
_isTopFieldFirst = avFrame.top_field_first;
506506
++count;
507-
if(progress.progress(count, _codecContext->gop_size) == eJobStatusCancel)
507+
if(progress.progress(count, getGopSize()) == eJobStatusCancel)
508508
stopAnalyse = true;
509509
}
510510
}
511511

512512
av_free_packet(&pkt);
513513

514-
if(_codecContext->gop_size == count)
514+
if(getGopSize() == count)
515515
{
516516
stopAnalyse = true;
517517
}

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)