xine-lib: xine-lib-1.2.12/src/demuxers/demux_avi.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Typedefs | Functions
demux_avi.c File Reference
`#include <stdio.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include "group_video.h"`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/demux.h>`
`#include "bswap.h"`

## Data Structures
struct | video_index_entry_t
struct | audio_index_entry_t
struct | _avisuperindex_entry
struct | _avistdindex_entry
struct | _avistdindex_chunk
struct | _avisuperindex_chunk
struct | video_index_t
struct | audio_index_t
struct | idx_grow_t
struct | avi_audio_t
struct | avi_t
struct | demux_avi_s

## Macros
#define | LOG_MODULE "demux_avi"
#define | LOG_VERBOSE
#define | AVIIF_KEYFRAME 0x00000010L
#define | MAX_AUDIO_STREAMS 8
#define | NUM_PREVIEW_BUFFERS 10
#define | AVI_INDEX_OF_INDEXES 0x00 /* when each entry in aIndex */
#define | AVI_INDEX_OF_CHUNKS 0x01 /* when each entry in aIndex */
#define | AVI_INDEX_IS_DATA 0x80 /* when each entry is aIndex is */
#define | AVI_INDEX_2FIELD 0x01 /* when fields within frames */
#define | AVI_ERR_SIZELIM
#define | AVI_ERR_OPEN
#define | AVI_ERR_READ 3 /* Error reading from AVI File */
#define | AVI_ERR_WRITE
#define | AVI_ERR_WRITE_INDEX
#define | AVI_ERR_CLOSE
#define | AVI_ERR_NOT_PERM
#define | AVI_ERR_NO_MEM 8 /* malloc failed */
#define | AVI_ERR_NO_AVI 9 /* Not an AVI file */
#define | AVI_ERR_NO_HDRL
#define | AVI_ERR_NO_MOVI
#define | AVI_ERR_NO_VIDS 12 /* AVI file contains no video data */
#define | AVI_ERR_NO_IDX
#define | AVI_ERR_BAD_SIZE 14 /* A chunk has an invalid size */
#define | AVI_HEADER_UNKNOWN -1
#define | AVI_HEADER_AUDIO 0
#define | AVI_HEADER_VIDEO 1
#define | AVI_HEADER_SIZE 8
#define | WRAP_THRESHOLD 90000
#define | PTS_AUDIO 0
#define | PTS_VIDEO 1
#define | PAD_EVEN(x) ( ((x)+1) & ~1 )
#define | ERR_EXIT(x)

## Typedefs
typedef struct _avisuperindex_entry | avisuperindex_entry
typedef struct _avistdindex_entry | avistdindex_entry
typedef struct _avistdindex_chunk | avistdindex_chunk
typedef struct _avisuperindex_chunk | avisuperindex_chunk
typedef struct demux_avi_s | demux_avi_t

## Functions
static uint32_t | odml_len (unsigned char *str)
static uint32_t | odml_key (unsigned char *str)
static void | check_newpts (demux_avi_t *this, int64_t pts, int video)
static int | video_index_append (avi_t *AVI, off_t pos, uint32_t len, uint32_t flags)
static int | audio_index_append (avi_t *AVI, int stream, off_t pos, uint32_t len, off_t tot, uint32_t block_no)
static int64_t | get_audio_pts (demux_avi_t *this, int track, uint32_t posc, off_t postot, uint32_t posb)
static int64_t | get_video_pts (demux_avi_t *this, off_t pos)
static int | video_pos_stopper (demux_avi_t *this, void *data)
static int | audio_pos_stopper (demux_avi_t *this, void *data)
static int | start_pos_stopper (demux_avi_t *this, void *data)
static int | start_time_stopper (demux_avi_t *this, void *data)
static int | idx_grow (demux_avi_t *this, int(*stopper)(demux_avi_t *, void *), void *stopdata)
static video_index_entry_t * | video_cur_index_entry (demux_avi_t *this)
static audio_index_entry_t * | audio_cur_index_entry (demux_avi_t *this, avi_audio_t *AVI_A)
static void | free_superindex (avisuperindex_chunk **p)
static void | AVI_close (avi_t *AVI)
static void | reset_idx (demux_avi_t *this, avi_t *AVI)
static avi_t * | AVI_init (demux_avi_t *this)
static void | AVI_seek_start (avi_t *AVI)
static int | AVI_read_audio (demux_avi_t *this, avi_audio_t *AVI_A, char *audbuf, uint32_t bytes, int *buf_flags)
static int | AVI_read_video (demux_avi_t *this, avi_t *AVI, char *vidbuf, uint32_t bytes, int *buf_flags)
static int | demux_avi_next (demux_avi_t *this, int decoder_flags)
static int | get_chunk_header (demux_avi_t *this, uint32_t *len, int *audio_stream)
static int | demux_avi_next_streaming (demux_avi_t *this, int decoder_flags)
static int | demux_avi_seek_internal (demux_avi_t *this)
static int | demux_avi_send_chunk (demux_plugin_t *this_gen)
static void | demux_avi_dispose (demux_plugin_t *this_gen)
static int | demux_avi_get_status (demux_plugin_t *this_gen)
static void | demux_avi_send_headers (demux_plugin_t *this_gen)
static int | demux_avi_seek (demux_plugin_t *this_gen, off_t start_pos, int start_time, int playing)
static int | demux_avi_get_stream_length (demux_plugin_t *this_gen)
static uint32_t | demux_avi_get_capabilities (demux_plugin_t *this_gen)
static int | demux_avi_get_optional_data (demux_plugin_t *this_gen, void *data, int data_type)
static demux_plugin_t * | open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input)
void * | demux_avi_init_class (xine_t *xine, const void *data)

