FFmpeg
Data Structures | Macros | Functions | Variables
idcinvideo.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "avcodec.h"
#include "internal.h"
#include "libavutil/internal.h"

Go to the source code of this file.

Data Structures

struct  hnode
 
struct  IdcinContext
 

Macros

#define HUFFMAN_TABLE_SIZE   64 * 1024
 
#define HUF_TOKENS   256
 
#define PALETTE_COUNT   256
 

Functions

static int huff_smallest_node (hnode *hnodes, int num_hnodes)
 Find the lowest probability node in a Huffman table, and mark it as being assigned to a higher probability. More...
 
static av_cold void huff_build_tree (IdcinContext *s, int prev)
 
static av_cold int idcin_decode_init (AVCodecContext *avctx)
 
static int idcin_decode_vlcs (IdcinContext *s, AVFrame *frame)
 
static int idcin_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 

Variables

static const AVCodecDefault idcin_defaults []
 
AVCodec ff_idcin_decoder
 

Detailed Description

id Quake II Cin Video Decoder by Dr. Tim Ferguson For more information about the id CIN format, visit: http://www.csse.monash.edu.au/~timf/

This video decoder outputs PAL8 colorspace data. Interacting with this decoder is a little involved. During initialization, the demuxer must transmit the 65536-byte Huffman table(s) to the decoder via extradata. Then, whenever a palette change is encountered while demuxing the file, the demuxer must use the same extradata space to transmit an AVPaletteControl structure.

id CIN video is purely Huffman-coded, intraframe-only codec. It achieves a little more compression by exploiting the fact that adjacent pixels tend to be similar.

Note that this decoder could use libavcodec's optimized VLC facilities rather than naive, tree-based Huffman decoding. However, there are 256 Huffman tables. Plus, the VLC bit coding order is right -> left instead or left -> right, so all of the bits would have to be reversed. Further, the original Quake II implementation likely used a similar naive decoding algorithm and it worked fine on much lower spec machines.

Definition in file idcinvideo.c.

Macro Definition Documentation

◆ HUFFMAN_TABLE_SIZE

#define HUFFMAN_TABLE_SIZE   64 * 1024

Definition at line 55 of file idcinvideo.c.

◆ HUF_TOKENS

#define HUF_TOKENS   256

Definition at line 56 of file idcinvideo.c.

◆ PALETTE_COUNT

#define PALETTE_COUNT   256

Definition at line 57 of file idcinvideo.c.

Function Documentation

◆ huff_smallest_node()

static int huff_smallest_node ( hnode hnodes,
int  num_hnodes 
)
static

Find the lowest probability node in a Huffman table, and mark it as being assigned to a higher probability.

Returns
the node index of the lowest unused node, or -1 if all nodes are used.

Definition at line 84 of file idcinvideo.c.

Referenced by huff_build_tree().

◆ huff_build_tree()

static av_cold void huff_build_tree ( IdcinContext s,
int  prev 
)
static

Definition at line 116 of file idcinvideo.c.

Referenced by idcin_decode_init().

◆ idcin_decode_init()

static av_cold int idcin_decode_init ( AVCodecContext avctx)
static

Definition at line 146 of file idcinvideo.c.

◆ idcin_decode_vlcs()

static int idcin_decode_vlcs ( IdcinContext s,
AVFrame frame 
)
static

Definition at line 172 of file idcinvideo.c.

Referenced by idcin_decode_frame().

◆ idcin_decode_frame()

static int idcin_decode_frame ( AVCodecContext avctx,
void *  data,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 210 of file idcinvideo.c.

Variable Documentation

◆ idcin_defaults

const AVCodecDefault idcin_defaults[]
static
Initial value:
= {
{ "max_pixels", "320*240" },
{ NULL },
}

Definition at line 246 of file idcinvideo.c.

◆ ff_idcin_decoder

AVCodec ff_idcin_decoder
Initial value:
= {
.name = "idcinvideo",
.long_name = NULL_IF_CONFIG_SMALL("id Quake II CIN video"),
.priv_data_size = sizeof(IdcinContext),
.capabilities = AV_CODEC_CAP_DR1,
}

Definition at line 251 of file idcinvideo.c.

AV_CODEC_ID_IDCIN
@ AV_CODEC_ID_IDCIN
Definition: avcodec.h:265
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
idcin_defaults
static const AVCodecDefault idcin_defaults[]
Definition: idcinvideo.c:246
defaults
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361
decode
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
IdcinContext
Definition: idcinvideo.c:65
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:981
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
idcin_decode_frame
static int idcin_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: idcinvideo.c:210
idcin_decode_init
static av_cold int idcin_decode_init(AVCodecContext *avctx)
Definition: idcinvideo.c:146
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201