fixes + refactoring + plan
This commit is contained in:
+31
-63
@@ -60,29 +60,6 @@ inline void pack_block(
|
||||
w[3] = (y4 & 0x3FFu) | ((p45.cr & 0x3FFu) << 10) | ((y5 & 0x3FFu) << 20);
|
||||
}
|
||||
|
||||
// Write one horizontal line of bars.
|
||||
// `stride` is the line size in bytes as returned by MXL (configInfo.discrete.sliceSizes[0]).
|
||||
// Bytes beyond the active pixels are already zeroed by the mmap, so no explicit padding needed.
|
||||
inline void write_bar_line(uint8_t* line, int width, uint32_t /*stride*/)
|
||||
{
|
||||
const int n = static_cast<int>(SMPTE_BARS.size());
|
||||
const int blocks = width / 6; // one V210 block = 6 pixels = 16 bytes
|
||||
|
||||
for (int b = 0; b < blocks; b++) {
|
||||
int x = b * 6;
|
||||
auto color = [&](int px) -> const Color& {
|
||||
return SMPTE_BARS[static_cast<size_t>(px * n / width)];
|
||||
};
|
||||
const Color& c01 = color(x);
|
||||
const Color& c23 = color(x + 2);
|
||||
const Color& c45 = color(x + 4);
|
||||
pack_block(line + b * 16,
|
||||
c01, c01.y, color(x+1).y,
|
||||
c23, c23.y, color(x+3).y,
|
||||
c45, c45.y, color(x+5).y);
|
||||
}
|
||||
}
|
||||
|
||||
// Write one horizontal line of an arbitrary bar palette.
|
||||
template<std::size_t N>
|
||||
inline void write_palette_line(uint8_t* line, int width, const std::array<Color, N>& palette)
|
||||
@@ -140,12 +117,6 @@ inline void fill_white(uint8_t* buf, int width, int height, uint32_t stride)
|
||||
fill_solid(buf, width, height, stride, {940, 512, 512});
|
||||
}
|
||||
|
||||
// Kept for backward compatibility.
|
||||
inline void fill_frame(uint8_t* buf, int width, int height, uint32_t stride)
|
||||
{
|
||||
fill_colorbars(buf, width, height, stride);
|
||||
}
|
||||
|
||||
inline void UYVYtoV210(uint8_t* src_buf, uint8_t* dst_buf, int width, int height, uint32_t src_stride, uint32_t dst_stride)
|
||||
{
|
||||
const uint8_t* src = src_buf;
|
||||
@@ -160,49 +131,46 @@ inline void UYVYtoV210(uint8_t* src_buf, uint8_t* dst_buf, int width, int height
|
||||
// mp[8]=U2, mp[9]=Y4, mp[10]=V2, mp[11]=Y5
|
||||
|
||||
dmf::v210::pack_block(dst + b * 16,
|
||||
{0, (uint16_t)(mp[0]<<2), (uint16_t)(mp[2]<<2)}, (uint16_t)(mp[1]<<2), (uint16_t)(mp[3]<<2),
|
||||
{0, (uint16_t)(mp[4]<<2), (uint16_t)(mp[6]<<2)}, (uint16_t)(mp[5]<<2), (uint16_t)(mp[7]<<2),
|
||||
{0, (uint16_t)(mp[8]<<2), (uint16_t)(mp[10]<<2)}, (uint16_t)(mp[9]<<2), (uint16_t)(mp[11]<<2)
|
||||
);
|
||||
{0, static_cast<uint16_t>(mp[0]<<2), static_cast<uint16_t>(mp[2]<<2)},
|
||||
static_cast<uint16_t>(mp[1]<<2), static_cast<uint16_t>(mp[3]<<2),
|
||||
{0, static_cast<uint16_t>(mp[4]<<2), static_cast<uint16_t>(mp[6]<<2)},
|
||||
static_cast<uint16_t>(mp[5]<<2), static_cast<uint16_t>(mp[7]<<2),
|
||||
{0, static_cast<uint16_t>(mp[8]<<2), static_cast<uint16_t>(mp[10]<<2)},
|
||||
static_cast<uint16_t>(mp[9]<<2), static_cast<uint16_t>(mp[11]<<2));
|
||||
}
|
||||
src += src_stride;
|
||||
dst += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
inline void YUV422P10toV210(const uint16_t* y, const uint16_t* u, const uint16_t* v,
|
||||
inline void YUV422P10toV210(
|
||||
const uint16_t* y, const uint16_t* u, const uint16_t* v,
|
||||
uint8_t* dst, int width, int height,
|
||||
int y_stride, int u_stride, int v_stride, // bytes between rows
|
||||
int y_stride, int u_stride, int v_stride,
|
||||
uint32_t dst_stride)
|
||||
{
|
||||
for (int row = 0; row < height; row++) {
|
||||
const uint16_t* y_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(y) + row * y_stride
|
||||
);
|
||||
const uint16_t* u_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(u) + row * u_stride
|
||||
);
|
||||
const uint16_t* v_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(v) + row * v_stride
|
||||
);
|
||||
|
||||
uint8_t* dst_row = dst + static_cast<ptrdiff_t>(row) * dst_stride;
|
||||
const int blocks = width / 6;
|
||||
|
||||
for (int b = 0; b < blocks; b++) {
|
||||
int x = b * 6;
|
||||
const uint16_t cb0 = u_row[x/2], cb1 = u_row[x/2+1], cb2 = u_row[x/2+2];
|
||||
const uint16_t cr0 = v_row[x/2], cr1 = v_row[x/2+1], cr2 = v_row[x/2+2];
|
||||
const uint16_t y0 = y_row[x], y1 = y_row[x+1], y2 = y_row[x+2];
|
||||
const uint16_t y3 = y_row[x+3], y4 = y_row[x+4], y5 = y_row[x+5];
|
||||
|
||||
auto* w = reinterpret_cast<uint32_t*>(dst_row + b * 16);
|
||||
w[0] = (cb0 & 0x3FFu) | ((y0 & 0x3FFu) << 10) | ((cr0 & 0x3FFu) << 20);
|
||||
w[1] = (y1 & 0x3FFu) | ((cb1 & 0x3FFu) << 10) | ((y2 & 0x3FFu) << 20);
|
||||
w[2] = (cr1 & 0x3FFu) | ((y3 & 0x3FFu) << 10) | ((cb2 & 0x3FFu) << 20);
|
||||
w[3] = (y4 & 0x3FFu) | ((cr2 & 0x3FFu) << 10) | ((y5 & 0x3FFu) << 20);
|
||||
}
|
||||
{
|
||||
for (int row = 0; row < height; row++) {
|
||||
const uint16_t* y_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(y) + row * y_stride);
|
||||
const uint16_t* u_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(u) + row * u_stride);
|
||||
const uint16_t* v_row = reinterpret_cast<const uint16_t*>(
|
||||
reinterpret_cast<const uint8_t*>(v) + row * v_stride);
|
||||
uint8_t* dst_row = dst + static_cast<ptrdiff_t>(row) * dst_stride;
|
||||
const int blocks = width / 6;
|
||||
for (int b = 0; b < blocks; b++) {
|
||||
const int x = b * 6;
|
||||
const uint16_t cb0 = u_row[x/2], cb1 = u_row[x/2+1], cb2 = u_row[x/2+2];
|
||||
const uint16_t cr0 = v_row[x/2], cr1 = v_row[x/2+1], cr2 = v_row[x/2+2];
|
||||
const uint16_t y0 = y_row[x], y1 = y_row[x+1], y2 = y_row[x+2];
|
||||
const uint16_t y3 = y_row[x+3], y4 = y_row[x+4], y5 = y_row[x+5];
|
||||
auto* w = reinterpret_cast<uint32_t*>(dst_row + b * 16);
|
||||
w[0] = (cb0 & 0x3FFu) | ((y0 & 0x3FFu) << 10) | ((cr0 & 0x3FFu) << 20);
|
||||
w[1] = (y1 & 0x3FFu) | ((cb1 & 0x3FFu) << 10) | ((y2 & 0x3FFu) << 20);
|
||||
w[2] = (cr1 & 0x3FFu) | ((y3 & 0x3FFu) << 10) | ((cb2 & 0x3FFu) << 20);
|
||||
w[3] = (y4 & 0x3FFu) | ((cr2 & 0x3FFu) << 10) | ((y5 & 0x3FFu) << 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace dmf::v210
|
||||
|
||||
Reference in New Issue
Block a user