## Macro Definition Documentation

## ◆ AVI_ERR_BAD_SIZE

#define AVI_ERR_BAD_SIZE 14 /* A chunk has an invalid size */

## ◆ AVI_ERR_CLOSE

#define AVI_ERR_CLOSE

Value:
6 /* Could not write header to AVI file
or not truncate the file during close,
file is most probably corrupted */

## ◆ AVI_ERR_NO_AVI

#define AVI_ERR_NO_AVI 9 /* Not an AVI file */

## ◆ AVI_ERR_NO_HDRL

#define AVI_ERR_NO_HDRL

Value:
10 /* AVI file has no header list,
corrupted ??? */

## ◆ AVI_ERR_NO_IDX

#define AVI_ERR_NO_IDX

Value:
13 /* The file has been opened with
getIndex==0, but an operation has been
performed that needs an index */

## ◆ AVI_ERR_NO_MEM

#define AVI_ERR_NO_MEM 8 /* malloc failed */

## ◆ AVI_ERR_NO_MOVI

#define AVI_ERR_NO_MOVI

Value:
11 /* AVI file has no MOVI list,
corrupted ??? */

## ◆ AVI_ERR_NO_VIDS

#define AVI_ERR_NO_VIDS 12 /* AVI file contains no video data */

## ◆ AVI_ERR_NOT_PERM

#define AVI_ERR_NOT_PERM

Value:
7 /* Operation not permitted:
trying to read from a file open
for writing or vice versa */

## ◆ AVI_ERR_OPEN

#define AVI_ERR_OPEN

Value:
2 /* Error opening the AVI file - wrong path
name or file nor readable/writable */

## ◆ AVI_ERR_READ

#define AVI_ERR_READ 3 /* Error reading from AVI File */

## ◆ AVI_ERR_SIZELIM

#define AVI_ERR_SIZELIM

Value:
1 /* The write of the data would exceed
the maximum size of the AVI file.
This is more a warning than an error
since the file may be closed safely */

## ◆ AVI_ERR_WRITE

#define AVI_ERR_WRITE

Value:
4 /* Error writing to AVI File,
disk full ??? */

## ◆ AVI_ERR_WRITE_INDEX

#define AVI_ERR_WRITE_INDEX

Value:
5 /* Could not write index to AVI file
during close, file may still be
usable */

## ◆ AVI_HEADER_AUDIO

#define AVI_HEADER_AUDIO 0

## ◆ AVI_HEADER_SIZE

#define AVI_HEADER_SIZE 8

## ◆ AVI_HEADER_UNKNOWN

#define AVI_HEADER_UNKNOWN -1

## ◆ AVI_HEADER_VIDEO

#define AVI_HEADER_VIDEO 1

## ◆ AVI_INDEX_2FIELD

#define AVI_INDEX_2FIELD 0x01 /* when fields within frames */

## ◆ AVI_INDEX_IS_DATA

