Go to the documentation of this file.
42 return start + *y *
stride;
50 uint8_t *start,
int w,
int h,
int stride,
54 int depth = (bpp + 1) >> 3;
56 uint8_t *
line = start;
63 "Ran ouf of data before end-of-image\n");
66 type = bytestream2_get_byteu(&
s->gb);
67 count = (
type & 0x7F) + 1;
71 int n =
FFMIN(count,
w - x);
80 }
while (
dst && count > 0);
85 int n =
FFMIN(count,
w - x);
96 }
while (
dst && count > 0);
114 int idlen, pal, compr, y,
w,
h, bpp,
flags,
ret;
115 int first_clr, colors, csize;
122 idlen = bytestream2_get_byte(&
s->gb);
123 pal = bytestream2_get_byte(&
s->gb);
124 compr = bytestream2_get_byte(&
s->gb);
125 first_clr = bytestream2_get_le16(&
s->gb);
126 colors = bytestream2_get_le16(&
s->gb);
127 csize = bytestream2_get_byte(&
s->gb);
129 w = bytestream2_get_le16(&
s->gb);
130 h = bytestream2_get_le16(&
s->gb);
131 bpp = bytestream2_get_byte(&
s->gb);
133 flags = bytestream2_get_byte(&
s->gb);
135 if (!pal && (first_clr || colors || csize)) {
138 first_clr = colors = csize = 0;
143 "Not enough data to read header\n");
169 if (colors && (colors + first_clr) > 256) {
170 av_log(avctx,
AV_LOG_ERROR,
"Incorrect palette: %i colors with offset %i\n", colors, first_clr);
182 img_size =
w * ((bpp + 1) >> 3);
185 "Not enough data available for image\n");
206 int pal_size, pal_sample_size;
209 case 32: pal_sample_size = 4;
break;
210 case 24: pal_sample_size = 3;
break;
212 case 15: pal_sample_size = 2;
break;
217 pal_size = colors * pal_sample_size;
222 uint32_t *pal = ((uint32_t *)p->
data[1]) + first_clr;
226 "Not enough data to read palette\n");
229 switch (pal_sample_size) {
231 for (t = 0; t < colors; t++)
232 *pal++ = bytestream2_get_le32u(&
s->gb);
236 for (t = 0; t < colors; t++)
237 *pal++ = (0xffU<<24) | bytestream2_get_le24u(&
s->gb);
241 for (t = 0; t < colors; t++) {
242 uint32_t v = bytestream2_get_le16u(&
s->gb);
243 v = ((v & 0x7C00) << 9) |
244 ((v & 0x03E0) << 6) |
247 v |= (v & 0xE0E0E0
U) >> 5;
248 *pal++ = (0xff
U<<24) | v;
252 #if FF_API_PALETTE_HAS_CHANGED
268 "Not enough data available for image\n");
281 for (
int y = 0; y <
h; y++) {
283 for (
int x = 0; x < w >> 1; x++) {
286 FFSWAP(uint32_t, ((uint32_t *)
line)[x], ((uint32_t *)
line)[
w - x - 1]);
289 FFSWAP(uint8_t, ((uint8_t *)
line)[3 * x ], ((uint8_t *)
line)[3 *
w - 3 * x - 3]);
290 FFSWAP(uint8_t, ((uint8_t *)
line)[3 * x + 1], ((uint8_t *)
line)[3 *
w - 3 * x - 2]);
291 FFSWAP(uint8_t, ((uint8_t *)
line)[3 * x + 2], ((uint8_t *)
line)[3 *
w - 3 * x - 1]);
294 FFSWAP(uint16_t, ((uint16_t *)
line)[x], ((uint16_t *)
line)[
w - x - 1]);
#define FF_ENABLE_DEPRECATION_WARNINGS
#define AV_LOG_WARNING
Something somehow does not look correct.
attribute_deprecated int palette_has_changed
Tell user application that palette has changed from previous frame.
This structure describes decoded (raw) audio or video data.
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
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.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
AVCodec p
The public AVCodec.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
@ AV_PICTURE_TYPE_I
Intra.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
@ AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
#define FFSWAP(type, a, b)
main external API structure.
const FFCodec ff_targa_decoder
#define FF_DISABLE_DEPRECATION_WARNINGS
This structure stores compressed data.
static int targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *start, int w, int h, int stride, int bpp, int interleave)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static uint8_t * advance_line(uint8_t *start, uint8_t *line, int stride, int *y, int h, int interleave)
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line