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); \
78 while (lines_to_change) {
79 skip = bytestream2_get_byte(&s->
g);
80 rle_code = (int8_t)bytestream2_get_byte(&s->
g);
86 pixel_ptr = row_ptr + 2 * (skip & 0x7f);
88 pixel_ptr += 2 * skip;
100 pi0 = bytestream2_get_byte(&s->
g);
101 pi1 = bytestream2_get_byte(&s->
g);
105 rgb[pixel_ptr++] = pi0;
106 rgb[pixel_ptr++] = pi1;
114 pixel_ptr += rle_code;
120 int lines_to_change,
int bpp)
128 int num_pixels = (bpp == 4) ? 8 : 16;
130 while (lines_to_change--) {
131 pixel_ptr = row_ptr + (num_pixels * (bytestream2_get_byte(&s->
g) - 1));
134 while ((rle_code = (int8_t)bytestream2_get_byte(&s->
g)) != -1) {
139 pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->
g) - 1));
141 }
else if (rle_code < 0) {
143 rle_code = -rle_code;
146 for (i = num_pixels-1; i >= 0; i--) {
147 pi[num_pixels-1-i] = (bytestream2_peek_byte(&s->
g) >> ((i*bpp) & 0x07)) & ((1<<bpp)-1);
152 memcpy(&rgb[pixel_ptr], &pi, num_pixels);
153 pixel_ptr += num_pixels;
161 int x = bytestream2_get_byte(&s->
g);
162 rgb[pixel_ptr++] = (x >> 4) & 0x0f;
163 rgb[pixel_ptr++] = x & 0x0f;
165 int x = bytestream2_get_byte(&s->
g);
166 rgb[pixel_ptr++] = (x >> 6) & 0x03;
167 rgb[pixel_ptr++] = (x >> 4) & 0x03;
168 rgb[pixel_ptr++] = (x >> 2) & 0x03;
169 rgb[pixel_ptr++] = x & 0x03;
187 while (lines_to_change--) {
188 pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&s->
g) - 1));
191 while ((rle_code = (int8_t)bytestream2_get_byte(&s->
g)) != -1) {
196 pixel_ptr += (4 * (bytestream2_get_byte(&s->
g) - 1));
198 }
else if (rle_code < 0) {
200 rle_code = -rle_code;
203 pi1 = bytestream2_get_byte(&s->
g);
204 pi2 = bytestream2_get_byte(&s->
g);
205 pi3 = bytestream2_get_byte(&s->
g);
206 pi4 = bytestream2_get_byte(&s->
g);
211 rgb[pixel_ptr++] = pi1;
212 rgb[pixel_ptr++] = pi2;
213 rgb[pixel_ptr++] = pi3;
214 rgb[pixel_ptr++] = pi4;
222 pixel_ptr += rle_code;
238 while (lines_to_change--) {
239 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 2;
242 while ((rle_code = (int8_t)bytestream2_get_byte(&s->
g)) != -1) {
247 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 2;
249 }
else if (rle_code < 0) {
251 rle_code = -rle_code;
252 rgb16 = bytestream2_get_be16(&s->
g);
257 *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
265 rgb16 = bytestream2_get_be16(&s->
g);
266 *(uint16_t *)(&rgb[pixel_ptr]) = rgb16;
284 while (lines_to_change--) {
285 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 3;
288 while ((rle_code = (int8_t)bytestream2_get_byte(&s->
g)) != -1) {
293 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 3;
295 }
else if (rle_code < 0) {
297 rle_code = -rle_code;
298 r = bytestream2_get_byte(&s->
g);
299 g = bytestream2_get_byte(&s->
g);
300 b = bytestream2_get_byte(&s->
g);
305 rgb[pixel_ptr++] =
r;
306 rgb[pixel_ptr++] =
g;
307 rgb[pixel_ptr++] =
b;
314 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
315 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
316 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
333 while (lines_to_change--) {
334 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 4;
337 while ((rle_code = (int8_t)bytestream2_get_byte(&s->
g)) != -1) {
342 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 4;
344 }
else if (rle_code < 0) {
346 rle_code = -rle_code;
347 argb = bytestream2_get_be32(&s->
g);
360 argb = bytestream2_get_be32(&s->
g);
416 void *
data,
int *got_frame,
437 header = bytestream2_get_be16(&s->
g);
440 if (header & 0x0008) {
441 if (avpkt->
size < 14)
443 start_line = bytestream2_get_be16(&s->
g);
445 height = bytestream2_get_be16(&s->
g);
static void qtrle_decode_2n4bpp(QtrleContext *s, int row_ptr, int lines_to_change, int bpp)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
packed RGB 8:8:8, 24bpp, RGBRGB...
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
8 bit with AV_PIX_FMT_RGB32 palette
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
static const uint8_t header[24]
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
Libavcodec external API header.
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...
static void qtrle_decode_8bpp(QtrleContext *s, int row_ptr, int lines_to_change)
#define CHECK_PIXEL_PTR(n)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
BYTE int const BYTE int int int height
int palette_has_changed
Tell user application that palette has changed from previous frame.
static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
static int qtrle_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_PIX_FMT_RGB555
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static void qtrle_decode_16bpp(QtrleContext *s, int row_ptr, int lines_to_change)
static av_cold int qtrle_decode_end(AVCodecContext *avctx)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.