diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-05-16 09:46:19 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-05-16 09:46:19 +0200 |
commit | 39354d608933fe37a5ec86de4c691bcb46df0dac (patch) | |
tree | d503a0a3bf2da5e070d456c1b683bfaf5b92aed8 /libavcodec/jpegls.h | |
parent | 0d83b5722e2875cd4a2ac3574af72b5be633c73d (diff) | |
parent | ff4fc5ef12a37716c5c5d8928a2db92428e916ec (diff) | |
download | ffmpeg-39354d608933fe37a5ec86de4c691bcb46df0dac.tar.gz |
Merge commit 'ff4fc5ef12a37716c5c5d8928a2db92428e916ec'
* commit 'ff4fc5ef12a37716c5c5d8928a2db92428e916ec':
jpegls: K&R formatting cosmetics
Conflicts:
libavcodec/jpegls.c
libavcodec/jpegls.h
libavcodec/jpeglsdec.c
libavcodec/jpeglsenc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/jpegls.h')
-rw-r--r-- | libavcodec/jpegls.h | 78 |
1 files changed, 45 insertions, 33 deletions
diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h index 0a6ead3d8f..2dc3832517 100644 --- a/libavcodec/jpegls.h +++ b/libavcodec/jpegls.h @@ -28,21 +28,21 @@ #ifndef AVCODEC_JPEGLS_H #define AVCODEC_JPEGLS_H -#include "avcodec.h" #include "libavutil/common.h" +#include "avcodec.h" -typedef struct JpeglsContext{ +typedef struct JpeglsContext { AVCodecContext *avctx; AVFrame picture; -}JpeglsContext; +} JpeglsContext; -typedef struct JLSState{ +typedef struct JLSState { int T1, T2, T3; int A[367], B[367], C[365], N[367]; int limit, reset, bpp, qbpp, maxval, range; int near, twonear; int run_index[4]; -}JLSState; +} JLSState; extern const uint8_t ff_log2_run[32]; @@ -54,19 +54,29 @@ void ff_jpegls_init_state(JLSState *state); /** * Calculate quantized gradient value, used for context determination */ -static inline int ff_jpegls_quantize(JLSState *s, int v){ //FIXME optimize - if(v==0) return 0; - if(v < 0){ - if(v <= -s->T3) return -4; - if(v <= -s->T2) return -3; - if(v <= -s->T1) return -2; - if(v < -s->near) return -1; +static inline int ff_jpegls_quantize(JLSState *s, int v) +{ + if (v == 0) return 0; - }else{ - if(v <= s->near) return 0; - if(v < s->T1) return 1; - if(v < s->T2) return 2; - if(v < s->T3) return 3; + if (v < 0) { + if (v <= -s->T3) + return -4; + if (v <= -s->T2) + return -3; + if (v <= -s->T1) + return -2; + if (v < -s->near) + return -1; + return 0; + } else { + if (v <= s->near) + return 0; + if (v < s->T1) + return 1; + if (v < s->T2) + return 2; + if (v < s->T3) + return 3; return 4; } } @@ -76,39 +86,41 @@ static inline int ff_jpegls_quantize(JLSState *s, int v){ //FIXME optimize */ void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all); - -static inline void ff_jpegls_downscale_state(JLSState *state, int Q){ - if(state->N[Q] == state->reset){ - state->A[Q] >>=1; - state->B[Q] >>=1; - state->N[Q] >>=1; +static inline void ff_jpegls_downscale_state(JLSState *state, int Q) +{ + if (state->N[Q] == state->reset) { + state->A[Q] >>= 1; + state->B[Q] >>= 1; + state->N[Q] >>= 1; } state->N[Q]++; } -static inline int ff_jpegls_update_state_regular(JLSState *state, int Q, int err){ +static inline int ff_jpegls_update_state_regular(JLSState *state, + int Q, int err) +{ if(FFABS(err) > 0xFFFF) return -0x10000; state->A[Q] += FFABS(err); - err *= state->twonear; + err *= state->twonear; state->B[Q] += err; ff_jpegls_downscale_state(state, Q); - if(state->B[Q] <= -state->N[Q]) { - state->B[Q]= FFMAX(state->B[Q] + state->N[Q], 1-state->N[Q]); - if(state->C[Q] > -128) + if (state->B[Q] <= -state->N[Q]) { + state->B[Q] = FFMAX(state->B[Q] + state->N[Q], 1 - state->N[Q]); + if (state->C[Q] > -128) state->C[Q]--; - }else if(state->B[Q] > 0){ - state->B[Q]= FFMIN(state->B[Q] - state->N[Q], 0); - if(state->C[Q] < 127) + } else if (state->B[Q] > 0) { + state->B[Q] = FFMIN(state->B[Q] - state->N[Q], 0); + if (state->C[Q] < 127) state->C[Q]++; } return err; } -#define R(a, i ) (bits == 8 ? ((uint8_t*)(a))[i] : ((uint16_t*)(a))[i] ) -#define W(a, i, v) (bits == 8 ? (((uint8_t*)(a))[i]=v) : (((uint16_t*)(a))[i]=v)) +#define R(a, i) (bits == 8 ? ((uint8_t *)(a))[i] : ((uint16_t *)(a))[i]) +#define W(a, i, v) (bits == 8 ? (((uint8_t *)(a))[i] = v) : (((uint16_t *)(a))[i] = v)) #endif /* AVCODEC_JPEGLS_H */ |