Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear LdDecodeMetaData contents before reading a file #723

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tools/library/tbc/lddecodemetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,22 +355,34 @@ void LdDecodeMetaData::Field::write(JsonWriter &writer) const

LdDecodeMetaData::LdDecodeMetaData()
{
// Set defaults
isFirstFieldFirst = false;
clear();
}

// Read all metadata from a JSON file
bool LdDecodeMetaData::read(QString fileName)
// Reset the metadata to the defaults
void LdDecodeMetaData::clear()
{
// Default to the standard still-frame field order (of first field first)
isFirstFieldFirst = true;

// Reset the parameters to their defaults
videoParameters = VideoParameters();
lineParameters = LineParameters();
pcmAudioParameters = PcmAudioParameters();

fields.clear();
}

// Read all metadata from a JSON file
bool LdDecodeMetaData::read(QString fileName)
{
std::ifstream jsonFile(fileName.toStdString());
if (jsonFile.fail()) {
qCritical("Opening JSON input file failed: JSON file cannot be opened/does not exist");
return false;
}

clear();

JsonReader reader(jsonFile);

try {
Expand Down
1 change: 1 addition & 0 deletions tools/library/tbc/lddecodemetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class LdDecodeMetaData
LdDecodeMetaData(const LdDecodeMetaData &) = delete;
LdDecodeMetaData& operator=(const LdDecodeMetaData &) = delete;

void clear();
bool read(QString fileName);
bool write(QString fileName) const;
void readFields(JsonReader &reader);
Expand Down