libavformat/matroskadec.c File Reference

Matroska file demuxer by Ronald Bultje <rbultje@ronald.bitfreak.net> with a little help from Moritz Bunkus <moritz@bunkus.org> totally reworked by Aurelien Jacobs <aurel@gnuage.org> Specs available on the Matroska project page: http://www.matroska.org/. More...

#include <stdio.h>
#include "avformat.h"
#include "internal.h"
#include "avio_internal.h"
#include "riff.h"
#include "isom.h"
#include "rm.h"
#include "matroska.h"
#include "libavcodec/mpeg4audio.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavutil/lzo.h"
#include "libavutil/dict.h"

Go to the source code of this file.

Data Structures

struct  EbmlSyntax
struct  EbmlList
struct  EbmlBin
struct  Ebml
struct  MatroskaTrackCompression
struct  MatroskaTrackEncoding
struct  MatroskaTrackVideo
struct  MatroskaTrackAudio
struct  MatroskaTrackPlane
struct  MatroskaTrackOperation
struct  MatroskaTrack
struct  MatroskaAttachement
struct  MatroskaChapter
struct  MatroskaIndexPos
struct  MatroskaIndex
struct  MatroskaTag
struct  MatroskaTagTarget
struct  MatroskaTags
struct  MatroskaSeekhead
struct  MatroskaLevel
struct  MatroskaDemuxContext
struct  MatroskaBlock
struct  MatroskaCluster

Enumerations

enum  EbmlType {
  EBML_NONE, EBML_UINT, EBML_FLOAT, EBML_STR,
  EBML_UTF8, EBML_BIN, EBML_NEST, EBML_PASS,
  EBML_STOP, EBML_TYPE_COUNT
}

Functions

static int ebml_level_end (MatroskaDemuxContext *matroska)
static int ebml_read_num (MatroskaDemuxContext *matroska, AVIOContext *pb, int max_size, uint64_t *number)
static int ebml_read_length (MatroskaDemuxContext *matroska, AVIOContext *pb, uint64_t *number)
 Read a EBML length value.
