Re: [PATCH] media: cedrus: skip invalid H.264 reference list entries

From: Paul Kocialkowski

Date: Thu Apr 09 2026 - 11:44:04 EST


Hi,

On Thu 09 Apr 26, 10:39, Nicolas Dufresne wrote:
> Hi,
>
> Le jeudi 09 avril 2026 à 16:31 +0200, Paul Kocialkowski a écrit :
> > I think it make sense yes, but it would be good to document it in the uAPI
> > document too.
>
> Basically, extend in the M2M decoder spec(s) on the existing documentation:
>
> V4L2_BUF_FLAG_ERROR:
> -
> When this flag is set, the buffer has been dequeued successfully, although
> the data might **have been corrupted**. This is recoverable, streaming may
> continue as normal and the buffer may be reused normally. Drivers set this
> flag when the VIDIOC_DQBUF ioctl is called.

Well this part is about v4l2 buffers in general, not just m2m/decoders.
But I guess this mechanism would make sense for more device classes than just
decoders, so we could indeed specify it there. Maybe with a sufficiently broad
wording.

But it would be good to also update the stateless decode document (and maybe
stateful too) where V4L2_BUF_FLAG_ERROR is already mentionned a few times.
We could indicate how this behavior related to reference frames there.

If we agree I could make a series with the following:
- Introduce a V4L2_H264_REF_MISSING 0xff define (same for HEVC)
- Update the v4l2_h264_reference doc to mention it
- Update the cedrus driver to error out (zero-size payload) when the L0/L1 index
is either V4L2_H264_REF_MISSING or an invalid index that doesn't exist in the
DPB (same for HEVC)
- Update the v4l2 buffer and stateless(+stateful) documents to mention that
buffers marked with V4L2_BUF_FLAG_ERROR may or may not contain usable (yet
corrupted) data depending on the payload size and how it relates to reference
frames.

Then we could later envision having a mechanism (hopefully common) to figure out
the best replacement to a given missing reference, which would allow cedrus
(and maybe other drivers too) to return a frame with incorrect data instead of
a zero-size payload error.

What do you think?

All the best,

Paul

--
Paul Kocialkowski,

Independent contractor - sys-base - https://www.sys-base.io/
Free software developer - https://www.paulk.fr/

Expert in multimedia, graphics and embedded hardware support with Linux.

Attachment: signature.asc
Description: PGP signature