libgpac
Documentation of the core library of GPAC
Hash and Compression

Data hashing, integrity and generic compression. More...

+ Collaboration diagram for Hash and Compression:

Macros

#define GF_SHA1_DIGEST_SIZE   20
 

Functions

u32 gf_crc_32 (const u8 *data, u32 size)
 CRC32 compute. More...
 
GF_Err gf_gz_compress_payload (u8 **data, u32 data_len, u32 *out_size)
 
GF_Err gf_gz_compress_payload_ex (u8 **data, u32 data_len, u32 *out_size, u8 data_offset, Bool skip_if_larger, u8 **out_comp_data, Bool use_gz)
 
GF_Err gf_gz_decompress_payload (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size)
 
GF_Err gf_gz_decompress_payload_ex (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size, Bool use_gz)
 
GF_Err gf_lz_compress_payload (u8 **data, u32 data_len, u32 *out_size)
 
GF_Err gf_lz_decompress_payload (u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size)
 
u64 gf_gzseek (void *file, u64 offset, int whence)
 
u64 gf_gztell (void *file)
 
s64 gf_gzrewind (void *file)
 
int gf_gzeof (void *file)
 
int gf_gzclose (void *file)
 
const char * gf_gzerror (void *file, int *errnum)
 
void gf_gzclearerr (void *file)
 
void * gf_gzopen (const char *path, const char *mode)
 
int gf_gzread (void *file, void *buf, unsigned len)
 
int gf_gzdirect (void *file)
 
int gf_gzgetc (void *file)
 
char * gf_gzgets (void *file, char *buf, int len)
 
GF_SHA1Context * gf_sha1_starts ()
 
void gf_sha1_update (GF_SHA1Context *ctx, u8 *input, u32 length)
 
void gf_sha1_finish (GF_SHA1Context *ctx, u8 digest[GF_SHA1_DIGEST_SIZE])
 
GF_Err gf_sha1_file (const char *filename, u8 digest[GF_SHA1_DIGEST_SIZE])
 
GF_Err gf_sha1_file_ptr (FILE *file, u8 digest[GF_SHA1_DIGEST_SIZE])
 
void gf_sha1_csum (u8 *buf, u32 buflen, u8 digest[GF_SHA1_DIGEST_SIZE])
 

Detailed Description

This section documents misc data functions such as integrity and parsing such as SHA-1 hashing CRC checksum, 128 bit ID parsing...

Macro Definition Documentation

◆ GF_SHA1_DIGEST_SIZE

#define GF_SHA1_DIGEST_SIZE   20

SHA1 message size

Function Documentation

◆ gf_crc_32()

u32 gf_crc_32 ( const u8 data,
u32  size 
)

Computes the CRC32 value of a buffer.

Parameters
databuffer
sizebuffer size
Returns
computed CRC32
+ Here is the caller graph for this function:

◆ gf_gz_compress_payload()

GF_Err gf_gz_compress_payload ( u8 **  data,
u32  data_len,
u32 out_size 
)

Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.

Parameters
datapointer to the data buffer to be compressed
data_lenlength of the data buffer to be compressed
out_sizepointer for output buffer size
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gz_compress_payload_ex()

GF_Err gf_gz_compress_payload_ex ( u8 **  data,
u32  data_len,
u32 out_size,
u8  data_offset,
Bool  skip_if_larger,
u8 **  out_comp_data,
Bool  use_gz 
)

Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.

Parameters
datapointer to the data buffer to be compressed
data_lenlength of the data buffer to be compressed
out_sizepointer for output buffer size
data_offsetoffset in source buffer - the input payload size is data_len - data_offset
skip_if_largerif GF_TRUE, will not override source buffer if compressed version is larger than input data
out_comp_dataif not NULL, the compressed result is set in this pointer rather than doing inplace compression
use_gzif true, GZ header is present
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gz_decompress_payload()

GF_Err gf_gz_decompress_payload ( u8 data,
u32  data_len,
u8 **  uncompressed_data,
u32 out_size 
)

Decompresses a data buffer using zlib/inflate.

Parameters
datadata buffer to be decompressed
data_lenlength of the data buffer to be decompressed
uncompressed_datapointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer.
out_sizesize of the uncompressed buffer
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gz_decompress_payload_ex()

GF_Err gf_gz_decompress_payload_ex ( u8 data,
u32  data_len,
u8 **  uncompressed_data,
u32 out_size,
Bool  use_gz 
)

Decompresses a data buffer using zlib/inflate.

Parameters
datadata buffer to be decompressed
data_lenlength of the data buffer to be decompressed
uncompressed_datapointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer.
out_sizesize of the uncompressed buffer
use_gzif true, gz header is present
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_lz_compress_payload()

GF_Err gf_lz_compress_payload ( u8 **  data,
u32  data_len,
u32 out_size 
)

