mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 06:16:55 -04:00
More metadata checks
This commit is contained in:
parent
c17ab2b44a
commit
0d7f08515a
@ -104,6 +104,28 @@ struct pcmaudio_metadata {
|
|||||||
// uint32_t samples_per_second;
|
// uint32_t samples_per_second;
|
||||||
|
|
||||||
auto operator<=>(pcmaudio_metadata const&) const = default;
|
auto operator<=>(pcmaudio_metadata const&) const = default;
|
||||||
|
|
||||||
|
bool check() const {
|
||||||
|
if (!(bits_per_sample == 8 || bits_per_sample == 16 ||
|
||||||
|
bits_per_sample == 20 || bits_per_sample == 24 ||
|
||||||
|
bits_per_sample == 32)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits_per_sample == 8 && bytes_per_sample != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits_per_sample == 16 && bytes_per_sample != 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bits_per_sample == 32 && bytes_per_sample != 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes_per_sample == 3 || bytes_per_sample == 4;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, pcmaudio_metadata const& m) {
|
std::ostream& operator<<(std::ostream& os, pcmaudio_metadata const& m) {
|
||||||
@ -292,6 +314,11 @@ bool pcmaudio_categorizer_<LoggerPolicy>::check_aiff(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!meta.check()) {
|
||||||
|
LOG_WARN << "[AIFF] " << path << ": metadata check failed: " << meta;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
meta_valid = true;
|
meta_valid = true;
|
||||||
|
|
||||||
LOG_TRACE << "[AIFF] " << path << ": meta=" << meta;
|
LOG_TRACE << "[AIFF] " << path << ": meta=" << meta;
|
||||||
@ -505,6 +532,11 @@ bool pcmaudio_categorizer_<LoggerPolicy>::check_caf(
|
|||||||
|
|
||||||
assert(meta.bytes_per_sample > 0);
|
assert(meta.bytes_per_sample > 0);
|
||||||
|
|
||||||
|
if (!meta.check()) {
|
||||||
|
LOG_WARN << "[CAF] " << path << ": metadata check failed: " << meta;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
meta_valid = true;
|
meta_valid = true;
|
||||||
|
|
||||||
LOG_TRACE << "[CAF] " << path << ": meta=" << meta;
|
LOG_TRACE << "[CAF] " << path << ": meta=" << meta;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user