46 const unsigned char *
buf;
52 #define CHECK_STREAM_PTR(n) \
53 if ((stream_ptr + n) > s->size) { \
54 av_log (s->avctx, AV_LOG_INFO, "Problem: stream_ptr out of bounds (%d >= %d)\n", \
55 stream_ptr + n, s->size); \
59 #define CHECK_PIXEL_PTR(n) \
60 if ((pixel_ptr + n > pixel_limit) || (pixel_ptr + n < 0)) { \
61 av_log (s->avctx, AV_LOG_INFO, "Problem: pixel_ptr = %d, pixel_limit = %d\n", \
62 pixel_ptr + n, pixel_limit); \
71 unsigned char pi0, pi1;
76 while (lines_to_change) {
78 skip = s->
buf[stream_ptr++];
79 rle_code = (
signed char)s->
buf[stream_ptr++];
85 pixel_ptr = row_ptr + 2 * (skip & 0x7f);
87 pixel_ptr += 2 * skip;
96 pi0 = s->
buf[stream_ptr++];
97 pi1 = s->
buf[stream_ptr++];
101 rgb[pixel_ptr++] = pi0;
102 rgb[pixel_ptr++] = pi1;
111 rgb[pixel_ptr++] = s->
buf[stream_ptr++];
117 int row_ptr,
int lines_to_change,
int bpp)
122 unsigned char pi[16];
125 int num_pixels = (bpp == 4) ? 8 : 16;
127 while (lines_to_change--) {
129 pixel_ptr = row_ptr + (num_pixels * (s->
buf[stream_ptr++] - 1));
131 while ((rle_code = (
signed char)s->
buf[stream_ptr++]) != -1) {
135 pixel_ptr += (num_pixels * (s->
buf[stream_ptr++] - 1));
137 }
else if (rle_code < 0) {
139 rle_code = -rle_code;
143 for (i = num_pixels-1; i >= 0; i--) {
144 pi[num_pixels-1-i] = (s->
buf[stream_ptr] >> ((i*bpp) & 0x07)) & ((1<<bpp)-1);
145 stream_ptr+= ((i & ((num_pixels>>2)-1)) == 0);
149 for (i = 0; i < num_pixels; i++)
150 rgb[pixel_ptr++] = pi[i];
159 rgb[pixel_ptr++] = ((s->
buf[stream_ptr]) >> 4) & 0x0f;
160 rgb[pixel_ptr++] = (s->
buf[stream_ptr++]) & 0x0f;
162 rgb[pixel_ptr++] = ((s->
buf[stream_ptr]) >> 6) & 0x03;
163 rgb[pixel_ptr++] = ((s->
buf[stream_ptr]) >> 4) & 0x03;
164 rgb[pixel_ptr++] = ((s->
buf[stream_ptr]) >> 2) & 0x03;
165 rgb[pixel_ptr++] = (s->
buf[stream_ptr++]) & 0x03;
179 unsigned char pi1, pi2, pi3, pi4;
183 while (lines_to_change--) {
185 pixel_ptr = row_ptr + (4 * (s->
buf[stream_ptr++] - 1));
187 while ((rle_code = (
signed char)s->
buf[stream_ptr++]) != -1) {
191 pixel_ptr += (4 * (s->
buf[stream_ptr++] - 1));
193 }
else if (rle_code < 0) {
195 rle_code = -rle_code;
199 pi1 = s->
buf[stream_ptr++];
200 pi2 = s->
buf[stream_ptr++];
201 pi3 = s->
buf[stream_ptr++];
202 pi4 = s->
buf[stream_ptr++];
207 rgb[pixel_ptr++] = pi1;
208 rgb[pixel_ptr++] = pi2;
209 rgb[pixel_ptr++] = pi3;
210 rgb[pixel_ptr++] = pi4;
219 rgb[pixel_ptr++] = s->
buf[stream_ptr++];
232 unsigned short rgb16;
236 while (lines_to_change--) {
238 pixel_ptr = row_ptr + (s->
buf[stream_ptr++] - 1) * 2;
240 while ((rle_code = (
signed char)s->
buf[stream_ptr++]) != -1) {
244 pixel_ptr += (s->
buf[stream_ptr++] - 1) * 2;
246 }
else if (rle_code < 0) {
248 rle_code = -rle_code;
256 *(
unsigned short *)(&rgb[pixel_ptr]) = rgb16;
267 *(
unsigned short *)(&rgb[pixel_ptr]) = rgb16;
281 unsigned char r,
g,
b;
285 while (lines_to_change--) {
287 pixel_ptr = row_ptr + (s->
buf[stream_ptr++] - 1) * 3;
289 while ((rle_code = (
signed char)s->
buf[stream_ptr++]) != -1) {
293 pixel_ptr += (s->
buf[stream_ptr++] - 1) * 3;
295 }
else if (rle_code < 0) {
297 rle_code = -rle_code;
299 r = s->
buf[stream_ptr++];
300 g = s->
buf[stream_ptr++];
301 b = s->
buf[stream_ptr++];
306 rgb[pixel_ptr++] =
r;
307 rgb[pixel_ptr++] =
g;
308 rgb[pixel_ptr++] =
b;
316 rgb[pixel_ptr++] = s->
buf[stream_ptr++];
317 rgb[pixel_ptr++] = s->
buf[stream_ptr++];
318 rgb[pixel_ptr++] = s->
buf[stream_ptr++];
335 while (lines_to_change--) {
337 pixel_ptr = row_ptr + (s->
buf[stream_ptr++] - 1) * 4;
339 while ((rle_code = (
signed char)s->
buf[stream_ptr++]) != -1) {
343 pixel_ptr += (s->
buf[stream_ptr++] - 1) * 4;
345 }
else if (rle_code < 0) {
347 rle_code = -rle_code;
419 void *
data,
int *data_size,
422 const uint8_t *buf = avpkt->
data;
423 int buf_size = avpkt->
size;
425 int header, start_line;
426 int stream_ptr,
height, row_ptr;
452 if (header & 0x0008) {
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
#define FF_BUFFER_HINTS_VALID
AV_WL32 AV_WL24 AV_WL16 AV_RB32
static void qtrle_decode_32bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
#define CHECK_STREAM_PTR(n)
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
const unsigned char * buf
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static void qtrle_decode_8bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
static av_cold int qtrle_decode_init(AVCodecContext *avctx)
struct QtrleContext QtrleContext
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void qtrle_decode_1bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#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.
struct AVFrame AVFrame
Audio Video Frame.
static void qtrle_decode_2n4bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change, int bpp)
#define CHECK_PIXEL_PTR(n)
#define FF_BUFFER_HINTS_REUSABLE
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_BUFFER_HINTS_PRESERVE
int palette_has_changed
Tell user application that palette has changed from previous frame.
#define FF_BUFFER_HINTS_READABLE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
8 bit with PIX_FMT_RGB32 palette
packed RGB 8:8:8, 24bpp, RGBRGB...
static void qtrle_decode_16bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change)
static int qtrle_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
static av_cold int qtrle_decode_end(AVCodecContext *avctx)