- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
// Copyright 2026 Axel Waggershauser
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
#include <span>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
namespace ZXing {
|
|
|
|
enum class RSField
|
|
{
|
|
Aztec4,
|
|
Aztec6,
|
|
Aztec8,
|
|
Aztec10,
|
|
Aztec12,
|
|
DataMatrix,
|
|
MaxiCode,
|
|
PDF417,
|
|
QRCode
|
|
};
|
|
|
|
inline RSField GF2nAztec(int wordSize)
|
|
{
|
|
switch (wordSize) {
|
|
case 4: return RSField::Aztec4;
|
|
case 6: return RSField::Aztec6;
|
|
case 8: return RSField::Aztec8;
|
|
case 10: return RSField::Aztec10;
|
|
case 12: return RSField::Aztec12;
|
|
default: throw std::invalid_argument("Unsupported word size " + std::to_string(wordSize));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief ReedSolomonDecode fixes errors in a codeword containing both data and parity symbols.
|
|
*
|
|
* @param codeword data and error-correction/parity symbols; corrected in place on success
|
|
* @param numECC number of error-correction/parity symbols
|
|
* @param erasures positions of known erasures in the codeword
|
|
* @return optional unused error correction in the range [0, 1] if codeword errors could successfully be fixed (or there have not been
|
|
* any), std::nullopt otherwise
|
|
*/
|
|
std::optional<double> ReedSolomonDecode(RSField field, std::span<int> codeword, int numECC, std::span<const int> erasures = {});
|
|
|
|
std::optional<double> ReedSolomonDecode(RSField field, std::span<uint8_t> codeword, int numECC,
|
|
std::span<const int> erasures = {});
|
|
|
|
/**
|
|
* @brief ReedSolomonEncode generates error correction symbols for the given data symbols.
|
|
*
|
|
* @param field The Galois field to use for encoding.
|
|
* @param data The input data symbols.
|
|
* @param parity The output buffer for the generated error correction symbols.
|
|
*/
|
|
void ReedSolomonEncode(RSField field, std::span<const uint8_t> data, std::span<uint8_t> parity);
|
|
|
|
/// @brief ReedSolomonEncode replaces the last numECC symbols in codeword with parity symbols
|
|
void ReedSolomonEncode(RSField field, std::span<uint8_t> codeword, int numECC);
|
|
void ReedSolomonEncode(RSField field, std::span<int> codeword, int numECC);
|
|
|
|
} // ZXing
|