39 return line + interleave *
stride;
41 *y = (*y + 1) & (interleave - 1);
43 return start + *y *
stride;
55 int depth = (bpp + 1) >> 3;
64 "Ran ouf of data before end-of-image\n");
67 type = bytestream2_get_byteu(&s->
gb);
68 count = (type & 0x7F) + 1;
72 int n =
FFMIN(count, w - x);
79 dst = line =
advance_line(start, line, stride, &y, h, interleave);
81 }
while (dst && count > 0);
86 int n =
FFMIN(count, w - x);
90 memcpy(dst, tmp, depth);
95 dst = line =
advance_line(start, line, stride, &y, h, interleave);
97 }
while (dst && count > 0);
110 void *
data,
int *got_frame,
117 int idlen, pal, compr,
y, w,
h, bpp,
flags,
ret;
118 int first_clr, colors, csize;
124 idlen = bytestream2_get_byte(&s->
gb);
125 pal = bytestream2_get_byte(&s->
gb);
126 compr = bytestream2_get_byte(&s->
gb);
127 first_clr = bytestream2_get_le16(&s->
gb);
128 colors = bytestream2_get_le16(&s->
gb);
129 csize = bytestream2_get_byte(&s->
gb);
131 w = bytestream2_get_le16(&s->
gb);
132 h = bytestream2_get_le16(&s->
gb);
133 bpp = bytestream2_get_byte(&s->
gb);
137 "Not enough data to read header\n");
141 flags = bytestream2_get_byte(&s->
gb);
143 if (!pal && (first_clr || colors || csize)) {
146 first_clr = colors = csize = 0;
171 if (colors && (colors + first_clr) > 256) {
172 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
195 int pal_size, pal_sample_size;
198 case 32: pal_sample_size = 4;
break;
199 case 24: pal_sample_size = 3;
break;
201 case 15: pal_sample_size = 2;
break;
206 pal_size = colors * pal_sample_size;
211 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
215 "Not enough data to read palette\n");
218 switch (pal_sample_size) {
220 for (t = 0; t < colors; t++)
221 *pal++ = bytestream2_get_le32u(&s->
gb);
225 for (t = 0; t < colors; t++)
226 *pal++ = (0xffU<<24) | bytestream2_get_le24u(&s->
gb);
230 for (t = 0; t < colors; t++) {
231 uint32_t
v = bytestream2_get_le16u(&s->
gb);
232 v = ((v & 0x7C00) << 9) |
233 ((v & 0x03E0) << 6) |
236 v |= (v & 0xE0E0E0
U) >> 5;
237 *pal++ = (0xff
U<<24) | v;
253 size_t img_size = w * ((bpp + 1) >> 3);
257 "Not enough data available for image\n");
265 line =
advance_line(dst, line, stride, &y, h, interleave);
272 for (y = 0; y <
h; y++) {
274 for (x = 0; x < w >> 1; x++) {
277 FFSWAP(uint32_t, ((uint32_t *)line)[x], ((uint32_t *)line)[w - x - 1]);
285 FFSWAP(uint16_t, ((uint16_t *)line)[x], ((uint16_t *)line)[w - x - 1]);
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
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 void interleave(IDWTELEM *dst, IDWTELEM *src0, IDWTELEM *src1, int w2, int add, int shift)
targa file common definitions
static uint8_t * advance_line(uint8_t *start, uint8_t *line, int stride, int *y, int h, int interleave)
8 bit with AV_PIX_FMT_RGB32 palette
#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. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
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.
enum AVPictureType pict_type
Picture type of the frame.
packed RGB 8:8:8, 24bpp, BGRBGR...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
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.
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)
GLint GLenum GLboolean GLsizei stride
static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *start, int w, int h, int stride, int bpp, int interleave)
common internal api header.
#define FFSWAP(type, a, b)
This structure stores compressed data.