FFmpeg
jpeglsdec.c
Go to the documentation of this file.
1 /*
2  * JPEG-LS decoder
3  * Copyright (c) 2003 Michael Niedermayer
4  * Copyright (c) 2006 Konstantin Shishkov
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 /**
24  * @file
25  * JPEG-LS decoder.
26  */
27 
28 #include "libavutil/attributes.h"
29 #include "libavutil/mem.h"
30 #include "avcodec.h"
31 #include "codec_internal.h"
32 #include "get_bits.h"
33 #include "golomb.h"
34 #include "mathops.h"
35 #include "mjpegdec.h"
36 #include "jpegls.h"
37 #include "jpeglsdec.h"
38 
39 /*
40  * Uncomment this to significantly speed up decoding of broken JPEG-LS
41  * (or test broken JPEG-LS decoder) and slow down ordinary decoding a bit.
42  *
43  * There is no Golomb code with length >= 32 bits possible, so check and
44  * avoid situation of 32 zeros, FFmpeg Golomb decoder is painfully slow
45  * on this errors.
46  */
47 //#define JLS_BROKEN
48 
49 /**
50  * Decode LSE block with initialization parameters
51  */
53 {
54  int id;
55  int tid, wt, maxtab, i, j;
56 
57  int len = bytestream2_get_be16(&s->gB);
58  id = bytestream2_get_byte(&s->gB);
59 
60  switch (id) {
61  case 1:
62  if (len < 13)
63  return AVERROR_INVALIDDATA;
64 
65  s->maxval = bytestream2_get_be16u(&s->gB);
66  s->t1 = bytestream2_get_be16u(&s->gB);
67  s->t2 = bytestream2_get_be16u(&s->gB);
68  s->t3 = bytestream2_get_be16u(&s->gB);
69  s->reset = bytestream2_get_be16u(&s->gB);
70 
71  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
72  av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d T2:%d T3:%d reset:%d\n",
73  s->maxval, s->t1, s->t2, s->t3, s->reset);
74  }
75 
76 // ff_jpegls_reset_coding_parameters(s, 0);
77  //FIXME quant table?
78  break;
79  case 2:
80  s->palette_index = 0;
82  case 3:
83  tid= bytestream2_get_byte(&s->gB);
84  wt = bytestream2_get_byte(&s->gB);
85 
86  if (len < 5)
87  return AVERROR_INVALIDDATA;
88 
89  if (wt < 1 || wt > MAX_COMPONENTS) {
90  avpriv_request_sample(s->avctx, "wt %d", wt);
91  return AVERROR_PATCHWELCOME;
92  }
93 
94  if (!s->maxval)
95  maxtab = 255;
96  else if ((5 + wt*(s->maxval+1)) < 65535)
97  maxtab = s->maxval;
98  else
99  maxtab = 65530/wt - 1;
100 
101  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
102  av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab);
103  }
104  if (maxtab >= 256) {
105  avpriv_request_sample(s->avctx, ">8bit palette");
106  return AVERROR_PATCHWELCOME;
107  }
108  maxtab = FFMIN(maxtab, (len - 5) / wt + s->palette_index);
109 
110  if (s->palette_index > maxtab)
111  return AVERROR_INVALIDDATA;
112 
113  if ((s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) &&
114  (s->picture_ptr->format == AV_PIX_FMT_GRAY8 || s->picture_ptr->format == AV_PIX_FMT_PAL8)) {
115  uint32_t *pal = (uint32_t *)s->picture_ptr->data[1];
116  int shift = 0;
117 
118  if (s->avctx->bits_per_raw_sample > 0 && s->avctx->bits_per_raw_sample < 8) {
119  maxtab = FFMIN(maxtab, (1<<s->avctx->bits_per_raw_sample)-1);
120  shift = 8 - s->avctx->bits_per_raw_sample;
121  }
122 
123  s->force_pal8++;
124  if (!pal) {
125  if (s->force_pal8 > 1)
126  return AVERROR_INVALIDDATA;
127  return 1;
128  }
129 
130  for (i=s->palette_index; i<=maxtab; i++) {
131  uint8_t k = i << shift;
132  pal[k] = wt < 4 ? 0xFF000000 : 0;
133  for (j=0; j<wt; j++) {
134  pal[k] |= bytestream2_get_byte(&s->gB) << (8*(wt-j-1));
135  }
136  }
137  s->palette_index = i;
138  }
139  break;
140  case 4:
141  avpriv_request_sample(s->avctx, "oversize image");
142  return AVERROR(ENOSYS);
143  default:
144  av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
145  return AVERROR_INVALIDDATA;
146  }
147  ff_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
148 
149  return 0;
150 }
151 
152 /**
153  * Get context-dependent Golomb code, decode it and update context
154  */
155 static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
156 {
157  int k, ret;
158 
159  for (k = 0; ((unsigned)state->N[Q] << k) < state->A[Q]; k++)
160  ;
161 
162 #ifdef JLS_BROKEN
163  if (!show_bits_long(gb, 32))
164  return -1;
165 #endif
166  ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
167 
168  /* decode mapped error */
169  if (ret & 1)
170  ret = -(ret + 1 >> 1);
171  else
172  ret >>= 1;
173 
174  /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */
175  if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
176  ret = -(ret + 1);
177 
179 
180  return ret;
181 }
182 
183 /**
184  * Get Golomb code, decode it and update state for run termination
185  */
187  int RItype, int limit_add)
188 {
189  int k, ret, temp, map;
190  int Q = 365 + RItype;
191 
192  temp = state->A[Q];
193  if (RItype)
194  temp += state->N[Q] >> 1;
195 
196  for (k = 0; ((unsigned)state->N[Q] << k) < temp; k++)
197  ;
198 
199 #ifdef JLS_BROKEN
200  if (!show_bits_long(gb, 32))
201  return -1;
202 #endif
203  ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
204  state->qbpp);
205  if (ret < 0)
206  return -0x10000;
207 
208  /* decode mapped error */
209  map = 0;
210  if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
211  map = 1;
212  ret += RItype + map;
213 
214  if (ret & 1) {
215  ret = map - (ret + 1 >> 1);
216  state->B[Q]++;
217  } else {
218  ret = ret >> 1;
219  }
220 
221  if (FFABS(ret) > 0xFFFF)
222  return -0x10000;
223  /* update state */
224  state->A[Q] += FFABS(ret) - RItype;
225  ret *= state->twonear;
227 
228  return ret;
229 }
230 
231 /**
232  * Decode one line of image
233  */
235  void *last, void *dst, int last2, int w,
236  int stride, int comp, int bits)
237 {
238  int i, x = 0;
239  int Ra, Rb, Rc, Rd;
240  int D0, D1, D2;
241 
242  while (x < w) {
243  int err, pred;
244 
245  if (get_bits_left(&s->gb) <= 0)
246  return AVERROR_INVALIDDATA;
247 
248  /* compute gradients */
249  Ra = x ? R(dst, x - stride) : R(last, x);
250  Rb = R(last, x);
251  Rc = x ? R(last, x - stride) : last2;
252  Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
253  D0 = Rd - Rb;
254  D1 = Rb - Rc;
255  D2 = Rc - Ra;
256  /* run mode */
257  if ((FFABS(D0) <= state->near) &&
258  (FFABS(D1) <= state->near) &&
259  (FFABS(D2) <= state->near)) {
260  int r;
261  int RItype;
262 
263  /* decode full runs while available */
264  while (get_bits1(&s->gb)) {
265  int r;
266  r = 1 << ff_log2_run[state->run_index[comp]];
267  if (x + r * stride > w)
268  r = (w - x) / stride;
269  for (i = 0; i < r; i++) {
270  W(dst, x, Ra);
271  x += stride;
272  }
273  /* if EOL reached, we stop decoding */
274  if (r != 1 << ff_log2_run[state->run_index[comp]])
275  return 0;
276  if (state->run_index[comp] < 31)
277  state->run_index[comp]++;
278  if (x + stride > w)
279  return 0;
280  }
281  /* decode aborted run */
282  r = ff_log2_run[state->run_index[comp]];
283  if (r)
284  r = get_bits(&s->gb, r);
285  if (x + r * stride > w) {
286  r = (w - x) / stride;
287  }
288  for (i = 0; i < r; i++) {
289  W(dst, x, Ra);
290  x += stride;
291  }
292 
293  if (x >= w) {
294  av_log(NULL, AV_LOG_ERROR, "run overflow\n");
295  av_assert0(x <= w);
296  return AVERROR_INVALIDDATA;
297  }
298 
299  /* decode run termination value */
300  Rb = R(last, x);
301  RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
302  err = ls_get_code_runterm(&s->gb, state, RItype,
303  ff_log2_run[state->run_index[comp]]);
304  if (state->run_index[comp])
305  state->run_index[comp]--;
306 
307  if (state->near && RItype) {
308  pred = Ra + err;
309  } else {
310  if (Rb < Ra)
311  pred = Rb - err;
312  else
313  pred = Rb + err;
314  }
315  } else { /* regular mode */
316  int context, sign;
317 
318  context = ff_jpegls_quantize(state, D0) * 81 +
319  ff_jpegls_quantize(state, D1) * 9 +
321  pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
322 
323  if (context < 0) {
324  context = -context;
325  sign = 1;
326  } else {
327  sign = 0;
328  }
329 
330  if (sign) {
331  pred = av_clip(pred - state->C[context], 0, state->maxval);
332  err = -ls_get_code_regular(&s->gb, state, context);
333  } else {
334  pred = av_clip(pred + state->C[context], 0, state->maxval);
335  err = ls_get_code_regular(&s->gb, state, context);
336  }
337 
338  /* we have to do something more for near-lossless coding */
339  pred += err;
340  }
341  if (state->near) {
342  if (pred < -state->near)
343  pred += state->range * state->twonear;
344  else if (pred > state->maxval + state->near)
345  pred -= state->range * state->twonear;
346  pred = av_clip(pred, 0, state->maxval);
347  }
348 
349  pred &= state->maxval;
350  W(dst, x, pred);
351  x += stride;
352  }
353 
354  return 0;
355 }
356 
358 {
359  int near = s->Ss;
360  int point_transform = s->Al;
361  int ilv = s->Se;
362  int i, t = 0;
363  uint8_t *zero, *last, *cur;
364  JLSState *state = s->jls_state;
365  int off = 0, stride = 1, width, shift, ret = 0;
366  int decoded_height = 0;
367 
368  /* Bound the total amount of JPEG-LS decoding work per packet:
369  * Per T.87, ILV=0 uses one scan per component while ILV=1/2 use a single
370  * interleaved scan, and ff_mjpeg_decode_sof() rejects subsampled JPEG-LS,
371  * so a valid image needs at most height * nb_components
372  * (<= height * MAX_COMPONENTS) rows of decoding. The extra factor of 2
373  * is slack so odd, damaged and weird files are not rejected. */
374  if (s->total_ls_decoded_height > s->height * 2LL * MAX_COMPONENTS)
375  return AVERROR_INVALIDDATA;
376 
377  if (!state) {
378  state = av_malloc(sizeof(*state));
379  if (!state)
380  return AVERROR(ENOMEM);
381  s->jls_state = state;
382  }
383  zero = av_mallocz(s->picture_ptr->linesize[0]);
384  if (!zero)
385  return AVERROR(ENOMEM);
386  last = zero;
387  cur = s->picture_ptr->data[0];
388 
389  /* initialize JPEG-LS state from JPEG parameters */
390  state->near = near;
391  state->bpp = (s->bits < 2) ? 2 : s->bits;
392  state->maxval = s->maxval;
393  state->T1 = s->t1;
394  state->T2 = s->t2;
395  state->T3 = s->t3;
396  state->reset = s->reset;
398 
399  /* Testing parameters here, we cannot test in LSE or SOF because
400  * these interdepend and are allowed in either order
401  */
402  if (state->maxval >= (1<<state->bpp) ||
403  state->T1 > state->T2 ||
404  state->T2 > state->T3 ||
405  state->T3 > state->maxval ||
406  state->reset > FFMAX(255, state->maxval)) {
408  goto end;
409  }
410 
411  if (s->bits <= 8)
412  shift = point_transform + (8 - s->bits);
413  else
414  shift = point_transform + (16 - s->bits);
415 
416  if (shift >= 16) {
418  goto end;
419  }
420 
421  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
422  av_log(s->avctx, AV_LOG_DEBUG,
423  "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
424  "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
425  s->width, s->height, state->near, state->maxval,
426  state->T1, state->T2, state->T3,
427  state->reset, state->limit, state->qbpp, state->range);
428  av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
429  ilv, point_transform, s->bits, s->cur_scan);
430  }
431 
432  s->restart_count = -1;
433 
434  if (ilv == 0) { /* separate planes */
435  if (s->cur_scan > s->nb_components) {
437  goto end;
438  }
439  stride = (s->nb_components > 1) ? 3 : 1;
440  off = av_clip(s->cur_scan - 1, 0, stride - 1);
441  width = s->width * stride;
442  cur += off;
443  for (i = 0; i < s->height; i++) {
444  int restart;
445  ret = ff_mjpeg_handle_restart(s, &restart);
446  if (ret < 0)
447  goto end;
448  if (restart) {
450  t = 0;
451  last = zero;
452  }
453  if (s->bits <= 8) {
454  ret = ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
455  t = last[0];
456  } else {
457  ret = ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
458  t = *((uint16_t *)last);
459  }
460  if (ret < 0)
461  break;
462  last = cur;
463  cur += s->picture_ptr->linesize[0];
464  }
465  decoded_height = i;
466  } else if (ilv == 1) { /* line interleaving */
467  int j;
468  int Rc[3] = { 0, 0, 0 };
469  stride = (s->nb_components > 1) ? 3 : 1;
470  memset(cur, 0, s->picture_ptr->linesize[0]);
471  width = s->width * stride;
472  for (i = 0; i < s->height; i++) {
473  int restart;
474  ret = ff_mjpeg_handle_restart(s, &restart);
475  if (ret < 0)
476  goto end;
477  if (restart) {
479  memset(Rc, 0, sizeof(Rc));
480  last = zero;
481  }
482  for (j = 0; j < stride; j++) {
483  ret = ls_decode_line(state, s, last + j, cur + j,
484  Rc[j], width, stride, j, 8);
485  if (ret < 0)
486  break;
487  Rc[j] = last[j];
488  }
489  if (ret < 0)
490  break;
491  last = cur;
492  cur += s->picture_ptr->linesize[0];
493  }
494  decoded_height = i;
495  } else if (ilv == 2) { /* sample interleaving */
496  avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
498  goto end;
499  } else { /* unknown interleaving */
500  avpriv_report_missing_feature(s->avctx, "Unknown interleaved images");
502  goto end;
503  }
504 
505  s->total_ls_decoded_height += decoded_height;
506 
507  if (s->xfrm && s->nb_components == 3) {
508  int x, w;
509 
510  w = s->width * s->nb_components;
511 
512  if (s->bits <= 8) {
513  uint8_t *src = s->picture_ptr->data[0];
514 
515  for (i = 0; i < decoded_height; i++) {
516  switch(s->xfrm) {
517  case 1:
518  for (x = off; x + 2 < w; x += 3) {
519  src[x ] += src[x+1] + 128;
520  src[x+2] += src[x+1] + 128;
521  }
522  break;
523  case 2:
524  for (x = off; x + 2 < w; x += 3) {
525  src[x ] += src[x+1] + 128;
526  src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
527  }
528  break;
529  case 3:
530  for (x = off; x + 2 < w; x += 3) {
531  int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
532  src[x+0] = src[x+2] + g + 128;
533  src[x+2] = src[x+1] + g + 128;
534  src[x+1] = g;
535  }
536  break;
537  case 4:
538  for (x = off; x + 2 < w; x += 3) {
539  int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
540  int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
541  int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
542  src[x+0] = av_clip_uint8(r);
543  src[x+1] = av_clip_uint8(g);
544  src[x+2] = av_clip_uint8(b);
545  }
546  break;
547  }
548  src += s->picture_ptr->linesize[0];
549  }
550  }else
551  avpriv_report_missing_feature(s->avctx, "16bit xfrm");
552  }
553 
554  if (shift) { /* we need to do point transform or normalize samples */
555  int x, w;
556 
557  w = s->width * s->nb_components;
558 
559  if (s->bits <= 8) {
560  uint8_t *src = s->picture_ptr->data[0];
561 
562  for (i = 0; i < decoded_height; i++) {
563  for (x = off; x < w; x += stride)
564  src[x] <<= shift;
565  src += s->picture_ptr->linesize[0];
566  }
567  } else {
568  uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
569 
570  for (i = 0; i < decoded_height; i++) {
571  for (x = 0; x < w; x++)
572  src[x] <<= shift;
573  src += s->picture_ptr->linesize[0] / 2;
574  }
575  }
576  }
577 
578 end:
579  av_free(zero);
580 
581  return ret;
582 }
583 
585  .p.name = "jpegls",
586  CODEC_LONG_NAME("JPEG-LS"),
587  .p.type = AVMEDIA_TYPE_VIDEO,
588  .p.id = AV_CODEC_ID_JPEGLS,
589  .priv_data_size = sizeof(MJpegDecodeContext),
593  .p.capabilities = AV_CODEC_CAP_DR1,
594  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
595 };
state
static struct @590 state
av_clip
#define av_clip
Definition: common.h:100
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:43
show_bits_long
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
Definition: get_bits.h:498
get_bits_left
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:688
r
const char * r
Definition: vf_curves.c:127
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:79
mjpegdec.h
b
#define b
Definition: input.c:43
jpeglsdec.h
R
#define R
Definition: huffyuv.h:44
FFCodec
Definition: codec_internal.h:127
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
ls_get_code_regular
static int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
Get context-dependent Golomb code, decode it and update context.
Definition: jpeglsdec.c:155
FF_DEBUG_PICT_INFO
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:1393
golomb.h
exp golomb vlc stuff
close
static av_cold void close(AVCodecParserContext *s)
Definition: apv_parser.c:197
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:337
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
ff_mjpeg_decode_init
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
Definition: mjpegdec.c:124
GetBitContext
Definition: get_bits.h:109
JLSState
Definition: jpegls.h:36
ff_mjpeg_handle_restart
static int ff_mjpeg_handle_restart(MJpegDecodeContext *s, int *restart)
Definition: mjpegdec.h:217
Q
#define Q(q)
jpegls.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
get_ur_golomb_jpegls
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
Definition: golomb.h:431
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:347
W
#define W(a, i, v)
Definition: jpegls.h:119
s
#define s(width, name)
Definition: cbs_vp9.c:198
g
const char * g
Definition: vf_curves.c:128
ff_jpegls_decoder
const FFCodec ff_jpegls_decoder
Definition: jpeglsdec.c:584
bits
uint8_t bits
Definition: vp3data.h:128
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:42
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
ls_decode_line
static int ls_decode_line(JLSState *state, MJpegDecodeContext *s, void *last, void *dst, int last2, int w, int stride, int comp, int bits)
Decode one line of image.
Definition: jpeglsdec.c:234
get_bits.h
ff_mjpeg_decode_end
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
Definition: mjpegdec.c:2899
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:332
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
if
if(ret)
Definition: filter_design.txt:179
context
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your context
Definition: writing_filters.txt:91
ff_jpegls_downscale_state
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition: jpegls.h:84
NULL
#define NULL
Definition: coverity.c:32
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
av_fallthrough
#define av_fallthrough
Definition: attributes.h:67
get_bits1
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:391
mathops.h
MJpegDecodeContext
Definition: mjpegdec.h:56
attributes.h
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
ff_dlog
#define ff_dlog(a,...)
Definition: tableprint_vlc.h:28
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:579
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
codec_internal.h
ff_jpegls_decode_lse
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
Decode LSE block with initialization parameters.
Definition: jpeglsdec.c:52
shift
static int shift(int a, int b)
Definition: bonk.c:261
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
ff_mjpeg_decode_frame
int ff_mjpeg_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
Definition: mjpegdec.c:2889
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
avpriv_report_missing_feature
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
ff_jpegls_quantize
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition: jpegls.h:52
zero
static int zero(InterplayACMContext *s, unsigned ind, unsigned col)
Definition: interplayacm.c:121
av_malloc
#define av_malloc(s)
Definition: ops_asmgen.c:44
ff_jpegls_init_state
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition: jpegls.c:34
ff_jpegls_update_state_regular
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition: jpegls.h:94
ff_jpegls_decode_picture
int ff_jpegls_decode_picture(MJpegDecodeContext *s)
Definition: jpeglsdec.c:357
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:179
len
int len
Definition: vorbis_enc_data.h:426
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:84
mid_pred
#define mid_pred
Definition: mathops.h:115
ret
ret
Definition: filter_design.txt:187
pred
static const float pred[4]
Definition: siprdata.h:259
ls_get_code_runterm
static int ls_get_code_runterm(GetBitContext *gb, JLSState *state, int RItype, int limit_add)
Get Golomb code, decode it and update state for run termination.
Definition: jpeglsdec.c:186
ff_jpegls_reset_coding_parameters
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition: jpegls.c:69
id
enum AVCodecID id
Definition: dts2pts.c:578
AV_CODEC_ID_JPEGLS
@ AV_CODEC_ID_JPEGLS
Definition: codec_id.h:63
temp
else temp
Definition: vf_mcdeint.c:271
av_clip_uint8
#define av_clip_uint8
Definition: common.h:106
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
mem.h
avpriv_request_sample
#define avpriv_request_sample(...)
Definition: tableprint_vlc.h:37
w
uint8_t w
Definition: llvidencdsp.c:39
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
ff_log2_run
const uint8_t ff_log2_run[41]
Definition: mathtables.c:155
MAX_COMPONENTS
#define MAX_COMPONENTS
Definition: mjpegdec.h:47
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
stride
#define stride
Definition: h264pred_template.c:536
width
#define width
Definition: dsp.h:89
src
#define src
Definition: vp8dsp.c:248