TUT HEVC Encoder
Loading...
Searching...
No Matches
bitstream.c File Reference
#include "bitstream.h"
#include <math.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "kvz_math.h"
Include dependency graph for bitstream.c:

Functions

void kvz_bitstream_init (bitstream_t *const stream)
 Initialize a new bitstream.
 
kvz_data_chunkkvz_bitstream_take_chunks (bitstream_t *const stream)
 Take chunks from a bitstream.
 
kvz_data_chunkkvz_bitstream_alloc_chunk ()
 Allocates a new bitstream chunk.
 
void kvz_bitstream_free_chunks (kvz_data_chunk *chunk)
 Free a list of chunks.
 
void kvz_bitstream_finalize (bitstream_t *const stream)
 Free resources used by a bitstream.
 
uint64_t kvz_bitstream_tell (const bitstream_t *const stream)
 Get the number of bits written.
 
void kvz_bitstream_writebyte (bitstream_t *const stream, const uint8_t byte)
 Write a byte to bitstream.
 
void kvz_bitstream_move (bitstream_t *const dst, bitstream_t *const src)
 Move data from one stream to another.
 
void kvz_bitstream_clear (bitstream_t *const stream)
 Reset stream.
 
void kvz_bitstream_put_byte (bitstream_t *const stream, uint32_t data)
 Write a byte to a byte aligned bitstream.
 
void kvz_bitstream_put (bitstream_t *const stream, const uint32_t data, uint8_t bits)
 Write bits to bitstream Buffers individual bits untill they make a full byte.
 
void kvz_bitstream_put_ue (bitstream_t *stream, uint32_t code_num)
 Write unsigned Exp-Golomb bit string.
 
void kvz_bitstream_put_se (bitstream_t *stream, int32_t data)
 Write signed Exp-Golomb bit string.
 
void kvz_bitstream_add_rbsp_trailing_bits (bitstream_t *const stream)
 Add rbsp_trailing_bits syntax element, which aligns the bitstream.
 
void kvz_bitstream_align (bitstream_t *const stream)
 Align the bitstream, unless it's already aligned.
 
void kvz_bitstream_align_zero (bitstream_t *const stream)
 Align the bitstream with zero.
 

Variables

const uint32_t kvz_bit_set_mask []
 

Function Documentation

◆ kvz_bitstream_add_rbsp_trailing_bits()

void kvz_bitstream_add_rbsp_trailing_bits ( bitstream_t *const stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_align()

void kvz_bitstream_align ( bitstream_t *const stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_align_zero()

void kvz_bitstream_align_zero ( bitstream_t *const stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_alloc_chunk()

kvz_data_chunk * kvz_bitstream_alloc_chunk ( )
Returns
Pointer to the new chunk, or NULL.
Here is the caller graph for this function:

◆ kvz_bitstream_clear()

void kvz_bitstream_clear ( bitstream_t *const stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_finalize()

void kvz_bitstream_finalize ( bitstream_t *const stream)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_free_chunks()

void kvz_bitstream_free_chunks ( kvz_data_chunk * chunk)
Here is the caller graph for this function:

◆ kvz_bitstream_init()

void kvz_bitstream_init ( bitstream_t *const stream)
Here is the caller graph for this function:

◆ kvz_bitstream_move()

void kvz_bitstream_move ( bitstream_t *const dst,
bitstream_t *const src )

Destination stream must be byte-aligned. Source stream will be cleared.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_put()

void kvz_bitstream_put ( bitstream_t *const stream,
const uint32_t data,
uint8_t bits )
Parameters
streamstream the data is to be appended to
datainput data
bitsnumber of bits to write from data to stream
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_put_byte()

void kvz_bitstream_put_byte ( bitstream_t *const stream,
uint32_t data )
Parameters
streamstream the data is to be appended to
datainput data
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_put_se()

void kvz_bitstream_put_se ( bitstream_t * stream,
int32_t data )
Here is the call graph for this function:

◆ kvz_bitstream_put_ue()

void kvz_bitstream_put_ue ( bitstream_t * stream,
uint32_t code_num )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ kvz_bitstream_take_chunks()

kvz_data_chunk * kvz_bitstream_take_chunks ( bitstream_t *const stream)

Move ownership of the chunks to the caller and clear the bitstream.

The bitstream must be byte-aligned.

Here is the caller graph for this function:

◆ kvz_bitstream_tell()

uint64_t kvz_bitstream_tell ( const bitstream_t *const stream)
Parameters
streambitstream
Returns
position
Here is the caller graph for this function:

◆ kvz_bitstream_writebyte()

void kvz_bitstream_writebyte ( bitstream_t *const stream,
const uint8_t byte )

The stream must be byte-aligned.

Parameters
streampointer bitstream to put the data
bytebyte to write
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ kvz_bit_set_mask

const uint32_t kvz_bit_set_mask[]
Initial value:
=
{
0x00000001,0x00000002,0x00000004,0x00000008,
0x00000010,0x00000020,0x00000040,0x00000080,
0x00000100,0x00000200,0x00000400,0x00000800,
0x00001000,0x00002000,0x00004000,0x00008000,
0x00010000,0x00020000,0x00040000,0x00080000,
0x00100000,0x00200000,0x00400000,0x00800000,
0x01000000,0x02000000,0x04000000,0x08000000,
0x10000000,0x20000000,0x40000000,0x80000000
}