ffmpeg: stricter refcount check in unref_buffer()