xine-lib: xine-lib-1.2.13/src/xine-utils/xine_buffer.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Functions
xine_buffer.c File Reference
`#include <stdlib.h>`
`#include <stdio.h>`
`#include <string.h>`
`#include <inttypes.h>`
`#include <xine/xineutils.h>`

## Data Structures
struct | xine_buffer_header_t

## Macros
#define | LOG_MODULE "xine_buffer"
#define | LOG_VERBOSE
#define | CHECKS
#define | XINE_BUFFER_HEADER_SIZE 9
#define | XINE_BUFFER_MAGIC 42
#define | CHECK_MAGIC(x, r)
#define | GET_HEADER(x) ((xine_buffer_header_t*)(((uint8_t*)x)-XINE_BUFFER_HEADER_SIZE))
#define | GET_HEADER_CONST(x) ((const xine_buffer_header_t *)(((const uint8_t *)x)-XINE_BUFFER_HEADER_SIZE))
#define | GROW_TO(buf, to_size)
#define | xine_buffer_free(buf) buf=_xine_buffer_free(buf)
#define | xine_buffer_copyin(buf, i, data, len) buf=_xine_buffer_copyin(buf,i,data,len)
#define | xine_buffer_set(buf, i, b, len) buf=_xine_buffer_set(buf,i,b,len)
#define | xine_buffer_strcat(buf, data) buf=_xine_buffer_strcat(buf,data)
#define | xine_buffer_strcpy(buf, index, data) buf=_xine_buffer_strcpy(buf,index,data)
#define | xine_buffer_ensure_size(buf, data) buf=_xine_buffer_ensure_size(buf,data)

## Functions
void * | xine_buffer_init (int chunk_size)
void * | _xine_buffer_free (void *buf)
void * | xine_buffer_dup (const void *buf)
void * | _xine_buffer_copyin (void *buf, int index, const void *data, int len)
void | xine_buffer_copyout (const void *buf, int index, void *data, int len)
void * | _xine_buffer_set (void *buf, int index, uint8_t b, int len)
void * | _xine_buffer_strcat (void *buf, const char *data)
void * | _xine_buffer_strcpy (void *buf, int index, const char *data)
char * | xine_buffer_strchr (const void *buf, int ch)
int | xine_buffer_get_size (const void *buf)
void * | _xine_buffer_ensure_size (void *buf, int size)

## Macro Definition Documentation

## ◆ CHECK_MAGIC

#define CHECK_MAGIC | ( |  | x,
|  |  | r )

Value:
do { \
_x_assert ( *(((const uint8_t *)x)-1)==XINE_BUFFER_MAGIC ); \
if (*(((const uint8_t *)x)-1) != XINE_BUFFER_MAGIC) { \
printf("xine_buffer: FATAL: xine_buffer_header not recognized!\n"); \
return r; \
} \
} while (0)
XINE_BUFFER_MAGIC
#define XINE_BUFFER_MAGIC
Definition xine_buffer.c:83

Referenced by _xine_buffer_copyin(), _xine_buffer_ensure_size(), _xine_buffer_free(), _xine_buffer_set(), _xine_buffer_strcpy(), xine_buffer_copyout(), xine_buffer_dup(), xine_buffer_get_size(), and xine_buffer_strchr().

## ◆ CHECKS

#define CHECKS

## ◆ GET_HEADER

#define GET_HEADER | ( |  | x | ) | ((xine_buffer_header_t*)(((uint8_t*)x)-XINE_BUFFER_HEADER_SIZE))

## ◆ GET_HEADER_CONST

#define GET_HEADER_CONST | ( |  | x | ) | ((const xine_buffer_header_t *)(((const uint8_t *)x)-XINE_BUFFER_HEADER_SIZE))

Referenced by xine_buffer_copyout(), xine_buffer_dup(), and xine_buffer_get_size().

## ◆ GROW_TO

#define GROW_TO | ( |  | buf,
|  |  | to_size )

Value:
if (GET_HEADER_CONST(buf)->size < (to_size)) { \
int new_size = (to_size) + GET_HEADER_CONST(buf)->chunk_size - \
((to_size) % GET_HEADER_CONST(buf)->chunk_size);\
\
buf = ((uint8_t*)realloc(((uint8_t*)buf)-XINE_BUFFER_HEADER_SIZE, new_size+XINE_BUFFER_HEADER_SIZE)) + XINE_BUFFER_HEADER_SIZE;\
GET_HEADER(buf)->size=new_size; }
XINE_BUFFER_HEADER_SIZE
#define XINE_BUFFER_HEADER_SIZE
Definition xine_buffer.c:82
GET_HEADER_CONST
#define GET_HEADER_CONST(x)
Definition xine_buffer.c:112

Referenced by _xine_buffer_copyin(), _xine_buffer_ensure_size(), _xine_buffer_set(), and _xine_buffer_strcpy().

## ◆ LOG_MODULE

#define LOG_MODULE "xine_buffer"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ xine_buffer_copyin

