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); \ 62 unsigned char pi0, pi1;
78 while (lines_to_change) {
79 skip = bytestream2_get_byte(&s->
g);
80 rle_code = (
signed char)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 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
120 int lines_to_change,
int bpp)
125 unsigned char pi[16];
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 = (
signed char)bytestream2_get_byte(&s->
g)) != -1) {
137 pixel_ptr += (num_pixels * (bytestream2_get_byte(&s->
g) - 1));
139 }
else if (rle_code < 0) {
141 rle_code = -rle_code;
144 for (i = num_pixels-1; i >= 0; i--) {
145 pi[num_pixels-1-
i] = (bytestream2_peek_byte(&s->
g) >> ((i*bpp) & 0x07)) & ((1<<bpp)-1);
150 for (i = 0; i < num_pixels; i++)
151 rgb[pixel_ptr++] = pi[i];
159 int x = bytestream2_get_byte(&s->
g);
160 rgb[pixel_ptr++] = (x >> 4) & 0x0f;
161 rgb[pixel_ptr++] = x & 0x0f;
163 int x = bytestream2_get_byte(&s->
g);
164 rgb[pixel_ptr++] = (x >> 6) & 0x03;
165 rgb[pixel_ptr++] = (x >> 4) & 0x03;
166 rgb[pixel_ptr++] = (x >> 2) & 0x03;
167 rgb[pixel_ptr++] = x & 0x03;
181 unsigned char pi1, pi2, pi3, pi4;
185 while (lines_to_change--) {
186 pixel_ptr = row_ptr + (4 * (bytestream2_get_byte(&s->
g) - 1));
189 while ((rle_code = (
signed char)bytestream2_get_byte(&s->
g)) != -1) {
192 pixel_ptr += (4 * (bytestream2_get_byte(&s->
g) - 1));
194 }
else if (rle_code < 0) {
196 rle_code = -rle_code;
199 pi1 = bytestream2_get_byte(&s->
g);
200 pi2 = bytestream2_get_byte(&s->
g);
201 pi3 = bytestream2_get_byte(&s->
g);
202 pi4 = bytestream2_get_byte(&s->
g);
207 rgb[pixel_ptr++] = pi1;
208 rgb[pixel_ptr++] = pi2;
209 rgb[pixel_ptr++] = pi3;
210 rgb[pixel_ptr++] = pi4;
218 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
231 unsigned short rgb16;
235 while (lines_to_change--) {
236 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 2;
239 while ((rle_code = (
signed char)bytestream2_get_byte(&s->
g)) != -1) {
242 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 2;
244 }
else if (rle_code < 0) {
246 rle_code = -rle_code;
247 rgb16 = bytestream2_get_be16(&s->
g);
252 *(
unsigned short *)(&rgb[pixel_ptr]) = rgb16;
260 rgb16 = bytestream2_get_be16(&s->
g);
261 *(
unsigned short *)(&rgb[pixel_ptr]) = rgb16;
275 unsigned char r,
g,
b;
279 while (lines_to_change--) {
280 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 3;
283 while ((rle_code = (
signed char)bytestream2_get_byte(&s->
g)) != -1) {
286 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 3;
288 }
else if (rle_code < 0) {
290 rle_code = -rle_code;
291 r = bytestream2_get_byte(&s->
g);
292 g = bytestream2_get_byte(&s->
g);
293 b = bytestream2_get_byte(&s->
g);
298 rgb[pixel_ptr++] =
r;
299 rgb[pixel_ptr++] =
g;
300 rgb[pixel_ptr++] =
b;
307 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
308 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
309 rgb[pixel_ptr++] = bytestream2_get_byte(&s->
g);
326 while (lines_to_change--) {
327 pixel_ptr = row_ptr + (bytestream2_get_byte(&s->
g) - 1) * 4;
330 while ((rle_code = (
signed char)bytestream2_get_byte(&s->
g)) != -1) {
333 pixel_ptr += (bytestream2_get_byte(&s->
g) - 1) * 4;
335 }
else if (rle_code < 0) {
337 rle_code = -rle_code;
338 argb = bytestream2_get_be32(&s->
g);
351 argb = bytestream2_get_be32(&s->
g);
405 void *
data,
int *got_frame,
409 int header, start_line;
426 header = bytestream2_get_be16(&s->
g);
429 if (header & 0x0008) {
430 if (avpkt->
size < 14)
432 start_line = bytestream2_get_be16(&s->
g);
434 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.
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)
static void qtrle_decode_24bpp(QtrleContext *s, int row_ptr, int lines_to_change)
8 bit with PIX_FMT_RGB32 palette
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
static void qtrle_decode_1bpp(QtrleContext *s, int row_ptr, int lines_to_change)
struct QtrleContext QtrleContext
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
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.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
BYTE int const BYTE int int int height
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
synthesis window for stochastic i
int palette_has_changed
Tell user application that palette has changed from previous frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
static void qtrle_decode_32bpp(QtrleContext *s, int row_ptr, int lines_to_change)
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by an given frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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 int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
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.