One user-space repair task per eligible HWE debug-diag / compile-deploy base ID: 320 admitted (C 218, C++ 97, build scripts 5), 1 skipped by the content filter. Each ships a public spec with a check-to-basis table, at least two defects with single-fix fixtures, a symptom-masking fixture and an alternative correct implementation. Claude re-checked all 320: structure, the HWE quality items and trace6 Docker calibration receipts against current digests (320/320 USABLE). Difficulty is unmeasured. Known follow-up: 212 tasks use 120 ad-hoc family names; the next batch maps them to the canonical list. The batch's 1,256-line progress log stays in its factory report and the 36-local branch batch15-hwe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.0 KiB
C++
65 lines
2.0 KiB
C++
#include "calibration.hpp"
|
|
#include <algorithm>
|
|
#include <utility>
|
|
namespace quant {
|
|
Decoder::Decoder(const Bank& bank) : bank_(bank) {
|
|
}
|
|
static bool sample_valid(int format, std::int32_t value) {
|
|
if (format == 0) {
|
|
return value >= 0 && value <= 255;
|
|
}
|
|
if (format == 1) {
|
|
return value >= -128 && value <= 127;
|
|
}
|
|
return format == 2;
|
|
}
|
|
Status Decoder::decode(std::uint32_t id, std::size_t channel_offset,
|
|
const std::vector<std::int32_t>& samples, Frame& output) const {
|
|
const Definition* definition = bank_.find(id);
|
|
if (definition == nullptr) {
|
|
return Status::Missing;
|
|
}
|
|
if (samples.size() > 64) {
|
|
return Status::Capacity;
|
|
}
|
|
for (std::int32_t sample : samples) {
|
|
if (!sample_valid(definition->format, sample)) {
|
|
return Status::Range;
|
|
}
|
|
}
|
|
Frame result;
|
|
result.revision = bank_.revision();
|
|
result.id = id;
|
|
std::size_t channel = channel_offset % definition->channels.size();
|
|
for (std::int32_t sample : samples) {
|
|
const Channel& calibration = definition->channels[channel];
|
|
std::int64_t difference = static_cast<std::int64_t>(sample) - 128;
|
|
double value = static_cast<double>(difference) * calibration.numerator;
|
|
value /= calibration.denominator;
|
|
result.values.push_back(value);
|
|
++channel;
|
|
if (channel == definition->channels.size()) {
|
|
channel = 0;
|
|
}
|
|
}
|
|
output = std::move(result);
|
|
return Status::Ok;
|
|
}
|
|
Summary Decoder::summarize(const Frame& frame) const {
|
|
Summary result;
|
|
result.count = frame.values.size();
|
|
if (frame.values.empty()) {
|
|
return result;
|
|
}
|
|
result.minimum = frame.values.front();
|
|
result.maximum = frame.values.front();
|
|
for (double value : frame.values) {
|
|
result.minimum = std::min(result.minimum, value);
|
|
result.maximum = std::max(result.maximum, value);
|
|
result.sum += value;
|
|
}
|
|
result.mean = result.sum / result.count;
|
|
return result;
|
|
}
|
|
}
|