[x264-devel] Should x264_reference_update be modifying unreferenced frames?

Loren Merritt lorenm at u.washington.edu
Thu Aug 6 19:21:04 CEST 2009


On Thu, 6 Aug 2009, Gregory Hartman wrote:

> Andrew and I are examining the memory behavior of x264, and we've noticed
> something that appears to be quite odd. It seems that x264_reference_update
> occasionally writes to frames that have a reference count of 0.

Not a bug.
In nonthreaded mode, fenc was unreferenced by the previous frame's 
x264_encoder_frame_end, but x264 hasn't done much of anything since then, 
so all of fenc's contents are still valid.
In threaded mode, x264_reference_update runs before the previous frame's 
x264_encoder_frame_end, so fenc is still referenced. In this case, your 
assert only fails at the last frame of the stream, when we're not starting 
any new frames so fenc is some old value. But this being the last frame, 
there won't be any more uses of lowres[], so it doesn't matter what we do 
to it in any frame, valid or otherwise.
You might argue that it's more correct to do all such modifications 
before decrementing the reference counter, but then we couldn't use the 
same code for threaded and nonthreaded.

That said, we intend to remove the buffer swapping entirely, as part of an 
effort to reduce memory usage.

--Loren Merritt


More information about the x264-devel mailing list