27 #define BITSTREAM_READER_LE
52 if (avctx->
width & 1) {
71 uint8_t *dst,
const int dst_size)
76 const uint8_t *dst_end = dst + dst_size;
80 tree_size = bytestream2_get_byte(&s->
gb);
81 eof = bytestream2_get_byte(&s->
gb);
82 tree_root = eof + tree_size;
86 bits = bytestream2_get_byte(&s->
gb);
89 int bit = !!(bits &
mask);
92 node = bytestream2_get_byte(&tree);
104 bits = bytestream2_get_byteu(&s->
gb);
113 uint8_t *dest,
const int dest_len)
118 const uint8_t *dest_end = dest + dest_len;
120 while (dest < dest_end) {
124 opcode = bytestream2_get_byteu(&s->
gb);
128 if ((opcode & 0x80) == 0) {
130 back = ((opcode & 0x60) << 3) + bytestream2_get_byte(&s->
gb) + 1;
131 size2 = ((opcode & 0x1c) >> 2) + 3;
132 }
else if ((opcode & 0x40) == 0) {
133 size = bytestream2_peek_byte(&s->
gb) >> 6;
134 back = (bytestream2_get_be16(&s->
gb) & 0x3fff) + 1;
135 size2 = (opcode & 0x3f) + 4;
138 back = ((opcode & 0x10) << 12) + bytestream2_get_be16(&s->
gb) + 1;
139 size2 = ((opcode & 0x0c) << 6) + bytestream2_get_byte(&s->
gb) + 5;
140 if (size + size2 > dest_end - dest)
143 if (dest + size + size2 > dest_end ||
144 dest - orig_dest + size < back)
151 int finish = opcode >= 0xfc;
153 size = finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
154 if (dest_end - dest < size)
162 return dest - orig_dest;
173 int mode, offset, dec_size, table_size;
182 mode = bytestream2_get_le16(&s->
gb);
184 table_size = bytestream2_get_le16(&s->
gb);
185 offset = table_size * 2;
204 src_end = src + dec_size;
206 for (j = 0; j < avctx->
height >> 1; j++) {
207 for (i = 0; i < avctx->
width >> 1; i++) {
209 if (val && val < table_size) {
210 val =
AV_RL16(table + (val << 1));
211 uval = (val >> 3) & 0xF8;
212 vval = (val >> 8) & 0xF8;
213 U[i] = uval | (uval >> 5);
214 V[i] = vval | (vval >> 5);
230 for (j = 0; j < avctx->
height >> 2; j++) {
231 for (i = 0; i < avctx->
width >> 1; i += 2) {
233 if (val && val < table_size) {
234 val =
AV_RL16(table + (val << 1));
235 uval = (val >> 3) & 0xF8;
236 vval = (val >> 8) & 0xF8;
237 U[i] = U[i+1] = U2[i] = U2[i+1] = uval | (uval >> 5);
238 V[i] = V[i+1] = V2[i] = V2[i+1] = vval | (vval >> 5);
247 int lines = ((avctx->
height + 1) >> 1) - (avctx->
height >> 2) * 2;
261 unsigned chroma_off, corr_off;
266 chroma_off = bytestream2_get_le32(&s->
gb);
267 corr_off = bytestream2_get_le32(&s->
gb);
286 for (j = 1; j < avctx->
width - 1; j += 2) {
287 cur = (last + *src++) & 0x1F;
288 ybuf[j] = last + cur;
289 ybuf[j+1] = cur << 1;
294 ybuf += avctx->
width;
296 for (i = 1; i < avctx->
height; i++) {
297 last = ((prev_buf[0] >> 1) + *src++) & 0x1F;
299 for (j = 1; j < avctx->
width - 1; j += 2) {
300 cur = ((prev_buf[j + 1] >> 1) + *src++) & 0x1F;
301 ybuf[j] = last + cur;
302 ybuf[j+1] = cur << 1;
307 ybuf += avctx->
width;
317 for (i = 0; i < dec_size; i++)
323 for (j = 0; j < avctx->
height; j++) {
324 for (i = 0; i < avctx->
width; i++)
325 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
353 for (i = 0; i < avctx->
height; i++) {
354 last = (ybuf[0] + (*src++ << 1)) & 0x3F;
356 for (j = 1; j < avctx->
width - 1; j += 2) {
357 cur = (ybuf[j + 1] + (*src++ << 1)) & 0x3F;
358 ybuf[j] = (last + cur) >> 1;
363 ybuf += avctx->
width;
368 for (j = 0; j < avctx->
height; j++) {
369 for (i = 0; i < avctx->
width; i++)
370 ybuf[i] = (src[i] << 2) | (src[i] >> 3);
379 void *
data,
int *got_frame,
396 ftype = bytestream2_get_le32(&s->
gb);
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
This structure describes decoded (raw) audio or video data.
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
memory handling functions
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
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static int xan_decode_frame_type0(AVCodecContext *avctx)
bitstream reader API header.
static int init(AVCodecParserContext *s)
static const uint16_t mask[17]
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
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. ...
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.
const uint8_t * buffer_end
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)
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)
const uint8_t * buffer_start
static int xan_unpack_luma(XanContext *s, uint8_t *dst, const int dst_size)
#define FF_BUFFER_HINTS_REUSABLE
static av_cold int xan_decode_init(AVCodecContext *avctx)
#define FF_BUFFER_HINTS_PRESERVE
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)
struct XanContext XanContext
#define AVERROR_INVALIDDATA
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)
#define FF_BUFFER_HINTS_VALID
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
deliberately overlapping memcpy implementation
This structure stores compressed data.
static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)