FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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/common.h"
27 #include "libavutil/pixdesc.h"
28 #include "libavutil/pixfmt.h"
29 
30 #include "avcodec.h"
31 #include "idctdsp.h"
32 #include "jpegtables.h"
33 #include "put_bits.h"
34 #include "mjpegenc.h"
35 #include "mjpegenc_common.h"
36 #include "mjpeg.h"
37 
38 /* table_class: 0 = DC coef, 1 = AC coefs */
39 static int put_huffman_table(PutBitContext *p, int table_class, int table_id,
40  const uint8_t *bits_table, const uint8_t *value_table)
41 {
42  int n, i;
43 
44  put_bits(p, 4, table_class);
45  put_bits(p, 4, table_id);
46 
47  n = 0;
48  for(i=1;i<=16;i++) {
49  n += bits_table[i];
50  put_bits(p, 8, bits_table[i]);
51  }
52 
53  for(i=0;i<n;i++)
54  put_bits(p, 8, value_table[i]);
55 
56  return n + 17;
57 }
58 
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  MpegEncContext *s = avctx->priv_data;
68 
69  if (avctx->codec_id != AV_CODEC_ID_LJPEG) {
70  int matrix_count = 1 + !!memcmp(luma_intra_matrix,
71  chroma_intra_matrix,
72  sizeof(luma_intra_matrix[0]) * 64);
74  matrix_count = 2;
75  /* quant matrixes */
76  put_marker(p, DQT);
77  put_bits(p, 16, 2 + matrix_count * (1 + 64));
78  put_bits(p, 4, 0); /* 8 bit precision */
79  put_bits(p, 4, 0); /* table 0 */
80  for(i=0;i<64;i++) {
81  j = intra_scantable->permutated[i];
82  put_bits(p, 8, luma_intra_matrix[j]);
83  }
84 
85  if (matrix_count > 1) {
86  put_bits(p, 4, 0); /* 8 bit precision */
87  put_bits(p, 4, 1); /* table 1 */
88  for(i=0;i<64;i++) {
89  j = intra_scantable->permutated[i];
90  put_bits(p, 8, chroma_intra_matrix[j]);
91  }
92  }
93  }
94 
96  put_marker(p, DRI);
97  put_bits(p, 16, 4);
98  put_bits(p, 16, (avctx->width-1)/(8*hsample[0]) + 1);
99  }
100 
101  /* huffman table */
102  put_marker(p, DHT);
103  flush_put_bits(p);
104  ptr = put_bits_ptr(p);
105  put_bits(p, 16, 0); /* patched later */
106  size = 2;
111 
116  AV_WB16(ptr, size);
117 }
118 
120 {
121  int size;
122  uint8_t *ptr;
123 
124  if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0) {
125  AVRational sar = avctx->sample_aspect_ratio;
126 
127  if (sar.num > 65535 || sar.den > 65535) {
128  if (!av_reduce(&sar.num, &sar.den, avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 65535))
129  av_log(avctx, AV_LOG_WARNING,
130  "Cannot store exact aspect ratio %d:%d\n",
131  avctx->sample_aspect_ratio.num,
132  avctx->sample_aspect_ratio.den);
133  }
134 
135  /* JFIF header */
136  put_marker(p, APP0);
137  put_bits(p, 16, 16);
138  avpriv_put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
139  /* The most significant byte is used for major revisions, the least
140  * significant byte for minor revisions. Version 1.02 is the current
141  * released revision. */
142  put_bits(p, 16, 0x0102);
143  put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
144  put_bits(p, 16, sar.num);
145  put_bits(p, 16, sar.den);
146  put_bits(p, 8, 0); /* thumbnail width */
147  put_bits(p, 8, 0); /* thumbnail height */
148  }
149 
150  /* comment */
151  if (!(avctx->flags & AV_CODEC_FLAG_BITEXACT)) {
152  put_marker(p, COM);
153  flush_put_bits(p);
154  ptr = put_bits_ptr(p);
155  put_bits(p, 16, 0); /* patched later */
157  size = strlen(LIBAVCODEC_IDENT)+3;
158  AV_WB16(ptr, size);
159  }
160 
161  if (((avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
162  avctx->pix_fmt == AV_PIX_FMT_YUV422P ||
163  avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->color_range != AVCOL_RANGE_JPEG)
164  || avctx->color_range == AVCOL_RANGE_MPEG) {
165  put_marker(p, COM);
166  flush_put_bits(p);
167  ptr = put_bits_ptr(p);
168  put_bits(p, 16, 0); /* patched later */
169  avpriv_put_string(p, "CS=ITU601", 1);
170  size = strlen("CS=ITU601")+3;
171  AV_WB16(ptr, size);
172  }
173 }
174 
175 void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
176 {
177  int chroma_h_shift, chroma_v_shift;
178 
179  av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift,
180  &chroma_v_shift);
181  if (avctx->codec->id == AV_CODEC_ID_LJPEG &&
182  ( avctx->pix_fmt == AV_PIX_FMT_BGR0
183  || avctx->pix_fmt == AV_PIX_FMT_BGRA
184  || avctx->pix_fmt == AV_PIX_FMT_BGR24)) {
185  vsample[0] = hsample[0] =
186  vsample[1] = hsample[1] =
187  vsample[2] = hsample[2] =
188  vsample[3] = hsample[3] = 1;
189  } else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P || avctx->pix_fmt == AV_PIX_FMT_YUVJ444P) {
190  vsample[0] = vsample[1] = vsample[2] = 2;
191  hsample[0] = hsample[1] = hsample[2] = 1;
192  } else {
193  vsample[0] = 2;
194  vsample[1] = 2 >> chroma_v_shift;
195  vsample[2] = 2 >> chroma_v_shift;
196  hsample[0] = 2;
197  hsample[1] = 2 >> chroma_h_shift;
198  hsample[2] = 2 >> chroma_h_shift;
199  }
200 }
201 
203  ScanTable *intra_scantable, int pred,
204  uint16_t luma_intra_matrix[64],
205  uint16_t chroma_intra_matrix[64])
206 {
207  const int lossless = avctx->codec_id != AV_CODEC_ID_MJPEG && avctx->codec_id != AV_CODEC_ID_AMV;
208  int hsample[4], vsample[4];
209  int i;
210  int components = 3 + (avctx->pix_fmt == AV_PIX_FMT_BGRA);
211  int chroma_matrix = !!memcmp(luma_intra_matrix,
212  chroma_intra_matrix,
213  sizeof(luma_intra_matrix[0])*64);
214 
215  ff_mjpeg_init_hvsample(avctx, hsample, vsample);
216 
217  put_marker(pb, SOI);
218 
219  // hack for AMV mjpeg format
220  if(avctx->codec_id == AV_CODEC_ID_AMV) goto end;
221 
222  jpeg_put_comments(avctx, pb);
223 
224  jpeg_table_header(avctx, pb, intra_scantable, luma_intra_matrix, chroma_intra_matrix, hsample);
225 
226  switch (avctx->codec_id) {
227  case AV_CODEC_ID_MJPEG: put_marker(pb, SOF0 ); break;
228  case AV_CODEC_ID_LJPEG: put_marker(pb, SOF3 ); break;
229  default: av_assert0(0);
230  }
231 
232  put_bits(pb, 16, 17);
233  if (lossless && ( avctx->pix_fmt == AV_PIX_FMT_BGR0
234  || avctx->pix_fmt == AV_PIX_FMT_BGRA
235  || avctx->pix_fmt == AV_PIX_FMT_BGR24))
236  put_bits(pb, 8, 9); /* 9 bits/component RCT */
237  else
238  put_bits(pb, 8, 8); /* 8 bits/component */
239  put_bits(pb, 16, avctx->height);
240  put_bits(pb, 16, avctx->width);
241  put_bits(pb, 8, components); /* 3 or 4 components */
242 
243  /* Y component */
244  put_bits(pb, 8, 1); /* component number */
245  put_bits(pb, 4, hsample[0]); /* H factor */
246  put_bits(pb, 4, vsample[0]); /* V factor */
247  put_bits(pb, 8, 0); /* select matrix */
248 
249  /* Cb component */
250  put_bits(pb, 8, 2); /* component number */
251  put_bits(pb, 4, hsample[1]); /* H factor */
252  put_bits(pb, 4, vsample[1]); /* V factor */
253  put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
254 
255  /* Cr component */
256  put_bits(pb, 8, 3); /* component number */
257  put_bits(pb, 4, hsample[2]); /* H factor */
258  put_bits(pb, 4, vsample[2]); /* V factor */
259  put_bits(pb, 8, lossless ? 0 : chroma_matrix); /* select matrix */
260 
261  if (components == 4) {
262  put_bits(pb, 8, 4); /* component number */
263  put_bits(pb, 4, hsample[3]); /* H factor */
264  put_bits(pb, 4, vsample[3]); /* V factor */
265  put_bits(pb, 8, 0); /* select matrix */
266  }
267 
268  /* scan header */
269  put_marker(pb, SOS);
270  put_bits(pb, 16, 6 + 2*components); /* length */
271  put_bits(pb, 8, components); /* 3 components */
272 
273  /* Y component */
274  put_bits(pb, 8, 1); /* index */
275  put_bits(pb, 4, 0); /* DC huffman table index */
276  put_bits(pb, 4, 0); /* AC huffman table index */
277 
278  /* Cb component */
279  put_bits(pb, 8, 2); /* index */
280  put_bits(pb, 4, 1); /* DC huffman table index */
281  put_bits(pb, 4, lossless ? 0 : 1); /* AC huffman table index */
282 
283  /* Cr component */
284  put_bits(pb, 8, 3); /* index */
285  put_bits(pb, 4, 1); /* DC huffman table index */
286  put_bits(pb, 4, lossless ? 0 : 1); /* AC huffman table index */
287 
288  if (components == 4) {
289  /* Alpha component */
290  put_bits(pb, 8, 4); /* index */
291  put_bits(pb, 4, 0); /* DC huffman table index */
292  put_bits(pb, 4, 0); /* AC huffman table index */
293  }
294 
295  put_bits(pb, 8, lossless ? pred : 0); /* Ss (not used) */
296 
297  switch (avctx->codec_id) {
298  case AV_CODEC_ID_MJPEG: put_bits(pb, 8, 63); break; /* Se (not used) */
299  case AV_CODEC_ID_LJPEG: put_bits(pb, 8, 0); break; /* not used */
300  default: av_assert0(0);
301  }
302 
303  put_bits(pb, 8, 0); /* Ah/Al (not used) */
304 
305 end:
306  if (!lossless) {
307  MpegEncContext *s = avctx->priv_data;
308  av_assert0(avctx->codec->priv_data_size == sizeof(MpegEncContext));
309 
310  s->esc_pos = put_bits_count(pb) >> 3;
311  for(i=1; i<s->slice_context_count; i++)
312  s->thread_context[i]->esc_pos = 0;
313  }
314 }
315 
317 {
318  int size;
319  int i, ff_count;
320  uint8_t *buf = pb->buf + start;
321  int align= (-(size_t)(buf))&3;
322  int pad = (-put_bits_count(pb))&7;
323 
324  if (pad)
325  put_bits(pb, pad, (1<<pad)-1);
326 
327  flush_put_bits(pb);
328  size = put_bits_count(pb) - start * 8;
329 
330  av_assert1((size&7) == 0);
331  size >>= 3;
332 
333  ff_count=0;
334  for(i=0; i<size && i<align; i++){
335  if(buf[i]==0xFF) ff_count++;
336  }
337  for(; i<size-15; i+=16){
338  int acc, v;
339 
340  v= *(uint32_t*)(&buf[i]);
341  acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
342  v= *(uint32_t*)(&buf[i+4]);
343  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
344  v= *(uint32_t*)(&buf[i+8]);
345  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
346  v= *(uint32_t*)(&buf[i+12]);
347  acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
348 
349  acc>>=4;
350  acc+= (acc>>16);
351  acc+= (acc>>8);
352  ff_count+= acc&0xFF;
353  }
354  for(; i<size; i++){
355  if(buf[i]==0xFF) ff_count++;
356  }
357 
358  if(ff_count==0) return;
359 
360  flush_put_bits(pb);
361  skip_put_bytes(pb, ff_count);
362 
363  for(i=size-1; ff_count; i--){
364  int v= buf[i];
365 
366  if(v==0xFF){
367  buf[i+ff_count]= 0;
368  ff_count--;
369  }
370 
371  buf[i+ff_count]= v;
372  }
373 }
374 
376 {
377  int i;
378  PutBitContext *pbc = &s->pb;
379  int mb_y = s->mb_y - !s->mb_x;
380 
381  int ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
382  put_bits_count(&s->pb) / 4 + 1000);
383  if (ret < 0) {
384  av_log(s->avctx, AV_LOG_ERROR, "Buffer reallocation failed\n");
385  goto fail;
386  }
387 
388  ff_mjpeg_escape_FF(pbc, s->esc_pos);
389 
390  if((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height)
391  put_marker(pbc, RST0 + (mb_y&7));
392  s->esc_pos = put_bits_count(pbc) >> 3;
393 fail:
394 
395  for(i=0; i<3; i++)
396  s->last_dc[i] = 128 << s->intra_dc_precision;
397 
398  return ret;
399 }
400 
402 {
403  av_assert1((header_bits & 7) == 0);
404 
405  put_marker(pb, EOI);
406 }
407 
409  uint8_t *huff_size, uint16_t *huff_code)
410 {
411  int mant, nbits;
412 
413  if (val == 0) {
414  put_bits(pb, huff_size[0], huff_code[0]);
415  } else {
416  mant = val;
417  if (val < 0) {
418  val = -val;
419  mant--;
420  }
421 
422  nbits= av_log2_16bit(val) + 1;
423 
424  put_bits(pb, huff_size[nbits], huff_code[nbits]);
425 
426  put_sbits(pb, nbits, mant);
427  }
428 }
const struct AVCodec * codec
Definition: avcodec.h:1658
const char const char void * val
Definition: avisynth_c.h:634
const char * s
Definition: avisynth_c.h:631
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:200
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Definition: j2kenc.c:206
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Definition: mjpeg.h:42
int acc
Definition: yuv2rgb.c:546
MJPEG encoder.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2385
Scantable.
Definition: idctdsp.h:29
int num
numerator
Definition: rational.h:44
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:2060
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1877
Definition: mjpeg.h:75
uint8_t permutated[64]
Definition: idctdsp.h:31
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
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
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
int intra_dc_precision
Definition: mpegvideo.h:460
ptrdiff_t size
Definition: opengl_enc.c:101
#define AV_WB16(p, v)
Definition: intreadwrite.h:405
#define av_log(a,...)
enum AVCodecID id
Definition: avcodec.h:3556
int slice_context_count
number of used thread_contexts
Definition: mpegvideo.h:153
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
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:227
int last_dc[3]
last DC values for MPEG-1
Definition: mpegvideo.h:182
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:2250
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:3098
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:96
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1744
uint8_t * buf
Definition: put_bits.h:38
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
#define fail()
Definition: checkasm.h:81
Definition: mjpeg.h:39
Definition: mjpeg.h:70
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:85
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:66
int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t size_increase)
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
Definition: mjpeg.h:79
static void put_marker(PutBitContext *p, enum JpegMarker code)
Definition: mjpegenc.h:54
Definition: mjpeg.h:56
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
Definition: put_bits.h:236
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:883
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
int width
picture width / height.
Definition: avcodec.h:1836
int priv_data_size
Definition: avcodec.h:3578
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
Definition: avcodec.h:3091
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
int n
Definition: avisynth_c.h:547
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:457
static const float pred[4]
Definition: siprdata.h:259
const AVS_VideoInfo int align
Definition: avisynth_c.h:658
struct MpegEncContext * thread_context[MAX_THREADS]
Definition: mpegvideo.h:152
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:1666
main external API structure.
Definition: avcodec.h:1649
void * buf
Definition: avisynth_c.h:553
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
rational number numerator/denominator
Definition: rational.h:43
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:253
int ff_mjpeg_encode_stuffing(MpegEncContext *s)
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
the normal 219*2^(n-8) "MPEG" YUV ranges
Definition: pixfmt.h:456
MpegEncContext.
Definition: mpegvideo.h:78
struct AVCodecContext * avctx
Definition: mpegvideo.h:95
PutBitContext pb
bit output
Definition: mpegvideo.h:148
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
Definition: put_bits.h:101
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:76
int den
denominator
Definition: rational.h:45
const uint8_t avpriv_mjpeg_bits_ac_luminance[17]
Definition: jpegtables.c:73
void * priv_data
Definition: avcodec.h:1691
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
void avpriv_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
Definition: bitstream.c:54
void INT64 start
Definition: avisynth_c.h:553
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p)
Definition: mjpeg.h:61
bitstream writer API