105{
106 try {
107 const auto&
pixels = std::get<std::vector<uint8_t>>(data);
108 const size_t frame_bytes = container->get_frame_byte_size();
109
110 if (frame_bytes == 0 ||
pixels.size() % frame_bytes != 0) {
111 error<std::invalid_argument>(Journal::Component::Kriya,
112 Journal::Context::CoroutineScheduling,
113 std::source_location::current(),
114 "Pixel data of {} bytes is not a whole number of {} byte frames",
115 pixels.size(), frame_bytes);
116 }
117
119 container->append_frame(std::span<const uint8_t>(
pixels.data() +
offset, frame_bytes));
120 }
121
122 } catch (const std::bad_variant_access& e) {
123 error_rethrow(Journal::Component::Kriya,
124 Journal::Context::CoroutineScheduling,
125 std::source_location::current(),
126 "Data type mismatch when writing to video container: {}",
127 e.what());
128 } catch (const std::exception& e) {
130 Journal::Context::CoroutineScheduling,
131 std::source_location::current(),
132 "Error writing to video container: {}",
133 e.what());
134 }
135}
const std::vector< float > * pixels
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.