#define xine_buffer_copyin | ( |  | buf,
|  |  | i,
|  |  | data,
|  |  | len ) buf=_xine_buffer_copyin(buf,i,data,len)

Referenced by filter(), image_decode_data(), jpeg_decode_data(), png_decode_data(), rtsp_session_start(), sdpplin_parse(), sdpplin_parse_stream(), and select_mlti_data().

## ◆ xine_buffer_ensure_size

#define xine_buffer_ensure_size | ( |  | buf,
|  |  | data ) buf=_xine_buffer_ensure_size(buf,data)

Referenced by real_get_rdt_chunk(), and real_setup_and_get_header().

## ◆ xine_buffer_free

#define xine_buffer_free | ( |  | buf | ) | buf=_xine_buffer_free(buf)

Referenced by deinterlace_class_dispose(), image_dispose(), jpeg_dispose(), png_dispose(), real_parse_sdp(), real_setup_and_get_header(), rtsp_session_end(), rtsp_session_start(), sdpplin_parse(), and sdpplin_parse_stream().

## ◆ XINE_BUFFER_HEADER_SIZE

#define XINE_BUFFER_HEADER_SIZE 9

Referenced by _xine_buffer_free(), xine_buffer_dup(), and xine_buffer_init().

## ◆ XINE_BUFFER_MAGIC

#define XINE_BUFFER_MAGIC 42

Referenced by xine_buffer_init().

## ◆ xine_buffer_set

#define xine_buffer_set | ( |  | buf,
|  |  | i,
|  |  | b,
|  |  | len ) buf=_xine_buffer_set(buf,i,b,len)

## ◆ xine_buffer_strcat

#define xine_buffer_strcat | ( |  | buf,
|  |  | data ) buf=_xine_buffer_strcat(buf,data)

Referenced by deinterlace_init_plugin(), and real_parse_sdp().

## ◆ xine_buffer_strcpy

#define xine_buffer_strcpy | ( |  | buf,
|  |  | index,
|  |  | data ) buf=_xine_buffer_strcpy(buf,index,data)

## Function Documentation

## ◆ _xine_buffer_copyin()

void * _xine_buffer_copyin | ( | void * | buf,
|  | int | index,
|  | const void * | data,
|  | int | len )

References CHECK_MAGIC, GROW_TO, lprintf, NULL, and xine_fast_memcpy.

## ◆ _xine_buffer_ensure_size()

void * _xine_buffer_ensure_size | ( | void * | buf,
|  | int | size )

References CHECK_MAGIC, GROW_TO, and lprintf.

## ◆ _xine_buffer_free()

void * _xine_buffer_free | ( | void * | buf | ) |

References CHECK_MAGIC, lprintf, NULL, and XINE_BUFFER_HEADER_SIZE.

## ◆ _xine_buffer_set()

void * _xine_buffer_set | ( | void * | buf,
|  | int | index,
|  | uint8_t | b,
|  | int | len )

References CHECK_MAGIC, GROW_TO, lprintf, and NULL.

## ◆ _xine_buffer_strcat()

void * _xine_buffer_strcat | ( | void * | buf,
|  | const char * | data )

References _xine_buffer_strcpy().

## ◆ _xine_buffer_strcpy()

void * _xine_buffer_strcpy | ( | void * | buf,
|  | int | index,
|  | const char * | data )

References CHECK_MAGIC, GROW_TO, lprintf, and NULL.

Referenced by _xine_buffer_strcat().

## ◆ xine_buffer_copyout()

void xine_buffer_copyout | ( | const void * | buf,
|  | int | index,
|  | void * | data,
|  | int | len )

References CHECK_MAGIC, GET_HEADER_CONST, lprintf, and xine_fast_memcpy.

## ◆ xine_buffer_dup()

void * xine_buffer_dup | ( | const void * | buf | ) |

References CHECK_MAGIC, GET_HEADER_CONST, lprintf, NULL, XINE_BUFFER_HEADER_SIZE, and xine_fast_memcpy.

## ◆ xine_buffer_get_size()

int xine_buffer_get_size | ( | const void * | buf | ) |

References CHECK_MAGIC, GET_HEADER_CONST, and lprintf.

## ◆ xine_buffer_init()

void * xine_buffer_init | ( | int | chunk_size | ) |

References xine_buffer_header_t::chunk_size, xine_buffer_header_t::magic, NULL, xine_buffer_header_t::size, XINE_BUFFER_HEADER_SIZE, and XINE_BUFFER_MAGIC.

Referenced by deinterlace_init_plugin(), open_plugin(), open_plugin(), open_plugin(), real_parse_sdp(), real_setup_and_get_header(), rtsp_session_start(), sdpplin_parse(), and sdpplin_parse_stream().

## ◆ xine_buffer_strchr()

char * xine_buffer_strchr | ( | const void * | buf,
|  | int | ch )

References CHECK_MAGIC, lprintf, and NULL.