FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 "avcodec.h"
29 #include "get_bits.h"
30 #include "golomb.h"
31 #include "internal.h"
32 #include "mathops.h"
33 #include "mjpeg.h"
34 #include "mjpegdec.h"
35 #include "jpegls.h"
36 #include "jpeglsdec.h"
37 
38 /*
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, FFmpeg Golomb decoder is painfully slow
44  * on this errors.
45  */
46 //#define JLS_BROKEN
47 
48 /**
49  * Decode LSE block with initialization parameters
50  */
52 {
53  int id;
54  int tid, wt, maxtab, i, j;
55 
56  int len = get_bits(&s->gb, 16);
57  id = get_bits(&s->gb, 8);
58 
59  switch (id) {
60  case 1:
61  if (len < 13)
62  return AVERROR_INVALIDDATA;
63 
64  s->maxval = get_bits(&s->gb, 16);
65  s->t1 = get_bits(&s->gb, 16);
66  s->t2 = get_bits(&s->gb, 16);
67  s->t3 = get_bits(&s->gb, 16);
68  s->reset = get_bits(&s->gb, 16);
69 
70  if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
71  av_log(s->avctx, AV_LOG_DEBUG, "Coding parameters maxval:%d T1:%d T2:%d T3:%d reset:%d\n",
72  s->maxval, s->t1, s->t2, s->t3, s->reset);
73  }
74 
75 // ff_jpegls_reset_coding_parameters(s, 0);
76  //FIXME quant table?
77  break;
78  case 2:
79  s->palette_index = 0;
80  case 3:
81  tid= get_bits(&s->gb, 8);
82  wt = get_bits(&s->gb, 8);
83 
84  if (len < 5)
85  return AVERROR_INVALIDDATA;
86 
87  if (wt < 1 || wt > MAX_COMPONENTS) {
88  avpriv_request_sample(s->avctx, "wt %d", wt);
89  return AVERROR_PATCHWELCOME;
90  }
91 
92  if (!s->maxval)
93  maxtab = 255;
94  else if ((5 + wt*(s->maxval+1)) < 65535)
95  maxtab = s->maxval;
96  else
97  maxtab = 65530/wt - 1;
98 
99  if(s->avctx->debug & FF_DEBUG_PICT_INFO) {
100  av_log(s->avctx, AV_LOG_DEBUG, "LSE palette %d tid:%d wt:%d maxtab:%d\n", id, tid, wt, maxtab);
101  }
102  if (maxtab >= 256) {
103  avpriv_request_sample(s->avctx, ">8bit palette");
104  return AVERROR_PATCHWELCOME;
105  }
106  maxtab = FFMIN(maxtab, (len - 5) / wt + s->palette_index);
107 
108  if (s->palette_index > maxtab)
109  return AVERROR_INVALIDDATA;
110 
111  if ((s->avctx->pix_fmt == AV_PIX_FMT_GRAY8 || s->avctx->pix_fmt == AV_PIX_FMT_PAL8) &&
113  uint32_t *pal = (uint32_t *)s->picture_ptr->data[1];
114  int shift = 0;
115 
116  if (s->avctx->bits_per_raw_sample > 0 && s->avctx->bits_per_raw_sample < 8) {
117  maxtab = FFMIN(maxtab, (1<<s->avctx->bits_per_raw_sample)-1);
118  shift = 8 - s->avctx->bits_per_raw_sample;
119  }
120 
121  s->picture_ptr->format =
123  for (i=s->palette_index; i<=maxtab; i++) {
124  uint8_t k = i << shift;
125  pal[k] = 0;
126  for (j=0; j<wt; j++) {
127  pal[k] |= get_bits(&s->gb, 8) << (8*(wt-j-1));
128  }
129  }
130  s->palette_index = i;
131  }
132  break;
133  case 4:
134  avpriv_request_sample(s->avctx, "oversize image");
135  return AVERROR(ENOSYS);
136  default:
137  av_log(s->avctx, AV_LOG_ERROR, "invalid id %d\n", id);
138  return AVERROR_INVALIDDATA;
139  }
140  ff_dlog(s->avctx, "ID=%i, T=%i,%i,%i\n", id, s->t1, s->t2, s->t3);
141 
142  return 0;
143 }
144 
145 /**
146  * Get context-dependent Golomb code, decode it and update context
147  */
148 static inline int ls_get_code_regular(GetBitContext *gb, JLSState *state, int Q)
149 {
150  int k, ret;
151 
152  for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
153  ;
154 
155 #ifdef JLS_BROKEN
156  if (!show_bits_long(gb, 32))
157  return -1;
158 #endif
159  ret = get_ur_golomb_jpegls(gb, k, state->limit, state->qbpp);
160 
161  /* decode mapped error */
162  if (ret & 1)
163  ret = -(ret + 1 >> 1);
164  else
165  ret >>= 1;
166 
167  /* for NEAR=0, k=0 and 2*B[Q] <= - N[Q] mapping is reversed */
168  if (!state->near && !k && (2 * state->B[Q] <= -state->N[Q]))
169  ret = -(ret + 1);
170 
171  ret = ff_jpegls_update_state_regular(state, Q, ret);
172 
173  return ret;
174 }
175 
176 /**
177  * Get Golomb code, decode it and update state for run termination
178  */
180  int RItype, int limit_add)
181 {
182  int k, ret, temp, map;
183  int Q = 365 + RItype;
184 
185  temp = state->A[Q];
186  if (RItype)
187  temp += state->N[Q] >> 1;
188 
189  for (k = 0; (state->N[Q] << k) < temp; k++)
190  ;
191 
192 #ifdef JLS_BROKEN
193  if (!show_bits_long(gb, 32))
194  return -1;
195 #endif
196  ret = get_ur_golomb_jpegls(gb, k, state->limit - limit_add - 1,
197  state->qbpp);
198 
199  /* decode mapped error */
200  map = 0;
201  if (!k && (RItype || ret) && (2 * state->B[Q] < state->N[Q]))
202  map = 1;
203  ret += RItype + map;
204 
205  if (ret & 1) {
206  ret = map - (ret + 1 >> 1);
207  state->B[Q]++;
208  } else {
209  ret = ret >> 1;
210  }
211 
212  if(FFABS(ret) > 0xFFFF)
213  return -0x10000;
214  /* update state */
215  state->A[Q] += FFABS(ret) - RItype;
216  ret *= state->twonear;
217  ff_jpegls_downscale_state(state, Q);
218 
219  return ret;
220 }
221 
222 /**
223  * Decode one line of image
224  */
226  void *last, void *dst, int last2, int w,
227  int stride, int comp, int bits)
228 {
229  int i, x = 0;
230  int Ra, Rb, Rc, Rd;
231  int D0, D1, D2;
232 
233  while (x < w) {
234  int err, pred;
235 
236  /* compute gradients */
237  Ra = x ? R(dst, x - stride) : R(last, x);
238  Rb = R(last, x);
239  Rc = x ? R(last, x - stride) : last2;
240  Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
241  D0 = Rd - Rb;
242  D1 = Rb - Rc;
243  D2 = Rc - Ra;
244  /* run mode */
245  if ((FFABS(D0) <= state->near) &&
246  (FFABS(D1) <= state->near) &&
247  (FFABS(D2) <= state->near)) {
248  int r;
249  int RItype;
250 
251  /* decode full runs while available */
252  while (get_bits1(&s->gb)) {
253  int r;
254  r = 1 << ff_log2_run[state->run_index[comp]];
255  if (x + r * stride > w)
256  r = (w - x) / stride;
257  for (i = 0; i < r; i++) {
258  W(dst, x, Ra);
259  x += stride;
260  }
261  /* if EOL reached, we stop decoding */
262  if (r != 1 << ff_log2_run[state->run_index[comp]])
263  return;
264  if (state->run_index[comp] < 31)
265  state->run_index[comp]++;
266  if (x + stride > w)
267  return;
268  }
269  /* decode aborted run */
270  r = ff_log2_run[state->run_index[comp]];
271  if (r)
272  r = get_bits_long(&s->gb, r);
273  if (x + r * stride > w) {
274  r = (w - x) / stride;
275  }
276  for (i = 0; i < r; i++) {
277  W(dst, x, Ra);
278  x += stride;
279  }
280 
281  if (x >= w) {
282  av_log(NULL, AV_LOG_ERROR, "run overflow\n");
283  av_assert0(x <= w);
284  return;
285  }
286 
287  /* decode run termination value */
288  Rb = R(last, x);
289  RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
290  err = ls_get_code_runterm(&s->gb, state, RItype,
291  ff_log2_run[state->run_index[comp]]);
292  if (state->run_index[comp])
293  state->run_index[comp]--;
294 
295  if (state->near && RItype) {
296  pred = Ra + err;
297  } else {
298  if (Rb < Ra)
299  pred = Rb - err;
300  else
301  pred = Rb + err;
302  }
303  } else { /* regular mode */
304  int context, sign;
305 
306  context = ff_jpegls_quantize(state, D0) * 81 +
307  ff_jpegls_quantize(state, D1) * 9 +
308  ff_jpegls_quantize(state, D2);
309  pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
310 
311  if (context < 0) {
312  context = -context;
313  sign = 1;
314  } else {
315  sign = 0;
316  }
317 
318  if (sign) {
319  pred = av_clip(pred - state->C[context], 0, state->maxval);
320  err = -ls_get_code_regular(&s->gb, state, context);
321  } else {
322  pred = av_clip(pred + state->C[context], 0, state->maxval);
323  err = ls_get_code_regular(&s->gb, state, context);
324  }
325 
326  /* we have to do something more for near-lossless coding */
327  pred += err;
328  }
329  if (state->near) {
330  if (pred < -state->near)
331  pred += state->range * state->twonear;
332  else if (pred > state->maxval + state->near)
333  pred -= state->range * state->twonear;
334  pred = av_clip(pred, 0, state->maxval);
335  }
336 
337  pred &= state->maxval;
338  W(dst, x, pred);
339  x += stride;
340  }
341 }
342 
344  int point_transform, int ilv)
345 {
346  int i, t = 0;
347  uint8_t *zero, *last, *cur;
348  JLSState *state;
349  int off = 0, stride = 1, width, shift, ret = 0;
350 
351  zero = av_mallocz(s->picture_ptr->linesize[0]);
352  if (!zero)
353  return AVERROR(ENOMEM);
354  last = zero;
355  cur = s->picture_ptr->data[0];
356 
357  state = av_mallocz(sizeof(JLSState));
358  if (!state) {
359  av_free(zero);
360  return AVERROR(ENOMEM);
361  }
362  /* initialize JPEG-LS state from JPEG parameters */
363  state->near = near;
364  state->bpp = (s->bits < 2) ? 2 : s->bits;
365  state->maxval = s->maxval;
366  state->T1 = s->t1;
367  state->T2 = s->t2;
368  state->T3 = s->t3;
369  state->reset = s->reset;
371  ff_jpegls_init_state(state);
372 
373  if (s->bits <= 8)
374  shift = point_transform + (8 - s->bits);
375  else
376  shift = point_transform + (16 - s->bits);
377 
378  if (shift >= 16) {
379  ret = AVERROR_INVALIDDATA;
380  goto end;
381  }
382 
383  if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
385  "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "
386  "RESET=%i, LIMIT=%i, qbpp=%i, RANGE=%i\n",
387  s->width, s->height, state->near, state->maxval,
388  state->T1, state->T2, state->T3,
389  state->reset, state->limit, state->qbpp, state->range);
390  av_log(s->avctx, AV_LOG_DEBUG, "JPEG params: ILV=%i Pt=%i BPP=%i, scan = %i\n",
391  ilv, point_transform, s->bits, s->cur_scan);
392  }
393  if (get_bits_left(&s->gb) < s->height) {
394  ret = AVERROR_INVALIDDATA;
395  goto end;
396  }
397  if (ilv == 0) { /* separate planes */
398  if (s->cur_scan > s->nb_components) {
399  ret = AVERROR_INVALIDDATA;
400  goto end;
401  }
402  stride = (s->nb_components > 1) ? 3 : 1;
403  off = av_clip(s->cur_scan - 1, 0, stride - 1);
404  width = s->width * stride;
405  cur += off;
406  for (i = 0; i < s->height; i++) {
407  if (s->bits <= 8) {
408  ls_decode_line(state, s, last, cur, t, width, stride, off, 8);
409  t = last[0];
410  } else {
411  ls_decode_line(state, s, last, cur, t, width, stride, off, 16);
412  t = *((uint16_t *)last);
413  }
414  last = cur;
415  cur += s->picture_ptr->linesize[0];
416 
417  if (s->restart_interval && !--s->restart_count) {
418  align_get_bits(&s->gb);
419  skip_bits(&s->gb, 16); /* skip RSTn */
420  }
421  }
422  } else if (ilv == 1) { /* line interleaving */
423  int j;
424  int Rc[3] = { 0, 0, 0 };
425  stride = (s->nb_components > 1) ? 3 : 1;
426  memset(cur, 0, s->picture_ptr->linesize[0]);
427  width = s->width * stride;
428  for (i = 0; i < s->height; i++) {
429  for (j = 0; j < stride; j++) {
430  ls_decode_line(state, s, last + j, cur + j,
431  Rc[j], width, stride, j, 8);
432  Rc[j] = last[j];
433 
434  if (s->restart_interval && !--s->restart_count) {
435  align_get_bits(&s->gb);
436  skip_bits(&s->gb, 16); /* skip RSTn */
437  }
438  }
439  last = cur;
440  cur += s->picture_ptr->linesize[0];
441  }
442  } else if (ilv == 2) { /* sample interleaving */
443  avpriv_report_missing_feature(s->avctx, "Sample interleaved images");
444  ret = AVERROR_PATCHWELCOME;
445  goto end;
446  }
447 
448  if (s->xfrm && s->nb_components == 3) {
449  int x, w;
450 
451  w = s->width * s->nb_components;
452 
453  if (s->bits <= 8) {
454  uint8_t *src = s->picture_ptr->data[0];
455 
456  for (i = 0; i < s->height; i++) {
457  switch(s->xfrm) {
458  case 1:
459  for (x = off; x < w; x += 3) {
460  src[x ] += src[x+1] + 128;
461  src[x+2] += src[x+1] + 128;
462  }
463  break;
464  case 2:
465  for (x = off; x < w; x += 3) {
466  src[x ] += src[x+1] + 128;
467  src[x+2] += ((src[x ] + src[x+1])>>1) + 128;
468  }
469  break;
470  case 3:
471  for (x = off; x < w; x += 3) {
472  int g = src[x+0] - ((src[x+2]+src[x+1])>>2) + 64;
473  src[x+0] = src[x+2] + g + 128;
474  src[x+2] = src[x+1] + g + 128;
475  src[x+1] = g;
476  }
477  break;
478  case 4:
479  for (x = off; x < w; x += 3) {
480  int r = src[x+0] - (( 359 * (src[x+2]-128) + 490) >> 8);
481  int g = src[x+0] - (( 88 * (src[x+1]-128) - 183 * (src[x+2]-128) + 30) >> 8);
482  int b = src[x+0] + ((454 * (src[x+1]-128) + 574) >> 8);
483  src[x+0] = av_clip_uint8(r);
484  src[x+1] = av_clip_uint8(g);
485  src[x+2] = av_clip_uint8(b);
486  }
487  break;
488  }
489  src += s->picture_ptr->linesize[0];
490  }
491  }else
492  avpriv_report_missing_feature(s->avctx, "16bit xfrm");
493  }
494 
495  if (shift) { /* we need to do point transform or normalize samples */
496  int x, w;
497 
498  w = s->width * s->nb_components;
499 
500  if (s->bits <= 8) {
501  uint8_t *src = s->picture_ptr->data[0];
502 
503  for (i = 0; i < s->height; i++) {
504  for (x = off; x < w; x += stride)
505  src[x] <<= shift;
506  src += s->picture_ptr->linesize[0];
507  }
508  } else {
509  uint16_t *src = (uint16_t *)s->picture_ptr->data[0];
510 
511  for (i = 0; i < s->height; i++) {
512  for (x = 0; x < w; x++)
513  src[x] <<= shift;
514  src += s->picture_ptr->linesize[0] / 2;
515  }
516  }
517  }
518 
519 end:
520  av_free(state);
521  av_free(zero);
522 
523  return ret;
524 }
525 
527  .name = "jpegls",
528  .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
529  .type = AVMEDIA_TYPE_VIDEO,
530  .id = AV_CODEC_ID_JPEGLS,
531  .priv_data_size = sizeof(MJpegDecodeContext),
533  .close = ff_mjpeg_decode_end,
535  .capabilities = AV_CODEC_CAP_DR1,
536  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
537 };
static unsigned int show_bits_long(GetBitContext *s, int n)
Show 0-32 bits.
Definition: get_bits.h:397
int reset
Definition: jpegls.h:42
#define NULL
Definition: coverity.c:32
const uint8_t ff_log2_run[41]
Definition: bitstream.c:39
const char * s
Definition: avisynth_c.h:768
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int T2
Definition: jpegls.h:40
static int shift(int a, int b)
Definition: sonic.c:82
static struct @260 state
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:261
else temp
Definition: vf_mcdeint.c:259
const char * g
Definition: vf_curves.c:112
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
const char * b
Definition: vf_curves.c:113
int C[365]
Definition: jpegls.h:41
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1974
int twonear
Definition: jpegls.h:43
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
static int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int esc_len)
read unsigned golomb rice code (jpegls).
Definition: golomb.h:305
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition: avcodec.h:3147
int limit
Definition: jpegls.h:42
#define src
Definition: vp8dsp.c:254
AVCodec.
Definition: avcodec.h:3722
JPEG-LS decoder.
MJPEG encoder and decoder.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
int bpp
Definition: jpegls.h:42
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int maxval
Definition: jpegls.h:42
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
uint8_t bits
Definition: crc.c:296
uint8_t
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:73
#define FF_DEBUG_PICT_INFO
Definition: avcodec.h:2988
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
AVFrame * picture_ptr
Definition: mjpegdec.h:97
#define MAX_COMPONENTS
Definition: mjpegdec.h:42
#define ff_dlog(a,...)
bitstream reader API header.
#define av_log(a,...)
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:587
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: mjpegdec.c:2100
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
Definition: mjpegdec.c:2522
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
const char * r
Definition: vf_curves.c:111
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
#define zero
Definition: regdef.h:64
uint16_t width
Definition: gdv.c:47
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition: jpegls.c:62
const char * name
Name of the codec implementation.
Definition: avcodec.h:3729
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition: jpegls.h:97
int B[367]
Definition: jpegls.h:41
int ff_jpegls_decode_lse(MJpegDecodeContext *s)
Decode LSE block with initialization parameters.
Definition: jpeglsdec.c:51
int near
Definition: jpegls.h:43
#define FFMIN(a, b)
Definition: common.h:96
Definition: vf_geq.c:47
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
GetBitContext gb
Definition: mjpegdec.h:47
static const float pred[4]
Definition: siprdata.h:259
int qbpp
Definition: jpegls.h:42
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:83
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:274
Libavcodec external API header.
static void 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:225
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
int debug
debug
Definition: avcodec.h:2987
int A[367]
Definition: jpegls.h:41
static unsigned int get_bits1(GetBitContext *s)
Definition: get_bits.h:313
int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv)
Definition: jpeglsdec.c:343
static void skip_bits(GetBitContext *s, int n)
Definition: get_bits.h:306
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:148
#define W(a, i, v)
Definition: jpegls.h:122
JPEG-LS common code.
int T1
Definition: jpegls.h:40
int range
Definition: jpegls.h:42
int N[367]
Definition: jpegls.h:41
#define mid_pred
Definition: mathops.h:97
int reset
context halfing interval ?rename
Definition: mjpegdec.h:77
const VDPAUPixFmtMap * map
AVCodec ff_jpegls_decoder
Definition: jpeglsdec.c:526
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
Definition: get_bits.h:346
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
Definition: mjpegdec.c:126
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
Y , 8bpp.
Definition: pixfmt.h:70
common internal api header.
if(ret< 0)
Definition: vf_mcdeint.c:282
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:179
AVCodecContext * avctx
Definition: mjpegdec.h:46
#define av_free(p)
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition: jpegls.h:55
int len
static const uint8_t * align_get_bits(GetBitContext *s)
Definition: get_bits.h:464
int T3
Definition: jpegls.h:40
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition: jpegls.c:31
#define stride
MJPEG decoder.
exp golomb vlc stuff
enum AVCodecID id
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:1001
for(j=16;j >0;--j)
int run_index[4]
Definition: jpegls.h:44
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition: jpegls.h:87