Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
loss.hpp
Go to the documentation of this file.
1#pragma once
2
6
7#include <cstdint>
8#include <optional>
9#include <span>
10#include <string_view>
11#include <vector>
12
13namespace pulp::interchange {
14
16struct LossEntry {
22 std::optional<Concept> degraded_to;
24 std::uint64_t count = 0;
26 std::vector<timeline::ItemId> owners;
28 std::string_view detail;
29};
30
38 public:
39 std::span<const LossEntry> entries() const noexcept { return entries_; }
40 bool empty() const noexcept { return entries_.empty(); }
41 const LossEntry* find(Concept concept_value) const noexcept;
42 void add(LossEntry entry);
43
44 private:
45 std::vector<LossEntry> entries_;
46};
47
49constexpr std::string_view export_level_id(ExportLevel level) noexcept {
50 switch (level) {
52 return "drop";
54 return "degrade";
56 return "roundtrip-only";
58 return "full";
59 }
60 return "drop";
61}
62
64constexpr std::string_view loss_class_id(LossClass loss_class) noexcept {
65 switch (loss_class) {
67 return "dropped";
69 return "degraded";
71 return "flattened";
73 return "approximated";
74 }
75 return "dropped";
76}
77
78} // namespace pulp::interchange
Everything one export costs the document.
Definition loss.hpp:37
const LossEntry * find(Concept concept_value) const noexcept
bool empty() const noexcept
Definition loss.hpp:40
void add(LossEntry entry)
std::span< const LossEntry > entries() const noexcept
Definition loss.hpp:39
Definition census.hpp:13
Concept
The format-neutral interchange concept vocabulary.
Definition concepts.hpp:13
@ Unknown
Definition concepts.hpp:14
ExportLevel
What a format's writer does with a concept the document uses.
Definition capability_tables.hpp:22
@ Degrade
Definition capability_tables.hpp:25
@ Drop
Definition capability_tables.hpp:23
@ RoundtripOnly
Definition capability_tables.hpp:24
@ Full
Definition capability_tables.hpp:26
constexpr std::string_view export_level_id(ExportLevel level) noexcept
Stable id for the lossy export level written into manifests.
Definition loss.hpp:49
LossClass
How a concept is lost when a format cannot carry it intact.
Definition capability_tables.hpp:30
@ Flattened
Definition capability_tables.hpp:33
@ Approximated
Definition capability_tables.hpp:34
@ Dropped
Definition capability_tables.hpp:31
@ Degraded
Definition capability_tables.hpp:32
constexpr std::string_view loss_class_id(LossClass loss_class) noexcept
Stable id for a loss class, for manifests written into an artifact.
Definition loss.hpp:64
One concept a document uses that an export cannot carry intact.
Definition loss.hpp:16
ExportLevel level
Drop or Degrade. Full and RoundtripOnly concepts never appear here.
Definition loss.hpp:19
std::optional< Concept > degraded_to
The concept a degrade lands on. Empty when the concept is dropped.
Definition loss.hpp:22
LossClass loss_class
Definition loss.hpp:20
std::uint64_t count
How many times the document uses the concept. Exact.
Definition loss.hpp:24
std::vector< timeline::ItemId > owners
A bounded sample of the affected items, per CensusLimits.
Definition loss.hpp:26
Concept concept_value
Definition loss.hpp:17
std::string_view detail
The format's own account of what is lost, from its capability table.
Definition loss.hpp:28