71218b1b1f
Add FFmpeg-based encoder/decoder with SPS/PPS extradata, Annex-B output normalization, low-latency libx264 settings, and a round-trip unit test. Includes review hardening: cached SwsContext, bitrate-only rate control, std::byte/uin8_t cast helpers, and richer test assertions.
37 lines
942 B
C++
37 lines
942 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <variant>
|
|
|
|
namespace sc {
|
|
|
|
struct CodecError {
|
|
std::string message;
|
|
};
|
|
|
|
// C++20 does not provide std::expected. Use a variant-based result type so
|
|
// fallible codec operations do not rely on exceptions.
|
|
template <typename T> using CodecResult = std::variant<T, CodecError>;
|
|
|
|
template <typename T> constexpr bool is_codec_error(const CodecResult<T>& result) noexcept {
|
|
return std::holds_alternative<CodecError>(result);
|
|
}
|
|
|
|
template <typename T> T& codec_value(CodecResult<T>& result) {
|
|
return std::get<T>(result);
|
|
}
|
|
|
|
template <typename T> const T& codec_value(const CodecResult<T>& result) {
|
|
return std::get<T>(result);
|
|
}
|
|
|
|
template <typename T> CodecError& codec_error(CodecResult<T>& result) {
|
|
return std::get<CodecError>(result);
|
|
}
|
|
|
|
template <typename T> const CodecError& codec_error(const CodecResult<T>& result) {
|
|
return std::get<CodecError>(result);
|
|
}
|
|
|
|
} // namespace sc
|