lavfi: move buffer management function to a separate file.