Libav
magicyuv.c
Go to the documentation of this file.
1 /*
2  * MagicYUV decoder
3  * Copyright (c) 2016 Paul B Mahol
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include <stdlib.h>
23 #include <string.h>
24 
25 #include "../libavutil/pixdesc.h"
26 
27 #include "avcodec.h"
28 #include "bytestream.h"
29 #include "get_bits.h"
30 #include "huffyuvdsp.h"
31 #include "internal.h"
32 #include "thread.h"
33 
34 typedef struct Slice {
35  uint32_t start;
36  uint32_t size;
37 } Slice;
38 
39 typedef enum Prediction {
40  LEFT = 1,
43 } Prediction;
44 
45 typedef struct HuffEntry {
48  uint32_t code;
49 } HuffEntry;
50 
51 typedef struct MagicYUVContext {
54  int nb_slices;
55  int planes; // number of encoded planes in bitstream
56  int decorrelate; // postprocessing work
57  int interlaced; // video is interlaced
58  uint8_t *buf; // pointer to AVPacket->data
59  int hshift[4];
60  int vshift[4];
61  Slice *slices[4]; // slice bitstream positions for each plane
62  unsigned int slices_size[4]; // slice sizes for each plane
63  uint8_t len[4][256]; // table of code lengths for each plane
64  VLC vlc[4]; // VLC for each plane
67 
68 static int huff_cmp_len(const void *a, const void *b)
69 {
70  const HuffEntry *aa = a, *bb = b;
71  return (aa->len - bb->len) * 256 + aa->sym - bb->sym;
72 }
73 
74 static int huff_build(VLC *vlc, uint8_t *len)
75 {
76  HuffEntry he[256];
77  uint32_t codes[256];
78  uint8_t bits[256];
79  uint8_t syms[256];
80  uint32_t code;
81  int i;
82 
83  for (i = 0; i < 256; i++) {
84  he[i].sym = 255 - i;
85  he[i].len = len[i];
86  }
87  qsort(he, 256, sizeof(HuffEntry), huff_cmp_len);
88 
89  code = 1;
90  for (i = 255; i >= 0; i--) {
91  codes[i] = code >> (32 - he[i].len);
92  bits[i] = he[i].len;
93  syms[i] = he[i].sym;
94  code += 0x80000000u >> (he[i].len - 1);
95  }
96 
97  ff_free_vlc(vlc);
98  return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256,
99  bits, sizeof(*bits), sizeof(*bits),
100  codes, sizeof(*codes), sizeof(*codes),
101  syms, sizeof(*syms), sizeof(*syms), 0);
102 }
103 
104 static int magy_decode_slice(AVCodecContext *avctx, void *tdata,
105  int j, int threadnr)
106 {
107  MagicYUVContext *s = avctx->priv_data;
108  int interlaced = s->interlaced;
109  AVFrame *p = s->p;
110  int i, k, x;
111  GetBitContext gb;
112  uint8_t *dst;
113 
114  for (i = 0; i < s->planes; i++) {
115  int left, lefttop, top;
116  int height = AV_CEIL_RSHIFT(FFMIN(s->slice_height, avctx->height - j * s->slice_height), s->vshift[i]);
117  int width = AV_CEIL_RSHIFT(avctx->width, s->hshift[i]);
118  int sheight = AV_CEIL_RSHIFT(s->slice_height, s->vshift[i]);
119  ptrdiff_t fake_stride = p->linesize[i] * (1 + interlaced);
120  ptrdiff_t stride = p->linesize[i];
121  int flags, pred;
122  int ret = init_get_bits8(&gb, s->buf + s->slices[i][j].start,
123  s->slices[i][j].size);
124 
125  if (ret < 0)
126  return ret;
127 
128  flags = get_bits(&gb, 8);
129  pred = get_bits(&gb, 8);
130 
131  dst = p->data[i] + j * sheight * stride;
132  if (flags & 1) {
133  for (k = 0; k < height; k++) {
134  for (x = 0; x < width; x++)
135  dst[x] = get_bits(&gb, 8);
136 
137  dst += stride;
138  }
139  } else {
140  for (k = 0; k < height; k++) {
141  for (x = 0; x < width; x++) {
142  int pix;
143  if (get_bits_left(&gb) <= 0)
144  return AVERROR_INVALIDDATA;
145 
146  pix = get_vlc2(&gb, s->vlc[i].table, s->vlc[i].bits, 3);
147  if (pix < 0)
148  return AVERROR_INVALIDDATA;
149 
150  dst[x] = 255 - pix;
151  }
152  dst += stride;
153  }
154  }
155 
156  switch (pred) {
157  case LEFT:
158  dst = p->data[i] + j * sheight * stride;
159  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
160  dst += stride;
161  if (interlaced) {
162  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
163  dst += stride;
164  }
165  for (k = 1 + interlaced; k < height; k++) {
166  s->hdsp.add_hfyu_left_pred(dst, dst, width, dst[-fake_stride]);
167  dst += stride;
168  }
169  break;
170  case GRADIENT:
171  dst = p->data[i] + j * sheight * stride;
172  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
173  left = lefttop = 0;
174  dst += stride;
175  if (interlaced) {
176  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
177  left = lefttop = 0;
178  dst += stride;
179  }
180  for (k = 1 + interlaced; k < height; k++) {
181  top = dst[-fake_stride];
182  left = top + dst[0];
183  dst[0] = left;
184  for (x = 1; x < width; x++) {
185  top = dst[x - fake_stride];
186  lefttop = dst[x - (fake_stride + 1)];
187  left += top - lefttop + dst[x];
188  dst[x] = left;
189  }
190  dst += stride;
191  }
192  break;
193  case MEDIAN:
194  dst = p->data[i] + j * sheight * stride;
195  lefttop = left = dst[0];
196  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
197  dst += stride;
198  if (interlaced) {
199  lefttop = left = dst[0];
200  s->hdsp.add_hfyu_left_pred(dst, dst, width, 0);
201  dst += stride;
202  }
203  for (k = 1 + interlaced; k < height; k++) {
204  s->hdsp.add_hfyu_median_pred(dst, dst - fake_stride,
205  dst, width, &left, &lefttop);
206  lefttop = left = dst[0];
207  dst += stride;
208  }
209  break;
210  default:
211  avpriv_request_sample(avctx, "Unknown prediction: %d", pred);
212  }
213  }
214 
215  if (s->decorrelate) {
216  int height = FFMIN(s->slice_height, avctx->height - j * s->slice_height);
217  int width = avctx->width;
218  uint8_t *b = p->data[0] + j * s->slice_height * p->linesize[0];
219  uint8_t *g = p->data[1] + j * s->slice_height * p->linesize[1];
220  uint8_t *r = p->data[2] + j * s->slice_height * p->linesize[2];
221 
222  for (i = 0; i < height; i++) {
223  s->hdsp.add_bytes(b, g, width);
224  s->hdsp.add_bytes(r, g, width);
225  b += p->linesize[0];
226  g += p->linesize[1];
227  r += p->linesize[2];
228  }
229  }
230 
231  return 0;
232 }
233 
234 static int magy_decode_frame(AVCodecContext *avctx, void *data,
235  int *got_frame, AVPacket *avpkt)
236 {
237  MagicYUVContext *s = avctx->priv_data;
238  ThreadFrame frame = { .f = data };
239  AVFrame *p = data;
240  GetByteContext gbyte;
241  GetBitContext gbit;
242  uint32_t first_offset, offset, next_offset, header_size, slice_width;
243  int width, height, format, version, table_size;
244  int ret, i, j, k;
245 
246  bytestream2_init(&gbyte, avpkt->data, avpkt->size);
247  if (bytestream2_get_le32(&gbyte) != MKTAG('M', 'A', 'G', 'Y'))
248  return AVERROR_INVALIDDATA;
249 
250  header_size = bytestream2_get_le32(&gbyte);
251  if (header_size < 32 || header_size >= avpkt->size) {
252  av_log(avctx, AV_LOG_ERROR,
253  "header or packet too small %"PRIu32"\n", header_size);
254  return AVERROR_INVALIDDATA;
255  }
256 
257  version = bytestream2_get_byte(&gbyte);
258  if (version != 7) {
259  avpriv_request_sample(avctx, "Version %d", version);
260  return AVERROR_PATCHWELCOME;
261  }
262 
263  s->hshift[1] =
264  s->vshift[1] =
265  s->hshift[2] =
266  s->vshift[2] = 0;
267  s->decorrelate = 0;
268 
269  format = bytestream2_get_byte(&gbyte);
270  switch (format) {
271  case 0x65:
272  avctx->pix_fmt = AV_PIX_FMT_GBRP;
273  s->decorrelate = 1;
274  break;
275  case 0x66:
276  avctx->pix_fmt = AV_PIX_FMT_GBRAP;
277  s->decorrelate = 1;
278  break;
279  case 0x67:
280  avctx->pix_fmt = AV_PIX_FMT_YUV444P;
281  break;
282  case 0x68:
283  avctx->pix_fmt = AV_PIX_FMT_YUV422P;
284  s->hshift[1] =
285  s->hshift[2] = 1;
286  break;
287  case 0x69:
288  avctx->pix_fmt = AV_PIX_FMT_YUV420P;
289  s->hshift[1] =
290  s->vshift[1] =
291  s->hshift[2] =
292  s->vshift[2] = 1;
293  break;
294  case 0x6a:
295  avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
296  break;
297  case 0x6b:
298  avctx->pix_fmt = AV_PIX_FMT_GRAY8;
299  break;
300  default:
301  avpriv_request_sample(avctx, "Format 0x%X", format);
302  return AVERROR_PATCHWELCOME;
303  }
305 
306  bytestream2_skip(&gbyte, 2);
307  s->interlaced = !!(bytestream2_get_byte(&gbyte) & 2);
308  bytestream2_skip(&gbyte, 3);
309 
310  width = bytestream2_get_le32(&gbyte);
311  height = bytestream2_get_le32(&gbyte);
312  ret = ff_set_dimensions(avctx, width, height);
313  if (ret < 0)
314  return ret;
315 
316  slice_width = bytestream2_get_le32(&gbyte);
317  if (slice_width != width) {
318  avpriv_request_sample(avctx, "Slice width %"PRIu32, slice_width);
319  return AVERROR_PATCHWELCOME;
320  }
321  s->slice_height = bytestream2_get_le32(&gbyte);
322  if (s->slice_height <= 0 || s->slice_height > INT_MAX - height) {
323  av_log(avctx, AV_LOG_ERROR,
324  "invalid slice height: %d\n", s->slice_height);
325  return AVERROR_INVALIDDATA;
326  }
327 
328  bytestream2_skip(&gbyte, 4);
329 
330  s->nb_slices = (height + s->slice_height - 1) / s->slice_height;
331  if (s->nb_slices > INT_MAX / sizeof(Slice)) {
332  av_log(avctx, AV_LOG_ERROR,
333  "invalid number of slices: %d\n", s->nb_slices);
334  return AVERROR_INVALIDDATA;
335  }
336 
337  for (i = 0; i < s->planes; i++) {
338  av_fast_malloc(&s->slices[i], &s->slices_size[i], s->nb_slices * sizeof(Slice));
339  if (!s->slices[i])
340  return AVERROR(ENOMEM);
341 
342  offset = bytestream2_get_le32(&gbyte);
343  if (offset >= avpkt->size - header_size)
344  return AVERROR_INVALIDDATA;
345 
346  if (i == 0)
347  first_offset = offset;
348 
349  for (j = 0; j < s->nb_slices - 1; j++) {
350  s->slices[i][j].start = offset + header_size;
351 
352  next_offset = bytestream2_get_le32(&gbyte);
353  if (next_offset <= offset || next_offset >= avpkt->size - header_size)
354  return AVERROR_INVALIDDATA;
355 
356  s->slices[i][j].size = next_offset - offset;
357  offset = next_offset;
358  }
359 
360  s->slices[i][j].start = offset + header_size;
361  s->slices[i][j].size = avpkt->size - s->slices[i][j].start;
362  }
363 
364  if (bytestream2_get_byte(&gbyte) != s->planes)
365  return AVERROR_INVALIDDATA;
366 
367  bytestream2_skip(&gbyte, s->nb_slices * s->planes);
368 
369  table_size = header_size + first_offset - bytestream2_tell(&gbyte);
370  if (table_size < 2)
371  return AVERROR_INVALIDDATA;
372 
373  ret = init_get_bits8(&gbit, avpkt->data + bytestream2_tell(&gbyte), table_size);
374  if (ret < 0)
375  return ret;
376 
377  memset(s->len, 0, sizeof(s->len));
378  j = i = 0;
379  while (get_bits_left(&gbit) >= 8) {
380  int b = get_bits(&gbit, 4);
381  int x = get_bits(&gbit, 4);
382  int l = get_bitsz(&gbit, b) + 1;
383 
384  for (k = 0; k < l; k++)
385  if (j + k < 256)
386  s->len[i][j + k] = x;
387 
388  j += l;
389  if (j == 256) {
390  j = 0;
391  if (huff_build(&s->vlc[i], s->len[i])) {
392  av_log(avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
393  return AVERROR_INVALIDDATA;
394  }
395  i++;
396  if (i == s->planes) {
397  break;
398  }
399  } else if (j > 256) {
400  return AVERROR_INVALIDDATA;
401  }
402  }
403 
404  if (i != s->planes) {
405  av_log(avctx, AV_LOG_ERROR, "Huffman tables too short\n");
406  return AVERROR_INVALIDDATA;
407  }
408 
410  p->key_frame = 1;
411 
412  if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0)
413  return ret;
414 
415  s->buf = avpkt->data;
416  s->p = p;
417  avctx->execute2(avctx, magy_decode_slice, NULL, NULL, s->nb_slices);
418 
419  if (avctx->pix_fmt == AV_PIX_FMT_GBRP ||
420  avctx->pix_fmt == AV_PIX_FMT_GBRAP) {
421  FFSWAP(uint8_t*, p->data[0], p->data[1]);
422  FFSWAP(int, p->linesize[0], p->linesize[1]);
423  }
424 
425  *got_frame = 1;
426 
427  return avpkt->size;
428 }
429 
430 #if HAVE_THREADS
431 static int magy_init_thread_copy(AVCodecContext *avctx)
432 {
433  MagicYUVContext *s = avctx->priv_data;
434  int i;
435 
436  for (i = 0; i < FF_ARRAY_ELEMS(s->slices); i++) {
437  s->slices[i] = NULL;
438  s->slices_size[i] = 0;
439  }
440 
441  return 0;
442 }
443 #endif
444 
446 {
447  MagicYUVContext *s = avctx->priv_data;
449  return 0;
450 }
451 
453 {
454  MagicYUVContext * const s = avctx->priv_data;
455  int i;
456 
457  for (i = 0; i < FF_ARRAY_ELEMS(s->slices); i++) {
458  av_freep(&s->slices[i]);
459  s->slices_size[i] = 0;
460  ff_free_vlc(&s->vlc[i]);
461  }
462 
463  return 0;
464 }
465 
467  .name = "magicyuv",
468  .long_name = NULL_IF_CONFIG_SMALL("MagicYUV video"),
469  .type = AVMEDIA_TYPE_VIDEO,
470  .id = AV_CODEC_ID_MAGICYUV,
471  .priv_data_size = sizeof(MagicYUVContext),
473  .init_thread_copy = ONLY_IF_THREADS_ENABLED(magy_init_thread_copy),
474  .close = magy_decode_end,
475  .decode = magy_decode_frame,
476  .capabilities = AV_CODEC_CAP_DR1 |
479  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
480 };
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
int vshift[4]
Definition: magicyuv.c:60
This structure describes decoded (raw) audio or video data.
Definition: frame.h:140
int hshift[4]
Definition: magicyuv.c:59
void(* add_bytes)(uint8_t *dst, uint8_t *src, int w)
Definition: huffyuvdsp.h:25
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:64
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition: get_bits.h:228
AVFrame * f
Definition: thread.h:36
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1805
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
Definition: utils.c:134
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:162
int size
Definition: avcodec.h:1347
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
av_cold void ff_huffyuvdsp_init(HuffYUVDSPContext *c)
Definition: huffyuvdsp.c:123
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1621
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:132
#define FF_ARRAY_ELEMS(a)
unsigned int slices_size[4]
Definition: magicyuv.c:62
int stride
Definition: mace.c:144
AVCodec.
Definition: avcodec.h:3120
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:202
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#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:40
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
Definition: bitstream.c:267
uint8_t bits
Definition: crc.c:252
uint8_t
#define av_cold
Definition: attributes.h:66
Multithreading support functions.
#define b
Definition: input.c:52
void(* add_hfyu_median_pred)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top)
Definition: huffyuvdsp.h:27
Prediction
Definition: magicyuv.c:39
const char data[16]
Definition: mxf.c:70
uint8_t * data
Definition: avcodec.h:1346
static int flags
Definition: log.c:50
bitstream reader API header.
uint32_t code
Definition: magicyuv.c:48
#define r
Definition: input.c:51
static int magy_decode_slice(AVCodecContext *avctx, void *tdata, int j, int threadnr)
Definition: magicyuv.c:104
static int huff_cmp_len(const void *a, const void *b)
Definition: magicyuv.c:68
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:526
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
int slice_height
Definition: magicyuv.c:53
#define AVERROR(e)
Definition: error.h:43
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:161
uint8_t sym
Definition: magicyuv.c:46
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
g
Definition: yuv2rgb.c:546
const char * name
Name of the codec implementation.
Definition: avcodec.h:3127
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:893
Definition: vlc.h:26
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:63
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:188
Slice * slices[4]
Definition: magicyuv.c:61
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:201
#define FFMIN(a, b)
Definition: common.h:66
HuffYUVDSPContext hdsp
Definition: magicyuv.c:65
int width
picture width / height.
Definition: avcodec.h:1580
Definition: magicyuv.c:34
AVFrame * p
Definition: magicyuv.c:52
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
Definition: get_bits.h:493
int(* add_hfyu_left_pred)(uint8_t *dst, const uint8_t *src, int w, int left)
Definition: huffyuvdsp.h:30
int bits
Definition: vlc.h:27
if(ac->has_optimized_func)
static const float pred[4]
Definition: siprdata.h:259
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
Definition: error.h:57
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:897
static av_cold int magy_decode_init(AVCodecContext *avctx)
Definition: magicyuv.c:445
static av_always_inline int bytestream2_tell(GetByteContext *g)
Definition: bytestream.h:185
int(* execute2)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count)
The codec may call this to execute several independent things.
Definition: avcodec.h:2866
NULL
Definition: eval.c:55
static int width
Definition: utils.c:156
uint8_t len
Definition: magicyuv.c:47
Libavcodec external API header.
version
Definition: ffv1enc.c:1091
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:158
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:395
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:170
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
Definition: avcodec.h:1409
static int magy_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: magicyuv.c:234
uint32_t size
Definition: magicyuv.c:36
uint32_t start
Definition: magicyuv.c:35
const char * format
Definition: movenc.c:47
uint8_t len[4][256]
Definition: magicyuv.c:63
AVCodec ff_magicyuv_decoder
Definition: magicyuv.c:466
Definition: magicyuv.c:40
#define u(width,...)
VLC vlc[4]
Definition: magicyuv.c:64
uint8_t * buf
Definition: magicyuv.c:58
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:146
int height
Definition: gxfenc.c:72
static av_cold int magy_decode_end(AVCodecContext *avctx)
Definition: magicyuv.c:452
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
Definition: mem.c:394
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:59
Y , 8bpp.
Definition: pixfmt.h:67
common internal api header.
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:208
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
void * priv_data
Definition: avcodec.h:1451
static int huff_build(VLC *vlc, uint8_t *len)
Definition: magicyuv.c:74
int len
VLC_TYPE(* table)[2]
code, bits
Definition: vlc.h:28
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:196
#define FFSWAP(type, a, b)
Definition: common.h:69
#define MKTAG(a, b, c, d)
Definition: common.h:256
This structure stores compressed data.
Definition: avcodec.h:1323
void ff_free_vlc(VLC *vlc)
Definition: bitstream.c:334
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:838
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
Definition: get_bits.h:242
#define AV_CEIL_RSHIFT(a, b)
Fast a / (1 << b) rounded toward +inf, assuming a >= 0 and b >= 0.
Definition: common.h:57