FFmpeg
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 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 encoder.
26  */
27 
28 #define UNCHECKED_BITSTREAM_READER 1
29 #include "libavutil/mem.h"
30 #include "libavutil/opt.h"
31 #include "avcodec.h"
32 #include "bytestream.h"
33 #include "codec_internal.h"
34 #include "encode.h"
35 #include "get_bits.h"
36 #include "put_bits.h"
37 #include "put_golomb.h"
38 #include "mathops.h"
39 #include "mjpeg.h"
40 #include "jpegls.h"
41 
42 typedef struct JPEGLSContext {
43  AVClass *class;
44 
45  int pred;
46  int comps;
47 
48  size_t size;
49  uint8_t *buf;
51 
52 static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
53 {
54  bytestream2_put_byteu(pb, 0xff);
55  bytestream2_put_byteu(pb, code);
56 }
57 
58 /**
59  * Encode error from regular symbol
60  */
61 static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q,
62  int err)
63 {
64  int k;
65  int val;
66  int map;
67 
68  for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
69  ;
70 
71  map = !state->near && !k && (2 * state->B[Q] <= -state->N[Q]);
72 
73  if (err < 0)
74  err += state->range;
75  if (err >= (state->range + 1 >> 1)) {
76  err -= state->range;
77  val = 2 * FFABS(err) - 1 - map;
78  } else
79  val = 2 * err + map;
80 
81  set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp);
82 
84 }
85 
86 /**
87  * Encode error from run termination
88  */
89 static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb,
90  int RItype, int err, int limit_add)
91 {
92  int k;
93  int val, map;
94  int Q = 365 + RItype;
95  int temp;
96 
97  temp = state->A[Q];
98  if (RItype)
99  temp += state->N[Q] >> 1;
100  for (k = 0; (state->N[Q] << k) < temp; k++)
101  ;
102  map = 0;
103  if (!k && err && (2 * state->B[Q] < state->N[Q]))
104  map = 1;
105 
106  if (err < 0)
107  val = -(2 * err) - 1 - RItype + map;
108  else
109  val = 2 * err - RItype - map;
110  set_ur_golomb_jpegls(pb, val, k, state->limit - limit_add - 1, state->qbpp);
111 
112  if (err < 0)
113  state->B[Q]++;
114  state->A[Q] += (val + 1 - RItype) >> 1;
115 
117 }
118 
119 /**
120  * Encode run value as specified by JPEG-LS standard
121  */
122 static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run,
123  int comp, int trail)
124 {
125  while (run >= (1 << ff_log2_run[state->run_index[comp]])) {
126  put_bits(pb, 1, 1);
127  run -= 1 << ff_log2_run[state->run_index[comp]];
128  if (state->run_index[comp] < 31)
129  state->run_index[comp]++;
130  }
131  /* if hit EOL, encode another full run, else encode aborted run */
132  if (!trail && run) {
133  put_bits(pb, 1, 1);
134  } else if (trail) {
135  put_bits(pb, 1, 0);
136  if (ff_log2_run[state->run_index[comp]])
137  put_bits(pb, ff_log2_run[state->run_index[comp]], run);
138  }
139 }
140 
141 /**
142  * Encode one line of image
143  */
144 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
145  void *tmp, const void *in, int last2, int w,
146  int stride, int comp, int bits)
147 {
148  int x = 0;
149  int Ra = R(tmp, 0), Rb, Rc = last2, Rd;
150  int D0, D1, D2;
151 
152  while (x < w) {
153  int err, pred, sign;
154 
155  /* compute gradients */
156  Rb = R(tmp, x);
157  Rd = (x >= w - stride) ? R(tmp, x) : R(tmp, x + stride);
158  D0 = Rd - Rb;
159  D1 = Rb - Rc;
160  D2 = Rc - Ra;
161 
162  /* run mode */
163  if ((FFABS(D0) <= state->near) &&
164  (FFABS(D1) <= state->near) &&
165  (FFABS(D2) <= state->near)) {
166  int RUNval, RItype, run;
167 
168  run = 0;
169  RUNval = Ra;
170  while (x < w && (FFABS(R(in, x) - RUNval) <= state->near)) {
171  run++;
172  W(tmp, x, Ra);
173  x += stride;
174  }
175  ls_encode_run(state, pb, run, comp, x < w);
176  if (x >= w)
177  return;
178  Rb = R(tmp, x);
179  RItype = FFABS(Ra - Rb) <= state->near;
180  pred = RItype ? Ra : Rb;
181  err = R(in, x) - pred;
182 
183  if (!RItype && Ra > Rb)
184  err = -err;
185 
186  if (state->near) {
187  if (err > 0)
188  err = (state->near + err) / state->twonear;
189  else
190  err = -(state->near - err) / state->twonear;
191 
192  if (RItype || (Rb >= Ra))
193  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
194  else
195  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
196  } else
197  Ra = R(in, x);
198  W(tmp, x, Ra);
199 
200  if (err < 0)
201  err += state->range;
202  if (err >= state->range + 1 >> 1)
203  err -= state->range;
204 
205  ls_encode_runterm(state, pb, RItype, err,
206  ff_log2_run[state->run_index[comp]]);
207 
208  if (state->run_index[comp] > 0)
209  state->run_index[comp]--;
210  } else { /* regular mode */
211  int context;
212 
213  context = ff_jpegls_quantize(state, D0) * 81 +
214  ff_jpegls_quantize(state, D1) * 9 +
216  pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
217 
218  if (context < 0) {
219  context = -context;
220  sign = 1;
221  pred = av_clip(pred - state->C[context], 0, state->maxval);
222  err = pred - R(in, x);
223  } else {
224  sign = 0;
225  pred = av_clip(pred + state->C[context], 0, state->maxval);
226  err = R(in, x) - pred;
227  }
228 
229  if (state->near) {
230  if (err > 0)
231  err = (state->near + err) / state->twonear;
232  else
233  err = -(state->near - err) / state->twonear;
234  if (!sign)
235  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
236  else
237  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
238  } else
239  Ra = R(in, x);
240  W(tmp, x, Ra);
241 
242  ls_encode_regular(state, pb, context, err);
243  }
244  Rc = Rb;
245  x += stride;
246  }
247 }
248 
250 {
251  /* Test if we have default params and don't need to store LSE */
252  JLSState state2 = { 0 };
253  state2.bpp = state->bpp;
254  state2.near = state->near;
256  if (state->T1 == state2.T1 &&
257  state->T2 == state2.T2 &&
258  state->T3 == state2.T3 &&
259  state->reset == state2.reset)
260  return;
261  /* store LSE type 1 */
262  put_marker_byteu(pb, LSE);
263  bytestream2_put_be16u(pb, 13);
264  bytestream2_put_byteu(pb, 1);
265  bytestream2_put_be16u(pb, state->maxval);
266  bytestream2_put_be16u(pb, state->T1);
267  bytestream2_put_be16u(pb, state->T2);
268  bytestream2_put_be16u(pb, state->T3);
269  bytestream2_put_be16u(pb, state->reset);
270 }
271 
273  const AVFrame *pict, int *got_packet)
274 {
275  JPEGLSContext *ctx = avctx->priv_data;
276  const AVFrame *const p = pict;
277  PutByteContext pb;
278  PutBitContext pb2;
279  GetBitContext gb;
280  const uint8_t *in;
281  uint8_t *last = NULL;
282  JLSState state = { 0 };
283  size_t size;
284  int i, ret, size_in_bits;
285  int comps;
286 
287  last = av_mallocz(FFABS(p->linesize[0]));
288  if (!last)
289  return AVERROR(ENOMEM);
290 
291  init_put_bits(&pb2, ctx->buf, ctx->size);
292 
293  comps = ctx->comps;
294  /* initialize JPEG-LS state from JPEG parameters */
295  state.near = ctx->pred;
296  state.bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
299 
300  in = p->data[0];
301  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
302  int t = 0;
303 
304  for (i = 0; i < avctx->height; i++) {
305  int last0 = last[0];
306  ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 8);
307  t = last0;
308  in += p->linesize[0];
309  }
310  } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
311  int t = 0;
312 
313  for (i = 0; i < avctx->height; i++) {
314  int last0 = *((uint16_t *)last);
315  ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 16);
316  t = last0;
317  in += p->linesize[0];
318  }
319  } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
320  int j, width;
321  int Rc[3] = { 0, 0, 0 };
322 
323  width = avctx->width * 3;
324  for (i = 0; i < avctx->height; i++) {
325  for (j = 0; j < 3; j++) {
326  int last0 = last[j];
327  ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
328  width, 3, j, 8);
329  Rc[j] = last0;
330  }
331  in += p->linesize[0];
332  }
333  } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
334  int j, width;
335  int Rc[3] = { 0, 0, 0 };
336 
337  width = avctx->width * 3;
338  for (i = 0; i < avctx->height; i++) {
339  for (j = 2; j >= 0; j--) {
340  int last0 = last[j];
341  ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
342  width, 3, j, 8);
343  Rc[j] = last0;
344  }
345  in += p->linesize[0];
346  }
347  }
348  av_free(last);
349  /* Now the actual image data has been written, which enables us to estimate
350  * the needed packet size: For every 15 input bits, an escape bit might be
351  * added below; and if put_bits_count % 15 is >= 8, then another bit might
352  * be added.
353  * Furthermore the specification says that after doing 0xff escaping unused
354  * bits in the last byte must be set to 0, so just append 7 "optional" zero
355  * bits to avoid special-casing. This also simplifies the size calculation:
356  * Properly rounding up is now automatically baked-in. */
357  put_bits(&pb2, 7, 0);
358  /* Make sure that the bit count + padding is representable in an int;
359  necessary for put_bits_count() as well as for using a GetBitContext. */
360  if (put_bytes_count(&pb2, 0) > INT_MAX / 8 - AV_INPUT_BUFFER_PADDING_SIZE)
361  return AVERROR(ERANGE);
362  size_in_bits = put_bits_count(&pb2);
363  flush_put_bits(&pb2);
364  size = size_in_bits * 2U / 15;
365  size += 2 + 2 + 2 + 1 + 2 + 2 + 1 + comps * (1 + 1 + 1) + 2 + 2 + 1
366  + comps * (1 + 1) + 1 + 1 + 1; /* Header */
367  size += 2 + 2 + 1 + 2 + 2 + 2 + 2 + 2; /* LSE */
368  size += 2; /* EOI */
369  if ((ret = ff_get_encode_buffer(avctx, pkt, size, 0)) < 0)
370  return ret;
371 
373 
374  /* write our own JPEG header, can't use mjpeg_picture_header */
375  put_marker_byteu(&pb, SOI);
376  put_marker_byteu(&pb, SOF48);
377  bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components
378  bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp
379  bytestream2_put_be16u(&pb, avctx->height);
380  bytestream2_put_be16u(&pb, avctx->width);
381  bytestream2_put_byteu(&pb, comps); // components
382  for (i = 1; i <= comps; i++) {
383  bytestream2_put_byteu(&pb, i); // component ID
384  bytestream2_put_byteu(&pb, 0x11); // subsampling: none
385  bytestream2_put_byteu(&pb, 0); // Tiq, used by JPEG-LS ext
386  }
387 
388  put_marker_byteu(&pb, SOS);
389  bytestream2_put_be16u(&pb, 6 + comps * 2);
390  bytestream2_put_byteu(&pb, comps);
391  for (i = 1; i <= comps; i++) {
392  bytestream2_put_byteu(&pb, i); // component ID
393  bytestream2_put_byteu(&pb, 0); // mapping index: none
394  }
395  bytestream2_put_byteu(&pb, ctx->pred);
396  bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
397  bytestream2_put_byteu(&pb, 0); // point transform: none
398 
399  ls_store_lse(&state, &pb);
400 
401  /* do escape coding */
402  init_get_bits(&gb, pb2.buf, size_in_bits);
403  size_in_bits -= 7;
404  while (get_bits_count(&gb) < size_in_bits) {
405  int v;
406  v = get_bits(&gb, 8);
407  bytestream2_put_byteu(&pb, v);
408  if (v == 0xFF) {
409  v = get_bits(&gb, 7);
410  bytestream2_put_byteu(&pb, v);
411  }
412  }
413 
414  /* End of image */
415  put_marker_byteu(&pb, EOI);
416 
418  *got_packet = 1;
419  return 0;
420 }
421 
423 {
424  JPEGLSContext *ctx = avctx->priv_data;
425  size_t size;
426 
427  if ((avctx->width | avctx->height) > UINT16_MAX) {
428  av_log(avctx, AV_LOG_ERROR, "Dimensions exceeding 65535x65535\n");
429  return AVERROR(EINVAL);
430  }
431  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
432  avctx->pix_fmt == AV_PIX_FMT_GRAY16)
433  ctx->comps = 1;
434  else
435  ctx->comps = 3;
437  /* INT_MAX due to PutBit-API. */
438  if (avctx->width * (unsigned)avctx->height > (INT_MAX - size) / 4 / ctx->comps)
439  return AVERROR(ERANGE);
440  size += 4 * ctx->comps * avctx->width * avctx->height;
441  ctx->size = size;
443  if (!ctx->buf)
444  return AVERROR(ENOMEM);
445 
446  return 0;
447 }
448 
450 {
451  JPEGLSContext *ctx = avctx->priv_data;
452 
453  av_freep(&ctx->buf);
454  return 0;
455 }
456 
457 #define OFFSET(x) offsetof(JPEGLSContext, x)
458 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
459 static const AVOption options[] = {
460 { "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, .unit = "pred" },
461  { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, .unit = "pred" },
462  { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, .unit = "pred" },
463  { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, .unit = "pred" },
464 
465  { NULL},
466 };
467 
468 static const AVClass jpegls_class = {
469  .class_name = "jpegls",
470  .item_name = av_default_item_name,
471  .option = options,
472  .version = LIBAVUTIL_VERSION_INT,
473 };
474 
476  .p.name = "jpegls",
477  CODEC_LONG_NAME("JPEG-LS"),
478  .p.type = AVMEDIA_TYPE_VIDEO,
479  .p.id = AV_CODEC_ID_JPEGLS,
480  .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS |
482  .priv_data_size = sizeof(JPEGLSContext),
483  .p.priv_class = &jpegls_class,
484  .init = encode_jpegls_init,
486  .close = encode_jpegls_close,
487  .p.pix_fmts = (const enum AVPixelFormat[]) {
491  },
492  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
493 };
JLSState::bpp
int bpp
Definition: jpegls.h:39
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
mjpeg.h
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
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
encode_jpegls_close
static av_cold int encode_jpegls_close(AVCodecContext *avctx)
Definition: jpeglsenc.c:449
opt.h
SOS
@ SOS
Definition: mjpeg.h:72
SOF48
@ SOF48
JPEG-LS.
Definition: mjpeg.h:103
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:81
init_put_bits
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:62
get_bits_count
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:266
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:389
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
put_bits
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:223
w
uint8_t w
Definition: llviddspenc.c:38
JLSState::T1
int T1
Definition: jpegls.h:37
AVPacket::data
uint8_t * data
Definition: packet.h:539
AVOption
AVOption.
Definition: opt.h:429
encode.h
put_bytes_count
static int put_bytes_count(const PutBitContext *s, int round_up)
Definition: put_bits.h:100
ls_encode_run
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:122
set_ur_golomb_jpegls
static void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int limit, int esc_len)
write unsigned golomb rice code (jpegls).
Definition: put_golomb.h:114
bytestream2_tell_p
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
R
#define R
Definition: huffyuv.h:44
JPEGLSContext
Definition: jpeglsenc.c:42
FFCodec
Definition: codec_internal.h:127
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
encode_jpegls_init
static av_cold int encode_jpegls_init(AVCodecContext *avctx)
Definition: jpeglsenc.c:422
JLSState::T2
int T2
Definition: jpegls.h:37
JpegMarker
JpegMarker
Definition: mjpeg.h:37
init_get_bits
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:514
FF_INPUT_BUFFER_MIN_SIZE
#define FF_INPUT_BUFFER_MIN_SIZE
Used by some encoders as upper bound for the length of headers.
Definition: encode.h:33
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:410
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
get_bits
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:335
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
av_shrink_packet
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition: packet.c:113
GetBitContext
Definition: get_bits.h:108
val
static double val(void *priv, double ch)
Definition: aeval.c:77
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:486
JLSState
Definition: jpegls.h:36
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
put_golomb.h
exp golomb vlc writing stuff
jpegls.h
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
av_cold
#define av_cold
Definition: attributes.h:90
JPEGLSContext::buf
uint8_t * buf
Definition: jpeglsenc.c:49
bytestream2_init_writer
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
VE
#define VE
Definition: jpeglsenc.c:458
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
bits
uint8_t bits
Definition: vp3data.h:128
ctx
AVFormatContext * ctx
Definition: movenc.c:49
get_bits.h
W
@ W
Definition: vf_addroi.c:27
PutBitContext
Definition: put_bits.h:50
ff_jpegls_encoder
const FFCodec ff_jpegls_encoder
Definition: jpeglsenc.c:475
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
JLSState::near
int near
Definition: jpegls.h:40
ls_encode_line
static void ls_encode_line(JLSState *state, PutBitContext *pb, void *tmp, const void *in, int last2, int w, int stride, int comp, int bits)
Encode one line of image.
Definition: jpeglsenc.c:144
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
AV_CODEC_CAP_FRAME_THREADS
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:110
ff_jpegls_downscale_state
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition: jpegls.h:84
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
PutBitContext::buf
uint8_t * buf
Definition: put_bits.h:53
NULL
#define NULL
Definition: coverity.c:32
run
uint8_t run
Definition: svq3.c:204
put_marker_byteu
static void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
Definition: jpeglsenc.c:52
state
static struct @466 state
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
mathops.h
options
Definition: swscale.c:42
OFFSET
#define OFFSET(x)
Definition: jpeglsenc.c:457
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
JPEGLSContext::comps
int comps
Definition: jpeglsenc.c:46
JPEGLSContext::pred
int pred
Definition: jpeglsenc.c:45
JLSState::T3
int T3
Definition: jpegls.h:37
PutByteContext
Definition: bytestream.h:37
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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
AVPacket::size
int size
Definition: packet.h:540
codec_internal.h
size
int size
Definition: twinvq_data.h:10344
JLSState::reset
int reset
Definition: jpegls.h:39
ff_jpegls_quantize
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition: jpegls.h:52
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
ff_jpegls_init_state
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition: jpegls.c:34
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
EOI
@ EOI
Definition: mjpeg.h:71
ff_jpegls_update_state_regular
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition: jpegls.h:94
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::height
int height
Definition: avcodec.h:624
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:663
ls_encode_regular
static void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err)
Encode error from regular symbol.
Definition: jpeglsenc.c:61
avcodec.h
stride
#define stride
Definition: h264pred_template.c:537
options
static const AVOption options[]
Definition: jpeglsenc.c:459
mid_pred
#define mid_pred
Definition: mathops.h:96
ret
ret
Definition: filter_design.txt:187
pred
static const float pred[4]
Definition: siprdata.h:259
ls_encode_runterm
static void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add)
Encode error from run termination.
Definition: jpeglsenc.c:89
AVClass::class_name
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:80
LSE
@ LSE
JPEG-LS extension parameters.
Definition: mjpeg.h:104
ff_jpegls_reset_coding_parameters
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition: jpegls.c:65
AV_INPUT_BUFFER_PADDING_SIZE
#define AV_INPUT_BUFFER_PADDING_SIZE
Definition: defs.h:40
U
#define U(x)
Definition: vpx_arith.h:37
AVCodecContext
main external API structure.
Definition: avcodec.h:451
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:106
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_CODEC_ID_JPEGLS
@ AV_CODEC_ID_JPEGLS
Definition: codec_id.h:63
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
temp
else temp
Definition: vf_mcdeint.c:263
ls_store_lse
static void ls_store_lse(JLSState *state, PutByteContext *pb)
Definition: jpeglsenc.c:249
encode_picture_ls
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: jpeglsenc.c:272
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
jpegls_class
static const AVClass jpegls_class
Definition: jpeglsenc.c:468
SOI
@ SOI
Definition: mjpeg.h:70
flush_put_bits
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:143
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
AVPacket
This structure stores compressed data.
Definition: packet.h:516
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:624
ff_log2_run
const uint8_t ff_log2_run[41]
Definition: mathtables.c:116
bytestream.h
Q
#define Q(x)
Definition: filter_template.c:423
AVFrame::linesize
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:434
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
width
#define width
Definition: dsp.h:85
put_bits.h
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
JPEGLSContext::size
size_t size
Definition: jpeglsenc.c:48