64 if (avctx->
width & 1) {
89 uint8_t *dst,
const int dst_size)
94 const uint8_t *dst_end = dst + dst_size;
98 tree_size = bytestream2_get_byte(&s->
gb);
99 eof = bytestream2_get_byte(&s->
gb);
100 tree_root = eof + tree_size;
104 bits = bytestream2_get_byte(&s->
gb);
107 int bit = !!(bits &
mask);
110 node = bytestream2_get_byte(&tree);
122 bits = bytestream2_get_byteu(&s->
gb);
131 uint8_t *dest,
const int dest_len)
136 const uint8_t *dest_end = dest + dest_len;
138 while (dest < dest_end) {
142 opcode = bytestream2_get_byteu(&s->
gb);
146 if ((opcode & 0x80) == 0) {
148 back = ((opcode & 0x60) << 3) + bytestream2_get_byte(&s->
gb) + 1;
149 size2 = ((opcode & 0x1c) >> 2) + 3;
150 }
else if ((opcode & 0x40) == 0) {
151 size = bytestream2_peek_byte(&s->
gb) >> 6;
152 back = (bytestream2_get_be16(&s->
gb) & 0x3fff) + 1;
153 size2 = (opcode & 0x3f) + 4;
156 back = ((opcode & 0x10) << 12) + bytestream2_get_be16(&s->
gb) + 1;
157 size2 = ((opcode & 0x0c) << 6) + bytestream2_get_byte(&s->
gb) + 5;
158 if (size + size2 > dest_end - dest)
161 if (dest + size + size2 > dest_end ||
162 dest - orig_dest + size < back)
169 int finish = opcode >= 0xfc;
171 size = finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
172 if (dest_end - dest < size)
180 return dest - orig_dest;
200 mode = bytestream2_get_le16(&s->
gb);
202 table_size = bytestream2_get_le16(&s->
gb);
203 offset = table_size * 2;
222 src_end = src + dec_size;
224 for (j = 0; j < avctx->
height >> 1; j++) {
225 for (i = 0; i < avctx->
width >> 1; i++) {
226 if (src_end - src < 1)
230 if (val >= table_size)
232 val =
AV_RL16(table + (val << 1));
233 uval = (val >> 3) & 0xF8;
234 vval = (val >> 8) & 0xF8;
235 U[i] = uval | (uval >> 5);
236 V[i] = vval | (vval >> 5);
250 for (j = 0; j < avctx->
height >> 2; j++) {
251 for (i = 0; i < avctx->
width >> 1; i += 2) {
252 if (src_end - src < 1)
256 if (val >= table_size)
258 val =
AV_RL16(table + (val << 1));
259 uval = (val >> 3) & 0xF8;
260 vval = (val >> 8) & 0xF8;
261 U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
262 V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
271 int lines = ((avctx->
height + 1) >> 1) - (avctx->
height >> 2) * 2;
285 unsigned chroma_off, corr_off;
290 chroma_off = bytestream2_get_le32(&s->
gb);
291 corr_off = bytestream2_get_le32(&s->
gb);
310 for (j = 1; j < avctx->
width - 1; j += 2) {
311 cur = (last + *src++) & 0x1F;
312 ybuf[j] = last + cur;
313 ybuf[j+1] = cur << 1;
318 ybuf += avctx->
width;
320 for (i = 1; i < avctx->
height; i++) {
321 last = ((prev_buf[0] >> 1) + *src++) & 0x1F;
323 for (j = 1; j < avctx->
width - 1; j += 2) {
324 cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;
325 ybuf[j] = last + cur;
326 ybuf[j+1] = cur << 1;
331 ybuf += avctx->
width;
344 for (i = 0; i < dec_size; i++)
350 for (j = 0; j < avctx->
height; j++) {
351 for (i = 0; i < avctx->
width; i++)
352 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
380 for (i = 0; i < avctx->
height; i++) {
381 last = (ybuf[0] + (*src++ << 1)) & 0x3F;
383 for (j = 1; j < avctx->
width - 1; j += 2) {
384 cur = (ybuf[j + 1] + (*src++ << 1)) & 0x3F;
385 ybuf[j] = (last + cur) >> 1;
390 ybuf += avctx->
width;
395 for (j = 0; j < avctx->
height; j++) {
396 for (i = 0; i < avctx->
width; i++)
397 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
406 void *
data,
int *got_frame,
417 ftype = bytestream2_get_le32(&s->
gb);
const char const char void * val
#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.
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
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)
AVCodec ff_xan_wc4_decoder
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int xan_decode_frame_type0(AVCodecContext *avctx)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
static av_always_inline int bytestream2_size(GetByteContext *g)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint16_t mask[17]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static const struct endianess table[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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.
static const uint8_t offset[127][2]
int width
picture width / height.
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_always_inline int bytestream2_tell(GetByteContext *g)
static av_cold int xan_decode_end(AVCodecContext *avctx)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static int xan_unpack_luma(XanContext *s, uint8_t *dst, const int dst_size)
static av_cold int xan_decode_init(AVCodecContext *avctx)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
static int xan_decode_frame_type1(AVCodecContext *avctx)
static int xan_unpack(XanContext *s, uint8_t *dest, const int dest_len)
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
This structure stores compressed data.
mode
Use these values in ebur128_init (or'ed).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)