daemon: AV_CODEC_FLAG_LOW_DELAY for H.264 — implements #11 part (2) #12
Reference in New Issue
Block a user
Delete Branch "noether/daemon-low-delay-h264"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Single-line change:
ctx->flags |= AV_CODEC_FLAG_LOW_DELAYbeforeavcodec_open2, gated oncodec_id == DAEDALUS_CODEC_H264.Forces libavcodec's H.264 decoder to emit pictures in decode order, one per
avcodec_send_packet, with no internal display-order reorder queue. Aligns daedalus's output ordering with what every V4L2 stateless decoder produces (cedrus, hantro, rkvdec — they hand CAPTURE buffers to libva in decode order, ffmpeg-vaapi reorders display upstream via per-surface POC).Closes the design loop from #11. Section (1) — concurrent in-flight requests — turned out to be unnecessary: with LOW_DELAY, each REQ_DECODE produces one CAPTURE completion immediately, and the existing synchronous chardev loop is already fast enough. Section (3) — libva-side reorder — was a misread, never needed (ffmpeg-vaapi handles display reorder upstream of us).
How
Inside
libavcodec/h264dec.c,AV_CODEC_FLAG_LOW_DELAYsetsh->low_delay = 1.h264_select_output_frame(inh264_picture.c) emits the just-decoded picture immediately instead of routing through the display-order DPB output queue.Reference-frame DPB management (short_ref / long_ref) is unaffected. B-frame decoding correctness preserved. Only the OUTPUT buffering is bypassed.
VP9 / AV1: flag not set — those codecs don't reorder, so it'd be a no-op but adds no value.
Verified
Field-test on higgs (Pi CM5, 6.18.29+rpt-rpi-2712), test daemon binary hot-swapped:
LIBVA_DRIVER_NAME=v4l2_request mpv --hwdec=vaapi-copy --frames=300 --no-config --no-audio --vo=null bbb_720p_h264.mp4--frames=300cap and exits cleanly withEnd of file.Firefox YouTube playback test pending — needs the bump in marfrit-packages first.
Wire compat
No protocol change.
DAEDALUS_PROTO_VERSIONstays at 0. Kernel module unchanged. This is a daedalus-v4l2 (userspace) package-only bump.Refs