mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
added const in bitstream
This commit is contained in:
parent
9ac3b7bf2b
commit
94a48fc153
|
@ -67,7 +67,7 @@ const bit_table *g_exp_table;
|
||||||
|
|
||||||
//From wikipedia
|
//From wikipedia
|
||||||
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
|
//http://en.wikipedia.org/wiki/Binary_logarithm#Algorithm
|
||||||
int floor_log2(unsigned int n) {
|
static int floor_log2(unsigned int n) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if (n >= 1<<16) { n >>= 16; pos += 16; }
|
if (n >= 1<<16) { n >>= 16; pos += 16; }
|
||||||
if (n >= 1<< 8) { n >>= 8; pos += 8; }
|
if (n >= 1<< 8) { n >>= 8; pos += 8; }
|
||||||
|
@ -84,7 +84,7 @@ int floor_log2(unsigned int n) {
|
||||||
*
|
*
|
||||||
* Allocates g_exp_table with len*sizeof(bit_table) and fills it with exponential golomb codes
|
* Allocates g_exp_table with len*sizeof(bit_table) and fills it with exponential golomb codes
|
||||||
*/
|
*/
|
||||||
int init_exp_golomb(uint32_t len)
|
int init_exp_golomb(const uint32_t len)
|
||||||
{
|
{
|
||||||
uint32_t code_num;
|
uint32_t code_num;
|
||||||
uint8_t M;
|
uint8_t M;
|
||||||
|
@ -182,9 +182,9 @@ void free_bitstream(bitstream* stream)
|
||||||
* \param byte byte to write
|
* \param byte byte to write
|
||||||
* \return 1 on success, 0 on failure
|
* \return 1 on success, 0 on failure
|
||||||
*/
|
*/
|
||||||
int bitstream_writebyte(bitstream *stream_abstract, uint8_t byte) {
|
int bitstream_writebyte(bitstream * const stream_abstract, const uint8_t byte) {
|
||||||
if (stream_abstract->type == BITSTREAM_TYPE_FILE) {
|
if (stream_abstract->type == BITSTREAM_TYPE_FILE) {
|
||||||
bitstream_file *stream = (bitstream_file*) stream_abstract;
|
bitstream_file * const stream = (bitstream_file * const) stream_abstract;
|
||||||
if (fwrite(&byte, 1, 1, stream->output) != 1) {
|
if (fwrite(&byte, 1, 1, stream->output) != 1) {
|
||||||
fprintf(stderr, "Could not write byte to bitstream_file object.");
|
fprintf(stderr, "Could not write byte to bitstream_file object.");
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -192,7 +192,7 @@ int bitstream_writebyte(bitstream *stream_abstract, uint8_t byte) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (stream_abstract->type == BITSTREAM_TYPE_MEMORY) {
|
} else if (stream_abstract->type == BITSTREAM_TYPE_MEMORY) {
|
||||||
bitstream_mem *stream = (bitstream_mem*) stream_abstract;
|
bitstream_mem * const stream = (bitstream_mem * const) stream_abstract;
|
||||||
if (stream->allocated_length==stream->output_length) {
|
if (stream->allocated_length==stream->output_length) {
|
||||||
//Need to reallocate
|
//Need to reallocate
|
||||||
uint32_t new_size = stream->allocated_length + BITSTREAM_MEMORY_CHUNK_SIZE;
|
uint32_t new_size = stream->allocated_length + BITSTREAM_MEMORY_CHUNK_SIZE;
|
||||||
|
@ -220,7 +220,7 @@ int bitstream_writebyte(bitstream *stream_abstract, uint8_t byte) {
|
||||||
* \param data input data
|
* \param data input data
|
||||||
* \param bits number of bits to write from data to stream
|
* \param bits number of bits to write from data to stream
|
||||||
*/
|
*/
|
||||||
void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits)
|
void bitstream_put(bitstream * const stream, const uint32_t data, uint8_t bits)
|
||||||
{
|
{
|
||||||
const uint8_t emulation_prevention_three_byte = 0x03;
|
const uint8_t emulation_prevention_three_byte = 0x03;
|
||||||
while(bits--) {
|
while(bits--) {
|
||||||
|
@ -251,7 +251,7 @@ void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits)
|
||||||
/**
|
/**
|
||||||
* \brief Align the bitstream with one-bit padding
|
* \brief Align the bitstream with one-bit padding
|
||||||
*/
|
*/
|
||||||
void bitstream_align(bitstream *stream)
|
void bitstream_align(bitstream * const stream)
|
||||||
{
|
{
|
||||||
bitstream_put(stream, 1, 1);
|
bitstream_put(stream, 1, 1);
|
||||||
if ((stream->cur_bit & 7) != 0) {
|
if ((stream->cur_bit & 7) != 0) {
|
||||||
|
@ -262,7 +262,7 @@ void bitstream_align(bitstream *stream)
|
||||||
/**
|
/**
|
||||||
* \brief Align the bitstream with zero
|
* \brief Align the bitstream with zero
|
||||||
*/
|
*/
|
||||||
void bitstream_align_zero(bitstream *stream)
|
void bitstream_align_zero(bitstream * const stream)
|
||||||
{
|
{
|
||||||
if ((stream->cur_bit & 7) != 0) {
|
if ((stream->cur_bit & 7) != 0) {
|
||||||
bitstream_put(stream, 0, 8 - (stream->cur_bit & 7));
|
bitstream_put(stream, 0, 8 - (stream->cur_bit & 7));
|
||||||
|
|
|
@ -60,9 +60,7 @@ typedef struct
|
||||||
|
|
||||||
extern const bit_table *g_exp_table;
|
extern const bit_table *g_exp_table;
|
||||||
|
|
||||||
int floor_log2(unsigned int n);
|
bitstream *create_bitstream(bitstream_type type);
|
||||||
|
|
||||||
bitstream *create_bitstream(const bitstream_type type);
|
|
||||||
void free_bitstream(bitstream *stream);
|
void free_bitstream(bitstream *stream);
|
||||||
void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits);
|
void bitstream_put(bitstream *stream, uint32_t data, uint8_t bits);
|
||||||
int bitstream_writebyte(bitstream *stream_abstract, uint8_t byte);
|
int bitstream_writebyte(bitstream *stream_abstract, uint8_t byte);
|
||||||
|
|
Loading…
Reference in a new issue