static int ebml_read_uint (AVIOContext *pb, int size, uint64_t *num)
static int ebml_read_float (AVIOContext *pb, int size, double *num)
static int ebml_read_ascii (AVIOContext *pb, int size, char **str)
static int ebml_read_binary (AVIOContext *pb, int length, EbmlBin *bin)
static int ebml_read_master (MatroskaDemuxContext *matroska, uint64_t length)
static int matroska_ebmlnum_uint (MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, uint64_t *num)
static int matroska_ebmlnum_sint (MatroskaDemuxContext *matroska, uint8_t *data, uint32_t size, int64_t *num)
static int ebml_parse_elem (MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
static int ebml_parse_id (MatroskaDemuxContext *matroska, EbmlSyntax *syntax, uint32_t id, void *data)
static int ebml_parse (MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
static int ebml_parse_nest (MatroskaDemuxContext *matroska, EbmlSyntax *syntax, void *data)
static void ebml_free (EbmlSyntax *syntax, void *data)
static int matroska_probe (AVProbeData *p)
static MatroskaTrackmatroska_find_track_by_num (MatroskaDemuxContext *matroska, int num)
static int matroska_decode_buffer (uint8_t **buf, int *buf_size, MatroskaTrack *track)
static void matroska_fix_ass_packet (MatroskaDemuxContext *matroska, AVPacket *pkt, uint64_t display_duration)
static int matroska_merge_packets (AVPacket *out, AVPacket *in)
static void matroska_convert_tag (AVFormatContext *s, EbmlList *list, AVDictionary **metadata, char *prefix)
static void matroska_convert_tags (AVFormatContext *s)
static void matroska_execute_seekhead (MatroskaDemuxContext *matroska)
static int matroska_aac_profile (char *codec_id)
static int matroska_aac_sri (int samplerate)
static int matroska_read_header (AVFormatContext *s, AVFormatParameters *ap)
static int matroska_deliver_packet (MatroskaDemuxContext *matroska, AVPacket *pkt)
static void matroska_clear_queue (MatroskaDemuxContext *matroska)
static int matroska_parse_block (MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int64_t cluster_pos)
static int matroska_parse_cluster (MatroskaDemuxContext *matroska)
static int matroska_read_packet (AVFormatContext *s, AVPacket *pkt)
static int matroska_read_seek (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int matroska_read_close (AVFormatContext *s)

Variables

static EbmlSyntax ebml_header []
static EbmlSyntax ebml_syntax []
static EbmlSyntax matroska_info []
static EbmlSyntax matroska_track_video []
static EbmlSyntax matroska_track_audio []
static EbmlSyntax matroska_track_encoding_compression []
static EbmlSyntax matroska_track_encoding []
static EbmlSyntax matroska_track_encodings []
static EbmlSyntax matroska_track_plane []
static EbmlSyntax matroska_track_combine_planes []
static EbmlSyntax matroska_track_operation []
static EbmlSyntax matroska_track []
static EbmlSyntax matroska_tracks []
static EbmlSyntax matroska_attachment []
static EbmlSyntax matroska_attachments []
static EbmlSyntax matroska_chapter_display []
static EbmlSyntax matroska_chapter_entry []
static EbmlSyntax matroska_chapter []
static EbmlSyntax matroska_chapters []
static EbmlSyntax matroska_index_pos []
static EbmlSyntax matroska_index_entry []
static EbmlSyntax matroska_index []
static EbmlSyntax matroska_simpletag []
static EbmlSyntax matroska_tagtargets []
static EbmlSyntax matroska_tag []
static EbmlSyntax matroska_tags []
static EbmlSyntax matroska_seekhead_entry []
static EbmlSyntax matroska_seekhead []
static EbmlSyntax matroska_segment []
static EbmlSyntax matroska_segments []
static EbmlSyntax matroska_blockgroup []
static EbmlSyntax matroska_cluster []
static EbmlSyntax matroska_clusters []
static const char * matroska_doctypes [] = { "matroska", "webm" }
AVInputFormat ff_matroska_demuxer


Detailed Description

Matroska file demuxer by Ronald Bultje <rbultje@ronald.bitfreak.net> with a little help from Moritz Bunkus <moritz@bunkus.org> totally reworked by Aurelien Jacobs <aurel@gnuage.org> Specs available on the Matroska project page: http://www.matroska.org/.

Definition in file matroskadec.c.


Enumeration Type Documentation

enum EbmlType

Enumerator:
EBML_NONE 
EBML_UINT 
EBML_FLOAT 
EBML_STR 
EBML_UTF8 
EBML_BIN 
EBML_NEST 
EBML_PASS 
EBML_STOP 
EBML_TYPE_COUNT 

Definition at line 53 of file matroskadec.c.


Function Documentation

static void ebml_free ( EbmlSyntax syntax,
void *  data 
) [static]

static int ebml_level_end ( MatroskaDemuxContext matroska  )  [static]

Definition at line 547 of file matroskadec.c.

Referenced by ebml_parse_nest().

static int ebml_parse ( MatroskaDemuxContext matroska,
EbmlSyntax syntax,
void *  data 
) [static]

static int ebml_parse_elem ( MatroskaDemuxContext matroska,
EbmlSyntax syntax,
void *  data 
) [static]

Definition at line 815 of file matroskadec.c.

Referenced by ebml_parse_id().

static int ebml_parse_id ( MatroskaDemuxContext matroska,
EbmlSyntax syntax,
uint32_t  id,
void *  data 
) [static]

Definition at line 761 of file matroskadec.c.

Referenced by ebml_parse(), and ebml_parse_elem().

static int ebml_parse_nest ( MatroskaDemuxContext matroska,
EbmlSyntax syntax,
void *  data 
) [static]

Definition at line 790 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_ascii ( AVIOContext pb,
int  size,
char **  str 
) [static]

Definition at line 665 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_binary ( AVIOContext pb,
int  length,
EbmlBin bin 
) [static]

Definition at line 688 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_float ( AVIOContext pb,
int  size,
double *  num 
) [static]

Definition at line 647 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_length ( MatroskaDemuxContext matroska,
AVIOContext pb,
uint64_t *  number 
) [static]

Read a EBML length value.

This needs special handling for the "unknown length" case which has multiple encodings.

Definition at line 615 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_master ( MatroskaDemuxContext matroska,
uint64_t  length 
) [static]

Definition at line 709 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int ebml_read_num ( MatroskaDemuxContext matroska,
AVIOContext pb,
int  max_size,
uint64_t *  number 
) [static]

Definition at line 570 of file matroskadec.c.

Referenced by ebml_parse(), ebml_read_length(), and matroska_ebmlnum_uint().

static int ebml_read_uint ( AVIOContext pb,
int  size,
uint64_t *  num 
) [static]

Definition at line 628 of file matroskadec.c.

Referenced by ebml_parse_elem().

static int matroska_aac_profile ( char *  codec_id  )  [static]

Definition at line 1230 of file matroskadec.c.

Referenced by matroska_read_header().

static int matroska_aac_sri ( int  samplerate  )  [static]

Definition at line 1241 of file matroskadec.c.

Referenced by matroska_read_header().

static void matroska_clear_queue ( MatroskaDemuxContext matroska  )  [static]

Definition at line 1677 of file matroskadec.c.

Referenced by matroska_read_close(), and matroska_read_seek().

static void matroska_convert_tag ( AVFormatContext s,
EbmlList list,
AVDictionary **  metadata,
char *  prefix 
) [static]

Definition at line 1106 of file matroskadec.c.

Referenced by matroska_convert_tags().

static void matroska_convert_tags ( AVFormatContext s  )  [static]

Definition at line 1138 of file matroskadec.c.

Referenced by matroska_read_header().

static int matroska_decode_buffer ( uint8_t **  buf,
int *  buf_size,
MatroskaTrack track 
) [static]

Definition at line 963 of file matroskadec.c.

Referenced by matroska_parse_block(), and matroska_read_header().

static int matroska_deliver_packet ( MatroskaDemuxContext matroska,
AVPacket pkt 
) [static]

Definition at line 1650 of file matroskadec.c.

Referenced by matroska_read_packet().

static int matroska_ebmlnum_sint ( MatroskaDemuxContext matroska,
uint8_t *  data,
uint32_t  size,
int64_t *  num 
) [static]

Definition at line 742 of file matroskadec.c.

Referenced by matroska_parse_block().

static int matroska_ebmlnum_uint ( MatroskaDemuxContext matroska,
uint8_t *  data,
uint32_t  size,
uint64_t *  num 
) [static]

Definition at line 731 of file matroskadec.c.

Referenced by matroska_ebmlnum_sint(), and matroska_parse_block().

static void matroska_execute_seekhead ( MatroskaDemuxContext matroska  )  [static]

Definition at line 1172 of file matroskadec.c.

Referenced by matroska_read_header().

static MatroskaTrack* matroska_find_track_by_num ( MatroskaDemuxContext matroska,
int  num 
) [static]

Definition at line 949 of file matroskadec.c.

Referenced by matroska_parse_block(), and matroska_read_header().

static void matroska_fix_ass_packet ( MatroskaDemuxContext matroska,
AVPacket pkt,
uint64_t  display_duration 
) [static]

Definition at line 1061 of file matroskadec.c.

Referenced by matroska_parse_block().

static int matroska_merge_packets ( AVPacket out,
AVPacket in 
) [static]

Definition at line 1093 of file matroskadec.c.

Referenced by matroska_parse_block().

static int matroska_parse_block ( MatroskaDemuxContext matroska,
uint8_t *  data,
int  size,
int64_t  pos,
uint64_t  cluster_time,
uint64_t  duration,
int  is_keyframe,
int64_t  cluster_pos 
) [static]

Definition at line 1690 of file matroskadec.c.

Referenced by matroska_parse_cluster().

static int matroska_parse_cluster ( MatroskaDemuxContext matroska  )  [static]

Definition at line 1956 of file matroskadec.c.

Referenced by matroska_read_packet(), and matroska_read_seek().

static int matroska_probe ( AVProbeData p  )  [static]

Definition at line 907 of file matroskadec.c.

static int matroska_read_close ( AVFormatContext s  )  [static]

Definition at line 2047 of file matroskadec.c.

static int matroska_read_header ( AVFormatContext s,
AVFormatParameters ap 
) [static]

Definition at line 1251 of file matroskadec.c.

static int matroska_read_packet ( AVFormatContext s,
AVPacket pkt 
) [static]

Definition at line 1983 of file matroskadec.c.

static int matroska_read_seek ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
) [static]

Definition at line 1996 of file matroskadec.c.


Variable Documentation

EbmlSyntax ebml_header[] [static]

Initial value:

 {
    { EBML_ID_EBMLREADVERSION,        EBML_UINT, 0, 0x42, {.u=EBML_VERSION} },
    { EBML_ID_EBMLMAXSIZELENGTH,      EBML_UINT, 0, 0x42, {.u=8} },
    { EBML_ID_EBMLMAXIDLENGTH,        EBML_UINT, 0, 0x42, {.u=4} },
    { EBML_ID_DOCTYPE,                EBML_STR,  0, 0x42, {.s="(none)"} },
    { EBML_ID_DOCTYPEREADVERSION,     EBML_UINT, 0, 0x42, {.u=1} },
    { EBML_ID_EBMLVERSION,            EBML_NONE },
    { EBML_ID_DOCTYPEVERSION,         EBML_NONE },
    { 0 }
}

Definition at line 272 of file matroskadec.c.

Referenced by mkv_write_header().

EbmlSyntax ebml_syntax[] [static]

Initial value:

 {
    { EBML_ID_HEADER,                 EBML_NEST, 0, 0, {.n=ebml_header} },
    { 0 }
}

Definition at line 283 of file matroskadec.c.

Initial value:

Definition at line 2063 of file matroskadec.c.

Initial value:

Definition at line 393 of file matroskadec.c.

Initial value:

Definition at line 402 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, 0x42 },
    { MATROSKA_ID_SIMPLEBLOCK,    EBML_BIN,  0, 0x42 },
    { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, 0x42 },
    { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, 0x42 },
    { 1,                          EBML_UINT, 0, 0x42, {.u=1} },
    { 0 }
}

