Go to the documentation of this file.
51 #define CHECK_PIXEL_PTR(n) \
52 if ((pixel_ptr + n > pixel_limit) || (pixel_ptr + n < 0)) { \
53 av_log (s->avctx, AV_LOG_ERROR, "Problem: pixel_ptr = %d, pixel_limit = %d\n",\
54 pixel_ptr + n, pixel_limit); \
62 int row_inc =
s->frame->linesize[0];
64 uint8_t *
rgb =
s->frame->data[0];
65 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
79 while (lines_to_change) {
80 skip = bytestream2_get_byte(&
s->g);
81 rle_code = (int8_t)bytestream2_get_byte(&
s->g);
87 pixel_ptr = row_ptr + 2 * 8 * (skip & 0x7f);
89 pixel_ptr += 2 * 8 * skip;
101 pi0 = bytestream2_get_byte(&
s->g);
102 pi1 = bytestream2_get_byte(&
s->g);
106 rgb[pixel_ptr++] = (pi0 >> 7) & 0x01;
107 rgb[pixel_ptr++] = (pi0 >> 6) & 0x01;
108 rgb[pixel_ptr++] = (pi0 >> 5) & 0x01;
109 rgb[pixel_ptr++] = (pi0 >> 4) & 0x01;
110 rgb[pixel_ptr++] = (pi0 >> 3) & 0x01;
111 rgb[pixel_ptr++] = (pi0 >> 2) & 0x01;
112 rgb[pixel_ptr++] = (pi0 >> 1) & 0x01;
113 rgb[pixel_ptr++] = pi0 & 0x01;
114 rgb[pixel_ptr++] = (pi1 >> 7) & 0x01;
115 rgb[pixel_ptr++] = (pi1 >> 6) & 0x01;
116 rgb[pixel_ptr++] = (pi1 >> 5) & 0x01;
117 rgb[pixel_ptr++] = (pi1 >> 4) & 0x01;
118 rgb[pixel_ptr++] = (pi1 >> 3) & 0x01;
119 rgb[pixel_ptr++] = (pi1 >> 2) & 0x01;
120 rgb[pixel_ptr++] = (pi1 >> 1) & 0x01;
121 rgb[pixel_ptr++] = pi1 & 0x01;
129 int x = bytestream2_get_byte(&
s->g);
130 rgb[pixel_ptr++] = (x >> 7) & 0x01;
131 rgb[pixel_ptr++] = (x >> 6) & 0x01;
132 rgb[pixel_ptr++] = (x >> 5) & 0x01;
133 rgb[pixel_ptr++] = (x >> 4) & 0x01;
134 rgb[pixel_ptr++] = (x >> 3) & 0x01;
135 rgb[pixel_ptr++] = (x >> 2) & 0x01;
136 rgb[pixel_ptr++] = (x >> 1) & 0x01;
137 rgb[pixel_ptr++] = x & 0x01;
144 int lines_to_change,
int bpp)
148 int row_inc =
s->frame->linesize[0];
150 uint8_t *
rgb =
s->frame->data[0];
151 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
152 int num_pixels = (bpp == 4) ? 8 : 16;
154 while (lines_to_change--) {
155 pixel_ptr = row_ptr + (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
158 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
163 pixel_ptr += (num_pixels * (bytestream2_get_byte(&
s->g) - 1));
165 }
else if (rle_code < 0) {
167 rle_code = -rle_code;
170 for (
i = num_pixels-1;
i >= 0;
i--) {
171 pi[num_pixels-1-
i] = (bytestream2_peek_byte(&
s->g) >> ((
i*bpp) & 0x07)) & ((1<<bpp)-1);
176 memcpy(&
rgb[pixel_ptr], &pi, num_pixels);
177 pixel_ptr += num_pixels;
185 int x = bytestream2_get_byte(&
s->g);
186 rgb[pixel_ptr++] = (x >> 4) & 0x0f;
187 rgb[pixel_ptr++] = x & 0x0f;
189 int x = bytestream2_get_byte(&
s->g);
190 rgb[pixel_ptr++] = (x >> 6) & 0x03;
191 rgb[pixel_ptr++] = (x >> 4) & 0x03;
192 rgb[pixel_ptr++] = (x >> 2) & 0x03;
193 rgb[pixel_ptr++] = x & 0x03;
206 int row_inc =
s->frame->linesize[0];
207 uint8_t pi1, pi2, pi3, pi4;
208 uint8_t *
rgb =
s->frame->data[0];
209 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
211 while (lines_to_change--) {
212 pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&
s->g) - 1));
215 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
220 pixel_ptr += (4 * (bytestream2_get_byte(&
s->g) - 1));
222 }
else if (rle_code < 0) {
224 rle_code = -rle_code;
227 pi1 = bytestream2_get_byte(&
s->g);
228 pi2 = bytestream2_get_byte(&
s->g);
229 pi3 = bytestream2_get_byte(&
s->g);
230 pi4 = bytestream2_get_byte(&
s->g);
235 rgb[pixel_ptr++] = pi1;
236 rgb[pixel_ptr++] = pi2;
237 rgb[pixel_ptr++] = pi3;
238 rgb[pixel_ptr++] = pi4;
246 pixel_ptr += rle_code;
257 int row_inc =
s->frame->linesize[0];
259 uint8_t *
rgb =
s->frame->data[0];
260 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
262 while (lines_to_change--) {
263 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 2;
266 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
271 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 2;
273 }
else if (rle_code < 0) {
275 rle_code = -rle_code;
276 rgb16 = bytestream2_get_be16(&
s->g);
281 *(uint16_t *)(&
rgb[pixel_ptr]) = rgb16;
289 rgb16 = bytestream2_get_be16(&
s->g);
290 *(uint16_t *)(&
rgb[pixel_ptr]) = rgb16;
301 int rle_code, rle_code_half;
303 int row_inc =
s->frame->linesize[0];
306 uint8_t *
rgb =
s->frame->data[0];
307 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
309 while (lines_to_change--) {
310 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 3;
313 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
318 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 3;
320 }
else if (rle_code < 0) {
322 rle_code = -rle_code;
324 b = bytestream2_get_byte(&
s->g);
330 rgb[pixel_ptr + 2] =
b;
336 rle_code_half = rle_code / 2;
338 while (rle_code_half--) {
344 if (rle_code % 2 != 0){
346 rgb[pixel_ptr + 2] = bytestream2_get_byte(&
s->g);
357 int rle_code, rle_code_half;
359 int row_inc =
s->frame->linesize[0];
361 uint8_t *
rgb =
s->frame->data[0];
362 int pixel_limit =
s->frame->linesize[0] *
s->avctx->height;
364 while (lines_to_change--) {
365 pixel_ptr = row_ptr + (bytestream2_get_byte(&
s->g) - 1) * 4;
368 while ((rle_code = (int8_t)bytestream2_get_byte(&
s->g)) != -1) {
373 pixel_ptr += (bytestream2_get_byte(&
s->g) - 1) * 4;
375 }
else if (rle_code < 0) {
377 rle_code = -rle_code;
390 rle_code_half = rle_code / 2;
391 while (rle_code_half--) {
396 if (rle_code % 2 != 0){
449 void *
data,
int *got_frame,
462 if (avpkt->
size < 8) {
468 size = bytestream2_get_be32(&
s->g) & 0x3FFFFFFF;
474 header = bytestream2_get_be16(&
s->g);
478 if (avpkt->
size < 14) {
482 start_line = bytestream2_get_be16(&
s->g);
484 height = bytestream2_get_be16(&
s->g);
486 if (
height >
s->avctx->height - start_line) {
497 row_ptr =
s->frame->linesize[0] * start_line;
550 if (!
s->frame->data[0])
static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
#define CHECK_PIXEL_PTR(n)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change)
#define bytestream2_get_ne64
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
const AVCodec ff_qtrle_decoder
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
#define bytestream2_get_ne32
static void flush(AVCodecContext *avctx)
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define bytestream2_get_ne16
static const uint8_t header[24]
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define i(width, name, range_min, range_max)
static int qtrle_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_PIX_FMT_RGB555
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
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.
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
Set various frame properties from the codec context / packet data.
main external API structure.
static void qtrle_decode_flush(AVCodecContext *avctx)
int discard_damaged_percentage
The percentage of damaged samples to discard a frame.
static void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr, int lines_to_change, int bpp)
static av_cold int qtrle_decode_end(AVCodecContext *avctx)
This structure stores compressed data.
static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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,...