FFmpeg
qtrle.c
Go to the documentation of this file.
1 /*
2  * Quicktime Animation (RLE) Video Decoder
3  * Copyright (C) 2004 The FFmpeg project
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg 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  * FFmpeg 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 FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * QT RLE Video Decoder by Mike Melanson (melanson@pcisys.net)
25  * For more information about the QT RLE format, visit:
26  * http://www.pcisys.net/~melanson/codecs/
27  *
28  * The QT RLE decoder has seven modes of operation:
29  * 1, 2, 4, 8, 16, 24, and 32 bits per pixel. For modes 1, 2, 4, and 8
30  * the decoder outputs PAL8 colorspace data. 16-bit data yields RGB555
31  * data. 24-bit data is RGB24 and 32-bit data is RGB32.
32  */
33 
34 #include <string.h>
35 
36 #include "avcodec.h"
37 #include "decode.h"
38 #include "bytestream.h"
39 #include "codec_internal.h"
40 
41 typedef struct QtrleContext {
44 
46  uint32_t pal[256];
47 } QtrleContext;
48 
49 #define CHECK_PIXEL_PTR(n) \
50  if ((pixel_ptr + n > pixel_limit) || (pixel_ptr + n < 0)) { \
51  av_log (s->avctx, AV_LOG_ERROR, "Problem: pixel_ptr = %d, pixel_limit = %d\n",\
52  pixel_ptr + n, pixel_limit); \
53  return; \
54  } \
55 
56 static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
57 {
58  int rle_code;
59  int pixel_ptr;
60  int row_inc = s->frame->linesize[0];
61  uint8_t pi0, pi1; /* 2 8-pixel values */
62  uint8_t *rgb = s->frame->data[0];
63  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
64  int skip;
65  /* skip & 0x80 appears to mean 'start a new line', which can be interpreted
66  * as 'go to next line' during the decoding of a frame but is 'go to first
67  * line' at the beginning. Since we always interpret it as 'go to next line'
68  * in the decoding loop (which makes code simpler/faster), the first line
69  * would not be counted, so we count one more.
70  * See: https://trac.ffmpeg.org/ticket/226
71  * In the following decoding loop, row_ptr will be the position of the
72  * current row. */
73 
74  row_ptr -= row_inc;
75  pixel_ptr = row_ptr;
76  lines_to_change++;
77  while (lines_to_change) {
78  skip = bytestream2_get_byte(&s->g);
79  rle_code = (int8_t)bytestream2_get_byte(&s->g);
80  if (rle_code == 0)
81  break;
82  if(skip & 0x80) {
83  lines_to_change--;
84  row_ptr += row_inc;
85  pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f);
86  } else
87  pixel_ptr += 2 * 8 * skip;
88  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
89 
90  if(rle_code == -1)
91  continue;
92 
93  if (rle_code < 0) {
94  /* decode the run length code */
95  rle_code = -rle_code;
96  /* get the next 2 bytes from the stream, treat them as groups
97  * of 8 pixels, and output them rle_code times */
98 
99  pi0 = bytestream2_get_byte(&s->g);
100  pi1 = bytestream2_get_byte(&s->g);
101  CHECK_PIXEL_PTR(rle_code * 2 * 8);
102 
103  while (rle_code--) {
104  rgb[pixel_ptr++] = (pi0 >> 7) & 0x01;
105  rgb[pixel_ptr++] = (pi0 >> 6) & 0x01;
106  rgb[pixel_ptr++] = (pi0 >> 5) & 0x01;
107  rgb[pixel_ptr++] = (pi0 >> 4) & 0x01;
108  rgb[pixel_ptr++] = (pi0 >> 3) & 0x01;
109  rgb[pixel_ptr++] = (pi0 >> 2) & 0x01;
110  rgb[pixel_ptr++] = (pi0 >> 1) & 0x01;
111  rgb[pixel_ptr++] = pi0 & 0x01;
112  rgb[pixel_ptr++] = (pi1 >> 7) & 0x01;
113  rgb[pixel_ptr++] = (pi1 >> 6) & 0x01;
114  rgb[pixel_ptr++] = (pi1 >> 5) & 0x01;
115  rgb[pixel_ptr++] = (pi1 >> 4) & 0x01;
116  rgb[pixel_ptr++] = (pi1 >> 3) & 0x01;
117  rgb[pixel_ptr++] = (pi1 >> 2) & 0x01;
118  rgb[pixel_ptr++] = (pi1 >> 1) & 0x01;
119  rgb[pixel_ptr++] = pi1 & 0x01;
120  }
121  } else {
122  /* copy the same pixel directly to output 2 times */
123  rle_code *= 2;
124  CHECK_PIXEL_PTR(rle_code * 8);
125 
126  while (rle_code--) {
127  int x = bytestream2_get_byte(&s->g);
128  rgb[pixel_ptr++] = (x >> 7) & 0x01;
129  rgb[pixel_ptr++] = (x >> 6) & 0x01;
130  rgb[pixel_ptr++] = (x >> 5) & 0x01;
131  rgb[pixel_ptr++] = (x >> 4) & 0x01;
132  rgb[pixel_ptr++] = (x >> 3) & 0x01;
133  rgb[pixel_ptr++] = (x >> 2) & 0x01;
134  rgb[pixel_ptr++] = (x >> 1) & 0x01;
135  rgb[pixel_ptr++] = x & 0x01;
136  }
137  }
138  }
139 }
140 
141 static inline void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr,
142  int lines_to_change, int bpp)
143 {
144  int rle_code, i;
145  int pixel_ptr;
146  int row_inc = s->frame->linesize[0];
147  uint8_t pi[16]; /* 16 palette indices */
148  uint8_t *rgb = s->frame->data[0];
149  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
150  int num_pixels = (bpp == 4) ? 8 : 16;
151 
152  while (lines_to_change--) {
153  pixel_ptr = row_ptr + (num_pixels * (bytestream2_get_byte(&s->g) - 1));
154  CHECK_PIXEL_PTR(0);
155 
156  while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
157  if (bytestream2_get_bytes_left(&s->g) < 1)
158  return;
159  if (rle_code == 0) {
160  /* there's another skip code in the stream */
161  pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->g) - 1));
162  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
163  } else if (rle_code < 0) {
164  /* decode the run length code */
165  rle_code = -rle_code;
166  /* get the next 4 bytes from the stream, treat them as palette
167  * indexes, and output them rle_code times */
168  for (i = num_pixels-1; i >= 0; i--) {
169  pi[num_pixels-1-i] = (bytestream2_peek_byte(&s->g) >> ((i*bpp) & 0x07)) & ((1<<bpp)-1);
170  bytestream2_skip(&s->g, ((i & ((num_pixels>>2)-1)) == 0));
171  }
172  CHECK_PIXEL_PTR(rle_code * num_pixels);
173  while (rle_code--) {
174  memcpy(&rgb[pixel_ptr], &pi, num_pixels);
175  pixel_ptr += num_pixels;
176  }
177  } else {
178  /* copy the same pixel directly to output 4 times */
179  rle_code *= 4;
180  CHECK_PIXEL_PTR(rle_code*(num_pixels>>2));
181  while (rle_code--) {
182  if(bpp == 4) {
183  int x = bytestream2_get_byte(&s->g);
184  rgb[pixel_ptr++] = (x >> 4) & 0x0f;
185  rgb[pixel_ptr++] = x & 0x0f;
186  } else {
187  int x = bytestream2_get_byte(&s->g);
188  rgb[pixel_ptr++] = (x >> 6) & 0x03;
189  rgb[pixel_ptr++] = (x >> 4) & 0x03;
190  rgb[pixel_ptr++] = (x >> 2) & 0x03;
191  rgb[pixel_ptr++] = x & 0x03;
192  }
193  }
194  }
195  }
196  row_ptr += row_inc;
197  }
198 }
199 
200 static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
201 {
202  int rle_code;
203  int pixel_ptr;
204  int row_inc = s->frame->linesize[0];
205  uint8_t pi1, pi2, pi3, pi4; /* 4 palette indexes */
206  uint8_t *rgb = s->frame->data[0];
207  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
208 
209  while (lines_to_change--) {
210  pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&s->g) - 1));
211  CHECK_PIXEL_PTR(0);
212 
213  while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
214  if (bytestream2_get_bytes_left(&s->g) < 1)
215  return;
216  if (rle_code == 0) {
217  /* there's another skip code in the stream */
218  pixel_ptr += (4 * (bytestream2_get_byte(&s->g) - 1));
219  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
220  } else if (rle_code < 0) {
221  /* decode the run length code */
222  rle_code = -rle_code;
223  /* get the next 4 bytes from the stream, treat them as palette
224  * indexes, and output them rle_code times */
225  pi1 = bytestream2_get_byte(&s->g);
226  pi2 = bytestream2_get_byte(&s->g);
227  pi3 = bytestream2_get_byte(&s->g);
228  pi4 = bytestream2_get_byte(&s->g);
229 
230  CHECK_PIXEL_PTR(rle_code * 4);
231 
232  while (rle_code--) {
233  rgb[pixel_ptr++] = pi1;
234  rgb[pixel_ptr++] = pi2;
235  rgb[pixel_ptr++] = pi3;
236  rgb[pixel_ptr++] = pi4;
237  }
238  } else {
239  /* copy the same pixel directly to output 4 times */
240  rle_code *= 4;
241  CHECK_PIXEL_PTR(rle_code);
242 
243  bytestream2_get_buffer(&s->g, &rgb[pixel_ptr], rle_code);
244  pixel_ptr += rle_code;
245  }
246  }
247  row_ptr += row_inc;
248  }
249 }
250 
251 static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change)
252 {
253  int rle_code;
254  int pixel_ptr;
255  int row_inc = s->frame->linesize[0];
256  uint16_t rgb16;
257  uint8_t *rgb = s->frame->data[0];
258  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
259 
260  while (lines_to_change--) {
261  pixel_ptr = row_ptr + (bytestream2_get_byte(&s->g) - 1) * 2;
262  CHECK_PIXEL_PTR(0);
263 
264  while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
265  if (bytestream2_get_bytes_left(&s->g) < 1)
266  return;
267  if (rle_code == 0) {
268  /* there's another skip code in the stream */
269  pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 2;
270  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
271  } else if (rle_code < 0) {
272  /* decode the run length code */
273  rle_code = -rle_code;
274  rgb16 = bytestream2_get_be16(&s->g);
275 
276  CHECK_PIXEL_PTR(rle_code * 2);
277 
278  while (rle_code--) {
279  *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
280  pixel_ptr += 2;
281  }
282  } else {
283  CHECK_PIXEL_PTR(rle_code * 2);
284 
285  /* copy pixels directly to output */
286  while (rle_code--) {
287  rgb16 = bytestream2_get_be16(&s->g);
288  *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
289  pixel_ptr += 2;
290  }
291  }
292  }
293  row_ptr += row_inc;
294  }
295 }
296 
297 static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
298 {
299  int rle_code, rle_code_half;
300  int pixel_ptr;
301  int row_inc = s->frame->linesize[0];
302  uint8_t b;
303  uint16_t rg;
304  uint8_t *rgb = s->frame->data[0];
305  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
306 
307  while (lines_to_change--) {
308  pixel_ptr = row_ptr + (bytestream2_get_byte(&s->g) - 1) * 3;
309  CHECK_PIXEL_PTR(0);
310 
311  while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
312  if (bytestream2_get_bytes_left(&s->g) < 1)
313  return;
314  if (rle_code == 0) {
315  /* there's another skip code in the stream */
316  pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 3;
317  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
318  } else if (rle_code < 0) {
319  /* decode the run length code */
320  rle_code = -rle_code;
321  rg = bytestream2_get_ne16(&s->g);
322  b = bytestream2_get_byte(&s->g);
323 
324  CHECK_PIXEL_PTR(rle_code * 3);
325 
326  while (rle_code--) {
327  AV_WN16(rgb + pixel_ptr, rg);
328  rgb[pixel_ptr + 2] = b;
329  pixel_ptr += 3;
330  }
331  } else {
332  CHECK_PIXEL_PTR(rle_code * 3);
333 
334  rle_code_half = rle_code / 2;
335 
336  while (rle_code_half--) { /* copy 2 raw rgb value at the same time */
337  AV_WN32(rgb + pixel_ptr, bytestream2_get_ne32(&s->g)); /* rgbr */
338  AV_WN16(rgb + pixel_ptr + 4, bytestream2_get_ne16(&s->g)); /* rgbr */
339  pixel_ptr += 6;
340  }
341 
342  if (rle_code % 2 != 0){ /* not even raw value */
343  AV_WN16(rgb + pixel_ptr, bytestream2_get_ne16(&s->g));
344  rgb[pixel_ptr + 2] = bytestream2_get_byte(&s->g);
345  pixel_ptr += 3;
346  }
347  }
348  }
349  row_ptr += row_inc;
350  }
351 }
352 
353 static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change)
354 {
355  int rle_code, rle_code_half;
356  int pixel_ptr;
357  int row_inc = s->frame->linesize[0];
358  unsigned int argb;
359  uint8_t *rgb = s->frame->data[0];
360  int pixel_limit = s->frame->linesize[0] * s->avctx->height;
361 
362  while (lines_to_change--) {
363  pixel_ptr = row_ptr + (bytestream2_get_byte(&s->g) - 1) * 4;
364  CHECK_PIXEL_PTR(0);
365 
366  while ((rle_code = (int8_t)bytestream2_get_byte(&s->g)) != -1) {
367  if (bytestream2_get_bytes_left(&s->g) < 1)
368  return;
369  if (rle_code == 0) {
370  /* there's another skip code in the stream */
371  pixel_ptr += (bytestream2_get_byte(&s->g) - 1) * 4;
372  CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */
373  } else if (rle_code < 0) {
374  /* decode the run length code */
375  rle_code = -rle_code;
376  argb = bytestream2_get_ne32(&s->g);
377 
378  CHECK_PIXEL_PTR(rle_code * 4);
379 
380  while (rle_code--) {
381  AV_WN32A(rgb + pixel_ptr, argb);
382  pixel_ptr += 4;
383  }
384  } else {
385  CHECK_PIXEL_PTR(rle_code * 4);
386 
387  /* copy pixels directly to output */
388  rle_code_half = rle_code / 2;
389  while (rle_code_half--) { /* copy 2 argb raw value at the same time */
390  AV_WN64(rgb + pixel_ptr, bytestream2_get_ne64(&s->g));
391  pixel_ptr += 8;
392  }
393 
394  if (rle_code % 2 != 0){ /* not even raw value */
395  AV_WN32A(rgb + pixel_ptr, bytestream2_get_ne32(&s->g));
396  pixel_ptr += 4;
397  }
398  }
399  }
400  row_ptr += row_inc;
401  }
402 }
403 
405 {
406  QtrleContext *s = avctx->priv_data;
407 
408  s->avctx = avctx;
409  switch (avctx->bits_per_coded_sample) {
410  case 1:
411  case 2:
412  case 4:
413  case 8:
414  case 33:
415  case 34:
416  case 36:
417  case 40:
418  avctx->pix_fmt = AV_PIX_FMT_PAL8;
419  break;
420 
421  case 16:
422  avctx->pix_fmt = AV_PIX_FMT_RGB555;
423  break;
424 
425  case 24:
426  avctx->pix_fmt = AV_PIX_FMT_RGB24;
427  break;
428 
429  case 32:
430  avctx->pix_fmt = AV_PIX_FMT_ARGB;
431  break;
432 
433  default:
434  av_log (avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
435  avctx->bits_per_coded_sample);
436  return AVERROR_INVALIDDATA;
437  }
438 
439  s->frame = av_frame_alloc();
440  if (!s->frame)
441  return AVERROR(ENOMEM);
442 
443  return 0;
444 }
445 
446 static int qtrle_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
447  int *got_frame, AVPacket *avpkt)
448 {
449  QtrleContext *s = avctx->priv_data;
450  int header, start_line;
451  int height, row_ptr;
452  int has_palette = 0;
453  int duplicate = 0;
454  int ret, size;
455 
456  bytestream2_init(&s->g, avpkt->data, avpkt->size);
457 
458  /* check if this frame is even supposed to change */
459  if (avpkt->size < 8) {
460  duplicate = 1;
461  goto done;
462  }
463 
464  /* start after the chunk size */
465  size = bytestream2_get_be32(&s->g) & 0x3FFFFFFF;
466  if (size - avpkt->size > size * (int64_t)avctx->discard_damaged_percentage / 100)
467  return AVERROR_INVALIDDATA;
468 
469 
470  /* fetch the header */
471  header = bytestream2_get_be16(&s->g);
472 
473  /* if a header is present, fetch additional decoding parameters */
474  if (header & 0x0008) {
475  if (avpkt->size < 14) {
476  duplicate = 1;
477  goto done;
478  }
479  start_line = bytestream2_get_be16(&s->g);
480  bytestream2_skip(&s->g, 2);
481  height = bytestream2_get_be16(&s->g);
482  bytestream2_skip(&s->g, 2);
483  if (height > s->avctx->height - start_line) {
484  duplicate = 1;
485  goto done;
486  }
487  } else {
488  start_line = 0;
489  height = s->avctx->height;
490  }
491  if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
492  return ret;
493 
494  row_ptr = s->frame->linesize[0] * start_line;
495 
496  switch (avctx->bits_per_coded_sample) {
497  case 1:
498  case 33:
499  qtrle_decode_1bpp(s, row_ptr, height);
500  has_palette = 1;
501  break;
502 
503  case 2:
504  case 34:
505  qtrle_decode_2n4bpp(s, row_ptr, height, 2);
506  has_palette = 1;
507  break;
508 
509  case 4:
510  case 36:
511  qtrle_decode_2n4bpp(s, row_ptr, height, 4);
512  has_palette = 1;
513  break;
514 
515  case 8:
516  case 40:
517  qtrle_decode_8bpp(s, row_ptr, height);
518  has_palette = 1;
519  break;
520 
521  case 16:
522  qtrle_decode_16bpp(s, row_ptr, height);
523  break;
524 
525  case 24:
526  qtrle_decode_24bpp(s, row_ptr, height);
527  break;
528 
529  case 32:
530  qtrle_decode_32bpp(s, row_ptr, height);
531  break;
532 
533  default:
534  av_log (s->avctx, AV_LOG_ERROR, "Unsupported colorspace: %d bits/sample?\n",
535  avctx->bits_per_coded_sample);
536  break;
537  }
538 
539  if(has_palette) {
540  s->frame->palette_has_changed = ff_copy_palette(s->pal, avpkt, avctx);
541 
542  /* make the palette available on the way out */
543  memcpy(s->frame->data[1], s->pal, AVPALETTE_SIZE);
544  }
545 
546 done:
547  if (!s->frame->data[0])
548  return AVERROR_INVALIDDATA;
549  if (duplicate) {
550  // ff_reget_buffer() isn't needed when frames don't change, so just update
551  // frame props.
552  ret = ff_decode_frame_props(avctx, s->frame);
553  if (ret < 0)
554  return ret;
555  }
556 
557  if ((ret = av_frame_ref(rframe, s->frame)) < 0)
558  return ret;
559  *got_frame = 1;
560 
561  /* always report that the buffer was completely consumed */
562  return avpkt->size;
563 }
564 
566 {
567  QtrleContext *s = avctx->priv_data;
568 
569  av_frame_unref(s->frame);
570 }
571 
573 {
574  QtrleContext *s = avctx->priv_data;
575 
576  av_frame_free(&s->frame);
577 
578  return 0;
579 }
580 
582  .p.name = "qtrle",
583  CODEC_LONG_NAME("QuickTime Animation (RLE) video"),
584  .p.type = AVMEDIA_TYPE_VIDEO,
585  .p.id = AV_CODEC_ID_QTRLE,
586  .priv_data_size = sizeof(QtrleContext),
588  .close = qtrle_decode_end,
590  .flush = qtrle_decode_flush,
591  .p.capabilities = AV_CODEC_CAP_DR1,
592 };
qtrle_decode_8bpp
static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
Definition: qtrle.c:200
CHECK_PIXEL_PTR
#define CHECK_PIXEL_PTR(n)
Definition: qtrle.c:49
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
GetByteContext
Definition: bytestream.h:33
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:99
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
AVPacket::data
uint8_t * data
Definition: packet.h:374
qtrle_decode_32bpp
static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change)
Definition: qtrle.c:353
b
#define b
Definition: input.c:41
qtrle_decode_frame
static int qtrle_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: qtrle.c:446
FFCodec
Definition: codec_internal.h:127
AV_WN32A
#define AV_WN32A(p, v)
Definition: intreadwrite.h:538
bytestream2_get_ne64
#define bytestream2_get_ne64
Definition: bytestream.h:122
bytestream2_skip
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition: bytestream.h:168
rgb
Definition: rpzaenc.c:59
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
qtrle_decode_16bpp
static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change)
Definition: qtrle.c:251
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:87
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
av_cold
#define av_cold
Definition: attributes.h:90
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
s
#define s(width, name)
Definition: cbs_vp9.c:256
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
decode.h
qtrle_decode_init
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
Definition: qtrle.c:404
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
bytestream2_get_ne32
#define bytestream2_get_ne32
Definition: bytestream.h:121
QtrleContext::avctx
AVCodecContext * avctx
Definition: qtrle.c:42
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
bytestream2_get_buffer
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
Definition: bytestream.h:267
bytestream2_get_bytes_left
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
Definition: bytestream.h:158
QtrleContext::g
GetByteContext g
Definition: qtrle.c:45
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:68
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVPacket::size
int size
Definition: packet.h:375
av_frame_ref
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:344
codec_internal.h
AV_WN32
#define AV_WN32(p, v)
Definition: intreadwrite.h:376
bytestream2_get_ne16
#define bytestream2_get_ne16
Definition: bytestream.h:119
QtrleContext
Definition: qtrle.c:41
size
int size
Definition: twinvq_data.h:10344
header
static const uint8_t header[24]
Definition: sdr2.c:67
height
#define height
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
AVCodecContext::bits_per_coded_sample
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
Definition: avcodec.h:1480
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
AV_PIX_FMT_RGB555
#define AV_PIX_FMT_RGB555
Definition: pixfmt.h:447
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:478
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:191
AVCodecContext::pix_fmt
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:635
avcodec.h
AV_PIX_FMT_PAL8
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
Definition: pixfmt.h:77
ff_reget_buffer
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
Definition: decode.c:1591
ret
ret
Definition: filter_design.txt:187
QtrleContext::frame
AVFrame * frame
Definition: qtrle.c:43
ff_decode_frame_props
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
Definition: decode.c:1350
AVCodecContext
main external API structure.
Definition: avcodec.h:426
ff_qtrle_decoder
const FFCodec ff_qtrle_decoder
Definition: qtrle.c:581
qtrle_decode_flush
static void qtrle_decode_flush(AVCodecContext *avctx)
Definition: qtrle.c:565
AVCodecContext::discard_damaged_percentage
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
Definition: avcodec.h:1986
qtrle_decode_2n4bpp
static void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr, int lines_to_change, int bpp)
Definition: qtrle.c:141
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_CODEC_ID_QTRLE
@ AV_CODEC_ID_QTRLE
Definition: codec_id.h:107
QtrleContext::pal
uint32_t pal[256]
Definition: qtrle.c:46
qtrle_decode_end
static av_cold int qtrle_decode_end(AVCodecContext *avctx)
Definition: qtrle.c:572
AVPacket
This structure stores compressed data.
Definition: packet.h:351
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:453
qtrle_decode_24bpp
static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
Definition: qtrle.c:297
qtrle_decode_1bpp
static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
Definition: qtrle.c:56
bytestream.h
bytestream2_init
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition: bytestream.h:137
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AV_WN64
#define AV_WN64(p, v)
Definition: intreadwrite.h:380
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
ff_copy_palette
int ff_copy_palette(void *dst, const AVPacket *src, void *logctx)
Check whether the side-data of src contains a palette of size AVPALETTE_SIZE; if so,...
Definition: decode.c:1674
skip
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
Definition: bitstream_template.h:375
AV_WN16
#define AV_WN16(p, v)
Definition: intreadwrite.h:372