Files
spoopyghosty0--frameport/native/venc/convert.h
T
spoopyghosty0 0ae754fa5d Live view: hardware H.264 encoder (fp_venc), x264 stays as fallback
native/venc/fp_venc: own clean-room driver of the Frame's iris encoder (V4L2 stateful encoder interface, written from
native/venc/SPEC.md = kernel docs + values measured on the Frame). Reads SteamVR's headset-view webcam, box-scales and
converts RGB24 to NV12 (NEON, bit-identical scalar reference), CBR H.264 with SPS/PPS on every IDR, one frame per slot
of an even fraction of the panel rate read through DRM (96 Hz -> 32 fps). stdin "k" = keyframe, EOF = stop;
--probe/--selftest. Static freestanding aarch64 binary in artifacts/linux-arm64-bin (reproducible).

livestream: the script probes fp_venc and pipes it into ffmpeg (-c:v copy + AAC), else the old x264 30 fps path; the
helper is synced to ~/.local/share/frameport/bin by sha256 at stream start (no agent change); a new viewer asks for a
keyframe and waits for it; the status line shows the encoder and fps. Tests: hardware/fallback script branches,
keyframe-on-join, helper sync; tests/test_venc.py compares convert.c with a Python reference (native marker).
Not yet run on the device.
2026-10-07 17:50:55 -04:00

28 lines
1.4 KiB
C

/* RGB24 -> NV12 picture converter for fp_venc (pure computation, no syscalls). See native/venc/SPEC.md "Converter".
* Built for aarch64 (NEON + scalar) and for x86_64 (scalar only; the host unit test loads it with ctypes). */
#ifndef FP_VENC_CONVERT_H
#define FP_VENC_CONVERT_H
#include <stdint.h>
#include <stddef.h>
/* Output size: height = min(max_h, src_h) (max_h <= 0 = src_h), width keeps the aspect; both rounded down to even,
* both >= 2. */
void fp_out_size(int src_w, int src_h, int max_h, int *out_w, int *out_h);
/* Bytes of scratch memory fp_convert/fp_convert_scalar need for these sizes. */
size_t fp_scratch_size(int src_w, int src_h, int out_w, int out_h);
/* RGB24 (R,G,B bytes) -> NV12 (BT.709, limited range): box-average downscale to out_w x out_h (out_w <= src_w,
* out_h <= src_h, both even), then out_w x out_h luma bytes and out_w x out_h/2 interleaved Cb,Cr bytes. */
void fp_convert_scalar(const uint8_t *src, int src_w, int src_h, int src_stride,
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
int out_w, int out_h, void *scratch);
/* Same result, byte for byte; NEON on aarch64, fp_convert_scalar elsewhere. */
void fp_convert(const uint8_t *src, int src_w, int src_h, int src_stride,
uint8_t *y, int y_stride, uint8_t *uv, int uv_stride,
int out_w, int out_h, void *scratch);
#endif