FFmpeg  4.4.4
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 #include "avcodec.h"
29 #include "bytestream.h"
30 #include "get_bits.h"
31 #include "put_bits.h"
32 #include "golomb.h"
33 #include "internal.h"
34 #include "mathops.h"
35 #include "mjpeg.h"
36 #include "mjpegenc.h"
37 #include "jpegls.h"
38 
39 typedef struct JPEGLSContext {
40  AVClass *class;
41 
42  int pred;
44 
45 static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
46 {
47  bytestream2_put_byteu(pb, 0xff);
48  bytestream2_put_byteu(pb, code);
49 }
50 
51 static inline void put_marker_byte(PutByteContext *pb, enum JpegMarker code)
52 {
53  bytestream2_put_byte(pb, 0xff);
54  bytestream2_put_byte(pb, code);
55 }
56 
57 /**
58  * Encode error from regular symbol
59  */
60 static inline void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q,
61  int err)
62 {
63  int k;
64  int val;
65  int map;
66 
67  for (k = 0; (state->N[Q] << k) < state->A[Q]; k++)
68  ;
69 
70  map = !state->near && !k && (2 * state->B[Q] <= -state->N[Q]);
71 
72  if (err < 0)
73  err += state->range;
74  if (err >= (state->range + 1 >> 1)) {
75  err -= state->range;
76  val = 2 * FFABS(err) - 1 - map;
77  } else
78  val = 2 * err + map;
79 
80  set_ur_golomb_jpegls(pb, val, k, state->limit, state->qbpp);
81 
83 }
84 
85 /**
86  * Encode error from run termination
87  */
88 static inline void ls_encode_runterm(JLSState *state, PutBitContext *pb,
89  int RItype, int err, int limit_add)
90 {
91  int k;
92  int val, map;
93  int Q = 365 + RItype;
94  int temp;
95 
96  temp = state->A[Q];
97  if (RItype)
98  temp += state->N[Q] >> 1;
99  for (k = 0; (state->N[Q] << k) < temp; k++)
100  ;
101  map = 0;
102  if (!k && err && (2 * state->B[Q] < state->N[Q]))
103  map = 1;
104 
105  if (err < 0)
106  val = -(2 * err) - 1 - RItype + map;
107  else
108  val = 2 * err - RItype - map;
109  set_ur_golomb_jpegls(pb, val, k, state->limit - limit_add - 1, state->qbpp);
110 
111  if (err < 0)
112  state->B[Q]++;
113  state->A[Q] += (val + 1 - RItype) >> 1;
114 
116 }
117 
118 /**
119  * Encode run value as specified by JPEG-LS standard
120  */
121 static inline void ls_encode_run(JLSState *state, PutBitContext *pb, int run,
122  int comp, int trail)
123 {
124  while (run >= (1 << ff_log2_run[state->run_index[comp]])) {
125  put_bits(pb, 1, 1);
126  run -= 1 << ff_log2_run[state->run_index[comp]];
127  if (state->run_index[comp] < 31)
128  state->run_index[comp]++;
129  }
130  /* if hit EOL, encode another full run, else encode aborted run */
131  if (!trail && run) {
132  put_bits(pb, 1, 1);
133  } else if (trail) {
134  put_bits(pb, 1, 0);
135  if (ff_log2_run[state->run_index[comp]])
136  put_bits(pb, ff_log2_run[state->run_index[comp]], run);
137  }
138 }
139 
140 /**
141  * Encode one line of image
142  */
143 static inline void ls_encode_line(JLSState *state, PutBitContext *pb,
144  void *tmp, const void *in, int last2, int w,
145  int stride, int comp, int bits)
146 {
147  int x = 0;
148  int Ra = R(tmp, 0), Rb, Rc = last2, Rd;
149  int D0, D1, D2;
150 
151  while (x < w) {
152  int err, pred, sign;
153 
154  /* compute gradients */
155  Rb = R(tmp, x);
156  Rd = (x >= w - stride) ? R(tmp, x) : R(tmp, x + stride);
157  D0 = Rd - Rb;
158  D1 = Rb - Rc;
159  D2 = Rc - Ra;
160 
161  /* run mode */
162  if ((FFABS(D0) <= state->near) &&
163  (FFABS(D1) <= state->near) &&
164  (FFABS(D2) <= state->near)) {
165  int RUNval, RItype, run;
166 
167  run = 0;
168  RUNval = Ra;
169  while (x < w && (FFABS(R(in, x) - RUNval) <= state->near)) {
170  run++;
171  W(tmp, x, Ra);
172  x += stride;
173  }
174  ls_encode_run(state, pb, run, comp, x < w);
175  if (x >= w)
176  return;
177  Rb = R(tmp, x);
178  RItype = FFABS(Ra - Rb) <= state->near;
179  pred = RItype ? Ra : Rb;
180  err = R(in, x) - pred;
181 
182  if (!RItype && Ra > Rb)
183  err = -err;
184 
185  if (state->near) {
186  if (err > 0)
187  err = (state->near + err) / state->twonear;
188  else
189  err = -(state->near - err) / state->twonear;
190 
191  if (RItype || (Rb >= Ra))
192  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
193  else
194  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
195  } else
196  Ra = R(in, x);
197  W(tmp, x, Ra);
198 
199  if (err < 0)
200  err += state->range;
201  if (err >= state->range + 1 >> 1)
202  err -= state->range;
203 
204  ls_encode_runterm(state, pb, RItype, err,
205  ff_log2_run[state->run_index[comp]]);
206 
207  if (state->run_index[comp] > 0)
208  state->run_index[comp]--;
209  } else { /* regular mode */
210  int context;
211 
212  context = ff_jpegls_quantize(state, D0) * 81 +
213  ff_jpegls_quantize(state, D1) * 9 +
215  pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
216 
217  if (context < 0) {
218  context = -context;
219  sign = 1;
220  pred = av_clip(pred - state->C[context], 0, state->maxval);
221  err = pred - R(in, x);
222  } else {
223  sign = 0;
224  pred = av_clip(pred + state->C[context], 0, state->maxval);
225  err = R(in, x) - pred;
226  }
227 
228  if (state->near) {
229  if (err > 0)
230  err = (state->near + err) / state->twonear;
231  else
232  err = -(state->near - err) / state->twonear;
233  if (!sign)
234  Ra = av_clip(pred + err * state->twonear, 0, state->maxval);
235  else
236  Ra = av_clip(pred - err * state->twonear, 0, state->maxval);
237  } else
238  Ra = R(in, x);
239  W(tmp, x, Ra);
240 
241  ls_encode_regular(state, pb, context, err);
242  }
243  Rc = Rb;
244  x += stride;
245  }
246 }
247 
249 {
250  /* Test if we have default params and don't need to store LSE */
251  JLSState state2 = { 0 };
252  state2.bpp = state->bpp;
253  state2.near = state->near;
255  if (state->T1 == state2.T1 &&
256  state->T2 == state2.T2 &&
257  state->T3 == state2.T3 &&
258  state->reset == state2.reset)
259  return;
260  /* store LSE type 1 */
261  put_marker_byteu(pb, LSE);
262  bytestream2_put_be16u(pb, 13);
263  bytestream2_put_byteu(pb, 1);
264  bytestream2_put_be16u(pb, state->maxval);
265  bytestream2_put_be16u(pb, state->T1);
266  bytestream2_put_be16u(pb, state->T2);
267  bytestream2_put_be16u(pb, state->T3);
268  bytestream2_put_be16u(pb, state->reset);
269 }
270 
272  const AVFrame *pict, int *got_packet)
273 {
274  JPEGLSContext *ctx = avctx->priv_data;
275  const AVFrame *const p = pict;
276  PutByteContext pb;
277  PutBitContext pb2;
278  GetBitContext gb;
279  const uint8_t *in;
280  uint8_t *last = NULL;
281  JLSState state = { 0 };
282  int i, size, ret;
283  int comps;
284 
285 #if FF_API_PRIVATE_OPT
287  if (avctx->prediction_method)
288  ctx->pred = avctx->prediction_method;
290 #endif
291 
292  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
293  avctx->pix_fmt == AV_PIX_FMT_GRAY16)
294  comps = 1;
295  else
296  comps = 3;
297 
298  if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width *avctx->height * comps * 4 +
299  AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0)
300  return ret;
301 
302  last = av_malloc((unsigned)pkt->size + FFABS(p->linesize[0]));
303  if (!last)
304  return AVERROR(ENOMEM);
305  memset(last, 0, FFABS(p->linesize[0]));
306 
308  init_put_bits(&pb2, last + FFABS(p->linesize[0]), pkt->size);
309 
310  /* write our own JPEG header, can't use mjpeg_picture_header */
311  put_marker_byteu(&pb, SOI);
312  put_marker_byteu(&pb, SOF48);
313  bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components
314  bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp
315  bytestream2_put_be16u(&pb, avctx->height);
316  bytestream2_put_be16u(&pb, avctx->width);
317  bytestream2_put_byteu(&pb, comps); // components
318  for (i = 1; i <= comps; i++) {
319  bytestream2_put_byteu(&pb, i); // component ID
320  bytestream2_put_byteu(&pb, 0x11); // subsampling: none
321  bytestream2_put_byteu(&pb, 0); // Tiq, used by JPEG-LS ext
322  }
323 
324  put_marker_byteu(&pb, SOS);
325  bytestream2_put_be16u(&pb, 6 + comps * 2);
326  bytestream2_put_byteu(&pb, comps);
327  for (i = 1; i <= comps; i++) {
328  bytestream2_put_byteu(&pb, i); // component ID
329  bytestream2_put_byteu(&pb, 0); // mapping index: none
330  }
331  bytestream2_put_byteu(&pb, ctx->pred);
332  bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line
333  bytestream2_put_byteu(&pb, 0); // point transform: none
334 
335  /* initialize JPEG-LS state from JPEG parameters */
336  state.near = ctx->pred;
337  state.bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
340 
341  ls_store_lse(&state, &pb);
342 
343  in = p->data[0];
344  if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
345  int t = 0;
346 
347  for (i = 0; i < avctx->height; i++) {
348  int last0 = last[0];
349  ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 8);
350  t = last0;
351  in += p->linesize[0];
352  }
353  } else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
354  int t = 0;
355 
356  for (i = 0; i < avctx->height; i++) {
357  int last0 = *((uint16_t *)last);
358  ls_encode_line(&state, &pb2, last, in, t, avctx->width, 1, 0, 16);
359  t = last0;
360  in += p->linesize[0];
361  }
362  } else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
363  int j, width;
364  int Rc[3] = { 0, 0, 0 };
365 
366  width = avctx->width * 3;
367  for (i = 0; i < avctx->height; i++) {
368  for (j = 0; j < 3; j++) {
369  int last0 = last[j];
370  ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
371  width, 3, j, 8);
372  Rc[j] = last0;
373  }
374  in += p->linesize[0];
375  }
376  } else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
377  int j, width;
378  int Rc[3] = { 0, 0, 0 };
379 
380  width = avctx->width * 3;
381  for (i = 0; i < avctx->height; i++) {
382  for (j = 2; j >= 0; j--) {
383  int last0 = last[j];
384  ls_encode_line(&state, &pb2, last + j, in + j, Rc[j],
385  width, 3, j, 8);
386  Rc[j] = last0;
387  }
388  in += p->linesize[0];
389  }
390  }
391 
392  /* the specification says that after doing 0xff escaping unused bits in
393  * the last byte must be set to 0, so just append 7 "optional" zero bits
394  * to avoid special-casing. */
395  put_bits(&pb2, 7, 0);
396  size = put_bits_count(&pb2);
397  flush_put_bits(&pb2);
398  /* do escape coding */
399  init_get_bits(&gb, pb2.buf, size);
400  size -= 7;
401  while (get_bits_count(&gb) < size) {
402  int v;
403  v = get_bits(&gb, 8);
404  bytestream2_put_byte(&pb, v);
405  if (v == 0xFF) {
406  v = get_bits(&gb, 7);
407  bytestream2_put_byte(&pb, v);
408  }
409  }
410  av_freep(&last);
411 
412  /* End of image */
413  put_marker_byte(&pb, EOI);
414 
415  emms_c();
416 
417  pkt->size = bytestream2_tell_p(&pb);
419  *got_packet = 1;
420  return 0;
421 }
422 
424 {
425 #if FF_API_CODED_FRAME
427  ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
428  ctx->coded_frame->key_frame = 1;
430 #endif
431 
432  if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
433  ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
434  ctx->pix_fmt != AV_PIX_FMT_RGB24 &&
435  ctx->pix_fmt != AV_PIX_FMT_BGR24) {
437  "Only grayscale and RGB24/BGR24 images are supported\n");
438  return -1;
439  }
440  return 0;
441 }
442 
443 #define OFFSET(x) offsetof(JPEGLSContext, x)
444 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
445 static const AVOption options[] = {
446 { "pred", "Prediction method", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 2, VE, "pred" },
447  { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
448  { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
449  { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "pred" },
450 
451  { NULL},
452 };
453 
454 static const AVClass jpegls_class = {
455  .class_name = "jpegls",
456  .item_name = av_default_item_name,
457  .option = options,
458  .version = LIBAVUTIL_VERSION_INT,
459 };
460 
462  .name = "jpegls",
463  .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
464  .type = AVMEDIA_TYPE_VIDEO,
465  .id = AV_CODEC_ID_JPEGLS,
466  .priv_data_size = sizeof(JPEGLSContext),
467  .priv_class = &jpegls_class,
468  .init = encode_init_ls,
469  .capabilities = AV_CODEC_CAP_FRAME_THREADS,
470  .encode2 = encode_picture_ls,
471  .pix_fmts = (const enum AVPixelFormat[]) {
475  },
476  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
478 };
static double val(void *priv, double ch)
Definition: aeval.c:76
#define av_cold
Definition: attributes.h:88
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
uint8_t
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
const uint8_t ff_log2_run[41]
Definition: bitstream.c:39
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition: bytestream.h:147
static av_always_inline int bytestream2_tell_p(PutByteContext *p)
Definition: bytestream.h:197
static struct @321 state
#define av_clip
Definition: common.h:122
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
#define NULL
Definition: coverity.c:32
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:85
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
Definition: encode.c:33
bitstream reader API header.
static int get_bits_count(const GetBitContext *s)
Definition: get_bits.h:219
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:379
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:659
exp golomb vlc stuff
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:695
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
@ AV_OPT_TYPE_INT
Definition: opt.h:225
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:108
@ AV_CODEC_ID_JPEGLS
Definition: codec_id.h:60
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
Definition: avcodec.h:222
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:410
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
@ AV_PICTURE_TYPE_I
Intra.
Definition: avutil.h:274
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
#define R
Definition: huffyuvdsp.h:34
const VDPAUPixFmtMap * map
int i
Definition: input.c:407
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:218
void ff_jpegls_init_state(JLSState *state)
Calculate initial JPEG-LS parameters.
Definition: jpegls.c:31
void ff_jpegls_reset_coding_parameters(JLSState *s, int reset_all)
Calculate JPEG-LS codec values.
Definition: jpegls.c:62
JPEG-LS common code.
static int ff_jpegls_update_state_regular(JLSState *state, int Q, int err)
Definition: jpegls.h:95
static void ff_jpegls_downscale_state(JLSState *state, int Q)
Definition: jpegls.h:85
static int ff_jpegls_quantize(JLSState *s, int v)
Calculate quantized gradient value, used for context determination.
Definition: jpegls.h:53
static void put_marker_byte(PutByteContext *pb, enum JpegMarker code)
Definition: jpeglsenc.c:51
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:121
static const AVOption options[]
Definition: jpeglsenc.c:445
#define VE
Definition: jpeglsenc.c:444
static void ls_store_lse(JLSState *state, PutByteContext *pb)
Definition: jpeglsenc.c:248
static const AVClass jpegls_class
Definition: jpeglsenc.c:454
static void ls_encode_runterm(JLSState *state, PutBitContext *pb, int RItype, int err, int limit_add)
Encode error from run termination.
Definition: jpeglsenc.c:88
static void ls_encode_regular(JLSState *state, PutBitContext *pb, int Q, int err)
Encode error from regular symbol.
Definition: jpeglsenc.c:60
AVCodec ff_jpegls_encoder
Definition: jpeglsenc.c:461
static void put_marker_byteu(PutByteContext *pb, enum JpegMarker code)
Definition: jpeglsenc.c:45
#define OFFSET(x)
Definition: jpeglsenc.c:443
static av_cold int encode_init_ls(AVCodecContext *ctx)
Definition: jpeglsenc.c:423
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: jpeglsenc.c:271
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:143
#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:41
#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:49
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:83
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:84
#define emms_c()
Definition: internal.h:54
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
uint8_t w
Definition: llviddspenc.c:39
int stride
Definition: mace.c:144
#define mid_pred
Definition: mathops.h:97
MJPEG encoder and decoder.
JpegMarker
Definition: mjpeg.h:37
@ SOS
Definition: mjpeg.h:72
@ SOF48
JPEG-LS.
Definition: mjpeg.h:103
@ SOI
Definition: mjpeg.h:70
@ LSE
JPEG-LS extension parameters.
Definition: mjpeg.h:104
@ EOI
Definition: mjpeg.h:71
MJPEG encoder.
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
bitstream writer API
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Definition: put_bits.h:57
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:76
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:110
static const float pred[4]
Definition: siprdata.h:259
const uint8_t * code
Definition: spdifenc.c:413
Describe the class of an AVClass context structure.
Definition: log.h:67
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:72
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
int width
picture width / height.
Definition: avcodec.h:709
attribute_deprecated int prediction_method
Definition: avcodec.h:895
void * priv_data
Definition: avcodec.h:563
AVCodec.
Definition: codec.h:197
const char * name
Name of the codec implementation.
Definition: codec.h:204
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:332
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:349
AVOption.
Definition: opt.h:248
This structure stores compressed data.
Definition: packet.h:346
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:375
int size
Definition: packet.h:370
uint8_t * data
Definition: packet.h:369
int reset
Definition: jpegls.h:40
int T3
Definition: jpegls.h:38
int near
Definition: jpegls.h:41
int T2
Definition: jpegls.h:38
int T1
Definition: jpegls.h:38
int bpp
Definition: jpegls.h:40
uint8_t * buf
Definition: put_bits.h:47
uint8_t run
Definition: svq3.c:205
#define av_freep(p)
#define av_malloc(s)
#define av_log(a,...)
static uint8_t tmp[11]
Definition: aes_ctr.c:27
AVPacket * pkt
Definition: movenc.c:59
AVFormatContext * ctx
Definition: movenc.c:48
#define width
int size
@ W
Definition: vf_addroi.c:26
else temp
Definition: vf_mcdeint.c:259
uint8_t bits
Definition: vp3data.h:141