#define AVI_INDEX_IS_DATA 0x80 /* when each entry is aIndex is */

## ◆ AVI_INDEX_OF_CHUNKS

#define AVI_INDEX_OF_CHUNKS 0x01 /* when each entry in aIndex */

## ◆ AVI_INDEX_OF_INDEXES

#define AVI_INDEX_OF_INDEXES 0x00 /* when each entry in aIndex */

## ◆ AVIIF_KEYFRAME

#define AVIIF_KEYFRAME 0x00000010L

## ◆ ERR_EXIT

#define ERR_EXIT | ( |  | x | ) |

Value:
do { \
this->AVI_errno = x; \
free (AVI); \
return 0; \
} while(0)

## ◆ LOG_MODULE

#define LOG_MODULE "demux_avi"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MAX_AUDIO_STREAMS

#define MAX_AUDIO_STREAMS 8

## ◆ NUM_PREVIEW_BUFFERS

#define NUM_PREVIEW_BUFFERS 10

## ◆ PAD_EVEN

#define PAD_EVEN | ( |  | x | ) | ( ((x)+1) & ~1 )

## ◆ PTS_AUDIO

#define PTS_AUDIO 0

## ◆ PTS_VIDEO

#define PTS_VIDEO 1

## ◆ WRAP_THRESHOLD

#define WRAP_THRESHOLD 90000

## Typedef Documentation

## ◆ avistdindex_chunk

typedef struct _avistdindex_chunk avistdindex_chunk

## ◆ avistdindex_entry

typedef struct _avistdindex_entry avistdindex_entry

## ◆ avisuperindex_chunk

typedef struct _avisuperindex_chunk avisuperindex_chunk

## ◆ avisuperindex_entry

typedef struct _avisuperindex_entry avisuperindex_entry

## ◆ demux_avi_t

typedef struct demux_avi_s demux_avi_t

## Function Documentation

## ◆ audio_cur_index_entry()

static audio_index_entry_t * audio_cur_index_entry | ( | demux_avi_t * | this,
|  | avi_audio_t * | AVI_A
| ) |  |
| static

References idx_grow(), NULL, video_index_t::video_frames, avi_t::video_idx, video_pos_stopper(), avi_t::video_posf, and video_index_t::vindex.

## ◆ audio_index_append()

static int audio_index_append | ( | avi_t * | AVI,
|  | int | stream,
|  | off_t | pos,
|  | uint32_t | len,
|  | off_t | tot,
|  | uint32_t | block_no
| ) |  |
| static

## ◆ audio_pos_stopper()

static int audio_pos_stopper | ( | demux_avi_t * | this,
|  | void * | data
| ) |  |
| static

## ◆ AVI_close()

static void AVI_close | ( | avi_t * | AVI | ) |
| static

References NULL.

Referenced by demux_avi_send_headers().

## ◆ AVI_init()

static avi_t * AVI_init | ( | demux_avi_t * | this | ) |
| static

References avi_t::audio, audio_index_t::audio_chunks, avi_audio_t::audio_idx, idx_grow(), avi_t::movi_start, avi_t::n_audio, video_index_t::video_frames, and avi_t::video_idx.

## ◆ AVI_read_audio()

static int AVI_read_audio | ( | demux_avi_t * | this,
|  | avi_audio_t * | AVI_A,
|  | char * | audbuf,
|  | uint32_t | bytes,
|  | int * | buf_flags
| ) |  |
| static

## ◆ AVI_read_video()

static int AVI_read_video | ( | demux_avi_t * | this,
|  | avi_t * | AVI,
|  | char * | vidbuf,
|  | uint32_t | bytes,
|  | int * | buf_flags
| ) |  |
| static

## ◆ AVI_seek_start()

static void AVI_seek_start | ( | avi_t * | AVI | ) |
| static

## ◆ check_newpts()

static void check_newpts | ( | demux_avi_t * | this,
|  | int64_t | pts,
|  | int | video
| ) |  |
| static

References _X_LE_32.

## ◆ demux_avi_dispose()

static void demux_avi_dispose | ( | demux_plugin_t * | this_gen | ) |
| static

## ◆ demux_avi_get_capabilities()

static uint32_t demux_avi_get_capabilities | ( | demux_plugin_t * | this_gen | ) |
| static

