From 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 14 Mar 2004 22:34:33 +0000 Subject: gst-indent Original commit message from CVS: gst-indent --- ext/tarkin/rle.h | 146 +++++++++++++++++++++++++++---------------------------- 1 file changed, 73 insertions(+), 73 deletions(-) (limited to 'ext/tarkin/rle.h') diff --git a/ext/tarkin/rle.h b/ext/tarkin/rle.h index 7cf79517..6ccef22b 100644 --- a/ext/tarkin/rle.h +++ b/ext/tarkin/rle.h @@ -19,7 +19,7 @@ #define ENTROPY_ENCODER_FLUSH(coder) rlecoder_encoder_flush(coder) #define ENTROPY_DECODER_INIT(coder,bitstream,limit) \ rlecoder_decoder_init(coder,bitstream,limit) -#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */ +#define ENTROPY_DECODER_DONE(coder) /* nothing to do ... */ #define ENTROPY_CODER_BITSTREAM(coder) ((coder)->bitcoder.bitstream) #define ENTROPY_CODER_EOS(coder) ((coder)->bitcoder.eos) @@ -31,12 +31,13 @@ -typedef struct { - int symbol; - uint32_t count; /* have seen count symbol's */ - BitCoderState bitcoder; - GolombAdaptiveCoderState golomb_state [2]; /* 2 states for 2 symbols... */ - int have_seen_1; +typedef struct +{ + int symbol; + uint32_t count; /* have seen count symbol's */ + BitCoderState bitcoder; + GolombAdaptiveCoderState golomb_state[2]; /* 2 states for 2 symbols... */ + int have_seen_1; } RLECoderState; @@ -44,100 +45,99 @@ typedef struct { /* * bit should be 0 or 1 !!! */ -static inline -void rlecoder_write_bit (RLECoderState *s, int bit) +static inline void +rlecoder_write_bit (RLECoderState * s, int bit) { - assert (bit == 0 || bit == 1); - - if (s->symbol == -1) { - s->symbol = bit & 1; - s->count = 1; - s->have_seen_1 = bit; - bitcoder_write_bit (&s->bitcoder, bit); - } - - if (s->symbol != bit) { - golombcoder_encode_number (&s->golomb_state[s->symbol], - &s->bitcoder, s->count); - s->symbol = ~s->symbol & 1; - s->have_seen_1 = 1; - s->count = 1; - } else - s->count++; + assert (bit == 0 || bit == 1); + + if (s->symbol == -1) { + s->symbol = bit & 1; + s->count = 1; + s->have_seen_1 = bit; + bitcoder_write_bit (&s->bitcoder, bit); + } + + if (s->symbol != bit) { + golombcoder_encode_number (&s->golomb_state[s->symbol], + &s->bitcoder, s->count); + s->symbol = ~s->symbol & 1; + s->have_seen_1 = 1; + s->count = 1; + } else + s->count++; } -static inline -int rlecoder_read_bit (RLECoderState *s) +static inline int +rlecoder_read_bit (RLECoderState * s) { - if (s->count == 0) { - s->symbol = ~s->symbol & 1; - s->count = golombcoder_decode_number (&s->golomb_state[s->symbol], - &s->bitcoder); - if (s->bitcoder.eos) { - s->symbol = 0; - s->count = ~0; - } - } - s->count--; - return (s->symbol); + if (s->count == 0) { + s->symbol = ~s->symbol & 1; + s->count = golombcoder_decode_number (&s->golomb_state[s->symbol], + &s->bitcoder); + if (s->bitcoder.eos) { + s->symbol = 0; + s->count = ~0; + } + } + s->count--; + return (s->symbol); } int coder_id = 0; FILE *file = NULL; -static inline -void rlecoder_encoder_init (RLECoderState *s, uint32_t limit) +static inline void +rlecoder_encoder_init (RLECoderState * s, uint32_t limit) { - bitcoder_encoder_init (&s->bitcoder, limit); - s->symbol = -1; - s->have_seen_1 = 0; - s->golomb_state[0].count = 0; - s->golomb_state[1].count = 0; - s->golomb_state[0].bits = 5 << 3; - s->golomb_state[1].bits = 5 << 3; + bitcoder_encoder_init (&s->bitcoder, limit); + s->symbol = -1; + s->have_seen_1 = 0; + s->golomb_state[0].count = 0; + s->golomb_state[1].count = 0; + s->golomb_state[0].bits = 5 << 3; + s->golomb_state[1].bits = 5 << 3; } /** * once you called this, you better should not encode any more symbols ... */ -static inline -uint32_t rlecoder_encoder_flush (RLECoderState *s) +static inline uint32_t +rlecoder_encoder_flush (RLECoderState * s) { - if (s->symbol == -1 || !s->have_seen_1) - return 0; + if (s->symbol == -1 || !s->have_seen_1) + return 0; - golombcoder_encode_number (&s->golomb_state[s->symbol], - &s->bitcoder, s->count); - return bitcoder_flush (&s->bitcoder); + golombcoder_encode_number (&s->golomb_state[s->symbol], + &s->bitcoder, s->count); + return bitcoder_flush (&s->bitcoder); } -static inline -void rlecoder_decoder_init (RLECoderState *s, uint8_t *bitstream, uint32_t limit) +static inline void +rlecoder_decoder_init (RLECoderState * s, uint8_t * bitstream, uint32_t limit) { - bitcoder_decoder_init (&s->bitcoder, bitstream, limit); - s->golomb_state[0].count = 0; - s->golomb_state[1].count = 0; - s->golomb_state[0].bits = 5 << 3; - s->golomb_state[1].bits = 5 << 3; - s->symbol = bitcoder_read_bit (&s->bitcoder); - s->count = golombcoder_decode_number (&s->golomb_state[s->symbol], - &s->bitcoder) - 1; - if (s->bitcoder.eos) { - s->symbol = 0; - s->count = ~0; - } + bitcoder_decoder_init (&s->bitcoder, bitstream, limit); + s->golomb_state[0].count = 0; + s->golomb_state[1].count = 0; + s->golomb_state[0].bits = 5 << 3; + s->golomb_state[1].bits = 5 << 3; + s->symbol = bitcoder_read_bit (&s->bitcoder); + s->count = golombcoder_decode_number (&s->golomb_state[s->symbol], + &s->bitcoder) - 1; + if (s->bitcoder.eos) { + s->symbol = 0; + s->count = ~0; + } } -static inline -void rlecoder_encoder_done (RLECoderState *s) +static inline void +rlecoder_encoder_done (RLECoderState * s) { - bitcoder_encoder_done (&s->bitcoder); + bitcoder_encoder_done (&s->bitcoder); } #endif - -- cgit v1.2.1