ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

SpeexBits: Bit-stream manipulations

SpeexBits: Bit-stream manipulations

This is the structure that holds the bit-stream when encoding or decoding with Speex. More...

Data Structures

struct  SpeexBits
 Bit-packing data structure representing (part of) a bit-stream. More...

Typedefs

typedef struct SpeexBits SpeexBits
 Bit-packing data structure representing (part of) a bit-stream.

Functions

void speex_bits_init (SpeexBits *bits)
 Initializes and allocates resources for a SpeexBits struct.
void speex_bits_init_buffer (SpeexBits *bits, void *buff, int buf_size)
 Initializes SpeexBits struct using a pre-allocated buffer.
void speex_bits_set_bit_buffer (SpeexBits *bits, void *buff, int buf_size)
 Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data)
void speex_bits_destroy (SpeexBits *bits)
 Frees all resources associated to a SpeexBits struct.
void speex_bits_reset (SpeexBits *bits)
 Resets bits to initial value (just after initialization, erasing content)
void speex_bits_rewind (SpeexBits *bits)
 Rewind the bit-stream to the beginning (ready for read) without erasing the content.
void speex_bits_read_from (SpeexBits *bits, char *bytes, int len)
 Initializes the bit-stream from the data in an area of memory.
void speex_bits_read_whole_bytes (SpeexBits *bits, char *bytes, int len)
 Append bytes to the bit-stream.
int speex_bits_write (SpeexBits *bits, char *bytes, int max_len)
 Write the content of a bit-stream to an area of memory.
int speex_bits_write_whole_bytes (SpeexBits *bits, char *bytes, int max_len)
 Like speex_bits_write, but writes only the complete bytes in the stream.
void speex_bits_pack (SpeexBits *bits, int data, int nbBits)
 Append bits to the bit-stream.
int speex_bits_unpack_signed (SpeexBits *bits, int nbBits)
 Interpret the next bits in the bit-stream as a signed integer.
unsigned int speex_bits_unpack_unsigned (SpeexBits *bits, int nbBits)
 Interpret the next bits in the bit-stream as an unsigned integer.
int speex_bits_nbytes (SpeexBits *bits)
 Returns the number of bytes in the bit-stream, including the last one even if it is not "full".
unsigned int speex_bits_peek_unsigned (SpeexBits *bits, int nbBits)
 Same as speex_bits_unpack_unsigned, but without modifying the cursor position.
int speex_bits_peek (SpeexBits *bits)
 Get the value of the next bit in the stream, without modifying the "cursor" position.
void speex_bits_advance (SpeexBits *bits, int n)
 Advances the position of the "bit cursor" in the stream.
int speex_bits_remaining (SpeexBits *bits)
 Returns the number of bits remaining to be read in a stream.
void speex_bits_insert_terminator (SpeexBits *bits)
 Insert a terminator so that the data can be sent as a packet while auto-detecting the number of frames in each packet.

Detailed Description

This is the structure that holds the bit-stream when encoding or decoding with Speex.

It allows some manipulations as well.


Typedef Documentation

typedef struct SpeexBits SpeexBits

Bit-packing data structure representing (part of) a bit-stream.


Function Documentation

void speex_bits_advance ( SpeexBits bits,
int  n 
)

Advances the position of the "bit cursor" in the stream.

Parameters:
bitsBit-stream to operate on
nNumber of bits to advance
void speex_bits_destroy ( SpeexBits bits )

Frees all resources associated to a SpeexBits struct.

Right now this does nothing since no resources are allocated, but this could change in the future.

void speex_bits_init ( SpeexBits bits )

Initializes and allocates resources for a SpeexBits struct.

void speex_bits_init_buffer ( SpeexBits bits,
void *  buff,
int  buf_size 
)

Initializes SpeexBits struct using a pre-allocated buffer.

void speex_bits_insert_terminator ( SpeexBits bits )

Insert a terminator so that the data can be sent as a packet while auto-detecting the number of frames in each packet.

Parameters:
bitsBit-stream to operate on
int speex_bits_nbytes ( SpeexBits bits )

Returns the number of bytes in the bit-stream, including the last one even if it is not "full".

Parameters:
bitsBit-stream to operate on
Returns:
Number of bytes in the stream
void speex_bits_pack ( SpeexBits bits,
int  data,
int  nbBits 
)

Append bits to the bit-stream.

Parameters:
bitsBit-stream to operate on
dataValue to append as integer
nbBitsnumber of bits to consider in "data"
int speex_bits_peek ( SpeexBits bits )

Get the value of the next bit in the stream, without modifying the "cursor" position.

Parameters:
bitsBit-stream to operate on
Returns:
Value of the bit peeked (one bit only)
unsigned int speex_bits_peek_unsigned ( SpeexBits bits,
int  nbBits 
)

Same as speex_bits_unpack_unsigned, but without modifying the cursor position.

Parameters:
bitsBit-stream to operate on
nbBitsNumber of bits to look for
Returns:
Value of the bits peeked, interpreted as unsigned
void speex_bits_read_from ( SpeexBits bits,
char *  bytes,
int  len 
)

Initializes the bit-stream from the data in an area of memory.

void speex_bits_read_whole_bytes ( SpeexBits bits,
char *  bytes,
int  len 
)

Append bytes to the bit-stream.

Parameters:
bitsBit-stream to operate on
bytespointer to the bytes what will be appended
lenNumber of bytes of append
int speex_bits_remaining ( SpeexBits bits )

Returns the number of bits remaining to be read in a stream.

Parameters:
bitsBit-stream to operate on
Returns:
Number of bits that can still be read from the stream
void speex_bits_reset ( SpeexBits bits )

Resets bits to initial value (just after initialization, erasing content)

void speex_bits_rewind ( SpeexBits bits )

Rewind the bit-stream to the beginning (ready for read) without erasing the content.

void speex_bits_set_bit_buffer ( SpeexBits bits,
void *  buff,
int  buf_size 
)

Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data)

int speex_bits_unpack_signed ( SpeexBits bits,
int  nbBits 
)

Interpret the next bits in the bit-stream as a signed integer.

Parameters:
bitsBit-stream to operate on
nbBitsNumber of bits to interpret
Returns:
A signed integer represented by the bits read
unsigned int speex_bits_unpack_unsigned ( SpeexBits bits,
int  nbBits 
)

Interpret the next bits in the bit-stream as an unsigned integer.

Parameters:
bitsBit-stream to operate on
nbBitsNumber of bits to interpret
Returns:
An unsigned integer represented by the bits read
int speex_bits_write ( SpeexBits bits,
char *  bytes,
int  max_len 
)

Write the content of a bit-stream to an area of memory.

Parameters:
bitsBit-stream to operate on
bytesMemory location where to write the bits
max_lenMaximum number of bytes to write (i.e. size of the "bytes" buffer)
Returns:
Number of bytes written to the "bytes" buffer
int speex_bits_write_whole_bytes ( SpeexBits bits,
char *  bytes,
int  max_len 
)

Like speex_bits_write, but writes only the complete bytes in the stream.

Also removes the written bytes from the stream