utvideo.c
Go to the documentation of this file.
1 /*
2  * Ut Video decoder
3  * Copyright (c) 2011 Konstantin Shishkov
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 
27 #include <stdlib.h>
28 
29 #include "libavutil/intreadwrite.h"
30 #include "avcodec.h"
31 #include "bytestream.h"
32 #include "get_bits.h"
33 #include "dsputil.h"
34 #include "thread.h"
35 
36 enum {
37  PRED_NONE = 0,
41 };
42 
43 typedef struct UtvideoContext {
47 
49  int planes;
50  int slices;
54 
55  uint8_t *slice_bits;
58 
59 typedef struct HuffEntry {
60  uint8_t sym;
61  uint8_t len;
62 } HuffEntry;
63 
64 static int huff_cmp(const void *a, const void *b)
65 {
66  const HuffEntry *aa = a, *bb = b;
67  return (aa->len - bb->len)*256 + aa->sym - bb->sym;
68 }
69 
70 static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
71 {
72  int i;
73  HuffEntry he[256];
74  int last;
75  uint32_t codes[256];
76  uint8_t bits[256];
77  uint8_t syms[256];
78  uint32_t code;
79 
80  *fsym = -1;
81  for (i = 0; i < 256; i++) {
82  he[i].sym = i;
83  he[i].len = *src++;
84  }
85  qsort(he, 256, sizeof(*he), huff_cmp);
86 
87  if (!he[0].len) {
88  *fsym = he[0].sym;
89  return 0;
90  }
91  if (he[0].len > 32)
92  return -1;
93 
94  last = 255;
95  while (he[last].len == 255 && last)
96  last--;
97 
98  code = 1;
99  for (i = last; i >= 0; i--) {
100  codes[i] = code >> (32 - he[i].len);
101  bits[i] = he[i].len;
102  syms[i] = he[i].sym;
103  code += 0x80000000u >> (he[i].len - 1);
104  }
105 
106  return ff_init_vlc_sparse(vlc, FFMIN(he[last].len, 9), last + 1,
107  bits, sizeof(*bits), sizeof(*bits),
108  codes, sizeof(*codes), sizeof(*codes),
109  syms, sizeof(*syms), sizeof(*syms), 0);
110 }
111 
112 static int decode_plane(UtvideoContext *c, int plane_no,
113  uint8_t *dst, int step, int stride,
114  int width, int height,
115  const uint8_t *src, int src_size, int use_pred)
116 {
117  int i, j, slice, pix;
118  int sstart, send;
119  VLC vlc;
120  GetBitContext gb;
121  int prev, fsym;
122  const int cmask = ~(!plane_no && c->avctx->pix_fmt == PIX_FMT_YUV420P);
123 
124  if (build_huff(src, &vlc, &fsym)) {
125  av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
126  return AVERROR_INVALIDDATA;
127  }
128  if (fsym >= 0) { // build_huff reported a symbol to fill slices with
129  send = 0;
130  for (slice = 0; slice < c->slices; slice++) {
131  uint8_t *dest;
132 
133  sstart = send;
134  send = (height * (slice + 1) / c->slices) & cmask;
135  dest = dst + sstart * stride;
136 
137  prev = 0x80;
138  for (j = sstart; j < send; j++) {
139  for (i = 0; i < width * step; i += step) {
140  pix = fsym;
141  if (use_pred) {
142  prev += pix;
143  pix = prev;
144  }
145  dest[i] = pix;
146  }
147  dest += stride;
148  }
149  }
150  return 0;
151  }
152 
153  src += 256;
154  src_size -= 256;
155 
156  send = 0;
157  for (slice = 0; slice < c->slices; slice++) {
158  uint8_t *dest;
159  int slice_data_start, slice_data_end, slice_size;
160 
161  sstart = send;
162  send = (height * (slice + 1) / c->slices) & cmask;
163  dest = dst + sstart * stride;
164 
165  // slice offset and size validation was done earlier
166  slice_data_start = slice ? AV_RL32(src + slice * 4 - 4) : 0;
167  slice_data_end = AV_RL32(src + slice * 4);
168  slice_size = slice_data_end - slice_data_start;
169 
170  if (!slice_size) {
171  for (j = sstart; j < send; j++) {
172  for (i = 0; i < width * step; i += step)
173  dest[i] = 0x80;
174  dest += stride;
175  }
176  continue;
177  }
178 
179  memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size);
180  memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
181  c->dsp.bswap_buf((uint32_t*)c->slice_bits, (uint32_t*)c->slice_bits,
182  (slice_data_end - slice_data_start + 3) >> 2);
183  init_get_bits(&gb, c->slice_bits, slice_size * 8);
184 
185  prev = 0x80;
186  for (j = sstart; j < send; j++) {
187  for (i = 0; i < width * step; i += step) {
188  if (get_bits_left(&gb) <= 0) {
189  av_log(c->avctx, AV_LOG_ERROR, "Slice decoding ran out of bits\n");
190  goto fail;
191  }
192  pix = get_vlc2(&gb, vlc.table, vlc.bits, 4);
193  if (pix < 0) {
194  av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n");
195  goto fail;
196  }
197  if (use_pred) {
198  prev += pix;
199  pix = prev;
200  }
201  dest[i] = pix;
202  }
203  dest += stride;
204  }
205  if (get_bits_left(&gb) > 32)
206  av_log(c->avctx, AV_LOG_WARNING, "%d bits left after decoding slice\n",
207  get_bits_left(&gb));
208  }
209 
210  ff_free_vlc(&vlc);
211 
212  return 0;
213 fail:
214  ff_free_vlc(&vlc);
215  return AVERROR_INVALIDDATA;
216 }
217 
218 static const int rgb_order[4] = { 1, 2, 0, 3 };
219 
220 static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, int height)
221 {
222  int i, j;
223  uint8_t r, g, b;
224 
225  for (j = 0; j < height; j++) {
226  for (i = 0; i < width * step; i += step) {
227  r = src[i];
228  g = src[i + 1];
229  b = src[i + 2];
230  src[i] = r + g - 0x80;
231  src[i + 2] = b + g - 0x80;
232  }
233  src += stride;
234  }
235 }
236 
237 static void restore_median(uint8_t *src, int step, int stride,
238  int width, int height, int slices, int rmode)
239 {
240  int i, j, slice;
241  int A, B, C;
242  uint8_t *bsrc;
243  int slice_start, slice_height;
244  const int cmask = ~rmode;
245 
246  for (slice = 0; slice < slices; slice++) {
247  slice_start = ((slice * height) / slices) & cmask;
248  slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
249  if (!slice_height)
250  continue;
251 
252  bsrc = src + slice_start * stride;
253 
254  // first line - left neighbour prediction
255  bsrc[0] += 0x80;
256  A = bsrc[0];
257  for (i = step; i < width * step; i += step) {
258  bsrc[i] += A;
259  A = bsrc[i];
260  }
261  bsrc += stride;
262  if (slice_height == 1)
263  continue;
264  // second line - first element has top predition, the rest uses median
265  C = bsrc[-stride];
266  bsrc[0] += C;
267  A = bsrc[0];
268  for (i = step; i < width * step; i += step) {
269  B = bsrc[i - stride];
270  bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
271  C = B;
272  A = bsrc[i];
273  }
274  bsrc += stride;
275  // the rest of lines use continuous median prediction
276  for (j = 2; j < slice_height; j++) {
277  for (i = 0; i < width * step; i += step) {
278  B = bsrc[i - stride];
279  bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
280  C = B;
281  A = bsrc[i];
282  }
283  bsrc += stride;
284  }
285  }
286 }
287 
288 /* UtVideo interlaced mode treats every two lines as a single one,
289  * so restoring function should take care of possible padding between
290  * two parts of the same "line".
291  */
292 static void restore_median_il(uint8_t *src, int step, int stride,
293  int width, int height, int slices, int rmode)
294 {
295  int i, j, slice;
296  int A, B, C;
297  uint8_t *bsrc;
298  int slice_start, slice_height;
299  const int cmask = ~(rmode ? 3 : 1);
300  const int stride2 = stride << 1;
301 
302  for (slice = 0; slice < slices; slice++) {
303  slice_start = ((slice * height) / slices) & cmask;
304  slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
305  slice_height >>= 1;
306  if (!slice_height)
307  continue;
308 
309  bsrc = src + slice_start * stride;
310 
311  // first line - left neighbour prediction
312  bsrc[0] += 0x80;
313  A = bsrc[0];
314  for (i = step; i < width * step; i += step) {
315  bsrc[i] += A;
316  A = bsrc[i];
317  }
318  for (i = 0; i < width * step; i += step) {
319  bsrc[stride + i] += A;
320  A = bsrc[stride + i];
321  }
322  bsrc += stride2;
323  if (slice_height == 1)
324  continue;
325  // second line - first element has top predition, the rest uses median
326  C = bsrc[-stride2];
327  bsrc[0] += C;
328  A = bsrc[0];
329  for (i = step; i < width * step; i += step) {
330  B = bsrc[i - stride2];
331  bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
332  C = B;
333  A = bsrc[i];
334  }
335  for (i = 0; i < width * step; i += step) {
336  B = bsrc[i - stride];
337  bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C));
338  C = B;
339  A = bsrc[stride + i];
340  }
341  bsrc += stride2;
342  // the rest of lines use continuous median prediction
343  for (j = 2; j < slice_height; j++) {
344  for (i = 0; i < width * step; i += step) {
345  B = bsrc[i - stride2];
346  bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
347  C = B;
348  A = bsrc[i];
349  }
350  for (i = 0; i < width * step; i += step) {
351  B = bsrc[i - stride];
352  bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C));
353  C = B;
354  A = bsrc[i + stride];
355  }
356  bsrc += stride2;
357  }
358  }
359 }
360 
361 static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
362 {
363  const uint8_t *buf = avpkt->data;
364  int buf_size = avpkt->size;
365  UtvideoContext *c = avctx->priv_data;
366  int i, j;
367  const uint8_t *plane_start[5];
368  int plane_size, max_slice_size = 0, slice_start, slice_end, slice_size;
369  int ret;
370  GetByteContext gb;
371 
372  if (c->pic.data[0])
373  ff_thread_release_buffer(avctx, &c->pic);
374 
375  c->pic.reference = 1;
377  if ((ret = ff_thread_get_buffer(avctx, &c->pic)) < 0) {
378  av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
379  return ret;
380  }
381 
382  ff_thread_finish_setup(avctx);
383 
384  /* parse plane structure to retrieve frame flags and validate slice offsets */
385  bytestream2_init(&gb, buf, buf_size);
386  for (i = 0; i < c->planes; i++) {
387  plane_start[i] = gb.buffer;
388  if (bytestream2_get_bytes_left(&gb) < 256 + 4 * c->slices) {
389  av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n");
390  return AVERROR_INVALIDDATA;
391  }
392  bytestream2_skipu(&gb, 256);
393  slice_start = 0;
394  slice_end = 0;
395  for (j = 0; j < c->slices; j++) {
396  slice_end = bytestream2_get_le32u(&gb);
397  slice_size = slice_end - slice_start;
398  if (slice_end <= 0 || slice_size <= 0 ||
399  bytestream2_get_bytes_left(&gb) < slice_end) {
400  av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
401  return AVERROR_INVALIDDATA;
402  }
403  slice_start = slice_end;
404  max_slice_size = FFMAX(max_slice_size, slice_size);
405  }
406  plane_size = slice_end;
407  bytestream2_skipu(&gb, plane_size);
408  }
409  plane_start[c->planes] = gb.buffer;
411  av_log(avctx, AV_LOG_ERROR, "Not enough data for frame information\n");
412  return AVERROR_INVALIDDATA;
413  }
414  c->frame_info = bytestream2_get_le32u(&gb);
415  av_log(avctx, AV_LOG_DEBUG, "frame information flags %X\n", c->frame_info);
416 
417  c->frame_pred = (c->frame_info >> 8) & 3;
418 
419  if (c->frame_pred == PRED_GRADIENT) {
420  av_log_ask_for_sample(avctx, "Frame uses gradient prediction\n");
421  return AVERROR_PATCHWELCOME;
422  }
423 
425  max_slice_size + FF_INPUT_BUFFER_PADDING_SIZE);
426 
427  if (!c->slice_bits) {
428  av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n");
429  return AVERROR(ENOMEM);
430  }
431 
432  switch (c->avctx->pix_fmt) {
433  case PIX_FMT_RGB24:
434  case PIX_FMT_RGBA:
435  for (i = 0; i < c->planes; i++) {
436  ret = decode_plane(c, i, c->pic.data[0] + rgb_order[i], c->planes,
437  c->pic.linesize[0], avctx->width, avctx->height,
438  plane_start[i], plane_start[i + 1] - plane_start[i],
439  c->frame_pred == PRED_LEFT);
440  if (ret)
441  return ret;
442  if (c->frame_pred == PRED_MEDIAN)
443  restore_median(c->pic.data[0] + rgb_order[i], c->planes,
444  c->pic.linesize[0], avctx->width, avctx->height,
445  c->slices, 0);
446  }
447  restore_rgb_planes(c->pic.data[0], c->planes, c->pic.linesize[0],
448  avctx->width, avctx->height);
449  break;
450  case PIX_FMT_YUV420P:
451  for (i = 0; i < 3; i++) {
452  ret = decode_plane(c, i, c->pic.data[i], 1,
453  c->pic.linesize[i], avctx->width >> !!i, avctx->height >> !!i,
454  plane_start[i], plane_start[i + 1] - plane_start[i],
455  c->frame_pred == PRED_LEFT);
456  if (ret)
457  return ret;
458  if (c->frame_pred == PRED_MEDIAN) {
459  if (!c->interlaced) {
460  restore_median(c->pic.data[i], 1, c->pic.linesize[i],
461  avctx->width >> !!i, avctx->height >> !!i,
462  c->slices, !i);
463  } else {
464  restore_median_il(c->pic.data[i], 1, c->pic.linesize[i],
465  avctx->width >> !!i,
466  avctx->height >> !!i,
467  c->slices, !i);
468  }
469  }
470  }
471  break;
472  case PIX_FMT_YUV422P:
473  for (i = 0; i < 3; i++) {
474  ret = decode_plane(c, i, c->pic.data[i], 1,
475  c->pic.linesize[i], avctx->width >> !!i, avctx->height,
476  plane_start[i], plane_start[i + 1] - plane_start[i],
477  c->frame_pred == PRED_LEFT);
478  if (ret)
479  return ret;
480  if (c->frame_pred == PRED_MEDIAN) {
481  if (!c->interlaced) {
482  restore_median(c->pic.data[i], 1, c->pic.linesize[i],
483  avctx->width >> !!i, avctx->height,
484  c->slices, 0);
485  } else {
486  restore_median_il(c->pic.data[i], 1, c->pic.linesize[i],
487  avctx->width >> !!i, avctx->height,
488  c->slices, 0);
489  }
490  }
491  }
492  break;
493  }
494 
495  *data_size = sizeof(AVFrame);
496  *(AVFrame*)data = c->pic;
497 
498  /* always report that the buffer was completely consumed */
499  return buf_size;
500 }
501 
503 {
504  UtvideoContext * const c = avctx->priv_data;
505 
506  c->avctx = avctx;
507 
508  dsputil_init(&c->dsp, avctx);
509 
510  if (avctx->extradata_size < 16) {
511  av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d, should be at least 16\n",
512  avctx->extradata_size);
513  return AVERROR_INVALIDDATA;
514  }
515 
516  av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d.%d.%d\n",
517  avctx->extradata[3], avctx->extradata[2],
518  avctx->extradata[1], avctx->extradata[0]);
519  av_log(avctx, AV_LOG_DEBUG, "Original format %X\n", AV_RB32(avctx->extradata + 4));
520  c->frame_info_size = AV_RL32(avctx->extradata + 8);
521  c->flags = AV_RL32(avctx->extradata + 12);
522 
523  if (c->frame_info_size != 4)
524  av_log_ask_for_sample(avctx, "Frame info is not 4 bytes\n");
525  av_log(avctx, AV_LOG_DEBUG, "Encoding parameters %08X\n", c->flags);
526  c->slices = (c->flags >> 24) + 1;
527  c->compression = c->flags & 1;
528  c->interlaced = c->flags & 0x800;
529 
530  c->slice_bits_size = 0;
531 
532  switch (avctx->codec_tag) {
533  case MKTAG('U', 'L', 'R', 'G'):
534  c->planes = 3;
535  avctx->pix_fmt = PIX_FMT_RGB24;
536  break;
537  case MKTAG('U', 'L', 'R', 'A'):
538  c->planes = 4;
539  avctx->pix_fmt = PIX_FMT_RGBA;
540  break;
541  case MKTAG('U', 'L', 'Y', '0'):
542  c->planes = 3;
543  avctx->pix_fmt = PIX_FMT_YUV420P;
544  break;
545  case MKTAG('U', 'L', 'Y', '2'):
546  c->planes = 3;
547  avctx->pix_fmt = PIX_FMT_YUV422P;
548  break;
549  default:
550  av_log(avctx, AV_LOG_ERROR, "Unknown Ut Video FOURCC provided (%08X)\n",
551  avctx->codec_tag);
552  return AVERROR_INVALIDDATA;
553  }
554 
555  return 0;
556 }
557 
559 {
560  UtvideoContext * const c = avctx->priv_data;
561 
562  if (c->pic.data[0])
563  ff_thread_release_buffer(avctx, &c->pic);
564 
565  av_freep(&c->slice_bits);
566 
567  return 0;
568 }
569 
571  .name = "utvideo",
572  .type = AVMEDIA_TYPE_VIDEO,
573  .id = CODEC_ID_UTVIDEO,
574  .priv_data_size = sizeof(UtvideoContext),
575  .init = decode_init,
576  .close = decode_end,
577  .decode = decode_frame,
578  .capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
579  .long_name = NULL_IF_CONFIG_SMALL("Ut Video"),
580 };
581 
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:68
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
Definition: avcodec.h:1426
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
#define FF_BUFFER_HINTS_VALID
Definition: avcodec.h:880
Audio Video Frame.
Definition: avcodec.h:985
AV_WL32 AV_WL24 AV_WL16 AV_RB32
Definition: bytestream.h:89
int buffer_hints
codec suggestion on buffer type if != 0
Definition: avcodec.h:1195
#define B
Definition: dsputil.c:1975
uint32_t flags
Definition: utvideo.c:48
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:788
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:117
int slice_bits_size
Definition: utvideo.c:56
Definition: vf_drawbox.c:32
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12.c:1901
int size
Definition: avcodec.h:909
int width
Definition: rotozoom.c:164
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:138
#define b
Definition: swscale.c:1335
int stride
Definition: mace.c:143
AVCodec.
Definition: avcodec.h:3189
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
Definition: utils.c:71
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:147
int interlaced
Definition: utvideo.c:52
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
Definition: mimic.c:228
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:258
uint8_t bits
Definition: crc.c:31
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:64
#define av_cold
Definition: attributes.h:71
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
Definition: utvideo.c:361
AVCodec ff_utvideo_decoder
Definition: utvideo.c:570
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1387
uint32_t frame_info
Definition: utvideo.c:48
const char data[16]
Definition: mxf.c:60
uint8_t * data
Definition: avcodec.h:908
static int decode_plane(UtvideoContext *c, int plane_no, uint8_t *dst, int step, int stride, int width, int height, const uint8_t *src, int src_size, int use_pred)
Definition: utvideo.c:112
const uint8_t * buffer
Definition: bytestream.h:32
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Definition: bytestream.h:173
bitstream reader API header.
av_cold void dsputil_init(DSPContext *c, AVCodecContext *avctx)
Definition: dsputil.c:2789
static int init(AVCodecParserContext *s)
Definition: h264_parser.c:336
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:719
static int get_bits_left(GetBitContext *gb)
Definition: get_bits.h:513
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
Definition: pthread.c:702
Multithreading support functions.
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
Definition: avcodec.h:1074
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
Definition: dsputil.h:393
#define AVERROR(e)
Definition: error.h:43
uint8_t sym
Definition: utvideo.c:60
static av_cold int decode_end(AVCodecContext *avctx)
Definition: utvideo.c:558
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
AV_RL32
Definition: bytestream.h:89
AVCodecContext * avctx
Definition: utvideo.c:44
g
Definition: yuv2rgb.c:481
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:157
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:140
const char * name
Name of the codec implementation.
Definition: avcodec.h:3196
uint32_t frame_info_size
Definition: utvideo.c:48
#define FFMAX(a, b)
Definition: common.h:53
Definition: get_bits.h:63
int compression
Definition: utvideo.c:51
DSPContext dsp
Definition: utvideo.c:46
AVFrame pic
Definition: utvideo.c:45
#define FFMIN(a, b)
Definition: common.h:55
int width
picture width / height.
Definition: avcodec.h:1408
struct AVFrame AVFrame
Audio Video Frame.
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:481
int bits
Definition: get_bits.h:64
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
Definition: error.h:57
static void restore_median(uint8_t *src, int step, int stride, int width, int height, int slices, int rmode)
Definition: utvideo.c:237
int frame_pred
Definition: utvideo.c:53
uint8_t len
Definition: utvideo.c:61
external API header
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
Definition: avcodec.h:1008
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
main external API structure.
Definition: avcodec.h:1329
static void close(AVCodecParserContext *s)
Definition: h264_parser.c:327
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:111
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1590
static void restore_median_il(uint8_t *src, int step, int stride, int width, int height, int slices, int rmode)
Definition: utvideo.c:292
struct UtvideoContext UtvideoContext
int extradata_size
Definition: avcodec.h:1388
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition: get_bits.h:354
static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, int height)
Definition: utvideo.c:220
#define mid_pred
Definition: mathops.h:88
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
Definition: avcodec.h:497
static int step
Definition: avplay.c:244
static int huff_cmp(const void *a, const void *b)
Definition: utvideo.c:64
uint8_t * slice_bits
Definition: utvideo.c:55
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: avcodec.h:997
int height
Definition: gxfenc.c:73
#define r(n)
Definition: regs.h:32
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:125
static int build_huff(const uint8_t *src, VLC *vlc, int *fsym)
Definition: utvideo.c:70
DSP utils.
void * priv_data
Definition: avcodec.h:1531
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:66
int len
VLC_TYPE(* table)[2]
code, bits
Definition: get_bits.h:65
static const int rgb_order[4]
Definition: utvideo.c:218
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around get_buffer() for frame-multithreaded codecs.
Definition: pthread.c:913
#define MKTAG(a, b, c, d)
Definition: common.h:231
void ff_free_vlc(VLC *vlc)
Definition: bitstream.c:321
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
Definition: pthread.c:967
static av_cold int decode_init(AVCodecContext *avctx)
Definition: utvideo.c:502
DSPContext.
Definition: dsputil.h:226
struct HuffEntry HuffEntry