37 #define CHECK_BUFFER_SIZE(buf, buf_end, needed, where) \
38 if(needed > buf_end - buf){ \
39 av_log(avctx, AV_LOG_ERROR, "Problem: unexpected end of data while reading " where "\n"); \
46 int depth = (bpp + 1) >> 3;
49 const uint8_t *src_end = src + src_size;
51 diff = stride - w *
depth;
56 count = (type & 0x7F) + 1;
58 if((x + count > w) && (x + count + 1 > (h - y) * w)){
59 av_log(avctx,
AV_LOG_ERROR,
"Packet went out of bounds: position (%i,%i) size %i\n", x, y, count);
67 for(i = 0; i < count; i++){
73 *((uint16_t*)dst) =
AV_RL16(src);
81 *((uint32_t*)dst) =
AV_RL32(src);
102 void *
data,
int *data_size,
105 const uint8_t *buf = avpkt->
data;
106 const uint8_t *buf_end = avpkt->
data + avpkt->
size;
112 int idlen, compr, y, w, h, bpp,
flags;
113 int first_clr, colors, csize;
120 first_clr =
AV_RL16(buf); buf += 2;
121 colors =
AV_RL16(buf); buf += 2;
176 int pal_size, pal_sample_size;
177 if((colors + first_clr) > 256){
178 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
182 case 24: pal_sample_size = 3;
break;
184 case 15: pal_sample_size = 2;
break;
189 pal_size = colors * pal_sample_size;
195 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
197 switch (pal_sample_size) {
200 for (t = 0; t < colors; t++)
201 *pal++ = bytestream_get_le24(&buf);
205 for (t = 0; t < colors; t++) {
206 uint32_t
v = bytestream_get_le16(&buf);
207 v = ((v & 0x7C00) << 9) |
208 ((v & 0x03E0) << 6) |
211 v |= (v & 0xE0E0E0
U) >> 5;
228 size_t img_size = s->
width * ((s->
bpp + 1) >> 3);
230 for(y = 0; y < s->
height; y++){
233 if((s->
bpp + 1) >> 3 == 2){
234 uint16_t *dst16 = (uint16_t*)dst;
235 for(x = 0; x < s->
width; x++)
236 dst16[x] =
AV_RL16(buf + x * 2);
237 }
else if((s->
bpp + 1) >> 3 == 4){
238 uint32_t *dst32 = (uint32_t*)dst;
239 for(x = 0; x < s->
width; x++)
240 dst32[x] =
AV_RL32(buf + x * 4);
243 memcpy(dst, buf, img_size);
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
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
four components are given, that's all.
targa file common definitions
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
#define CHECK_BUFFER_SIZE(buf, buf_end, needed, where)
void avcodec_set_dimensions(AVCodecContext *s, int width, int height)
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#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.
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
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.
static av_cold int targa_init(AVCodecContext *avctx)
static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, int src_size, uint8_t *dst, int w, int h, int stride, int bpp)
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.
int palette_has_changed
Tell user application that palette has changed from previous frame.
packed RGB 8:8:8, 24bpp, BGRBGR...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
struct TargaContext TargaContext
static av_cold int targa_end(AVCodecContext *avctx)
8 bit with PIX_FMT_RGB32 palette
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.