MCPcopy Create free account
hub / github.com/IENT/YUView / scanBitstream

Method scanBitstream

YUViewLib/src/filesource/FileSourceFFmpegFile.cpp:420–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420bool FileSourceFFmpegFile::scanBitstream(QWidget *mainWindow)
421{
422 if (!this->isFileOpened)
423 return false;
424
425 // Create the dialog (if the given pointer is not null)
426 auto maxPTS = this->getMaxTS();
427 // Updating the dialog (setValue) is quite slow. Only do this if the percent value changes.
428 int curPercentValue = 0;
429 QScopedPointer<QProgressDialog> progress;
430 if (mainWindow != nullptr)
431 {
432 progress.reset(
433 new QProgressDialog("Parsing (indexing) bitstream...", "Cancel", 0, 100, mainWindow));
434 progress->setMinimumDuration(1000); // Show after 1s
435 progress->setAutoClose(false);
436 progress->setAutoReset(false);
437 progress->setWindowModality(Qt::WindowModal);
438 }
439
440 this->nrFrames = 0;
441 while (this->goToNextPacket(true))
442 {
443 DEBUG_FFMPEG("FileSourceFFmpegFile::scanBitstream: frame %d pts %d dts %d%s",
444 this->nrFrames,
445 (int)this->currentPacket.getPTS(),
446 (int)this->currentPacket.getDTS(),
447 this->currentPacket.getFlagKeyframe() ? " - keyframe" : "");
448
449 if (this->currentPacket.getFlagKeyframe())
450 this->keyFrameList.append(pictureIdx(this->nrFrames, this->currentPacket.getDTS()));
451
452 if (progress && progress->wasCanceled())
453 return false;
454
455 int newPercentValue = 0;
456 if (maxPTS != 0)
457 newPercentValue = functions::clip(int(this->currentPacket.getPTS() * 100 / maxPTS), 0, 100);
458 if (newPercentValue != curPercentValue)
459 {
460 if (progress)
461 progress->setValue(newPercentValue);
462 curPercentValue = newPercentValue;
463 }
464
465 this->nrFrames++;
466 }
467
468 DEBUG_FFMPEG("FileSourceFFmpegFile::scanBitstream: Scan done. Found %d frames and %d keyframes.",
469 this->nrFrames,
470 this->keyFrameList.length());
471 return !progress->wasCanceled();
472}
473
474void FileSourceFFmpegFile::openFileAndFindVideoStream(QString fileName)
475{

Callers 1

openFileMethod · 0.95

Calls 8

getMaxTSMethod · 0.95
goToNextPacketMethod · 0.95
pictureIdxClass · 0.85
clipFunction · 0.85
getDTSMethod · 0.80
getFlagKeyframeMethod · 0.80
appendMethod · 0.80
getPTSMethod · 0.45

Tested by

no test coverage detected