h264: max_num_ref_frames fallback + libva-boundary instrumentation (#8) #9
Reference in New Issue
Block a user
Delete Branch "claude-noether/libva-v4l2-request-fourier:noether/h264-3-set-controls-bitstream-bug-8"
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?
Addresses the libva-side portion of #8.
Summary
src/h264.ch264_set_controls: two additions, no behavior change for the existing HW decoder paths.1.
max_num_ref_framesfallback — whenVAPicture->num_ref_framesis 0, count non-INVALID DPB entries inReferenceFrames[16]; if even that is 0, use a per-profile spec minimum (1 for baseline, 4 for main/high). Lenient HW decoders (rkvdec, hantro, rpi-hevc-dec) tolerated the 0; libavcodec-via-daedalus rejected every frame againstsps.max_num_ref_frames.2. Libva-boundary instrumentation — single
request_logdumping the raw VAAPI fields (seq_fields.value, pic_fields.value, num_ref_frames, bit_depth_, picture__in_mbs_minus1) at function entry. This is the disambiguation handle for fix-4 of the issue (PPS flags read 0 → was it ffmpeg-vaapi not populating, or daedalus_v4l2 wire-protocol corrupting?). One printf per H.264 frame; safe to leave in.What's intentionally NOT in this PR
Proposed fixes #1 and #2 from the issue body —
profile_idcandlevel_idcfromseq_fields.bits.*— are infeasible. Verified higgs libva 2.22.0-3/usr/include/va/va.h:3571-3622:VAPictureParameterBufferH264.seq_fields.bitscarrieschroma_format_idc,frame_mbs_only_flag,log2_max_frame_num_minus4,pic_order_cnt_type,log2_max_pic_order_cnt_lsb_minus4,delta_pic_order_always_zero_flag, plus a handful of binary flags — noprofile_idc, nolevel_idc, noconstraint_set*_flag. Same VAAPI-blindspot family as the HEVC SPS fields tracked infeedback_vaapi_blind_to_some_hevc_sps_fields.A real fix for those requires SPS-NAL parsing from
surface->source_data(parse the AnnexB prefix; ffmpeg-vaapi typically writes SPS+PPS+slice) OR a daedalus wire-protocol pass-through letting the client deliver the actual bitstream values. Both are operator-design calls — separate scoped commit. Full triage in #8 comment 1555.Test plan
vainfoagainst patched .so enumerates all 8 codec profiles. No init regression. Multi-device probe still wires rkvdec / rpi-hevc-dec / daedalus_v4l2 slots.max_num_ref_framesfallback fire. Operator-track — daedalus daemon is your branch; happy to run the smoke if you have a reference encoder + canned bitstream handy.Reviewer questions
request_logfine as the always-on path here, or should it gate on a debug-level (existing logs in h264.c are unconditional, so this matches the file's style)?max_num_ref_frameswhen even DPB count is 0: ConstrainedBaseline → 1, everything else → 4. Acceptable, or want different values?