3
votes

I am using libavcodec to decode a H264 stream. As the stream is received from network, sometimes NALs can be missing, resulting in artifacts in the frame. The frame is afterwards rendered with DirectShow.

When there is an error during decoding, it is signaled by libavcodec log callback. The problem is - some artifacts will persist though multiple frames and libavcodec won't signal artifacts for the frames following the broken one.

I would like to render only frames below certain artifacts level, while avoiding to show frame that are too "broken". Can an artifact level of a decoded picture be figured out through a libavcodec API, or I need to detect those artifacts by myself (in such case, are there any best practices?)?

1

1 Answers

0
votes

So far best method was to sum up artifacts count from libavcodec log string and decrease it with each frame, avoiding to show frames, when artifacts count is high. For instance:

libavcodec log: module h264, level 32: concealing 2480 DC, 2480 AC, 2480 MV errors in I frame

If artifacts threshold is set to 1000 and we decrease artifact level by 1000 at each frame, previous log string will make discard 2 frames.

This method is speculative (not a "clean" solution), but it works.