Skip to content

Commit

Permalink
Replace some QList with std::vector in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Sep 23, 2023
1 parent 3daed20 commit 239e3a0
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
6 changes: 3 additions & 3 deletions YUViewLib/src/parser/AV1/ParserAV1OBU.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class ParserAV1OBU : public Parser
assert(false);
return false;
}
QList<QTreeWidgetItem *> getStreamInfo() override { return {}; }
unsigned int getNrStreams() override { return 1; }
QString getShortStreamDescription(int) const override { return "Video"; }
vector<QTreeWidgetItem *> getStreamInfo() override { return {}; }
unsigned int getNrStreams() override { return 1; }
QString getShortStreamDescription(int) const override { return "Video"; }

protected:
av1::GlobalDecodingValues decValues;
Expand Down
15 changes: 8 additions & 7 deletions YUViewLib/src/parser/AVFormat/ParserAVFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,29 @@ const ByteVector startCode({0, 0, 1});

using namespace reader;

QList<QTreeWidgetItem *> ParserAVFormat::getStreamInfo()
vector<QTreeWidgetItem *> ParserAVFormat::getStreamInfo()
{
// streamInfoAllStreams containse all the info for all streams.
// The first QStringPairList contains the general info, next all infos for each stream follows

QList<QTreeWidgetItem *> info;
if (this->streamInfoAllStreams.count() == 0)
return info;
return {};

QStringPairList generalInfo = this->streamInfoAllStreams[0];
QTreeWidgetItem *general = new QTreeWidgetItem(QStringList() << "General");
auto generalInfo = this->streamInfoAllStreams[0];
auto general = new QTreeWidgetItem(QStringList() << "General");
for (QStringPair p : generalInfo)
new QTreeWidgetItem(general, QStringList() << p.first << p.second);
info.append(general);

vector<QTreeWidgetItem *> info;
info.push_back(general);

for (int i = 1; i < this->streamInfoAllStreams.count(); i++)
{
QTreeWidgetItem *streamInfo =
new QTreeWidgetItem(QStringList() << QString("Stream %1").arg(i - 1));
for (QStringPair p : this->streamInfoAllStreams[i])
new QTreeWidgetItem(streamInfo, QStringList() << p.first << p.second);
info.append(streamInfo);
info.push_back(streamInfo);
}

return info;
Expand Down
4 changes: 2 additions & 2 deletions YUViewLib/src/parser/AVFormat/ParserAVFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class ParserAVFormat : public Parser
ParserAVFormat(QObject *parent = nullptr) : Parser(parent) {}
~ParserAVFormat() {}

QList<QTreeWidgetItem *> getStreamInfo() override;
unsigned int getNrStreams() override
vector<QTreeWidgetItem *> getStreamInfo() override;
unsigned int getNrStreams() override
{
return streamInfoAllStreams.empty() ? 0 : streamInfoAllStreams.length() - 1;
}
Expand Down
4 changes: 2 additions & 2 deletions YUViewLib/src/parser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class Parser : public QObject
void enableModel();

// Get info about the stream organized in a tree
virtual QList<QTreeWidgetItem *> getStreamInfo() = 0;
virtual unsigned int getNrStreams() = 0;
virtual vector<QTreeWidgetItem *> getStreamInfo() = 0;
virtual unsigned int getNrStreams() = 0;

// For parsing files in the background (threading) in the bitstream analysis dialog:
virtual bool runParsingOfFile(QString fileName) = 0;
Expand Down
19 changes: 10 additions & 9 deletions YUViewLib/src/parser/ParserAnnexB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,23 @@ bool ParserAnnexB::runParsingOfFile(QString compressedFilePath)
return this->parseAnnexBFile(file);
}

QList<QTreeWidgetItem *> ParserAnnexB::stream_info_type::getStreamInfo()
vector<QTreeWidgetItem *> ParserAnnexB::stream_info_type::getStreamInfo()
{
QList<QTreeWidgetItem *> infoList;
infoList.append(new QTreeWidgetItem(QStringList() << "File size" << QString::number(file_size)));
vector<QTreeWidgetItem *> infoList;
infoList.push_back(
new QTreeWidgetItem(QStringList() << "File size" << QString::number(file_size)));
if (parsing)
{
infoList.append(new QTreeWidgetItem(QStringList() << "Number NAL units"
<< "Parsing..."));
infoList.append(new QTreeWidgetItem(QStringList() << "Number Frames"
<< "Parsing..."));
infoList.push_back(new QTreeWidgetItem(QStringList() << "Number NAL units"
<< "Parsing..."));
infoList.push_back(new QTreeWidgetItem(QStringList() << "Number Frames"
<< "Parsing..."));
}
else
{
infoList.append(
infoList.push_back(
new QTreeWidgetItem(QStringList() << "Number NAL units" << QString::number(nr_nal_units)));
infoList.append(
infoList.push_back(
new QTreeWidgetItem(QStringList() << "Number Frames" << QString::number(nr_frames)));
}

Expand Down
8 changes: 4 additions & 4 deletions YUViewLib/src/parser/ParserAnnexB.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class ParserAnnexB : public Parser
// Clear all knowledge about the bitstream.
void clearData();

QList<QTreeWidgetItem *> getStreamInfo() override { return stream_info.getStreamInfo(); }
unsigned int getNrStreams() override { return 1; }
QString getShortStreamDescription(int streamIndex) const override;
vector<QTreeWidgetItem *> getStreamInfo() override { return this->stream_info.getStreamInfo(); }
unsigned int getNrStreams() override { return 1; }
QString getShortStreamDescription(int streamIndex) const override;

/* Parse the NAL unit and what it contains
*
Expand Down Expand Up @@ -158,7 +158,7 @@ class ParserAnnexB : public Parser
// Save general information about the file here
struct stream_info_type
{
QList<QTreeWidgetItem *> getStreamInfo();
vector<QTreeWidgetItem *> getStreamInfo();

size_t file_size;
unsigned nr_nal_units{0};
Expand Down
3 changes: 2 additions & 1 deletion YUViewLib/src/ui/widgets/BitstreamAnalysisWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ void BitstreamAnalysisWidget::updateParserItemModel()
void BitstreamAnalysisWidget::updateStreamInfo()
{
this->ui.streamInfoTreeWidget->clear();
this->ui.streamInfoTreeWidget->addTopLevelItems(this->parser->getStreamInfo());
for (auto item : this->parser->getStreamInfo())
this->ui.streamInfoTreeWidget->addTopLevelItem(item);
this->ui.streamInfoTreeWidget->expandAll();

DEBUG_ANALYSIS("BitstreamAnalysisWidget::updateStreamInfo comboBox entries "
Expand Down

0 comments on commit 239e3a0

Please sign in to comment.