Definition at line 515 of file matroskadec.c.

Initial value:

Definition at line 407 of file matroskadec.c.

Initial value:

Definition at line 434 of file matroskadec.c.

const char* matroska_doctypes[] = { "matroska", "webm" } [static]

Definition at line 542 of file matroskadec.c.

Referenced by matroska_probe(), and matroska_read_header().

Initial value:

Definition at line 452 of file matroskadec.c.

Initial value:

Definition at line 446 of file matroskadec.c.

Initial value:

Definition at line 439 of file matroskadec.c.

Initial value:

Definition at line 288 of file matroskadec.c.

Initial value:

Definition at line 493 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_SEEKID,             EBML_UINT, 0, 0x42 },
    { MATROSKA_ID_SEEKPOSITION,       EBML_UINT, 0, 0x42, {.u=-1} },
    { 0 }
}

Definition at line 487 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_SEGMENT,        EBML_NEST, 0, 0, {.n=matroska_segment    } },
    { 0 }
}

Definition at line 510 of file matroskadec.c.

Initial value:

Definition at line 457 of file matroskadec.c.

Initial value:

Definition at line 476 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_TAG,                EBML_NEST, sizeof(MatroskaTags), 0x42, {.n=matroska_tag} },
    { 0 }
}

Definition at line 482 of file matroskadec.c.

Initial value:

Definition at line 467 of file matroskadec.c.

Initial value:

Definition at line 317 of file matroskadec.c.

Initial value:

Definition at line 350 of file matroskadec.c.

Initial value:

Definition at line 331 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_ENCODINGCOMPALGO,   EBML_UINT, 0, 0x42, {.u=0} },
    { MATROSKA_ID_ENCODINGCOMPSETTINGS,EBML_BIN, 0, 0x42 },
    { 0 }
}

Definition at line 325 of file matroskadec.c.

Initial value:

Definition at line 339 of file matroskadec.c.

Initial value:

Definition at line 355 of file matroskadec.c.

Initial value:

Definition at line 344 of file matroskadec.c.

Initial value:

 {
    { MATROSKA_ID_TRACKENTRY,         EBML_NEST, sizeof(MatroskaTrack), 0x42, {.n=matroska_track} },
    { 0 }
}

Definition at line 388 of file matroskadec.c.


Generated on Fri Oct 26 02:38:20 2012 for FFmpeg by  doxygen 1.5.8