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