Skip to content

Commit e5be536

Browse files
committed
Fix empty plots when first track is not a video track
Signed-off-by: Maxime Gervais <[email protected]>
1 parent 025572d commit e5be536

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

Source/Core/CommonStats.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class CommonStats
5454
double* y_Max; // Maximum y by plot
5555
double FirstTimeStamp; // Time stamp of the first frame
5656
char** comments; // Comments per frame (utf-8)
57+
int streamIndex; // Stream index in the container
5758

5859
// Status
5960
int Type_Get();
@@ -184,7 +185,6 @@ class CommonStats
184185

185186
// Info
186187
double Frequency;
187-
int streamIndex;
188188

189189
// Memory management
190190
size_t Data_Reserved; // Count of frames reserved in memory;

Source/Core/FileInformation.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,11 +1060,16 @@ FileInformation::FileInformation (SignalServer* signalServer, const QString &Fil
10601060
QObject::connect(m_mediaParser, &QAVPlayer::audioFrame, m_mediaParser, [this](const QAVAudioFrame &frame) {
10611061
qDebug() << "audio frame came from: " << frame.filterName() << frame.stream() << frame.stream().index();
10621062

1063-
if (frame.filterName() == astats && frame.stream().index() < Stats.size()) {
1064-
auto stat = Stats[frame.stream().index()];
1063+
if (frame.filterName() == astats) {
1064+
auto it = std::find_if(Stats.begin(), Stats.end(), [&](CommonStats* stat) {
1065+
return stat->streamIndex == frame.stream().index();
1066+
});
10651067

1066-
stat->TimeStampFromFrame(frame, stat->x_Current);
1067-
stat->StatsFromFrame(frame, 0, 0);
1068+
if(it != Stats.end()) {
1069+
auto stat = *it;
1070+
stat->TimeStampFromFrame(frame, stat->x_Current);
1071+
stat->StatsFromFrame(frame, 0, 0);
1072+
}
10681073
}
10691074
},
10701075
// Qt::QueuedConnection
@@ -1074,12 +1079,16 @@ FileInformation::FileInformation (SignalServer* signalServer, const QString &Fil
10741079
QObject::connect(m_mediaParser, &QAVPlayer::videoFrame, m_mediaParser, [this](const QAVVideoFrame &frame) {
10751080
qDebug() << "video frame came from: " << frame.filterName() << frame.stream() << frame.stream().index();
10761081

1077-
if(frame.filterName() == stats && frame.stream().index() < Stats.size()) {
1078-
auto stat = Stats[frame.stream().index()];
1079-
1080-
stat->TimeStampFromFrame(frame, stat->x_Current);
1081-
stat->StatsFromFrame(frame, frame.size().width(), frame.size().height());
1082+
if(frame.filterName() == stats) {
1083+
auto it = std::find_if(Stats.begin(), Stats.end(), [&](CommonStats* stat) {
1084+
return stat->streamIndex == frame.stream().index();
1085+
});
10821086

1087+
if(it != Stats.end()) {
1088+
auto stat = *it;
1089+
stat->TimeStampFromFrame(frame, stat->x_Current);
1090+
stat->StatsFromFrame(frame, frame.size().width(), frame.size().height());
1091+
}
10831092
} else if(frame.filterName().startsWith(panelOutputPrefix)) {
10841093
auto indexString = frame.filterName().mid(panelOutputPrefix.length());
10851094
auto index = indexString.toInt();

0 commit comments

Comments
 (0)