Compresses a data buffer in place using LZMA. Buffer may be reallocated in the process.

Parameters
datapointer to the data buffer to be compressed
data_lenlength of the data buffer to be compressed
out_sizepointer for output buffer size
Returns
error if any
+ Here is the caller graph for this function:

◆ gf_lz_decompress_payload()

GF_Err gf_lz_decompress_payload ( u8 data,
u32  data_len,
u8 **  uncompressed_data,
u32 out_size 
)

Decompresses a data buffer using LZMA.

Parameters
datadata buffer to be decompressed
data_lenlength of the data buffer to be decompressed
uncompressed_datapointer to the uncompressed data buffer. It is the responsibility of the caller to free this buffer.
out_sizesize of the uncompressed buffer
Returns
error if any
+ Here is the caller graph for this function:

◆ gf_gzseek()

u64 gf_gzseek ( void *  file,
u64  offset,
int  whence 
)

Wrapper around gzseek, same parameters

Parameters
filetarget gzfile
offsetoffset in file
whencesame as gzseek
Returns
same as gzseek
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gztell()

u64 gf_gztell ( void *  file)

Wrapper around gf_gztell, same parameters

Parameters
filetarget gzfile
Returns
postion in file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzrewind()

s64 gf_gzrewind ( void *  file)

Wrapper around gzrewind, same parameters

Parameters
filetarget gzfile
Returns
same as gzrewind
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzeof()

int gf_gzeof ( void *  file)

Wrapper around gzeof, same parameters

Parameters
filetarget gzfile
Returns
same as gzeof
+ Here is the caller graph for this function:

◆ gf_gzclose()

int gf_gzclose ( void *  file)

Wrapper around gzclose, same parameters

Parameters
filetarget gzfile
Returns
same as gzclose
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzerror()

const char* gf_gzerror ( void *  file,
int *  errnum 
)

Wrapper around gzerror, same parameters

Parameters
filetarget gzfile
errnumsame as gzerror
Returns
same as gzerror

◆ gf_gzclearerr()

void gf_gzclearerr ( void *  file)

Wrapper around gzclearerr, same parameters

Parameters
filetarget gzfile

◆ gf_gzopen()

void* gf_gzopen ( const char *  path,
const char *  mode 
)

Wrapper around gzopen, same parameters

Parameters
paththe file name to open
modethe file open mode
Returns
open file
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzread()

int gf_gzread ( void *  file,
void *  buf,
unsigned  len 
)

Wrapper around gzread, same parameters

Parameters
filetarget gzfile
bufsame as gzread
lensame as gzread
Returns
same as gzread
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzdirect()

int gf_gzdirect ( void *  file)

Wrapper around gzdirect, same parameters

Parameters
filetarget gzfile
Returns
same as gzdirect

◆ gf_gzgetc()

int gf_gzgetc ( void *  file)

Wrapper around gzgetc, same parameters

Parameters
filetarget gzfile
Returns
same as gzgetc
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_gzgets()

char* gf_gzgets ( void *  file,
char *  buf,
int  len 
)

Wrapper around gzgets, same parameters

Parameters
filetarget gzfile
bufsame as gzread
lensame as gzread
Returns
same as gzgets
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sha1_starts()

GF_SHA1Context* gf_sha1_starts ( )

create SHA-1 context

Returns
the SHA1 context
+ Here is the caller graph for this function:

◆ gf_sha1_update()

void gf_sha1_update ( GF_SHA1Context *  ctx,
u8 input,
u32  length 
)

adds byte to the SHA-1 context

Parameters
ctxthe target SHA1 context
inputdata to hash
lengthsize of data in bytes
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sha1_finish()

void gf_sha1_finish ( GF_SHA1Context *  ctx,
u8  digest[GF_SHA1_DIGEST_SIZE] 
)

generates SHA-1 of all bytes ingested

Parameters
ctxthe target SHA1 context
digestbuffer to store message digest
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sha1_file()

GF_Err gf_sha1_file ( const char *  filename,
u8  digest[GF_SHA1_DIGEST_SIZE] 
)

gets SHA1 message digest of a file

Parameters
filenamename of file to hash
digestbuffer to store message digest
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sha1_file_ptr()

GF_Err gf_sha1_file_ptr ( FILE *  file,
u8  digest[GF_SHA1_DIGEST_SIZE] 
)

gets SHA1 message digest of a opened file

Parameters
filehandle to open file
digestbuffer to store message digest
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sha1_csum()

void gf_sha1_csum ( u8 buf,
u32  buflen,
u8  digest[GF_SHA1_DIGEST_SIZE] 
)

gets SHA-1 of input buffer

Parameters
bufinput buffer to hash
buflensize of input buffer in bytes
digestbuffer to store message digest
+ Here is the call graph for this function:
+ Here is the caller graph for this function: