@@ -509,24 +509,24 @@ std::vector<std::pair<char, int> > VideoProperties::getGopStructure() const
509
509
return _gopStructure;
510
510
}
511
511
512
- void VideoProperties::analyseGopStructure (IProgress& progress)
512
+ size_t VideoProperties::analyseGopStructure (IProgress& progress)
513
513
{
514
514
if (! _formatContext || ! _codecContext || ! _codec)
515
- return ;
515
+ return 0 ;
516
516
if (! _codecContext->width || ! _codecContext->height )
517
- return ;
517
+ return 0 ;
518
518
519
519
InputFile& file = const_cast <InputFile&>(_fileProperties->getInputFile ());
520
520
// Get the stream
521
521
IInputStream& stream = file.getStream (_streamIndex);
522
522
stream.activate ();
523
523
// Create a decoder
524
524
VideoDecoder decoder (static_cast <InputStream&>(stream));
525
+ VideoFrame frame (VideoFrameDesc (getWidth (), getHeight (), getPixelFormatName (getPixelProperties ().getAVPixelFormat ())), false );
525
526
526
- size_t count = 0 ;
527
+ size_t nbDecodedFrames = 0 ;
527
528
int positionOfFirstKeyFrame = -1 ;
528
529
int positionOfLastKeyFrame = -1 ;
529
- VideoFrame frame (VideoFrameDesc (getWidth (), getHeight (), getPixelFormatName (getPixelProperties ().getAVPixelFormat ())), false );
530
530
while (decoder.decodeNextFrame (frame))
531
531
{
532
532
AVFrame& avFrame = frame.getAVFrame ();
@@ -538,12 +538,12 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
538
538
if (avFrame.pict_type == AV_PICTURE_TYPE_I)
539
539
{
540
540
if (positionOfFirstKeyFrame == -1 )
541
- positionOfFirstKeyFrame = count ;
541
+ positionOfFirstKeyFrame = nbDecodedFrames ;
542
542
else
543
- positionOfLastKeyFrame = count ;
543
+ positionOfLastKeyFrame = nbDecodedFrames ;
544
544
}
545
545
546
- _gopSize = ++count ;
546
+ _gopSize = ++nbDecodedFrames ;
547
547
548
548
// If the first 2 key frames are found
549
549
if (positionOfFirstKeyFrame != -1 && positionOfLastKeyFrame != -1 )
@@ -565,6 +565,7 @@ void VideoProperties::analyseGopStructure(IProgress& progress)
565
565
{
566
566
throw std::runtime_error (" Invalid GOP size when decoding the first data." );
567
567
}
568
+ return nbDecodedFrames;
568
569
}
569
570
570
571
void VideoProperties::analyseFull (IProgress& progress)
0 commit comments