22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/imgutils.h"
40 int depth = (bpp + 1) >> 3;
44 diff = stride - w * depth;
49 "Ran ouf of data before end-of-image\n");
52 type = bytestream2_get_byteu(&s->
gb);
53 count = (type & 0x7F) + 1;
55 if (x + count > w && x + count + 1 > (h - y) * w) {
57 "Packet went out of bounds: position (%i,%i) size %i\n",
63 int n =
FFMIN(count, w - x);
78 int n =
FFMIN(count, w - x);
82 memcpy(dst, tmp, depth);
97 void *
data,
int *got_frame,
104 int idlen, compr, y, w, h, bpp,
flags, ret;
105 int first_clr, colors, csize;
110 idlen = bytestream2_get_byte(&s->
gb);
112 compr = bytestream2_get_byte(&s->
gb);
113 first_clr = bytestream2_get_le16(&s->
gb);
114 colors = bytestream2_get_le16(&s->
gb);
115 csize = bytestream2_get_byte(&s->
gb);
117 w = bytestream2_get_le16(&s->
gb);
118 h = bytestream2_get_le16(&s->
gb);
119 bpp = bytestream2_get_byte(&s->
gb);
120 flags = bytestream2_get_byte(&s->
gb);
161 int pal_size, pal_sample_size;
162 if((colors + first_clr) > 256){
163 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
167 case 24: pal_sample_size = 3;
break;
169 case 15: pal_sample_size = 2;
break;
174 pal_size = colors * pal_sample_size;
179 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
183 "Not enough data to read palette\n");
186 switch (pal_sample_size) {
189 for (t = 0; t < colors; t++)
190 *pal++ = bytestream2_get_le24u(&s->
gb);
194 for (t = 0; t < colors; t++) {
195 uint32_t v = bytestream2_get_le16u(&s->
gb);
196 v = ((v & 0x7C00) << 9) |
197 ((v & 0x03E0) << 6) |
200 v |= (v & 0xE0E0E0
U) >> 5;
216 size_t img_size = w * ((bpp + 1) >> 3);
219 "Not enough data available for image\n");
222 for (y = 0; y < h; y++) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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 av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, uint8_t *dst, unsigned int size)
targa file common definitions
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *dst, int w, int h, int stride, int bpp)
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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. ...
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)
Libavcodec external API header.
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
8 bit with PIX_FMT_RGB32 palette
main external API structure.
packed RGB 8:8:8, 24bpp, BGRBGR...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int palette_has_changed
Tell user application that palette has changed from previous frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.