History

jpegls: K&R formatting cosmetics

Luca Barbato committed 13 years ago

Commit ff4fc5e1 parent 9cacdab5 files · +336 −266Browse files

Unified · Split

5 files
  1. libavcodec/jpegls.c +43 −30
  2. libavcodec/jpegls.h +45 −33
  3. libavcodec/jpeglsdec.c +112 −96
  4. libavcodec/jpeglsdec.h +2 −1
  5. libavcodec/jpeglsenc.c +134 −106
libavcodec/jpegls.c+43−30
@@ -27,63 +27,76 @@ · 26 unmodified lines
2727
2828 #include "jpegls.h"
2929
30−void ff_jpegls_init_state(JLSState *state){
30+void ff_jpegls_init_state(JLSState *state)
31+{
3132 int i;
3233
3334 state->twonear = state->near * 2 + 1;
3435 state->range = (state->maxval + state->twonear - 1) / state->twonear + 1;
3536
3637 // QBPP = ceil(log2(RANGE))
37− for(state->qbpp = 0; (1 << state->qbpp) < state->range; state->qbpp++);
38+ for (state->qbpp = 0; (1 << state->qbpp) < state->range; state->qbpp++)
39+ ;
3840
39− if(state->bpp < 8)
40− state->limit = 16 + 2 * state->bpp - state->qbpp;
41+ if (state->bpp < 8)
42+ state->limit = 2 * state->bpp - state->qbpp + 16;
4143 else
4244 state->limit = 4 * state->bpp - state->qbpp;
4345
44− for(i = 0; i < 367; i++) {
46+ for (i = 0; i < 367; i++) {
4547 state->A[i] = FFMAX(state->range + 32 >> 6, 2);
4648 state->N[i] = 1;
4749 }
48−
4950 }
5051
5152 /**
5253 * Custom value clipping function used in T1, T2, T3 calculation
5354 */
54−static inline int iso_clip(int v, int vmin, int vmax){
55− if(v > vmax || v < vmin) return vmin;
56− else return v;
55+static inline int iso_clip(int v, int vmin, int vmax)
56+{
57+ if (v > vmax || v < vmin)
58+ return vmin;
59+ else
60+ return v;
5761 }
5862
59−void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all){
60− const int basic_t1= 3;
61− const int basic_t2= 7;
62− const int basic_t3= 21;
63+void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
64+{
65+ const int basic_t1 = 3;
66+ const int basic_t2 = 7;
67+ const int basic_t3 = 21;
6368 int factor;
6469
65− if(s->maxval==0 || reset_all) s->maxval= (1 << s->bpp) - 1;
70+ if (s->maxval == 0 || reset_all)
71+ s->maxval = (1 << s->bpp) - 1;
6672
67− if(s->maxval >=128){
73+ if (s->maxval >= 128) {
6874 factor = FFMIN(s->maxval, 4095) + 128 >> 8;
6975
70− if(s->T1==0 || reset_all)
71− s->T1= iso_clip(factor*(basic_t1-2) + 2 + 3*s->near, s->near+1, s->maxval);
72− if(s->T2==0 || reset_all)
73− s->T2= iso_clip(factor*(basic_t2-3) + 3 + 5*s->near, s->T1, s->maxval);
74− if(s->T3==0 || reset_all)
75− s->T3= iso_clip(factor*(basic_t3-4) + 4 + 7*s->near, s->T2, s->maxval);
76− }else{
77− factor= 256 / (s->maxval + 1);
76+ if (s->T1 == 0 || reset_all)
77+ s->T1 = iso_clip(factor * (basic_t1 - 2) + 2 + 3 * s->near,
78+ s->near + 1, s->maxval);
79+ if (s->T2 == 0 || reset_all)
80+ s->T2 = iso_clip(factor * (basic_t2 - 3) + 3 + 5 * s->near,
81+ s->T1, s->maxval);
82+ if (s->T3 == 0 || reset_all)
83+ s->T3 = iso_clip(factor * (basic_t3 - 4) + 4 + 7 * s->near,
84+ s->T2, s->maxval);
85+ } else {
86+ factor = 256 / (s->maxval + 1);
7887
79− if(s->T1==0 || reset_all)
80− s->T1= iso_clip(FFMAX(2, basic_t1/factor + 3*s->near), s->near+1, s->maxval);
81− if(s->T2==0 || reset_all)
82− s->T2= iso_clip(FFMAX(3, basic_t2/factor + 5*s->near), s->T1, s->maxval);
83− if(s->T3==0 || reset_all)
84− s->T3= iso_clip(FFMAX(4, basic_t3/factor + 7*s->near), s->T2, s->maxval);
88+ if (s->T1 == 0 || reset_all)
89+ s->T1 = iso_clip(FFMAX(2, basic_t1 / factor + 3 * s->near),
90+ s->near + 1, s->maxval);
91+ if (s->T2 == 0 || reset_all)
92+ s->T2 = iso_clip(FFMAX(3, basic_t2 / factor + 5 * s->near),
93+ s->T1, s->maxval);
94+ if (s->T3 == 0 || reset_all)
95+ s->T3 = iso_clip(FFMAX(4, basic_t3 / factor + 7 * s->near),
96+ s->T2, s->maxval);
8597 }
8698
87− if(s->reset==0 || reset_all) s->reset= 64;
99+ if (s->reset == 0 || reset_all)
100+ s->reset = 64;
88101 av_dlog(NULL, "[JPEG-LS RESET] T=%i,%i,%i\n", s->T1, s->T2, s->T3);
89102 }
libavcodec/jpegls.h+45−33
@@ -28,21 +28,21 @@ · 27 unmodified lines
2828 #ifndef AVCODEC_JPEGLS_H
2929 #define AVCODEC_JPEGLS_H
3030
31−#include "avcodec.h"
3231 #include "libavutil/common.h"
32+#include "avcodec.h"
3333
34−typedef struct JpeglsContext{
34+typedef struct JpeglsContext {
3535 AVCodecContext *avctx;
3636 AVFrame picture;
37−}JpeglsContext;
37+} JpeglsContext;
3838
39−typedef struct JLSState{
39+typedef struct JLSState {
4040 int T1, T2, T3;
4141 int A[367], B[367], C[365], N[367];
4242 int limit, reset, bpp, qbpp, maxval, range;
4343 int near, twonear;
4444 int run_index[3];
45−}JLSState;
45+} JLSState;
4646
4747 extern const uint8_t ff_log2_run[32];
4848
@@ -54,19 +54,29 @@ void ff_jpegls_init_state(JLSState *state); · 5 unmodified lines
5454 /**
5555 * Calculate quantized gradient value, used for context determination
5656 */
57−static inline int ff_jpegls_quantize(JLSState *s, int v){ //FIXME optimize
58− if(v==0) return 0;
59− if(v < 0){
60− if(v <= -s->T3) return -4;
61− if(v <= -s->T2) return -3;
62− if(v <= -s->T1) return -2;
63− if(v < -s->near) return -1;
57+static inline int ff_jpegls_quantize(JLSState *s, int v)
58+{
59+ if (v == 0)
6460 return 0;
65− }else{
66− if(v <= s->near) return 0;
67− if(v < s->T1) return 1;
68− if(v < s->T2) return 2;
69− if(v < s->T3) return 3;
61+ if (v < 0) {
62+ if (v <= -s->T3)
63+ return -4;
64+ if (v <= -s->T2)
65+ return -3;
66+ if (v <= -s->T1)
67+ return -2;
68+ if (v < -s->near)
69+ return -1;
70+ return 0;
71+ } else {
72+ if (v <= s->near)
73+ return 0;
74+ if (v < s->T1)
75+ return 1;
76+ if (v < s->T2)
77+ return 2;
78+ if (v < s->T3)
79+ return 3;
7080 return 4;
7181 }
7282 }
@@ -76,37 +86,39 @@ static inline int ff_jpegls_quantize(JLSState *s, int v){ //FIXME optimize · 3 unmodified lines
7686 */
7787 void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all);
7888
79−
80−static inline void ff_jpegls_downscale_state(JLSState *state, int Q){
81− if(state->N[Q] == state->reset){
82− state->A[Q] >>=1;
83− state->B[Q] >>=1;
84− state->N[Q] >>=1;
89+static inline void ff_jpegls_downscale_state(JLSState *state, int Q)
90+{
91+ if (state->N[Q] == state->reset) {
92+ state->A[Q] >>= 1;
93+ state->B[Q] >>= 1;
94+ state->N[Q] >>= 1;
8595 }
8696 state->N[Q]++;
8797 }
8898
89−static inline int ff_jpegls_update_state_regular(JLSState *state, int Q, int err){
99+static inline int ff_jpegls_update_state_regular(JLSState *state,
100+ int Q, int err)
101+{
90102 state->A[Q] += FFABS(err);
91− err *= state->twonear;
103+ err *= state->twonear;
92104 state->B[Q] += err;
93105
94106 ff_jpegls_downscale_state(state, Q);
95107
96− if(state->B[Q] <= -state->N[Q]) {
97− state->B[Q]= FFMAX(state->B[Q] + state->N[Q], 1-state->N[Q]);
98− if(state->C[Q] > -128)
108+ if (state->B[Q] <= -state->N[Q]) {
109+ state->B[Q] = FFMAX(state->B[Q] + state->N[Q], 1 - state->N[Q]);
110+ if (state->C[Q] > -128)
99111 state->C[Q]--;
100− }else if(state->B[Q] > 0){
101− state->B[Q]= FFMIN(state->B[Q] - state->N[Q], 0);
102− if(state->C[Q] < 127)
112+ } else if (state->B[Q] > 0) {
113+ state->B[Q] = FFMIN(state->B[Q] - state->N[Q], 0);
114+ if (state->C[Q] < 127)
103115 state->C[Q]++;
104116 }
105117
106118 return err;
107119 }
108120
109−#define R(a, i ) (bits == 8 ? ((uint8_t*)(a))[i] : ((uint16_t*)(a))[i] )
110−#define W(a, i, v) (bits == 8 ? (((uint8_t*)(a))[i]=v) : (((uint16_t*)(a))[i]=v))
121+#define R(a, i) (bits == 8 ? ((uint8_t *)(a))[i] : ((uint16_t *)(a))[i])
122+#define W(a, i, v) (bits == 8 ? (((uint8_t *)(a))[i] = v) : (((uint16_t *)(a))[i] = v))
111123
112124 #endif /* AVCODEC_JPEGLS_H */
libavcodec/jpeglsdec.c+112−96
@@ -34,18 +34,16 @@ · 33 unmodified lines
3434 #include "jpegls.h"
3535 #include "jpeglsdec.h"
3636
37−
3837 /*
39−* Uncomment this to significantly speed up decoding of broken JPEG-LS
40−* (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit.
41−*
42−* There is no Golomb code with length >= 32 bits possible, so check and
43−* avoid situation of 32 zeros, Libav Golomb decoder is painfully slow
44−* on this errors.
45−*/
38+ * Uncomment this to significantly speed up decoding of broken JPEG-LS
39+ * (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit.
40+ *
41+ * There is no Golomb code with length >= 32 bits possible, so check and
42+ * avoid situation of 32 zeros, Libav Golomb decoder is painfully slow
43+ * on this errors.
44+ */
4645 //#define JLS_BROKEN
4746
48−
4947 /**
5048 * Decode LSE block with initialization parameters
5149 */
@@ -56,13 +54,13 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s) · 4 unmodified lines
5654 skip_bits(&s->gb, 16); /* length: FIXME: verify field validity */
5755 id = get_bits(&s->gb, 8);
5856
59− switch(id){
57+ switch (id) {
6058 case 1:
61− s->maxval= get_bits(&s->gb, 16);
62− s->t1= get_bits(&s->gb, 16);
63− s->t2= get_bits(&s->gb, 16);
64− s->t3= get_bits(&s->gb, 16);
65− s->reset= get_bits(&s->gb, 16);
59+ s->maxval = get_bits(&s->gb, 16);
60+ s->t1 = get_bits(&s->gb, 16);
61+ s->t2 = get_bits(&s->gb, 16);
62+ s->t3 = get_bits(&s->gb, 16);
63+ s->reset = get_bits(&s->gb, 16);
6664
6765 // ff_jpegls_reset_coding_parameters(s, 0);
6866 //FIXME quant table?
@@ -86,27 +84,30 @@ int ff_jpegls_decode_lse(MJpegDecodeContext *s) · 17 unmodified lines
8684 /**
8785 * Get context-dependent Golomb code, decode it and update context
8886 */
89−static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q){
87+static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
88+{
9089 int k, ret;
9190
92− for(k = 0; (state->N[Q] << k) < state->A[Q]; k++);
91+ for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
92+ ;
9393
9494 #ifdef JLS_BROKEN
95− if(!show_bits_long(gb, 32))return -1;
95+ if (!show_bits_long(gb, 32))
96+ return -1;
9697 #endif
9798 ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
9899
99100 /* decode mapped error */
100− if(ret & 1)
101+ if (ret & 1)
101102 ret = -(ret + 1 >> 1);
102103 else
103104 ret >>= 1;
104105
105106 /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */
106− if(!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
107+ if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
107108 ret = -(ret + 1);
108109
109− ret= ff_jpegls_update_state_regular(state, Q, ret);
110+ ret = ff_jpegls_update_state_regular(state, Q, ret);
110111
111112 return ret;
112113 }
@@ -114,28 +115,33 @@ static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q) · 1 unmodified line
114115 /**
115116 * Get Golomb code, decode it and update state for run termination
116117 */
117−static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RItype, int limit_add){
118+static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state,
119+ int RItype, int limit_add)
120+{
118121 int k, ret, temp, map;
119122 int Q = 365 + RItype;
120123
121− temp= state->A[Q];
122− if(RItype)
124+ temp = state->A[Q];
125+ if (RItype)
123126 temp += state->N[Q] >> 1;
124127
125− for(k = 0; (state->N[Q] << k) < temp; k++);
128+ for (k = 0; (state->N[Q] << k) < temp; k++)
129+ ;
126130
127131 #ifdef JLS_BROKEN
128− if(!show_bits_long(gb, 32))return -1;
132+ if (!show_bits_long(gb, 32))
133+ return -1;
129134 #endif
130− ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1, state->qbpp);
135+ ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
136+ state->qbpp);
131137
132138 /* decode mapped error */
133139 map = 0;
134− if(!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
140+ if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
135141 map = 1;
136142 ret += RItype + map;
137143
138− if(ret & 1){
144+ if (ret & 1) {
139145 ret = map - (ret + 1 >> 1);
140146 state->B[Q]++;
141147 } else {
@@ -144,7 +150,7 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI · 2 unmodified lines
144150
145151 /* update state */
146152 state->A[Q] += FFABS(ret) - RItype;
147− ret *= state->twonear;
153+ ret *= state->twonear;
148154 ff_jpegls_downscale_state(state, Q);
149155
150156 return ret;
@@ -153,12 +159,15 @@ static inline int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RI · 2 unmodified lines
153159 /**
154160 * Decode one line of image
155161 */
156−static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *last, void *dst, int last2, int w, int stride, int comp, int bits){
162+static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
163+ void *last, void *dst, int last2, int w,
164+ int stride, int comp, int bits)
165+{
157166 int i, x = 0;
158167 int Ra, Rb, Rc, Rd;
159168 int D0, D1, D2;
160169
161− while(x < w) {
170+ while (x < w) {
162171 int err, pred;
163172
164173 /* compute gradients */
@@ -170,49 +179,51 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void * · 5 unmodified lines
170179 D1 = Rb - Rc;
171180 D2 = Rc - Ra;
172181 /* run mode */
173− if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) {
182+ if ((FFABS(D0) <= state->near) &&
183+ (FFABS(D1) <= state->near) &&
184+ (FFABS(D2) <= state->near)) {
174185 int r;
175186 int RItype;
176187
177188 /* decode full runs while available */
178− while(get_bits1(&s->gb)) {
189+ while (get_bits1(&s->gb)) {
179190 int r;
180191 r = 1 << ff_log2_run[state->run_index[comp]];
181− if(x + r * stride > w) {
192+ if (x + r * stride > w)
182193 r = (w - x) / stride;
183− }
184− for(i = 0; i < r; i++) {
194+ for (i = 0; i < r; i++) {
185195 W(dst, x, Ra);
186196 x += stride;
187197 }
188198 /* if EOL reached, we stop decoding */
189199 if (r != 1 << ff_log2_run[state->run_index[comp]])
190200 return;
191− if(state->run_index[comp] < 31)
201+ if (state->run_index[comp] < 31)
192202 state->run_index[comp]++;
193− if(x + stride > w)
203+ if (x + stride > w)
194204 return;
195205 }
196206 /* decode aborted run */
197207 r = ff_log2_run[state->run_index[comp]];
198− if(r)
208+ if (r)
199209 r = get_bits_long(&s->gb, r);
200− for(i = 0; i < r; i++) {
210+ for (i = 0; i < r; i++) {
201211 W(dst, x, Ra);
202212 x += stride;
203213 }
204214
205215 /* decode run termination value */
206− Rb = R(last, x);
216+ Rb = R(last, x);
207217 RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
208− err = ls_get_code_runterm(&s->gb, state, RItype, ff_log2_run[state->run_index[comp]]);
209− if(state->run_index[comp])
218+ err = ls_get_code_runterm(&s->gb, state, RItype,
219+ ff_log2_run[state->run_index[comp]]);
220+ if (state->run_index[comp])
210221 state->run_index[comp]--;
211222
212− if(state->near && RItype){
223+ if (state->near && RItype) {
213224 pred = Ra + err;
214225 } else {
215− if(Rb < Ra)
226+ if (Rb < Ra)
216227 pred = Rb - err;
217228 else
218229 pred = Rb + err;
@@ -220,31 +231,33 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void * · 1 unmodified line
220231 } else { /* regular mode */
221232 int context, sign;
222233
223− context = ff_jpegls_quantize(state, D0) * 81 + ff_jpegls_quantize(state, D1) * 9 + ff_jpegls_quantize(state, D2);
224− pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
234+ context = ff_jpegls_quantize(state, D0) * 81 +
235+ ff_jpegls_quantize(state, D1) * 9 +
236+ ff_jpegls_quantize(state, D2);
237+ pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
225238
226− if(context < 0){
239+ if (context < 0) {
227240 context = -context;
228− sign = 1;
229− }else{
241+ sign = 1;
242+ } else {
230243 sign = 0;
231244 }
232245
233− if(sign){
246+ if (sign) {
234247 pred = av_clip(pred - state->C[context], 0, state->maxval);
235− err = -ls_get_code_regular(&s->gb, state, context);
248+ err = -ls_get_code_regular(&s->gb, state, context);
236249 } else {
237250 pred = av_clip(pred + state->C[context], 0, state->maxval);
238− err = ls_get_code_regular(&s->gb, state, context);
251+ err = ls_get_code_regular(&s->gb, state, context);
239252 }
240253
241254 /* we have to do something more for near-lossless coding */
242255 pred += err;
243256 }
244− if(state->near){
245− if(pred < -state->near)
257+ if (state->near) {
258+ if (pred < -state->near)
246259 pred += state->range * state->twonear;
247− else if(pred > state->maxval + state->near)
260+ else if (pred > state->maxval + state->near)
248261 pred -= state->range * state->twonear;
249262 pred = av_clip(pred, 0, state->maxval);
250263 }
@@ -255,7 +268,9 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, void * · 4 unmodified lines
255268 }
256269 }
257270
258−int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv){
271+int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
272+ int point_transform, int ilv)
273+{
259274 int i, t = 0;
260275 uint8_t *zero, *last, *cur;
261276 JLSState *state;
@@ -263,43 +278,45 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor · 1 unmodified line
263278
264279 zero = av_mallocz(s->picture_ptr->linesize[0]);
265280 last = zero;
266− cur = s->picture_ptr->data[0];
281+ cur = s->picture_ptr->data[0];
267282
268283 state = av_mallocz(sizeof(JLSState));
269284 /* initialize JPEG-LS state from JPEG parameters */
270− state->near = near;
271− state->bpp = (s->bits < 2) ? 2 : s->bits;
285+ state->near = near;
286+ state->bpp = (s->bits < 2) ? 2 : s->bits;
272287 state->maxval = s->maxval;
273− state->T1 = s->t1;
274− state->T2 = s->t2;
275− state->T3 = s->t3;
276− state->reset = s->reset;
288+ state->T1 = s->t1;
289+ state->T2 = s->t2;
290+ state->T3 = s->t3;
291+ state->reset = s->reset;
277292 ff_jpegls_reset_coding_parameters(state, 0);
278293 ff_jpegls_init_state(state);
279294
280− if(s->bits <= 8)
295+ if (s->bits <= 8)
281296 shift = point_transform + (8 - s->bits);
282297 else
283298 shift = point_transform + (16 - s->bits);
284299
285− av_dlog(s->avctx, "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
300+ av_dlog(s->avctx,
301+ "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
302+ "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
286303 s->width, s->height, state->near, state->maxval,
287304 state->T1, state->T2, state->T3,
288305 state->reset, state->limit, state->qbpp, state->range);
289306 av_dlog(s->avctx, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
290307 ilv, point_transform, s->bits, s->cur_scan);
291− if(ilv == 0) { /* separate planes */
292− off = s->cur_scan - 1;
308+ if (ilv == 0) { /* separate planes */
309+ off = s->cur_scan - 1;
293310 stride = (s->nb_components > 1) ? 3 : 1;
294− width = s->width * stride;
295− cur += off;
296− for(i = 0; i < s->height; i++) {
297− if(s->bits <= 8){
298− ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
311+ width = s->width * stride;
312+ cur += off;
313+ for (i = 0; i < s->height; i++) {
314+ if (s->bits <= 8) {
315+ ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
299316 t = last[0];
300− }else{
317+ } else {
301318 ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
302− t = *((uint16_t*)last);
319+ t = *((uint16_t *)last);
303320 }
304321 last = cur;
305322 cur += s->picture_ptr->linesize[0];
@@ -309,14 +326,15 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor · 3 unmodified lines
309326 skip_bits(&s->gb, 16); /* skip RSTn */
310327 }
311328 }
312− } else if(ilv == 1) { /* line interleaving */
329+ } else if (ilv == 1) { /* line interleaving */
313330 int j;
314− int Rc[3] = {0, 0, 0};
331+ int Rc[3] = { 0, 0, 0 };
315332 memset(cur, 0, s->picture_ptr->linesize[0]);
316333 width = s->width * 3;
317− for(i = 0; i < s->height; i++) {
318− for(j = 0; j < 3; j++) {
319− ls_decode_line(state, s, last + j, cur + j, Rc[j], width, 3, j, 8);
334+ for (i = 0; i < s->height; i++) {
335+ for (j = 0; j < 3; j++) {
336+ ls_decode_line(state, s, last + j, cur + j,
337+ Rc[j], width, 3, j, 8);
320338 Rc[j] = last[j];
321339
322340 if (s->restart_interval && !--s->restart_count) {
@@ -327,35 +345,34 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor · 4 unmodified lines
327345 last = cur;
328346 cur += s->picture_ptr->linesize[0];
329347 }
330− } else if(ilv == 2) { /* sample interleaving */
331− av_log(s->avctx, AV_LOG_ERROR, "Sample interleaved images are not supported.\n");
348+ } else if (ilv == 2) { /* sample interleaving */
349+ av_log(s->avctx, AV_LOG_ERROR,
350+ "Sample interleaved images are not supported.\n");
332351 av_free(state);
333352 av_free(zero);
334353 return -1;
335354 }
336355
337− if(shift){ /* we need to do point transform or normalize samples */
356+ if (shift) { /* we need to do point transform or normalize samples */
338357 int x, w;
339358
340359 w = s->width * s->nb_components;
341360
342− if(s->bits <= 8){
361+ if (s->bits <= 8) {
343362 uint8_t *src = s->picture_ptr->data[0];
344363
345− for(i = 0; i < s->height; i++){
346− for(x = off; x < w; x+= stride){
364+ for (i = 0; i < s->height; i++) {
365+ for (x = off; x < w; x += stride)
347366 src[x] <<= shift;
348− }
349367 src += s->picture_ptr->linesize[0];
350368 }
351− }else{
352− uint16_t *src = (uint16_t*) s->picture_ptr->data[0];
369+ } else {
370+ uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
353371
354− for(i = 0; i < s->height; i++){
355− for(x = 0; x < w; x++){
372+ for (i = 0; i < s->height; i++) {
373+ for (x = 0; x < w; x++)
356374 src[x] <<= shift;
357− }
358− src += s->picture_ptr->linesize[0]/2;
375+ src += s->picture_ptr->linesize[0] / 2;
359376 }
360377 }
361378 }
@@ -365,9 +382,9 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transfor · 3 unmodified lines
365382 return 0;
366383 }
367384
368−
369385 AVCodec ff_jpegls_decoder = {
370386 .name = "jpegls",
387+ .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
371388 .type = AVMEDIA_TYPE_VIDEO,
372389 .id = AV_CODEC_ID_JPEGLS,
373390 .priv_data_size = sizeof(MJpegDecodeContext),
@@ -375,5 +392,4 @@ AVCodec ff_jpegls_decoder = { · 1 unmodified line
375392 .close = ff_mjpeg_decode_end,
376393 .decode = ff_mjpeg_decode_frame,
377394 .capabilities = CODEC_CAP_DR1,
378− .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
379395 };
libavcodec/jpeglsdec.h+2−1
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636 */
3737 int ff_jpegls_decode_lse(MJpegDecodeContext *s);
3838
39−int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv);
39+int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
40+ int point_transform, int ilv);
4041
4142 #endif /* AVCODEC_JPEGLSDEC_H */
libavcodec/jpeglsenc.c+134−106
@@ -33,24 +33,26 @@ · 32 unmodified lines
3333 #include "mjpeg.h"
3434 #include "jpegls.h"
3535
36−
3736 /**
3837 * Encode error from regular symbol
3938 */
40−static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err){
39+static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q,
40+ int err)
41+{
4142 int k;
4243 int val;
4344 int map;
4445
45− for(k = 0; (state->N[Q] << k) < state->A[Q]; k++);
46+ for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
47+ ;
4648
4749 map = !state->near && !k && (2 * state->B[Q] <= -state->N[Q]);
4850
49− if(err < 0)
51+ if (err < 0)
5052 err += state->range;
5153 if (err >= (state->range + 1 >> 1)) {
5254 err -= state->range;
53− val = 2 * FFABS(err) - 1 - map;
55+ val = 2 * FFABS(err) - 1 - map;
5456 } else
5557 val = 2 * err + map;
5658
@@ -62,27 +64,30 @@ static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, · 5 unmodified lines
6264 /**
6365 * Encode error from run termination
6466 */
65−static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add){
67+static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb,
68+ int RItype, int err, int limit_add)
69+{
6670 int k;
6771 int val, map;
6872 int Q = 365 + RItype;
6973 int temp;
7074
7175 temp = state->A[Q];
72− if(RItype)
76+ if (RItype)
7377 temp += state->N[Q] >> 1;
74− for(k = 0; (state->N[Q] << k) < temp; k++);
78+ for (k = 0; (state->N[Q] << k) < temp; k++)
79+ ;
7580 map = 0;
76− if(!k && err && (2 * state->B[Q] < state->N[Q]))
81+ if (!k && err && (2 * state->B[Q] < state->N[Q]))
7782 map = 1;
7883
79− if(err < 0)
80− val = - (2 * err) - 1 - RItype + map;
84+ if (err < 0)
85+ val = -(2 * err) - 1 - RItype + map;
8186 else
8287 val = 2 * err - RItype - map;
8388 set_ur_golomb_jpegls(pb, val, k, state->limit - limit_add - 1, state->qbpp);
8489
85− if(err < 0)
90+ if (err < 0)
8691 state->B[Q]++;
8792 state->A[Q] += (val + 1 - RItype) >> 1;
8893
@@ -92,19 +97,21 @@ static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RIt · 3 unmodified lines
9297 /**
9398 * Encode run value as specified by JPEG-LS standard
9499 */
95−static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run, int comp, int trail){
96− while(run >= (1 << ff_log2_run[state->run_index[comp]])){
100+static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run,
101+ int comp, int trail)
102+{
103+ while (run >= (1 << ff_log2_run[state->run_index[comp]])) {
97104 put_bits(pb, 1, 1);
98105 run -= 1 << ff_log2_run[state->run_index[comp]];
99− if(state->run_index[comp] < 31)
106+ if (state->run_index[comp] < 31)
100107 state->run_index[comp]++;
101108 }
102109 /* if hit EOL, encode another full run, else encode aborted run */
103− if(!trail && run) {
110+ if (!trail && run) {
104111 put_bits(pb, 1, 1);
105− }else if(trail){
112+ } else if (trail) {
106113 put_bits(pb, 1, 0);
107− if(ff_log2_run[state->run_index[comp]])
114+ if (ff_log2_run[state->run_index[comp]])
108115 put_bits(pb, ff_log2_run[state->run_index[comp]], run);
109116 }
110117 }
@@ -112,12 +119,15 @@ static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run, in · 1 unmodified line
112119 /**
113120 * Encode one line of image
114121 */
115−static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last, void *cur, int last2, int w, int stride, int comp, int bits){
122+static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
123+ void *last, void *cur, int last2, int w,
124+ int stride, int comp, int bits)
125+{
116126 int x = 0;
117127 int Ra, Rb, Rc, Rd;
118128 int D0, D1, D2;
119129
120− while(x < w) {
130+ while (x < w) {
121131 int err, pred, sign;
122132
123133 /* compute gradients */
@@ -130,71 +140,76 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last · 6 unmodified lines
130140 D2 = Rc - Ra;
131141
132142 /* run mode */
133− if((FFABS(D0) <= state->near) && (FFABS(D1) <= state->near) && (FFABS(D2) <= state->near)) {
143+ if ((FFABS(D0) <= state->near) &&
144+ (FFABS(D1) <= state->near) &&
145+ (FFABS(D2) <= state->near)) {
134146 int RUNval, RItype, run;
135147
136− run = 0;
148+ run = 0;
137149 RUNval = Ra;
138− while(x < w && (FFABS(R(cur, x) - RUNval) <= state->near)){
150+ while (x < w && (FFABS(R(cur, x) - RUNval) <= state->near)) {
139151 run++;
140152 W(cur, x, Ra);
141153 x += stride;
142154 }
143155 ls_encode_run(state, pb, run, comp, x < w);
144− if(x >= w)
156+ if (x >= w)
145157 return;
146− Rb = R(last, x);
158+ Rb = R(last, x);
147159 RItype = FFABS(Ra - Rb) <= state->near;
148− pred = RItype ? Ra : Rb;
149− err = R(cur, x) - pred;
160+ pred = RItype ? Ra : Rb;
161+ err = R(cur, x) - pred;
150162
151− if(!RItype && Ra > Rb)
163+ if (!RItype && Ra > Rb)
152164 err = -err;
153165
154− if(state->near){
155− if(err > 0)
156− err = (state->near + err) / state->twonear;
166+ if (state->near) {
167+ if (err > 0)
168+ err = (state->near + err) / state->twonear;
157169 else
158170 err = -(state->near - err) / state->twonear;
159171
160− if(RItype || (Rb >= Ra))
172+ if (RItype || (Rb >= Ra))
161173 Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
162174 else
163175 Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
164176 W(cur, x, Ra);
165177 }
166− if(err < 0)
178+ if (err < 0)
167179 err += state->range;
168180 if (err >= state->range + 1 >> 1)
169181 err -= state->range;
170182
171− ls_encode_runterm(state, pb, RItype, err, ff_log2_run[state->run_index[comp]]);
183+ ls_encode_runterm(state, pb, RItype, err,
184+ ff_log2_run[state->run_index[comp]]);
172185
173− if(state->run_index[comp] > 0)
186+ if (state->run_index[comp] > 0)
174187 state->run_index[comp]--;
175188 } else { /* regular mode */
176189 int context;
177190
178− context = ff_jpegls_quantize(state, D0) * 81 + ff_jpegls_quantize(state, D1) * 9 + ff_jpegls_quantize(state, D2);
179− pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
191+ context = ff_jpegls_quantize(state, D0) * 81 +
192+ ff_jpegls_quantize(state, D1) * 9 +
193+ ff_jpegls_quantize(state, D2);
194+ pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
180195
181− if(context < 0){
196+ if (context < 0) {
182197 context = -context;
183− sign = 1;
184− pred = av_clip(pred - state->C[context], 0, state->maxval);
185− err = pred - R(cur, x);
186− }else{
198+ sign = 1;
199+ pred = av_clip(pred - state->C[context], 0, state->maxval);
200+ err = pred - R(cur, x);
201+ } else {
187202 sign = 0;
188203 pred = av_clip(pred + state->C[context], 0, state->maxval);
189− err = R(cur, x) - pred;
204+ err = R(cur, x) - pred;
190205 }
191206
192− if(state->near){
193− if(err > 0)
194− err = (state->near + err) / state->twonear;
207+ if (state->near) {
208+ if (err > 0)
209+ err = (state->near + err) / state->twonear;
195210 else
196211 err = -(state->near - err) / state->twonear;
197− if(!sign)
212+ if (!sign)
198213 Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
199214 else
200215 Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
@@ -207,18 +222,22 @@ static inline void ls_encode_line(JLSState *state, PutBitContext *pb, void *last · 6 unmodified lines
207222 }
208223 }
209224
210−static void ls_store_lse(JLSState *state, PutBitContext *pb){
225+static void ls_store_lse(JLSState *state, PutBitContext *pb)
226+{
211227 /* Test if we have default params and don't need to store LSE */
212228 JLSState state2 = { 0 };
213− state2.bpp = state->bpp;
229+ state2.bpp = state->bpp;
214230 state2.near = state->near;
215231 ff_jpegls_reset_coding_parameters(&state2, 1);
216− if(state->T1 == state2.T1 && state->T2 == state2.T2 && state->T3 == state2.T3 && state->reset == state2.reset)
232+ if (state->T1 == state2.T1 &&
233+ state->T2 == state2.T2 &&
234+ state->T3 == state2.T3 &&
235+ state->reset == state2.reset)
217236 return;
218237 /* store LSE type 1 */
219238 put_marker(pb, LSE);
220239 put_bits(pb, 16, 13);
221− put_bits(pb, 8, 1);
240+ put_bits(pb, 8, 1);
222241 put_bits(pb, 16, state->maxval);
223242 put_bits(pb, 16, state->T1);
224243 put_bits(pb, 16, state->T2);
@@ -229,9 +248,9 @@ static void ls_store_lse(JLSState *state, PutBitContext *pb){ · 4 unmodified lines
229248 static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
230249 const AVFrame *pict, int *got_packet)
231250 {
232− JpeglsContext * const s = avctx->priv_data;
233− AVFrame * const p = &s->picture;
234− const int near = avctx->prediction_method;
251+ JpeglsContext *const s = avctx->priv_data;
252+ AVFrame *const p = &s->picture;
253+ const int near = avctx->prediction_method;
235254 PutBitContext pb, pb2;
236255 GetBitContext gb;
237256 uint8_t *buf2, *zero, *cur, *last;
@@ -239,17 +258,18 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 1 unmodified line
239258 int i, size, ret;
240259 int comps;
241260
242− *p = *pict;
243− p->pict_type= AV_PICTURE_TYPE_I;
244− p->key_frame= 1;
261+ *p = *pict;
262+ p->pict_type = AV_PICTURE_TYPE_I;
263+ p->key_frame = 1;
245264
246− if(avctx->pix_fmt == AV_PIX_FMT_GRAY8 || avctx->pix_fmt == AV_PIX_FMT_GRAY16)
265+ if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
266+ avctx->pix_fmt == AV_PIX_FMT_GRAY16)
247267 comps = 1;
248268 else
249269 comps = 3;
250270
251− if ((ret = ff_alloc_packet(pkt, avctx->width*avctx->height*comps*4 +
252− FF_MIN_BUFFER_SIZE)) < 0) {
271+ if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 +
272+ FF_MIN_BUFFER_SIZE)) < 0) {
253273 av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
254274 return ret;
255275 }
@@ -263,31 +283,31 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 7 unmodified lines
263283 put_marker(&pb, SOI);
264284 put_marker(&pb, SOF48);
265285 put_bits(&pb, 16, 8 + comps * 3); // header size depends on components
266− put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp
286+ put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp
267287 put_bits(&pb, 16, avctx->height);
268288 put_bits(&pb, 16, avctx->width);
269− put_bits(&pb, 8, comps); // components
270− for(i = 1; i <= comps; i++) {
271− put_bits(&pb, 8, i); // component ID
272− put_bits(&pb, 8, 0x11); // subsampling: none
273− put_bits(&pb, 8, 0); // Tiq, used by JPEG-LS ext
289+ put_bits(&pb, 8, comps); // components
290+ for (i = 1; i <= comps; i++) {
291+ put_bits(&pb, 8, i); // component ID
292+ put_bits(&pb, 8, 0x11); // subsampling: none
293+ put_bits(&pb, 8, 0); // Tiq, used by JPEG-LS ext
274294 }
275295
276296 put_marker(&pb, SOS);
277297 put_bits(&pb, 16, 6 + comps * 2);
278− put_bits(&pb, 8, comps);
279− for(i = 1; i <= comps; i++) {
280− put_bits(&pb, 8, i); // component ID
281− put_bits(&pb, 8, 0); // mapping index: none
298+ put_bits(&pb, 8, comps);
299+ for (i = 1; i <= comps; i++) {
300+ put_bits(&pb, 8, i); // component ID
301+ put_bits(&pb, 8, 0); // mapping index: none
282302 }
283− put_bits(&pb, 8, near);
284− put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
285− put_bits(&pb, 8, 0); // point transform: none
303+ put_bits(&pb, 8, near);
304+ put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
305+ put_bits(&pb, 8, 0); // point transform: none
286306
287307 state = av_mallocz(sizeof(JLSState));
288308 /* initialize JPEG-LS state from JPEG parameters */
289309 state->near = near;
290− state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
310+ state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
291311 ff_jpegls_reset_coding_parameters(state, 0);
292312 ff_jpegls_init_state(state);
293313
@@ -295,46 +315,48 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 1 unmodified line
295315
296316 zero = av_mallocz(p->linesize[0]);
297317 last = zero;
298− cur = p->data[0];
299− if(avctx->pix_fmt == AV_PIX_FMT_GRAY8){
318+ cur = p->data[0];
319+ if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
300320 int t = 0;
301321
302− for(i = 0; i < avctx->height; i++) {
303− ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
304− t = last[0];
322+ for (i = 0; i < avctx->height; i++) {
323+ ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
324+ t = last[0];
305325 last = cur;
306326 cur += p->linesize[0];
307327 }
308− }else if(avctx->pix_fmt == AV_PIX_FMT_GRAY16){
328+ } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
309329 int t = 0;
310330
311− for(i = 0; i < avctx->height; i++) {
331+ for (i = 0; i < avctx->height; i++) {
312332 ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16);
313− t = *((uint16_t*)last);
333+ t = *((uint16_t *)last);
314334 last = cur;
315335 cur += p->linesize[0];
316336 }
317− }else if(avctx->pix_fmt == AV_PIX_FMT_RGB24){
337+ } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
318338 int j, width;
319− int Rc[3] = {0, 0, 0};
339+ int Rc[3] = { 0, 0, 0 };
320340
321341 width = avctx->width * 3;
322− for(i = 0; i < avctx->height; i++) {
323− for(j = 0; j < 3; j++) {
324− ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8);
342+ for (i = 0; i < avctx->height; i++) {
343+ for (j = 0; j < 3; j++) {
344+ ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
345+ width, 3, j, 8);
325346 Rc[j] = last[j];
326347 }
327348 last = cur;
328349 cur += s->picture.linesize[0];
329350 }
330− }else if(avctx->pix_fmt == AV_PIX_FMT_BGR24){
351+ } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
331352 int j, width;
332− int Rc[3] = {0, 0, 0};
353+ int Rc[3] = { 0, 0, 0 };
333354
334355 width = avctx->width * 3;
335− for(i = 0; i < avctx->height; i++) {
336− for(j = 2; j >= 0; j--) {
337− ls_encode_line(state, &pb2, last + j, cur + j, Rc[j], width, 3, j, 8);
356+ for (i = 0; i < avctx->height; i++) {
357+ for (j = 2; j >= 0; j--) {
358+ ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
359+ width, 3, j, 8);
338360 Rc[j] = last[j];
339361 }
340362 last = cur;
@@ -345,20 +367,20 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 4 unmodified lines
345367 av_free(zero);
346368 av_free(state);
347369
348− // the specification says that after doing 0xff escaping unused bits in the
349− // last byte must be set to 0, so just append 7 "optional" zero-bits to
350− // avoid special-casing.
370+ /* the specification says that after doing 0xff escaping unused bits in
371+ * the last byte must be set to 0, so just append 7 "optional" zero-bits
372+ * to avoid special-casing. */
351373 put_bits(&pb2, 7, 0);
352374 size = put_bits_count(&pb2);
353375 flush_put_bits(&pb2);
354376 /* do escape coding */
355377 init_get_bits(&gb, buf2, size);
356378 size -= 7;
357− while(get_bits_count(&gb) < size){
379+ while (get_bits_count(&gb) < size) {
358380 int v;
359381 v = get_bits(&gb, 8);
360382 put_bits(&pb, 8, v);
361− if(v == 0xFF){
383+ if (v == 0xFF) {
362384 v = get_bits(&gb, 7);
363385 put_bits(&pb, 8, v);
364386 }
@@ -378,29 +400,35 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, · 13 unmodified lines
378400 return 0;
379401 }
380402
381−static av_cold int encode_init_ls(AVCodecContext *ctx) {
382− JpeglsContext *c = (JpeglsContext*)ctx->priv_data;
403+static av_cold int encode_init_ls(AVCodecContext *ctx)
404+{
405+ JpeglsContext *c = (JpeglsContext *)ctx->priv_data;
383406
384− c->avctx = ctx;
407+ c->avctx = ctx;
385408 ctx->coded_frame = &c->picture;
386409
387− if(ctx->pix_fmt != AV_PIX_FMT_GRAY8 && ctx->pix_fmt != AV_PIX_FMT_GRAY16 && ctx->pix_fmt != AV_PIX_FMT_RGB24 && ctx->pix_fmt != AV_PIX_FMT_BGR24){
388− av_log(ctx, AV_LOG_ERROR, "Only grayscale and RGB24/BGR24 images are supported\n");
410+ if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
411+ ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
412+ ctx->pix_fmt != AV_PIX_FMT_RGB24 &&
413+ ctx->pix_fmt != AV_PIX_FMT_BGR24) {
414+ av_log(ctx, AV_LOG_ERROR,
415+ "Only grayscale and RGB24/BGR24 images are supported\n");
389416 return -1;
390417 }
391418 return 0;
392419 }
393420
394−AVCodec ff_jpegls_encoder = { //FIXME avoid MPV_* lossless JPEG should not need them
421+AVCodec ff_jpegls_encoder = {
395422 .name = "jpegls",
423+ .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
396424 .type = AVMEDIA_TYPE_VIDEO,
397425 .id = AV_CODEC_ID_JPEGLS,
398426 .priv_data_size = sizeof(JpeglsContext),
399427 .init = encode_init_ls,
400428 .encode2 = encode_picture_ls,
401− .pix_fmts = (const enum AVPixelFormat[]){
402− AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
429+ .pix_fmts = (const enum AVPixelFormat[]) {
430+ AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,
431+ AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
403432 AV_PIX_FMT_NONE
404433 },
405− .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
406434 };

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t