## ◆ demux_avi_get_optional_data()

static int demux_avi_get_optional_data | ( | demux_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type
| ) |  |
| static

References get_video_pts().

## ◆ demux_avi_get_status()

static int demux_avi_get_status | ( | demux_plugin_t * | this_gen | ) |
| static

## ◆ demux_avi_get_stream_length()

static int demux_avi_get_stream_length | ( | demux_plugin_t * | this_gen | ) |
| static

## ◆ demux_avi_init_class()

void * demux_avi_init_class | ( | xine_t * | xine,
|  | const void * | data
| ) |  |

## ◆ demux_avi_next()

static int demux_avi_next | ( | demux_avi_t * | this,
|  | int | decoder_flags
| ) |  |
| static

## ◆ demux_avi_next_streaming()

static int demux_avi_next_streaming | ( | demux_avi_t * | this,
|  | int | decoder_flags
| ) |  |
| static

## ◆ demux_avi_seek()

static int demux_avi_seek | ( | demux_plugin_t * | this_gen,
|  | off_t | start_pos,
|  | int | start_time,
|  | int | playing
| ) |  |
| static

## ◆ demux_avi_seek_internal()

static int demux_avi_seek_internal | ( | demux_avi_t * | this | ) |
| static

References _x_demux_flush_engine(), and DEMUX_OK.

## ◆ demux_avi_send_chunk()

static int demux_avi_send_chunk | ( | demux_plugin_t * | this_gen | ) |
| static

## ◆ demux_avi_send_headers()

static void demux_avi_send_headers | ( | demux_plugin_t * | this_gen | ) |
| static

References AVI_close().

## ◆ free_superindex()

static void free_superindex | ( | avisuperindex_chunk ** | p | ) |
| static

References audio_index_t::audio_chunks, avi_audio_t::audio_idx, avi_audio_t::audio_posc, and lprintf.

## ◆ get_audio_pts()

static int64_t get_audio_pts | ( | demux_avi_t * | this,
|  | int | track,
|  | uint32_t | posc,
|  | off_t | postot,
|  | uint32_t | posb
| ) |  |
| static

## ◆ get_chunk_header()

static int get_chunk_header | ( | demux_avi_t * | this,
|  | uint32_t * | len,
|  | int * | audio_stream
| ) |  |
| static

## ◆ get_video_pts()

static int64_t get_video_pts | ( | demux_avi_t * | this,
|  | off_t | pos
| ) |  |
| static

Referenced by demux_avi_get_optional_data().

## ◆ idx_grow()

static int idx_grow | ( | demux_avi_t * | this,
|  | int(*)(demux_avi_t *, void *) | stopper,
|  | void * | stopdata
| ) |  |
| static

Referenced by audio_cur_index_entry(), and AVI_init().

## ◆ odml_key()

static uint32_t odml_key | ( | unsigned char * | str | ) |
| static

## ◆ odml_len()

static uint32_t odml_len | ( | unsigned char * | str | ) |
| static

## ◆ open_plugin()

static demux_plugin_t * open_plugin | ( | demux_class_t * | class_gen,
|  | xine_stream_t * | stream,
|  | input_plugin_t * | input
| ) |  |
| static

## ◆ reset_idx()

static void reset_idx | ( | demux_avi_t * | this,
|  | avi_t * | AVI
| ) |  |
| static

## ◆ start_pos_stopper()

static int start_pos_stopper | ( | demux_avi_t * | this,
|  | void * | data
| ) |  |
| static

References audio_index_t::audio_chunks, avi_audio_t::audio_idx, and avi_audio_t::audio_posc.

## ◆ start_time_stopper()

static int start_time_stopper | ( | demux_avi_t * | this,
|  | void * | data
| ) |  |
| static

References AVIIF_KEYFRAME.

## ◆ video_cur_index_entry()

static video_index_entry_t * video_cur_index_entry | ( | demux_avi_t * | this | ) |
| static

## ◆ video_index_append()

static int video_index_append | ( | avi_t * | AVI,
|  | off_t | pos,
|  | uint32_t | len,
|  | uint32_t | flags
| ) |  |
| static

## ◆ video_pos_stopper()

static int video_pos_stopper | ( | demux_avi_t * | this,
|  | void * | data
| ) |  |
| static

Referenced by audio_cur_index_entry().