lavc, lavfi: fix counting number of planes in AVBufferRef wrappers