Libav
jpeglsenc.c
Go to the documentation of this file.
1 /*
2  * JPEG-LS encoder
3  * Copyright (c) 2003 Michael Niedermayer
4  * Copyright (c) 2006 Konstantin Shishkov
5  *
6  * This file is part of Libav.
7  *
8  * Libav 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  * Libav 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 Libav; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
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 "mjpegenc.h"
35 #include "jpegls.h"
36 
37 typedef struct JPEGLSContext {
38  AVClass *class;
39 
40  int pred;
42 
46 static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q,
47  int err)
48 {
49  int k;
50  int val;
51  int map;
52 
53  for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
54  ;
55 
56  map = !state->near && !k && (2 * state->B[Q] <= -state->N[Q]);
57 
58  if (err < 0)
59  err += state->range;
60  if (err >= (state->range + 1 >> 1)) {
61  err -= state->range;
62  val = 2 * FFABS(err) - 1 - map;
63  } else
64  val = 2 * err + map;
65 
66  set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp);
67 
68  ff_jpegls_update_state_regular(state, Q, err);
69 }
70 
74 static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb,
75  int RItype, int err, int limit_add)
76 {
77  int k;
78  int val, map;
79  int Q = 365 + RItype;
80  int temp;
81 
82  temp = state->A[Q];
83  if (RItype)
84  temp += state->N[Q] >> 1;
85  for (k = 0; (state->N[Q] << k) < temp; k++)
86  ;
87  map = 0;
88  if (!k && err && (2 * state->B[Q] < state->N[Q]))
89  map = 1;
90 
91  if (err < 0)
92  val = -(2 * err) - 1 - RItype + map;
93  else
94  val = 2 * err - RItype - map;
95  set_ur_golomb_jpegls(pb, val, k, state->limit - limit_add - 1, state->qbpp);
96 
97  if (err < 0)
98  state->B[Q]++;
99  state->A[Q] += (val + 1 - RItype) >> 1;
100 
101  ff_jpegls_downscale_state(state, Q);
102 }
103 
107 static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run,
108  int comp, int trail)
109 {
110  while (run >= (1 << ff_log2_run[state->run_index[comp]])) {
111  put_bits(pb, 1, 1);
112  run -= 1 << ff_log2_run[state->run_index[comp]];
113  if (state->run_index[comp] < 31)
114  state->run_index[comp]++;
115  }
116  /* if hit EOL, encode another full run, else encode aborted run */
117  if (!trail && run) {
118  put_bits(pb, 1, 1);
119  } else if (trail) {
120  put_bits(pb, 1, 0);
121  if (ff_log2_run[state->run_index[comp]])
122  put_bits(pb, ff_log2_run[state->run_index[comp]], run);
123  }
124 }
125 
129 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
130  void *last, void *cur, int last2, int w,
131  int stride, int comp, int bits)
132 {
133  int x = 0;
134  int Ra, Rb, Rc, Rd;
135  int D0, D1, D2;
136 
137  while (x < w) {
138  int err, pred, sign;
139 
140  /* compute gradients */
141  Ra = x ? R(cur, x - stride) : R(last, x);
142  Rb = R(last, x);
143  Rc = x ? R(last, x - stride) : last2;
144  Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
145  D0 = Rd - Rb;
146  D1 = Rb - Rc;
147  D2 = Rc - Ra;
148 
149  /* run mode */
150  if ((FFABS(D0) <= state->near) &&
151  (FFABS(D1) <= state->near) &&
152  (FFABS(D2) <= state->near)) {
153  int RUNval, RItype, run;
154 
155  run = 0;
156  RUNval = Ra;
157  while (x < w && (FFABS(R(cur, x) - RUNval) <= state->near)) {
158  run++;
159  W(cur, x, Ra);
160  x += stride;
161  }
162  ls_encode_run(state, pb, run, comp, x < w);
163  if (x >= w)
164  return;
165  Rb = R(last, x);
166  RItype = FFABS(Ra - Rb) <= state->near;
167  pred = RItype ? Ra : Rb;
168  err = R(cur, x) - pred;
169 
170  if (!RItype && Ra > Rb)
171  err = -err;
172 
173  if (state->near) {
174  if (err > 0)
175  err = (state->near + err) / state->twonear;
176  else
177  err = -(state->near - err) / state->twonear;
178 
179  if (RItype || (Rb >= Ra))
180  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
181  else
182  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
183  W(cur, x, Ra);
184  }
185  if (err < 0)
186  err += state->range;
187  if (err >= state->range + 1 >> 1)
188  err -= state->range;
189 
190  ls_encode_runterm(state, pb, RItype, err,
191  ff_log2_run[state->run_index[comp]]);
192 
193  if (state->run_index[comp] > 0)
194  state->run_index[comp]--;
195  } else { /* regular mode */
196  int context;
197 
198  context = ff_jpegls_quantize(state, D0) * 81 +
199  ff_jpegls_quantize(state, D1) * 9 +
200  ff_jpegls_quantize(state, D2);
201  pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
202 
203  if (context < 0) {
204  context = -context;
205  sign = 1;
206  pred = av_clip(pred - state->C[context], 0, state->maxval);
207  err = pred - R(cur, x);
208  } else {
209  sign = 0;
210  pred = av_clip(pred + state->C[context], 0, state->maxval);
211  err = R(cur, x) - pred;
212  }
213 
214  if (state->near) {
215  if (err > 0)
216  err = (state->near + err) / state->twonear;
217  else
218  err = -(state->near - err) / state->twonear;
219  if (!sign)
220  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
221  else
222  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
223  W(cur, x, Ra);
224  }
225 
226  ls_encode_regular(state, pb, context, err);
227  }
228  x += stride;
229  }
230 }
231 
233 {
234  /* Test if we have default params and don't need to store LSE */
235  JLSState state2 = { 0 };
236  state2.bpp = state->bpp;
237  state2.near = state->near;
239  if (state->T1 == state2.T1 &&
240  state->T2 == state2.T2 &&
241  state->T3 == state2.T3 &&
242  state->reset == state2.reset)
243  return;
244  /* store LSE type 1 */
245  put_marker(pb, LSE);
246  put_bits(pb, 16, 13);
247  put_bits(pb, 8, 1);
248  put_bits(pb, 16, state->maxval);
249  put_bits(pb, 16, state->T1);
250  put_bits(pb, 16, state->T2);
251  put_bits(pb, 16, state->T3);
252  put_bits(pb, 16, state->reset);
253 }
254 
255 static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
256  const AVFrame *pict, int *got_packet)
257 {
258  JPEGLSContext *ctx = avctx->priv_data;
259  const AVFrame *const p = pict;
260  PutBitContext pb, pb2;
261  GetBitContext gb;
262  uint8_t *buf2 = NULL;
263  uint8_t *zero = NULL;
264  uint8_t *cur = NULL;
265  uint8_t *last = NULL;
266  JLSState *state;
267  int i, size, ret;
268  int comps;
269 
270 #if FF_API_PRIVATE_OPT
272  if (avctx->prediction_method)
273  ctx->pred = avctx->prediction_method;
275 #endif
276 
277  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
278  avctx->pix_fmt == AV_PIX_FMT_GRAY16)
279  comps = 1;
280  else
281  comps = 3;
282 
283  if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 +
284  AV_INPUT_BUFFER_MIN_SIZE)) < 0) {
285  av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
286  return ret;
287  }
288 
289  buf2 = av_malloc(pkt->size);
290  if (!buf2)
291  goto memfail;
292 
293  init_put_bits(&pb, pkt->data, pkt->size);
294  init_put_bits(&pb2, buf2, pkt->size);
295 
296  /* write our own JPEG header, can't use mjpeg_picture_header */
297  put_marker(&pb, SOI);
298  put_marker(&pb, SOF48);
299  put_bits(&pb, 16, 8 + comps * 3); // header size depends on components
300  put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp
301  put_bits(&pb, 16, avctx->height);
302  put_bits(&pb, 16, avctx->width);
303  put_bits(&pb, 8, comps); // components
304  for (i = 1; i <= comps; i++) {
305  put_bits(&pb, 8, i); // component ID
306  put_bits(&pb, 8, 0x11); // subsampling: none
307  put_bits(&pb, 8, 0); // Tiq, used by JPEG-LS ext
308  }
309 
310  put_marker(&pb, SOS);
311  put_bits(&pb, 16, 6 + comps * 2);
312  put_bits(&pb, 8, comps);
313  for (i = 1; i <= comps; i++) {
314  put_bits(&pb, 8, i); // component ID
315  put_bits(&pb, 8, 0); // mapping index: none
316  }
317  put_bits(&pb, 8, ctx->pred);
318  put_bits(&pb, 8, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
319  put_bits(&pb, 8, 0); // point transform: none
320 
321  state = av_mallocz(sizeof(JLSState));
322  if (!state)
323  goto memfail;
324 
325  /* initialize JPEG-LS state from JPEG parameters */
326  state->near = ctx->pred;
327  state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
329  ff_jpegls_init_state(state);
330 
331  ls_store_lse(state, &pb);
332 
333  zero = last = av_mallocz(p->linesize[0]);
334  if (!zero)
335  goto memfail;
336 
337  cur = p->data[0];
338  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
339  int t = 0;
340 
341  for (i = 0; i < avctx->height; i++) {
342  ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
343  t = last[0];
344  last = cur;
345  cur += p->linesize[0];
346  }
347  } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
348  int t = 0;
349 
350  for (i = 0; i < avctx->height; i++) {
351  ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16);
352  t = *((uint16_t *)last);
353  last = cur;
354  cur += p->linesize[0];
355  }
356  } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
357  int j, width;
358  int Rc[3] = { 0, 0, 0 };
359 
360  width = avctx->width * 3;
361  for (i = 0; i < avctx->height; i++) {
362  for (j = 0; j < 3; j++) {
363  ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
364  width, 3, j, 8);
365  Rc[j] = last[j];
366  }
367  last = cur;
368  cur += p->linesize[0];
369  }
370  } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
371  int j, width;
372  int Rc[3] = { 0, 0, 0 };
373 
374  width = avctx->width * 3;
375  for (i = 0; i < avctx->height; i++) {
376  for (j = 2; j >= 0; j--) {
377  ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
378  width, 3, j, 8);
379  Rc[j] = last[j];
380  }
381  last = cur;
382  cur += p->linesize[0];
383  }
384  }
385 
386  av_freep(&zero);
387  av_freep(&state);
388 
389  /* the specification says that after doing 0xff escaping unused bits in
390  * the last byte must be set to 0, so just append 7 "optional" zero bits
391  * to avoid special-casing. */
392  put_bits(&pb2, 7, 0);
393  size = put_bits_count(&pb2);
394  flush_put_bits(&pb2);
395  /* do escape coding */
396  init_get_bits(&gb, buf2, size);
397  size -= 7;
398  while (get_bits_count(&gb) < size) {
399  int v;
400  v = get_bits(&gb, 8);
401  put_bits(&pb, 8, v);
402  if (v == 0xFF) {
403  v = get_bits(&gb, 7);
404  put_bits(&pb, 8, v);
405  }
406  }
408  av_freep(&buf2);
409 
410  /* End of image */
411  put_marker(&pb, EOI);
412  flush_put_bits(&pb);
413 
414  emms_c();
415 
416  pkt->size = put_bits_count(&pb) >> 3;
417  pkt->flags |= AV_PKT_FLAG_KEY;
418  *got_packet = 1;
419  return 0;
420 
421 memfail:
422  av_packet_unref(pkt);
423  av_freep(&buf2);
424  av_freep(&state);
425  av_freep(&zero);
426  return AVERROR(ENOMEM);
427 }
428 
430 {
431 #if FF_API_CODED_FRAME
434  ctx->coded_frame->key_frame = 1;
436 #endif
437 
438  if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
439  ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
440  ctx->pix_fmt != AV_PIX_FMT_RGB24 &&
441  ctx->pix_fmt != AV_PIX_FMT_BGR24) {
442  av_log(ctx, AV_LOG_ERROR,
443  "Only grayscale and RGB24/BGR24 images are supported\n");
444  return -1;
445  }
446  return 0;
447 }
448 
449 #define OFFSET(x) offsetof(JPEGLSContext, x)
450 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
451 static const AVOption options[] = {
452 { "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "pred" },
453  { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
454  { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
455  { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
456 
457  { NULL},
458 };
459 
460 static const AVClass jpegls_class = {
461  .class_name = "jpegls",
462  .item_name = av_default_item_name,
463  .option = options,
464  .version = LIBAVUTIL_VERSION_INT,
465 };
466 
468  .name = "jpegls",
469  .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
470  .type = AVMEDIA_TYPE_VIDEO,
471  .id = AV_CODEC_ID_JPEGLS,
472  .priv_data_size = sizeof(JPEGLSContext),
473  .priv_class = &jpegls_class,
474  .init = encode_init_ls,
475  .encode2 = encode_picture_ls,
476  .pix_fmts = (const enum AVPixelFormat[]) {
480  },
481  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
483 };
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
int reset
Definition: jpegls.h:41
const uint8_t ff_log2_run[41]
Definition: bitstream.c:37
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:62
int T2
Definition: jpegls.h:39
int size
This structure describes decoded (raw) audio or video data.
Definition: frame.h:140
AVCodec ff_jpegls_encoder
Definition: jpeglsenc.c:467
AVOption.
Definition: opt.h:234
Definition: mjpeg.h:71
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:228
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:61
static void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err)
Encode error from regular symbol.
Definition: jpeglsenc.c:46
#define R
Definition: huffyuv.h:51
MJPEG encoder.
int size
Definition: avcodec.h:1347
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int C[365]
Definition: jpegls.h:40
void avpriv_align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
Definition: bitstream.c:46
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1621
int twonear
Definition: jpegls.h:42
uint8_t run
Definition: svq3.c:203
int limit
Definition: jpegls.h:41
int stride
Definition: mace.c:144
AVCodec.
Definition: avcodec.h:3120
MJPEG encoder and decoder.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:202
int bpp
Definition: jpegls.h:41
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:39
int maxval
Definition: jpegls.h:41
#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
static const AVOption options[]
Definition: jpeglsenc.c:451
Definition: mjpeg.h:72
uint8_t bits
Definition: crc.c:252
uint8_t
#define av_cold
Definition: attributes.h:66
#define emms_c()
Definition: internal.h:48
uint8_t * data
Definition: avcodec.h:1346
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:182
static void ls_encode_line(JLSState *state, PutBitContext *pb, void *last, void *cur, int last2, int w, int stride, int comp, int bits)
Encode one line of image.
Definition: jpeglsenc.c:129
bitstream reader API header.
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
Definition: avcodec.h:645
#define VE
Definition: jpeglsenc.c:450
static void ls_encode_run(JLSState *state, PutBitContext *pb, int run, int comp, int trail)
Encode run value as specified by JPEG-LS standard.
Definition: jpeglsenc.c:107
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: avcodec.h:1378
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
#define AVERROR(e)
Definition: error.h:43
static void ls_store_lse(JLSState *state, PutBitContext *pb)
Definition: jpeglsenc.c:232
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
int run_index[3]
Definition: jpegls.h:43
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition: jpegls.c:64
const char * name
Name of the codec implementation.
Definition: avcodec.h:3127
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition: jpegls.h:98
int B[367]
Definition: jpegls.h:40
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: jpeglsenc.c:255
static void put_bits(PutBitContext *s, int n, unsigned int value)
Write up to 31 bits into a bitstream.
Definition: put_bits.h:134
Definition: mjpeg.h:70
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1352
int near
Definition: jpegls.h:42
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:67
JPEG-LS.
Definition: mjpeg.h:103
static void put_marker(PutBitContext *p, enum JpegMarker code)
Definition: mjpegenc.h:54
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:201
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:247
int width
picture width / height.
Definition: avcodec.h:1580
AVFormatContext * ctx
Definition: movenc.c:48
#define FFABS(a)
Definition: common.h:61
int ff_alloc_packet(AVPacket *avpkt, int size)
Check AVPacket size and/or allocate data.
Definition: utils.c:1211
static void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add)
Encode error from run termination.
Definition: jpeglsenc.c:74
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:62
static void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (jpegls).
Definition: golomb.h:519
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int qbpp
Definition: jpegls.h:41
NULL
Definition: eval.c:55
static int width
Definition: utils.c:156
Libavcodec external API header.
#define OFFSET(x)
Definition: jpeglsenc.c:449
attribute_deprecated int prediction_method
Definition: avcodec.h:1784
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:158
av_default_item_name
Definition: dnxhdenc.c:55
main external API structure.
Definition: avcodec.h:1409
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:347
int A[367]
Definition: jpegls.h:40
Describe the class of an AVClass context structure.
Definition: log.h:34
#define W(a, i, v)
Definition: jpegls.h:121
JPEG-LS common code.
int T1
Definition: jpegls.h:39
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:362
int range
Definition: jpegls.h:41
int N[367]
Definition: jpegls.h:40
#define mid_pred
Definition: mathops.h:99
static const AVClass jpegls_class
Definition: jpeglsenc.c:460
const VDPAUPixFmtMap * map
static av_cold int encode_init_ls(AVCodecContext *ctx)
Definition: jpeglsenc.c:429
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:257
JPEG-LS extension parameters.
Definition: mjpeg.h:104
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:146
static struct @174 state
Y , 8bpp.
Definition: pixfmt.h:67
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:77
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:83
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
Definition: avcodec.h:2797
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:48
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
void * priv_data
Definition: avcodec.h:1451
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:78
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition: jpegls.h:56
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:196
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
Definition: eamad.c:83
int T3
Definition: jpegls.h:39
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition: jpegls.c:31
exp golomb vlc stuff
AVPixelFormat
Pixel format.
Definition: pixfmt.h:57
This structure stores compressed data.
Definition: avcodec.h:1323
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:211
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition: jpegls.h:88