69 int mask = 0x10000, bitbuf = 0;
74 segments = bytestream2_get_le32(gb);
75 offset = bytestream2_get_le32(gb);
84 if (
mask == 0x10000) {
85 bitbuf = bytestream2_get_le16u(gb);
91 v = bytestream2_get_le16(gb);
92 offset = (v & 0x1FFF) << 1;
93 count = ((v >> 13) + 2) << 1;
99 *
frame++ = bytestream2_get_byte(gb);
100 *
frame++ = bytestream2_get_byte(gb);
112 int mask = 0x10000, bitbuf = 0;
113 int v,
offset, count, segments;
115 segments = bytestream2_get_le16(gb);
119 if (
mask == 0x10000) {
120 bitbuf = bytestream2_get_le16u(gb);
126 v = bytestream2_get_le16(gb);
127 offset = (v & 0x1FFF) << 1;
128 count = ((v >> 13) + 2) << 1;
133 }
else if (bitbuf & (
mask << 1)) {
134 frame += bytestream2_get_le16(gb);
136 *
frame++ = bytestream2_get_byte(gb);
137 *
frame++ = bytestream2_get_byte(gb);
149 int mask = 0x10000, bitbuf = 0;
150 int i, v,
offset, count, segments;
154 segments = bytestream2_get_le16(gb);
158 if (
mask == 0x10000) {
159 bitbuf = bytestream2_get_le16u(gb);
164 v = bytestream2_get_le16(gb);
165 offset = (v & 0x1FFF) << 2;
166 count = ((v >> 13) + 2) << 1;
169 for (
i = 0;
i < count;
i++) {
175 }
else if (bitbuf & (
mask << 1)) {
176 v = bytestream2_get_le16(gb)*2;
199 int count, lines, segments;
201 count = bytestream2_get_le16(gb);
205 lines = bytestream2_get_le16(gb);
206 if (count + lines >
height)
214 segments = bytestream2_get_byteu(gb);
216 if (
frame - line_ptr <= bytestream2_peek_byte(gb))
218 line_ptr += bytestream2_get_byte(gb);
219 count = (int8_t)bytestream2_get_byte(gb);
221 if (
frame - line_ptr < count)
227 if (
frame - line_ptr < count)
229 memset(line_ptr, bytestream2_get_byte(gb), count);
242 int count,
i, v, lines, segments;
245 lines = bytestream2_get_le16(gb);
252 segments = bytestream2_get_le16u(gb);
253 while ((segments & 0xC000) == 0xC000) {
254 unsigned skip_lines = -(int16_t)segments;
260 segments = bytestream2_get_le16(gb);
265 if (segments & 0x8000) {
267 segments = bytestream2_get_le16(gb);
275 if (
frame - line_ptr <= bytestream2_peek_byte(gb))
277 line_ptr += bytestream2_get_byte(gb);
278 count = (int8_t)bytestream2_get_byte(gb);
280 if (
frame - line_ptr < count * 2)
284 line_ptr += count * 2;
287 if (
frame - line_ptr < count * 2)
289 v = bytestream2_get_le16(gb);
290 for (
i = 0;
i < count;
i++)
291 bytestream_put_le16(&line_ptr, v);
302 uint32_t segments = bytestream2_get_le32(gb);
308 copy = bytestream2_get_byteu(gb) * 2;
309 skip = bytestream2_get_byteu(gb) * 2;
336 "COPY",
"TSW1",
"BDLT",
"WDLT",
"TDLT",
"DSW1",
"BLCK",
"DDS1"
340 void *
data,
int *got_frame,
347 uint32_t chunk_type, chunk_size;
361 chunk_size = bytestream2_get_le32(&gb);
362 chunk_type = bytestream2_get_le32(&gb);
365 if (chunk_type == 1) {
366 pal_elems =
FFMIN(chunk_size / 3, 256);
367 for (
i = 0;
i < pal_elems;
i++) {
368 s->pal[
i] = bytestream2_get_be24(&gb) << 2;
369 s->pal[
i] |= 0xFFU << 24 | (
s->pal[
i] >> 6) & 0x30303;
372 }
else if (chunk_type <= 9) {
380 "Ignoring unknown chunk type %"PRIu32
"\n",
391 for(j = 0; j < avctx->
width; j++) {
392 dst[j] = buf[ (
i&3)*(avctx->
width /4) + (j/4) +
396 memcpy(dst, buf, avctx->
width);
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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...
static int decode_dsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
static int dfa_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int(* chunk_decoder)(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode_bdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
static const char chunk_name[8][5]
static int decode_tsw1(GetByteContext *gb, uint8_t *frame, int width, int height)
static const chunk_decoder decoder[8]
static int decode_dds1(GetByteContext *gb, uint8_t *frame, int width, int height)
static av_cold int dfa_decode_init(AVCodecContext *avctx)
static int decode_tdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
static av_cold int dfa_decode_end(AVCodecContext *avctx)
static int decode_wdlt(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode_copy(GetByteContext *gb, uint8_t *frame, int width, int height)
static int decode_blck(GetByteContext *gb, uint8_t *frame, int width, int height)
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const uint16_t mask[17]
Memory handling functions.
static void frame_end(MpegEncContext *s)
static int frame_start(MpegEncContext *s)
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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.
This structure stores compressed data.
static const uint8_t offset[127][2]
static void copy(const float *p1, float *p2, const int length)