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