41 int depth = (bpp + 1) >> 3;
45 diff = stride - w * depth;
50 "Ran ouf of data before end-of-image\n");
53 type = bytestream2_get_byteu(&s->
gb);
54 count = (type & 0x7F) + 1;
56 if (x + count > w && x + count + 1 > (h - y) * w) {
58 "Packet went out of bounds: position (%i,%i) size %i\n",
64 int n =
FFMIN(count, w - x);
79 int n =
FFMIN(count, w - x);
83 memcpy(dst, tmp, depth);
98 void *
data,
int *got_frame,
106 int idlen, compr, y, w, h, bpp,
flags;
107 int first_clr, colors, csize;
112 idlen = bytestream2_get_byte(&s->
gb);
114 compr = bytestream2_get_byte(&s->
gb);
115 first_clr = bytestream2_get_le16(&s->
gb);
116 colors = bytestream2_get_le16(&s->
gb);
117 csize = bytestream2_get_byte(&s->
gb);
119 w = bytestream2_get_le16(&s->
gb);
120 h = bytestream2_get_le16(&s->
gb);
121 bpp = bytestream2_get_byte(&s->
gb);
122 flags = bytestream2_get_byte(&s->
gb);
167 int pal_size, pal_sample_size;
168 if((colors + first_clr) > 256){
169 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
173 case 24: pal_sample_size = 3;
break;
175 case 15: pal_sample_size = 2;
break;
180 pal_size = colors * pal_sample_size;
185 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
189 "Not enough data to read palette\n");
192 switch (pal_sample_size) {
195 for (t = 0; t < colors; t++)
196 *pal++ = bytestream2_get_le24u(&s->
gb);
200 for (t = 0; t < colors; t++) {
201 uint32_t v = bytestream2_get_le16u(&s->
gb);
202 v = ((v & 0x7C00) << 9) |
203 ((v & 0x03E0) << 6) |
206 v |= (v & 0xE0E0E0
U) >> 5;
222 size_t img_size = w * ((bpp + 1) >> 3);
225 "Not enough data available for image\n");
228 for (y = 0; y < h; y++) {
This structure describes decoded (raw) audio or video data.
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
AVFrame * coded_frame
the picture in the bitstream
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
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)
8 bit with PIX_FMT_RGB32 palette
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static int init(AVCodecParserContext *s)
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)
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
int width
picture width / height.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
static av_cold int targa_init(AVCodecContext *avctx)
packed RGB 8:8:8, 24bpp, BGRBGR...
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)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
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.
struct TargaContext TargaContext
common internal api header.
static av_cold int targa_end(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
This structure stores compressed data.