Commit 4af5310d authored by Diego Biurrun's avatar Diego Biurrun

get_bits/put_bits: K&R formatting cosmetics

Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
parent 570a4a01
This diff is collapsed.
......@@ -29,6 +29,7 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include "libavutil/bswap.h"
#include "libavutil/common.h"
#include "libavutil/intreadwrite.h"
......@@ -49,19 +50,20 @@ typedef struct PutBitContext {
* @param buffer the buffer where to put bits
* @param buffer_size the size in bytes of buffer
*/
static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
static inline void init_put_bits(PutBitContext *s, uint8_t *buffer,
int buffer_size)
{
if(buffer_size < 0) {
if (buffer_size < 0) {
buffer_size = 0;
buffer = NULL;
buffer = NULL;
}
s->size_in_bits= 8*buffer_size;
s->buf = buffer;
s->buf_end = s->buf + buffer_size;
s->buf_ptr = s->buf;
s->bit_left=32;
s->bit_buf=0;
s->size_in_bits = 8 * buffer_size;
s->buf = buffer;
s->buf_end = s->buf + buffer_size;
s->buf_ptr = s->buf;
s->bit_left = 32;
s->bit_buf = 0;
}
/**
......@@ -79,21 +81,21 @@ static inline void flush_put_bits(PutBitContext *s)
{
#ifndef BITSTREAM_WRITER_LE
if (s->bit_left < 32)
s->bit_buf<<= s->bit_left;
s->bit_buf <<= s->bit_left;
#endif
while (s->bit_left < 32) {
/* XXX: should test end of buffer */
#ifdef BITSTREAM_WRITER_LE
*s->buf_ptr++=s->bit_buf;
s->bit_buf>>=8;
*s->buf_ptr++ = s->bit_buf;
s->bit_buf >>= 8;
#else
*s->buf_ptr++=s->bit_buf >> 24;
s->bit_buf<<=8;
*s->buf_ptr++ = s->bit_buf >> 24;
s->bit_buf <<= 8;
#endif
s->bit_left+=8;
s->bit_left += 8;
}
s->bit_left=32;
s->bit_buf=0;
s->bit_left = 32;
s->bit_buf = 0;
}
#ifdef BITSTREAM_WRITER_LE
......@@ -111,7 +113,8 @@ void avpriv_align_put_bits(PutBitContext *s);
*
* @param terminate_string 0-terminates the written string if value is 1
*/
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string);
void avpriv_put_string(PutBitContext *pb, const char *string,
int terminate_string);
/**
* Copy the content of src to the bitstream.
......@@ -132,7 +135,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
assert(n <= 31 && value < (1U << n));
bit_buf = s->bit_buf;
bit_buf = s->bit_buf;
bit_left = s->bit_left;
/* XXX: optimize */
......@@ -140,26 +143,26 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
bit_buf |= value << (32 - bit_left);
if (n >= bit_left) {
AV_WL32(s->buf_ptr, bit_buf);
s->buf_ptr+=4;
bit_buf = (bit_left==32)?0:value >> bit_left;
bit_left+=32;
s->buf_ptr += 4;
bit_buf = (bit_left == 32) ? 0 : value >> bit_left;
bit_left += 32;
}
bit_left-=n;
bit_left -= n;
#else
if (n < bit_left) {
bit_buf = (bit_buf<<n) | value;
bit_left-=n;
bit_buf = (bit_buf << n) | value;
bit_left -= n;
} else {
bit_buf<<=bit_left;
bit_buf |= value >> (n - bit_left);
bit_buf <<= bit_left;
bit_buf |= value >> (n - bit_left);
AV_WB32(s->buf_ptr, bit_buf);
s->buf_ptr+=4;
bit_left+=32 - n;
bit_buf = value;
s->buf_ptr += 4;
bit_left += 32 - n;
bit_buf = value;
}
#endif
s->bit_buf = bit_buf;
s->bit_buf = bit_buf;
s->bit_left = bit_left;
}
......@@ -167,7 +170,7 @@ static inline void put_sbits(PutBitContext *pb, int n, int32_t value)
{
assert(n >= 0 && n <= 31);
put_bits(pb, n, value & ((1<<n)-1));
put_bits(pb, n, value & ((1 << n) - 1));
}
/**
......@@ -190,9 +193,9 @@ static void av_unused put_bits32(PutBitContext *s, uint32_t value)
* Return the pointer to the byte where the bitstream writer will put
* the next bit.
*/
static inline uint8_t* put_bits_ptr(PutBitContext *s)
static inline uint8_t *put_bits_ptr(PutBitContext *s)
{
return s->buf_ptr;
return s->buf_ptr;
}
/**
......@@ -201,9 +204,9 @@ static inline uint8_t* put_bits_ptr(PutBitContext *s)
*/
static inline void skip_put_bytes(PutBitContext *s, int n)
{
assert((put_bits_count(s)&7)==0);
assert(s->bit_left==32);
s->buf_ptr += n;
assert((put_bits_count(s) & 7) == 0);
assert(s->bit_left == 32);
s->buf_ptr += n;
}
/**
......@@ -214,7 +217,7 @@ static inline void skip_put_bytes(PutBitContext *s, int n)
static inline void skip_put_bits(PutBitContext *s, int n)
{
s->bit_left -= n;
s->buf_ptr-= 4*(s->bit_left>>5);
s->buf_ptr -= 4 * (s->bit_left >> 5);
s->bit_left &= 31;
}
......@@ -225,7 +228,7 @@ static inline void skip_put_bits(PutBitContext *s, int n)
*/
static inline void set_put_bits_buffer_size(PutBitContext *s, int size)
{
s->buf_end= s->buf + size;
s->buf_end = s->buf + size;
}
#endif /* AVCODEC_PUT_BITS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment