Go to the documentation of this file.
   64     if (avctx->
width & 1) {
 
   73     s->scratch_buffer = 
av_malloc(
s->buffer_size + 130);
 
   74     if (!
s->scratch_buffer)
 
   85                            uint8_t *dst, 
const int dst_size)
 
   90     const uint8_t *dst_end = dst + dst_size;
 
   94     tree_size = bytestream2_get_byte(&
s->gb);
 
   95     eof       = bytestream2_get_byte(&
s->gb);
 
   96     tree_root = eof + tree_size;
 
  100     bits = bytestream2_get_byte(&
s->gb);
 
  106         node = bytestream2_get_byte(&tree);
 
  118             bits = bytestream2_get_byteu(&
s->gb);
 
  127                       uint8_t *dest, 
const int dest_len)
 
  132     const uint8_t *dest_end = dest + dest_len;
 
  134     while (dest < dest_end) {
 
  138         opcode = bytestream2_get_byteu(&
s->gb);
 
  142             if ((opcode & 0x80) == 0) {
 
  144                 back  = ((opcode & 0x60) << 3) + bytestream2_get_byte(&
s->gb) + 1;
 
  145                 size2 = ((opcode & 0x1c) >> 2) + 3;
 
  146             } 
else if ((opcode & 0x40) == 0) {
 
  147                 size  = bytestream2_peek_byte(&
s->gb) >> 6;
 
  148                 back  = (bytestream2_get_be16(&
s->gb) & 0x3fff) + 1;
 
  149                 size2 = (opcode & 0x3f) + 4;
 
  152                 back  = ((opcode & 0x10) << 12) + bytestream2_get_be16(&
s->gb) + 1;
 
  153                 size2 = ((opcode & 0x0c) <<  6) + bytestream2_get_byte(&
s->gb) + 5;
 
  154                 if (
size + size2 > dest_end - dest)
 
  157             if (dest + 
size + size2 > dest_end ||
 
  158                 dest - orig_dest + 
size < back)
 
  165             int finish = opcode >= 0xfc;
 
  167             size = 
finish ? opcode & 3 : ((opcode & 0x1f) << 2) + 4;
 
  168             if (dest_end - dest < 
size)
 
  176     return dest - orig_dest;
 
  196     mode        = bytestream2_get_le16(&
s->gb);
 
  198     table_size  = bytestream2_get_le16(&
s->gb);
 
  208     memset(
s->scratch_buffer, 0, 
s->buffer_size);
 
  217     src     = 
s->scratch_buffer;
 
  218     src_end = 
src + dec_size;
 
  220         for (j = 0; j < avctx->
height >> 1; j++) {
 
  221             for (
i = 0; 
i < avctx->
width >> 1; 
i++) {
 
  222                 if (src_end - 
src < 1)
 
  226                     if (
val >= table_size)
 
  229                     uval = (
val >> 3) & 0xF8;
 
  230                     vval = (
val >> 8) & 0xF8;
 
  231                     U[
i] = uval | (uval >> 5);
 
  232                     V[
i] = vval | (vval >> 5);
 
  235             U += 
s->pic->linesize[1];
 
  236             V += 
s->pic->linesize[2];
 
  239             memcpy(
U, 
U - 
s->pic->linesize[1], avctx->
width >> 1);
 
  240             memcpy(
V, 
V - 
s->pic->linesize[2], avctx->
width >> 1);
 
  246         for (j = 0; j < avctx->
height >> 2; j++) {
 
  247             for (
i = 0; 
i < avctx->
width >> 1; 
i += 2) {
 
  248                 if (src_end - 
src < 1)
 
  252                     if (
val >= table_size)
 
  255                     uval = (
val >> 3) & 0xF8;
 
  256                     vval = (
val >> 8) & 0xF8;
 
  257                     U[
i] = 
U[
i+1] = U2[
i] = U2[
i+1] = uval | (uval >> 5);
 
  258                     V[
i] = 
V[
i+1] = V2[
i] = V2[
i+1] = vval | (vval >> 5);
 
  261             U  += 
s->pic->linesize[1] * 2;
 
  262             V  += 
s->pic->linesize[2] * 2;
 
  263             U2 += 
s->pic->linesize[1] * 2;
 
  264             V2 += 
s->pic->linesize[2] * 2;
 
  267             int lines = ((avctx->
height + 1) >> 1) - (avctx->
height >> 2) * 2;
 
  269             memcpy(
U, 
U - lines * 
s->pic->linesize[1], lines * 
s->pic->linesize[1]);
 
  270             memcpy(
V, 
V - lines * 
s->pic->linesize[2], lines * 
s->pic->linesize[2]);
 
  280     uint8_t *ybuf, *prev_buf, *
src = 
s->scratch_buffer;
 
  281     unsigned  chroma_off, corr_off;
 
  286     chroma_off = bytestream2_get_le32(&
s->gb);
 
  287     corr_off   = bytestream2_get_le32(&
s->gb);
 
  306     for (j = 1; j < avctx->
width - 1; j += 2) {
 
  307         cur = (last + *
src++) & 0x1F;
 
  308         ybuf[j]   = last + cur;
 
  309         ybuf[j+1] = cur << 1;
 
  314     ybuf += avctx->
width;
 
  317         last = ((prev_buf[0] >> 1) + *
src++) & 0x1F;
 
  319         for (j = 1; j < avctx->
width - 1; j += 2) {
 
  320             cur = ((prev_buf[j + 1] >> 1) + *
src++) & 0x1F;
 
  321             ybuf[j]   = last + cur;
 
  322             ybuf[j+1] = cur << 1;
 
  327         ybuf += avctx->
width;
 
  334         dec_size = 
xan_unpack(
s, 
s->scratch_buffer, 
s->buffer_size / 2);
 
  338             dec_size = 
FFMIN(dec_size, 
s->buffer_size/2 - 1);
 
  340         for (
i = 0; 
i < dec_size; 
i++)
 
  341             s->y_buffer[
i*2+1] = (
s->y_buffer[
i*2+1] + (
s->scratch_buffer[
i] << 1)) & 0x3F;
 
  345     ybuf = 
s->pic->data[0];
 
  346     for (j = 0; j < avctx->
height; j++) {
 
  350         ybuf += 
s->pic->linesize[0];
 
  369                           s->buffer_size >> 1);
 
  377         last = (ybuf[0] + (*
src++ << 1)) & 0x3F;
 
  379         for (j = 1; j < avctx->
width - 1; j += 2) {
 
  380             cur = (ybuf[j + 1] + (*
src++ << 1)) & 0x3F;
 
  381             ybuf[j]   = (last + cur) >> 1;
 
  386         ybuf += avctx->
width;
 
  390     ybuf = 
s->pic->data[0];
 
  391     for (j = 0; j < avctx->
height; j++) {
 
  395         ybuf += 
s->pic->linesize[0];
 
  402                             void *
data, 
int *got_frame,
 
  413     ftype = bytestream2_get_le32(&
s->gb);
 
  
#define AV_LOG_WARNING
Something somehow does not look correct.
 
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
 
static av_cold int init(AVCodecContext *avctx)
 
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
 
static int xan_decode_frame_type0(AVCodecContext *avctx)
 
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
 
static av_always_inline int bytestream2_seek(GetByteContext *g, int offset, int whence)
 
This structure describes decoded (raw) audio or video data.
 
static int xan_unpack(XanContext *s, uint8_t *dest, const int dest_len)
 
static const uint16_t table[]
 
static int xan_decode_frame_type1(AVCodecContext *avctx)
 
#define bit(string, value)
 
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
 
static av_cold int xan_decode_end(AVCodecContext *avctx)
 
static double val(void *priv, double ch)
 
static int xan_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
 
static const uint16_t mask[17]
 
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
 
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
 
static av_cold int xan_decode_init(AVCodecContext *avctx)
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
 
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
 
AVCodec ff_xan_wc4_decoder
 
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 int bytestream2_tell(GetByteContext *g)
 
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_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.
 
static av_always_inline int bytestream2_size(GetByteContext *g)
 
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
 
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 offset
 
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
 
static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
 
const char * name
Name of the codec implementation.
 
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
 
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
 
main external API structure.
 
This structure stores compressed data.
 
int width
picture width / height.
 
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
 
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
 
static int xan_unpack_luma(XanContext *s, uint8_t *dst, const int dst_size)