FFmpeg
mjpegenc_common.c
Go to the documentation of this file.
1 /*
2  * lossless JPEG shared bits
3  * Copyright (c) 2000, 2001 Fabrice Bellard
4  * Copyright (c) 2003 Alex Beregszaszi
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 #include <stdint.h>
24 #include <string.h>
25 
26 #include "libavutil/pixdesc.h"
27 #include "libavutil/pixfmt.h"
28 
29 #include "avcodec.h"
30 #include "idctdsp.h"
31 #include "jpegtables.h"
32 #include "put_bits.h"
33 #include "mjpegenc.h"
34 #include "mjpegenc_common.h"
35 #include "mjpeg.h"
36 
37 /* table_class: 0 = DC coef, 1 = AC coefs */
38 static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
39  const uint8_t *bits_table, const uint8_t *value_table)
40 {
41  int n, i;
42 
43  put_bits(p, 4, table_class);
44  put_bits(p, 4, table_id);
45 
46  n = 0;
47  for(i=1;i<=16;i++) {
48  n += bits_table[i];
49  put_bits(p, 8, bits_table[i]);
50  }
51 
52  for(i=0;i<n;i++)
53  put_bits(p, 8, value_table[i]);
54 
55  return n + 17;
56 }
57 
59  ScanTable *intra_scantable,
60  uint16_t luma_intra_matrix[64],
61  uint16_t chroma_intra_matrix[64],
62  int hsample[3])
63 {
64  int i, j, size;
65  uint8_t *ptr;
67 
68  /* Since avctx->priv_data will point to LJpegEncContext in this case */
69  if (avctx->codec_id != AV_CODEC_ID_LJPEG)
70  s = avctx->priv_data;
71 
72  if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
73  int matrix_count = 1 + !!memcmp(luma_intra_matrix,
74  chroma_intra_matrix,
75  sizeof(luma_intra_matrix[0]) * 64);
76  if (s && s->force_duplicated_matrix)
77  matrix_count = 2;
78  /* quant matrixes */
79  put_marker(p, DQT);
80  put_bits(p, 16, 2 + matrix_count * (1 + 64));
81  put_bits(p, 4, 0); /* 8 bit precision */
82  put_bits(p, 4, 0); /* table 0 */
83  for(i=0;i<64;i++) {
84  j = intra_scantable->permutated[i];
85  put_bits(p, 8, luma_intra_matrix[j]);
86  }
87 
88  if (matrix_count > 1) {
89  put_bits(p, 4, 0); /* 8 bit precision */
90  put_bits(p, 4, 1); /* table 1 */
91  for(i=0;i<64;i++) {
92  j = intra_scantable->permutated[i];
93  put_bits(p, 8, chroma_intra_matrix[j]);
94  }
95  }
96  }
97 
99  put_marker(p, DRI);
100  put_bits(p, 16, 4);
101  put_bits(p, 16, (avctx->width-1)/(8*hsample[0]) + 1);
102  }
103 
104  /* huffman table */
105  put_marker(p, DHT);
106  flush_put_bits(p);
107  ptr = put_bits_ptr(p);
108  put_bits(p, 16, 0); /* patched later */
109  size = 2;
110 
111  // Only MJPEG can have a variable Huffman variable. All other
112  // formats use the default Huffman table.
113  if (s && s->huffman == HUFFMAN_TABLE_OPTIMAL) {
114  size += put_huffman_table(p, 0, 0, s->mjpeg_ctx->bits_dc_luminance,
116  size += put_huffman_table(p, 0, 1, s->mjpeg_ctx->bits_dc_chrominance,
118 
119  size += put_huffman_table(p, 1, 0, s->mjpeg_ctx->bits_ac_luminance,
121  size += put_huffman_table(p, 1, 1, s->mjpeg_ctx->bits_ac_chrominance,
123  } else {
128 
133  }
134  AV_WB16(ptr, size);
135 }
136 
138 {
139  int size;
140  uint8_t *ptr;
141 
142  if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
143  AVRational sar = avctx->sample_aspect_ratio;
144 
145  if (sar.num > 65535 || sar.den > 65535) {
146  if (!av_reduce(&sar.num, &sar.den, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 65535))
147  av_log(avctx, AV_LOG_WARNING,
148  "Cannot store exact aspect ratio %d:%d\n",
149  avctx->sample_aspect_ratio.num,
150  avctx->sample_aspect_ratio.den);
151  }
152 
153  /* JFIF header */
154  put_marker(p, APP0);
155  put_bits(p, 16, 16);
156  ff_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
157  /* The most significant byte is used for major revisions, the least
158  * significant byte for minor revisions. Version 1.02 is the current
159  * released revision. */
160  put_bits(p, 16, 0x0102);
161  put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
162  put_bits(p, 16, sar.num);
163  put_bits(p, 16, sar.den);
164  put_bits(p, 8, 0); /* thumbnail width */
165  put_bits(p, 8, 0); /* thumbnail height */
166  }
167 
168  /* comment */
169  if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
170  put_marker(p, COM);
171  flush_put_bits(p);
172  ptr = put_bits_ptr(p);
173  put_bits(p, 16, 0); /* patched later */
175  size = strlen(LIBAVCODEC_IDENT)+3;
176  AV_WB16(ptr, size);
177  }
178 
179  if (((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
180  avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
181  avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->color_range != AVCOL_RANGE_JPEG)
182  || avctx->color_range == AVCOL_RANGE_MPEG) {
183  put_marker(p, COM);
184  flush_put_bits(p);
185  ptr = put_bits_ptr(p);
186  put_bits(p, 16, 0); /* patched later */
187  ff_put_string(p, "CS=ITU601", 1);
188  size = strlen("CS=ITU601")+3;
189  AV_WB16(ptr, size);
190  }
191 }
192 
193 void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
194 {
195  int chroma_h_shift, chroma_v_shift;
196 
197  av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
198  &chroma_v_shift);
199  if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
200  ( avctx->pix_fmt == AV_PIX_FMT_BGR0
201  || avctx->pix_fmt == AV_PIX_FMT_BGRA
202  || avctx->pix_fmt == AV_PIX_FMT_BGR24)) {
203  vsample[0] = hsample[0] =
204  vsample[1] = hsample[1] =
205  vsample[2] = hsample[2] =
206  vsample[3] = hsample[3] = 1;
207  } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P) {
208  vsample[0] = vsample[1] = vsample[2] = 2;
209  hsample[0] = hsample[1] = hsample[2] = 1;
210  } else {
211  vsample[0] = 2;
212  vsample[1] = 2 >> chroma_v_shift;
213  vsample[2] = 2 >> chroma_v_shift;
214  hsample[0] = 2;
215  hsample[1] = 2 >> chroma_h_shift;
216  hsample[2] = 2 >> chroma_h_shift;
217  }
218 }
219 
221  ScanTable *intra_scantable, int pred,
222  uint16_t luma_intra_matrix[64],
223  uint16_t chroma_intra_matrix[64])
224 {
225  const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG && avctx->codec_id != AV_CODEC_ID_AMV;
226  int hsample[4], vsample[4];
227  int i;
228  int components = 3 + (avctx->pix_fmt == AV_PIX_FMT_BGRA);
229  int chroma_matrix = !!memcmp(luma_intra_matrix,
230  chroma_intra_matrix,
231  sizeof(luma_intra_matrix[0])*64);
232 
233  ff_mjpeg_init_hvsample(avctx, hsample, vsample);
234 
235  put_marker(pb, SOI);
236 
237  // hack for AMV mjpeg format
238  if(avctx->codec_id == AV_CODEC_ID_AMV) goto end;
239 
240  jpeg_put_comments(avctx, pb);
241 
242  jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
243 
244  switch (avctx->codec_id) {
245  case AV_CODEC_ID_MJPEG: put_marker(pb, SOF0 ); break;
246  case AV_CODEC_ID_LJPEG: put_marker(pb, SOF3 ); break;
247  default: av_assert0(0);
248  }
249 
250  put_bits(pb, 16, 17);
251  if (lossless && ( avctx->pix_fmt == AV_PIX_FMT_BGR0
252  || avctx->pix_fmt == AV_PIX_FMT_BGRA
253  || avctx->pix_fmt == AV_PIX_FMT_BGR24))
254  put_bits(pb, 8, 9); /* 9 bits/component RCT */
255  else
256  put_bits(pb, 8, 8); /* 8 bits/component */
257  put_bits(pb, 16, avctx->height);
258  put_bits(pb, 16, avctx->width);
259  put_bits(pb, 8, components); /* 3 or 4 components */
260 
261  /* Y component */
262  put_bits(pb, 8, 1); /* component number */
263  put_bits(pb, 4, hsample[0]); /* H factor */
264  put_bits(pb, 4, vsample[0]); /* V factor */
265  put_bits(pb, 8, 0); /* select matrix */
266 
267  /* Cb component */
268  put_bits(pb, 8, 2); /* component number */
269  put_bits(pb, 4, hsample[1]); /* H factor */
270  put_bits(pb, 4, vsample[1]); /* V factor */
271  put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
272 
273  /* Cr component */
274  put_bits(pb, 8, 3); /* component number */
275  put_bits(pb, 4, hsample[2]); /* H factor */
276  put_bits(pb, 4, vsample[2]); /* V factor */
277  put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
278 
279  if (components == 4) {
280  put_bits(pb, 8, 4); /* component number */
281  put_bits(pb, 4, hsample[3]); /* H factor */
282  put_bits(pb, 4, vsample[3]); /* V factor */
283  put_bits(pb, 8, 0); /* select matrix */
284  }
285 
286  /* scan header */
287  put_marker(pb, SOS);
288  put_bits(pb, 16, 6 + 2*components); /* length */
289  put_bits(pb, 8, components); /* 3 components */
290 
291  /* Y component */
292  put_bits(pb, 8, 1); /* index */
293  put_bits(pb, 4, 0); /* DC huffman table index */
294  put_bits(pb, 4, 0); /* AC huffman table index */
295 
296  /* Cb component */
297  put_bits(pb, 8, 2); /* index */
298  put_bits(pb, 4, 1); /* DC huffman table index */
299  put_bits(pb, 4, lossless ? 0 : 1); /* AC huffman table index */
300 
301  /* Cr component */
302  put_bits(pb, 8, 3); /* index */
303  put_bits(pb, 4, 1); /* DC huffman table index */
304  put_bits(pb, 4, lossless ? 0 : 1); /* AC huffman table index */
305 
306  if (components == 4) {
307  /* Alpha component */
308  put_bits(pb, 8, 4); /* index */
309  put_bits(pb, 4, 0); /* DC huffman table index */
310  put_bits(pb, 4, 0); /* AC huffman table index */
311  }
312 
313  put_bits(pb, 8, lossless ? pred : 0); /* Ss (not used) */
314 
315  switch (avctx->codec_id) {
316  case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */
317  case AV_CODEC_ID_LJPEG: put_bits(pb, 8, 0); break; /* not used */
318  default: av_assert0(0);
319  }
320 
321  put_bits(pb, 8, 0); /* Ah/Al (not used) */
322 
323 end:
324  if (!lossless) {
325  MpegEncContext *s = avctx->priv_data;
326  av_assert0(avctx->codec->priv_data_size == sizeof(MpegEncContext));
327 
328  s->esc_pos = put_bytes_count(pb, 0);
329  for(i=1; i<s->slice_context_count; i++)
330  s->thread_context[i]->esc_pos = 0;
331  }
332 }
333 
334 void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
335 {
336  int size;
337  int i, ff_count;
338  uint8_t *buf = pb->buf + start;
339  int align= (-(size_t)(buf))&3;
340  int pad = (-put_bits_count(pb))&7;
341 
342  if (pad)
343  put_bits(pb, pad, (1<<pad)-1);
344 
345  flush_put_bits(pb);
346  size = put_bytes_output(pb) - start;
347 
348  ff_count=0;
349  for(i=0; i<size && i<align; i++){
350  if(buf[i]==0xFF) ff_count++;
351  }
352  for(; i<size-15; i+=16){
353  int acc, v;
354 
355  v= *(uint32_t*)(&buf[i]);
356  acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
357  v= *(uint32_t*)(&buf[i+4]);
358  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
359  v= *(uint32_t*)(&buf[i+8]);
360  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
361  v= *(uint32_t*)(&buf[i+12]);
362  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
363 
364  acc>>=4;
365  acc+= (acc>>16);
366  acc+= (acc>>8);
367  ff_count+= acc&0xFF;
368  }
369  for(; i<size; i++){
370  if(buf[i]==0xFF) ff_count++;
371  }
372 
373  if(ff_count==0) return;
374 
375  flush_put_bits(pb);
376  skip_put_bytes(pb, ff_count);
377 
378  for(i=size-1; ff_count; i--){
379  int v= buf[i];
380 
381  if(v==0xFF){
382  buf[i+ff_count]= 0;
383  ff_count--;
384  }
385 
386  buf[i+ff_count]= v;
387  }
388 }
389 
390 /* isn't this function nicer than the one in the libjpeg ? */
391 void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
392  const uint8_t *bits_table,
393  const uint8_t *val_table)
394 {
395  int k, code;
396 
397  k = 0;
398  code = 0;
399  for (int i = 1; i <= 16; i++) {
400  int nb = bits_table[i];
401  for (int j = 0; j < nb; j++) {
402  int sym = val_table[k++];
403  huff_size[sym] = i;
404  huff_code[sym] = code;
405  code++;
406  }
407  code <<= 1;
408  }
409 }
410 
412 {
413  av_assert1((header_bits & 7) == 0);
414 
415  put_marker(pb, EOI);
416 }
417 
419  uint8_t *huff_size, uint16_t *huff_code)
420 {
421  int mant, nbits;
422 
423  if (val == 0) {
424  put_bits(pb, huff_size[0], huff_code[0]);
425  } else {
426  mant = val;
427  if (val < 0) {
428  val = -val;
429  mant--;
430  }
431 
432  nbits= av_log2_16bit(val) + 1;
433 
434  put_bits(pb, huff_size[nbits], huff_code[nbits]);
435 
436  put_sbits(pb, nbits, mant);
437  }
438 }
439 
441 {
443  avctx->color_range != AVCOL_RANGE_JPEG &&
444  (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
445  avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
446  avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
447  avctx->color_range == AVCOL_RANGE_MPEG)) {
448  av_log(avctx, AV_LOG_ERROR,
449  "Non full-range YUV is non-standard, set strict_std_compliance "
450  "to at most unofficial to use it.\n");
451  return AVERROR(EINVAL);
452  }
453  return 0;
454 }
#define NULL
Definition: coverity.c:32
const struct AVCodec * codec
Definition: avcodec.h:545
Definition: mjpeg.h:71
Definition: mjpeg.h:111
Definition: mjpeg.h:73
static void put_sbits(PutBitContext *pb, int n, int32_t value)
Definition: put_bits.h:290
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:218
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:200
Definition: mjpeg.h:42
int acc
Definition: yuv2rgb.c:555
MJPEG encoder.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1171
Scantable.
Definition: idctdsp.h:31
int num
Numerator.
Definition: rational.h:59
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition: avcodec.h:915
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
Definition: mjpeg.h:75
uint8_t permutated[64]
Definition: idctdsp.h:33
static int put_bytes_count(const PutBitContext *s, int round_up)
Definition: put_bits.h:104
int av_log2_16bit(unsigned v)
Definition: intmath.c:31
MJPEG encoder and decoder.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
Definition: mjpeg.h:72
uint8_t
uint8_t val_ac_luminance[256]
AC luminance Huffman values.
Definition: mjpegenc.h:84
uint8_t val_dc_chrominance[12]
DC chrominance Huffman values.
Definition: mjpegenc.h:80
int force_duplicated_matrix
Force duplication of mjpeg matrices, useful for rtp streaming.
Definition: mpegvideo.h:304
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
Definition: jpegtables.c:65
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
ptrdiff_t size
Definition: opengl_enc.c:100
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
#define AV_WB16(p, v)
Definition: intreadwrite.h:405
#define av_log(a,...)
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
Definition: avcodec.h:1605
enum AVCodecID id
Definition: codec.h:211
int slice_context_count
number of used thread_contexts
Definition: mpegvideo.h:156
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
Definition: put_bits.h:379
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
Definition: jpegtables.c:70
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
Definition: pixdesc.c:2601
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:1792
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:616
uint8_t * buf
Definition: put_bits.h:54
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
uint8_t bits_dc_luminance[17]
DC luminance Huffman bits.
Definition: mjpegenc.h:77
Definition: mjpeg.h:39
Definition: mjpeg.h:70
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:84
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
Definition: mjpeg.h:79
static void put_marker(PutBitContext *p, enum JpegMarker code)
Definition: mjpegenc.h:101
Definition: mjpeg.h:56
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
Definition: put_bits.h:388
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:333
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
uint8_t val_ac_chrominance[256]
AC chrominance Huffman values.
Definition: mjpegenc.h:86
int width
picture width / height.
Definition: avcodec.h:709
int priv_data_size
Definition: codec.h:245
#define s(width, name)
Definition: cbs_vp9.c:257
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
Definition: avcodec.h:1785
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:69
static int put_bytes_output(const PutBitContext *s)
Definition: put_bits.h:93
Compute and use optimal Huffman tables.
Definition: mjpegenc.h:97
Full range content.
Definition: pixfmt.h:586
static const float pred[4]
Definition: siprdata.h:259
struct MJpegContext * mjpeg_ctx
Definition: mpegvideo.h:426
struct MpegEncContext * thread_context[MAX_THREADS]
Definition: mpegvideo.h:155
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
Libavcodec external API header.
enum AVCodecID codec_id
Definition: avcodec.h:546
main external API structure.
Definition: avcodec.h:536
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, ScanTable *intra_scantable, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64], int hsample[3])
const uint8_t avpriv_mjpeg_val_dc[12]
Definition: jpegtables.c:67
uint8_t bits_ac_chrominance[17]
AC chrominance Huffman bits.
Definition: mjpegenc.h:85
Rational number (pair of numerator and denominator).
Definition: rational.h:58
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:240
const uint8_t avpriv_mjpeg_bits_ac_chrominance[17]
Definition: jpegtables.c:99
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64])
const uint8_t avpriv_mjpeg_val_ac_chrominance[]
Definition: jpegtables.c:102
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
uint8_t val_dc_luminance[12]
DC luminance Huffman values.
Definition: mjpegenc.h:78
Narrow or limited range content.
Definition: pixfmt.h:569
MpegEncContext.
Definition: mpegvideo.h:81
uint8_t bits_dc_chrominance[17]
DC chrominance Huffman bits.
Definition: mjpegenc.h:79
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
Definition: bitstream.c:59
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:147
uint8_t bits_ac_luminance[17]
AC luminance Huffman bits.
Definition: mjpegenc.h:83
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
int den
Denominator.
Definition: rational.h:60
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
Definition: jpegtables.c:73
void * priv_data
Definition: avcodec.h:563
pixel format definitions
const uint8_t avpriv_mjpeg_val_ac_luminance[]
Definition: jpegtables.c:75
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
#define LIBAVCODEC_IDENT
Definition: version.h:42
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
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
int ff_mjpeg_encode_check_pix_fmt(AVCodecContext *avctx)
static double val(void *priv, double ch)
Definition: aeval.c:76
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
Definition: avcodec.h:1601
int i
Definition: input.c:407
bitstream writer API