1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-03-23 04:24:35 +02:00

avutil/lzo: K&R formatting cosmetics

This commit is contained in:
Diego Biurrun 2012-10-18 19:15:43 +02:00
parent c9ef43215c
commit c08536979b
2 changed files with 58 additions and 48 deletions

View File

@ -29,6 +29,7 @@
#define OUTBUF_PADDED 1 #define OUTBUF_PADDED 1
/// Define if we may read up to 8 bytes beyond the input buffer. /// Define if we may read up to 8 bytes beyond the input buffer.
#define INBUF_PADDED 1 #define INBUF_PADDED 1
typedef struct LZOContext { typedef struct LZOContext {
const uint8_t *in, *in_end; const uint8_t *in, *in_end;
uint8_t *out_start, *out, *out_end; uint8_t *out_start, *out, *out_end;
@ -39,7 +40,8 @@ typedef struct LZOContext {
* @brief Reads one byte from the input buffer, avoiding an overrun. * @brief Reads one byte from the input buffer, avoiding an overrun.
* @return byte read * @return byte read
*/ */
static inline int get_byte(LZOContext *c) { static inline int get_byte(LZOContext *c)
{
if (c->in < c->in_end) if (c->in < c->in_end)
return *c->in++; return *c->in++;
c->error |= AV_LZO_INPUT_DEPLETED; c->error |= AV_LZO_INPUT_DEPLETED;
@ -58,10 +60,12 @@ static inline int get_byte(LZOContext *c) {
* @param mask bits used from x * @param mask bits used from x
* @return decoded length value * @return decoded length value
*/ */
static inline int get_len(LZOContext *c, int x, int mask) { static inline int get_len(LZOContext *c, int x, int mask)
{
int cnt = x & mask; int cnt = x & mask;
if (!cnt) { if (!cnt) {
while (!(x = get_byte(c))) cnt += 255; while (!(x = get_byte(c)))
cnt += 255;
cnt += mask + x; cnt += mask + x;
} }
return cnt; return cnt;
@ -84,7 +88,8 @@ static inline int get_len(LZOContext *c, int x, int mask) {
* @brief Copies bytes from input to output buffer with checking. * @brief Copies bytes from input to output buffer with checking.
* @param cnt number of bytes to copy, must be >= 0 * @param cnt number of bytes to copy, must be >= 0
*/ */
static inline void copy(LZOContext *c, int cnt) { static inline void copy(LZOContext *c, int cnt)
{
register const uint8_t *src = c->in; register const uint8_t *src = c->in;
register uint8_t *dst = c->out; register uint8_t *dst = c->out;
if (cnt > c->in_end - src) { if (cnt > c->in_end - src) {
@ -117,7 +122,8 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt);
* cnt > back is valid, this will copy the bytes we just copied, * cnt > back is valid, this will copy the bytes we just copied,
* thus creating a repeating pattern with a period length of back. * thus creating a repeating pattern with a period length of back.
*/ */
static inline void copy_backptr(LZOContext *c, int back, int cnt) { static inline void copy_backptr(LZOContext *c, int back, int cnt)
{
register const uint8_t *src = &c->out[-back]; register const uint8_t *src = &c->out[-back];
register uint8_t *dst = c->out; register uint8_t *dst = c->out;
if (src < c->out_start || src > dst) { if (src < c->out_start || src > dst) {
@ -132,7 +138,8 @@ static inline void copy_backptr(LZOContext *c, int back, int cnt) {
c->out = dst + cnt; c->out = dst + cnt;
} }
static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) { static inline void memcpy_backptr(uint8_t *dst, int back, int cnt)
{
const uint8_t *src = &dst[-back]; const uint8_t *src = &dst[-back];
if (back == 1) { if (back == 1) {
memset(dst, *src, cnt); memset(dst, *src, cnt);
@ -166,11 +173,13 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt) {
} }
} }
void av_memcpy_backptr(uint8_t *dst, int back, int cnt) { void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
{
memcpy_backptr(dst, back, cnt); memcpy_backptr(dst, back, cnt);
} }
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
{
int state = 0; int state = 0;
int x; int x;
LZOContext c; LZOContext c;
@ -191,7 +200,8 @@ int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) {
if (x > 17) { if (x > 17) {
copy(&c, x - 17); copy(&c, x - 17);
x = GETB(c); x = GETB(c);
if (x < 16) c.error |= AV_LZO_ERROR; if (x < 16)
c.error |= AV_LZO_ERROR;
} }
if (c.in > c.in_end) if (c.in > c.in_end)
c.error |= AV_LZO_INPUT_DEPLETED; c.error |= AV_LZO_INPUT_DEPLETED;