FFmpeg
Data Structures | Macros | Functions | Variables
idcin.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "avformat.h"
#include "demux.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  IdcinDemuxContext
 

Macros

#define HUFFMAN_TABLE_SIZE   (64 * 1024)
 
#define IDCIN_FPS   14
 

Functions

static int idcin_probe (const AVProbeData *p)
 
static int idcin_read_header (AVFormatContext *s)
 
static int idcin_read_packet (AVFormatContext *s, AVPacket *pkt)
 
static int idcin_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 

Variables

const FFInputFormat ff_idcin_demuxer
 

Detailed Description

id Quake II CIN file demuxer by Mike Melanson (melan.nosp@m.son@.nosp@m.pcisy.nosp@m.s.ne.nosp@m.t) For more information about the id CIN format, visit: http://www.csse.monash.edu.au/~timf/

CIN is a somewhat quirky and ill-defined format. Here are some notes for anyone trying to understand the technical details of this format:

The format has no definite file signature. This is problematic for a general-purpose media player that wants to automatically detect file types. However, a CIN file does start with 5 32-bit numbers that specify audio and video parameters. This demuxer gets around the lack of file signature by performing sanity checks on those parameters. Probabilistically, this is a reasonable solution since the number of valid combinations of the 5 parameters is a very small subset of the total 160-bit number space.

Refer to the function idcin_probe() for the precise A/V parameters that this demuxer allows.

Next, each audio and video frame has a duration of 1/14 sec. If the audio sample rate is a multiple of the common frequency 22050 Hz it will divide evenly by 14. However, if the sample rate is 11025 Hz: 11025 (samples/sec) / 14 (frames/sec) = 787.5 (samples/frame) The way the CIN stores audio in this case is by storing 787 sample frames in the first audio frame and 788 sample frames in the second audio frame. Therefore, the total number of bytes in an audio frame is given as: audio frame #0: 787 * (bytes/sample) * (# channels) bytes in frame audio frame #1: 788 * (bytes/sample) * (# channels) bytes in frame audio frame #2: 787 * (bytes/sample) * (# channels) bytes in frame audio frame #3: 788 * (bytes/sample) * (# channels) bytes in frame

Finally, not all id CIN creation tools agree on the resolution of the color palette, apparently. Some creation tools specify red, green, and blue palette components in terms of 6-bit VGA color DAC values which range from 0..63. Other tools specify the RGB components as full 8-bit values that range from 0..255. Since there are no markers in the file to differentiate between the two variants, this demuxer uses the following heuristic:

Definition in file idcin.c.

Macro Definition Documentation

◆ HUFFMAN_TABLE_SIZE

#define HUFFMAN_TABLE_SIZE   (64 * 1024)

Definition at line 78 of file idcin.c.

◆ IDCIN_FPS

#define IDCIN_FPS   14

Definition at line 79 of file idcin.c.

Function Documentation

◆ idcin_probe()

static int idcin_probe ( const AVProbeData p)
static

Definition at line 95 of file idcin.c.

◆ idcin_read_header()

static int idcin_read_header ( AVFormatContext s)
static

Definition at line 153 of file idcin.c.

◆ idcin_read_packet()

static int idcin_read_packet ( AVFormatContext s,
AVPacket pkt 
)
static

Definition at line 250 of file idcin.c.

◆ idcin_read_seek()

static int idcin_read_seek ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)
static

Definition at line 351 of file idcin.c.

Variable Documentation

◆ ff_idcin_demuxer

const FFInputFormat ff_idcin_demuxer
Initial value:
= {
.p.name = "idcin",
.p.long_name = NULL_IF_CONFIG_SMALL("id Cinematic"),
.p.flags = AVFMT_NO_BYTE_SEEK,
.priv_data_size = sizeof(IdcinDemuxContext),
}

Definition at line 368 of file idcin.c.

IdcinDemuxContext
Definition: idcin.c:81
AVFMT_NO_BYTE_SEEK
#define AVFMT_NO_BYTE_SEEK
Format does not allow seeking by bytes.
Definition: avformat.h:487
idcin_read_header
static int idcin_read_header(AVFormatContext *s)
Definition: idcin.c:153
read_seek
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition: libcdio.c:151
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_read_callback.c:42
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:540
idcin_probe
static int idcin_probe(const AVProbeData *p)
Definition: idcin.c:95
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:94
idcin_read_seek
static int idcin_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Definition: idcin.c:351
idcin_read_packet
static int idcin_read_packet(AVFormatContext *s, AVPacket *pkt)
Definition: idcin.c:250
read_probe
static int read_probe(const AVProbeData *p)
Definition: cdg.c:30