ccv

A Modern Computer Vision Library

View the Project on GitHub liuliu/ccv

lib/ccv_memory.c

ccv_dense_matrix_renew

ccv_dense_matrix_renew(ccv_dense_matrix_t *x, int rows, int cols, int types, int prefer_type, uint64_t sig)

Check the input matrix, if it is the allowed type, return it, otherwise create one with prefer_type.

return: The returned matrix object that satisfies the requirements.

ccv_dense_matrix_new

ccv_dense_matrix_new(int rows, int cols, int type, void *data, uint64_t sig)

Create a dense matrix with rows, cols, and type.

return: The newly created matrix object.

ccv_dense_matrix

ccv_dense_matrix_t ccv_dense_matrix(int rows, int cols, int type, void *data, uint64_t sig)

This method will return a dense matrix allocated on stack, with a data pointer to a custom memory region.

return: static matrix structs.

ccv_make_matrix_mutable

void ccv_make_matrix_mutable(ccv_matrix_t *mat)

Mark the current matrix as mutable. Under the hood, it will set matrix signature to 0, and mark the matrix as non-collectable.

ccv_make_matrix_immutable

void ccv_make_matrix_immutable(ccv_matrix_t *mat)

Mark the current matrix as immutable. Under the hood, it will generate a signature for the matrix, and mark it as non-collectable. For the convention, if the matrix is marked as immutable, you shouldn’t change the content of the matrix, otherwise it will cause surprising behavior. If you want to change the content of the matrix, mark it as mutable first.

ccv_sparse_matrix_new

ccv_sparse_matrix_new(int rows, int cols, int type, int major, uint64_t sig)

Create a sparse matrix. ccv uses a double hash table for memory-efficient and quick-access sparse matrix.

return: The newly created sparse matrix object.

ccv_matrix_free_immediately

void ccv_matrix_free_immediately(ccv_matrix_t *mat)

Skip garbage-collecting process and free the matrix immediately.

ccv_matrix_free

void ccv_matrix_free(ccv_matrix_t *mat)

In principal, you should always use this method to free a matrix. If you enabled cache in ccv, this method won’t immediately free up memory space of the matrix. Instead, it will push the matrix to a cache if applicable so that if you want to create the same matrix again, ccv can shortcut the required matrix/image processing and return it from the cache.

ccv_cache_generate_signature

uint64_t ccv_cache_generate_signature(const char *msg, int len, uint64_t sig_start,...)

Generate a matrix signature based on input message and other signatures. This is the core method for ccv cache. In short, ccv does a given image processing by first generating an appropriate signature for that operation. It requires 1). an operation-specific message, which can be generated by concatenate the operation name and parameters. 2). the signature of input matrix(es). After that, ccv will look-up matrix in cache with the newly generated signature. If it exists, ccv will return that matrix and skip the whole operation.

return: The generated 64-bit signature.

ccv_drain_cache

void ccv_drain_cache(void)

Drain up the cache.

ccv_disable_cache

void ccv_disable_cache(void)

Drain up and disable the application-wide cache.

ccv_enable_default_cache

void ccv_enable_default_cache(void)

Enable a application-wide cache for ccv at default memory bound (64MiB).

ccv_enable_cache

void ccv_enable_cache(size_t size)

Enable a application-wide cache for ccv. The cache is bounded by given memory size.

‹  back 

comments powered by Disqus