libavformat/matroskaenc.c File Reference

#include "avformat.h"
#include "md5.h"
#include "riff.h"
#include "xiph.h"
#include "matroska.h"
#include "avc.h"

Go to the source code of this file.

Data Structures

struct  ebml_master
struct  mkv_seekhead_entry
struct  mkv_seekhead
struct  mkv_cuepoint
struct  mkv_cues
struct  MatroskaMuxContext

Defines

#define MAX_SEEKENTRY_SIZE   21
 2 bytes * 3 for EBML IDs, 3 1-byte EBML lengths, 8 bytes for 64 bit offset, 4 bytes for target EBML ID
#define MAX_CUETRACKPOS_SIZE   22
 per-cuepoint-track - 3 1-byte EBML IDs, 3 1-byte EBML sizes, 2 8-byte uint max
#define MAX_CUEPOINT_SIZE(num_tracks)   12 + MAX_CUETRACKPOS_SIZE*num_tracks
 per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max
#define FLAC_STREAMINFO_SIZE   34

Functions

static int ebml_id_size (unsigned int id)
static void put_ebml_id (ByteIOContext *pb, unsigned int id)
static void put_ebml_size_unknown (ByteIOContext *pb, int bytes)
 Write an EBML size meaning "unknown size".
static int ebml_num_size (uint64_t num)
 Calculate how many bytes are needed to represent a given number in EBML.
static void put_ebml_num (ByteIOContext *pb, uint64_t num, int bytes)
 Write a number in EBML variable length format.
static void put_ebml_uint (ByteIOContext *pb, unsigned int elementid, uint64_t val)
static void put_ebml_float (ByteIOContext *pb, unsigned int elementid, double val)
static void put_ebml_binary (ByteIOContext *pb, unsigned int elementid, const uint8_t *buf, int size)
static void put_ebml_string (ByteIOContext *pb, unsigned int elementid, const char *str)
static void put_ebml_void (ByteIOContext *pb, uint64_t size)
 Writes a void element of a given size.
static ebml_master start_ebml_master (ByteIOContext *pb, unsigned int elementid, uint64_t expectedsize)
static void end_ebml_master (ByteIOContext *pb, ebml_master master)
static void put_xiph_size (ByteIOContext *pb, int size)
static mkv_seekheadmkv_start_seekhead (ByteIOContext *pb, offset_t segment_offset, int numelements)
 Initialize a mkv_seekhead element to be ready to index level 1 Matroska elements.
static int mkv_add_seekhead_entry (mkv_seekhead *seekhead, unsigned int elementid, uint64_t filepos)
static offset_t mkv_write_seekhead (ByteIOContext *pb, mkv_seekhead *seekhead)
 Write the seek head to the file and free it.
static mkv_cuesmkv_start_cues (offset_t segment_offset)
static int mkv_add_cuepoint (mkv_cues *cues, AVPacket *pkt, offset_t cluster_pos)
static offset_t mkv_write_cues (ByteIOContext *pb, mkv_cues *cues, int num_tracks)
static int put_xiph_codecpriv (AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
static int put_flac_codecpriv (AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec)
static void get_aac_sample_rates (AVFormatContext *s, AVCodecContext *codec, int *sample_rate, int *output_sample_rate)
static int mkv_write_codecprivate (AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id)
static int mkv_write_tracks (AVFormatContext *s)
static int mkv_write_header (AVFormatContext *s)
static int mkv_block_size (AVPacket *pkt)
static int mkv_blockgroup_size (AVPacket *pkt)
static void mkv_write_block (AVFormatContext *s, unsigned int blockid, AVPacket *pkt, int flags)
static int mkv_write_packet (AVFormatContext *s, AVPacket *pkt)
static int mkv_write_trailer (AVFormatContext *s)

Variables

AVOutputFormat matroska_muxer
AVOutputFormat matroska_audio_muxer


Define Documentation

#define FLAC_STREAMINFO_SIZE   34

Definition at line 419 of file matroskaenc.c.

#define MAX_CUEPOINT_SIZE ( num_tracks   )     12 + MAX_CUETRACKPOS_SIZE*num_tracks

per-cuepoint - 2 1-byte EBML IDs, 2 1-byte EBML sizes, 8-byte uint max

Definition at line 86 of file matroskaenc.c.

Referenced by mkv_write_cues().

#define MAX_CUETRACKPOS_SIZE   22

per-cuepoint-track - 3 1-byte EBML IDs, 3 1-byte EBML sizes, 2 8-byte uint max

Definition at line 83 of file matroskaenc.c.

Referenced by mkv_write_cues().

#define MAX_SEEKENTRY_SIZE   21

2 bytes * 3 for EBML IDs, 3 1-byte EBML lengths, 8 bytes for 64 bit offset, 4 bytes for target EBML ID

Definition at line 79 of file matroskaenc.c.

Referenced by mkv_start_seekhead(), and mkv_write_seekhead().


Function Documentation

static int ebml_id_size ( unsigned int  id  )  [static]

Definition at line 89 of file matroskaenc.c.

Referenced by mkv_write_seekhead(), and put_ebml_id().

static int ebml_num_size ( uint64_t  num  )  [static]

Calculate how many bytes are needed to represent a given number in EBML.

Definition at line 117 of file matroskaenc.c.

Referenced by mkv_blockgroup_size(), put_ebml_num(), and start_ebml_master().

static void end_ebml_master ( ByteIOContext pb,
ebml_master  master 
) [static]

static void get_aac_sample_rates ( AVFormatContext s,
AVCodecContext codec,
int *  sample_rate,
int *  output_sample_rate 
) [static]

Definition at line 438 of file matroskaenc.c.

Referenced by mkv_write_tracks().

static int mkv_add_cuepoint ( mkv_cues cues,
AVPacket pkt,
offset_t  cluster_pos 
) [static]

Definition at line 340 of file matroskaenc.c.

Referenced by mkv_write_packet().

static int mkv_add_seekhead_entry ( mkv_seekhead seekhead,
unsigned int  elementid,
uint64_t  filepos 
) [static]

static int mkv_block_size ( AVPacket pkt  )  [static]

Definition at line 692 of file matroskaenc.c.

Referenced by mkv_blockgroup_size(), and mkv_write_block().

static int mkv_blockgroup_size ( AVPacket pkt  )  [static]

Definition at line 698 of file matroskaenc.c.

Referenced by mkv_write_packet().

static mkv_cues* mkv_start_cues ( offset_t  segment_offset  )  [static]

Definition at line 330 of file matroskaenc.c.

Referenced by mkv_write_header().

static mkv_seekhead* mkv_start_seekhead ( ByteIOContext pb,
offset_t  segment_offset,
int  numelements 
) [static]

Initialize a mkv_seekhead element to be ready to index level 1 Matroska elements.

If a maximum number of elements is specified, enough space will be reserved at the current file location to write a seek head of that size.

Parameters:
segment_offset The absolute offset to the position in the file where the segment begins.
numelements The maximum number of elements that will be indexed by this seek head, 0 if unlimited.

Definition at line 244 of file matroskaenc.c.

Referenced by mkv_write_header().

static void mkv_write_block ( AVFormatContext s,
unsigned int  blockid,
AVPacket pkt,
int  flags 
) [static]

Definition at line 709 of file matroskaenc.c.

Referenced by mkv_write_packet().

static int mkv_write_codecprivate ( AVFormatContext s,
ByteIOContext pb,
AVCodecContext codec,
int  native_id 
) [static]

Definition at line 469 of file matroskaenc.c.

Referenced by mkv_write_tracks().

static offset_t mkv_write_cues ( ByteIOContext pb,
mkv_cues cues,
int  num_tracks 
) [static]

Definition at line 356 of file matroskaenc.c.

Referenced by mkv_write_trailer().

static int mkv_write_header ( AVFormatContext s  )  [static]

Definition at line 619 of file matroskaenc.c.

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

Definition at line 725 of file matroskaenc.c.

static offset_t mkv_write_seekhead ( ByteIOContext pb,
mkv_seekhead seekhead 
) [static]

Write the seek head to the file and free it.

If a maximum number of elements was specified to mkv_start_seekhead(), the seek head will be written at the location reserved for it. Otherwise, it is written at the current location in the file.

Returns:
The file offset where the seekhead was written.

Definition at line 291 of file matroskaenc.c.

Referenced by mkv_write_trailer().

static int mkv_write_tracks ( AVFormatContext s  )  [static]

Definition at line 516 of file matroskaenc.c.

Referenced by mkv_write_header().

static int mkv_write_trailer ( AVFormatContext s  )  [static]

Definition at line 777 of file matroskaenc.c.

static void put_ebml_binary ( ByteIOContext pb,
unsigned int  elementid,
const uint8_t buf,
int  size 
) [static]

Definition at line 167 of file matroskaenc.c.

Referenced by mkv_write_codecprivate(), mkv_write_trailer(), and put_ebml_string().

static void put_ebml_float ( ByteIOContext pb,
unsigned int  elementid,
double  val 
) [static]

Definition at line 160 of file matroskaenc.c.

Referenced by mkv_write_tracks(), and mkv_write_trailer().

static void put_ebml_id ( ByteIOContext pb,
unsigned int  id 
) [static]

static void put_ebml_num ( ByteIOContext pb,
uint64_t  num,
int  bytes 
) [static]

Write a number in EBML variable length format.

Parameters:
bytes The number of bytes that need to be used to write the number. If zero, any number of bytes can be used.

Definition at line 130 of file matroskaenc.c.

Referenced by end_ebml_master(), mkv_write_block(), mkv_write_seekhead(), put_ebml_binary(), put_ebml_float(), put_ebml_uint(), and put_ebml_void().

static void put_ebml_size_unknown ( ByteIOContext pb,
int  bytes 
) [static]

Write an EBML size meaning "unknown size".

Parameters:
bytes The number of bytes the size should occupy (maximum: 8).

Definition at line 106 of file matroskaenc.c.

Referenced by start_ebml_master().

static void put_ebml_string ( ByteIOContext pb,
unsigned int  elementid,
const char *  str 
) [static]

Definition at line 175 of file matroskaenc.c.

Referenced by mkv_write_header(), and mkv_write_tracks().

static void put_ebml_uint ( ByteIOContext pb,
unsigned int  elementid,
uint64_t  val 
) [static]

static void put_ebml_void ( ByteIOContext pb,
uint64_t  size 
) [static]

Writes a void element of a given size.

Useful for reserving space in the file to be written to later.

Parameters:
size The number of bytes to reserve, which must be at least 2.

Definition at line 186 of file matroskaenc.c.

Referenced by mkv_start_seekhead(), mkv_write_header(), and mkv_write_seekhead().

static int put_flac_codecpriv ( AVFormatContext s,
ByteIOContext pb,
AVCodecContext codec 
) [static]

Definition at line 421 of file matroskaenc.c.

Referenced by mkv_write_codecprivate().

static int put_xiph_codecpriv ( AVFormatContext s,
ByteIOContext pb,
AVCodecContext codec 
) [static]

Definition at line 391 of file matroskaenc.c.

Referenced by mkv_write_codecprivate().

static void put_xiph_size ( ByteIOContext pb,
int  size 
) [static]

Definition at line 225 of file matroskaenc.c.

Referenced by put_flac_codecpriv(), and put_xiph_codecpriv().

static ebml_master start_ebml_master ( ByteIOContext pb,
unsigned int  elementid,
uint64_t  expectedsize 
) [static]


Variable Documentation

Initial value:

 {
    "matroska",
    "Matroska File Format",
    "audio/x-matroska",
    "mka",
    sizeof(MatroskaMuxContext),
    CODEC_ID_MP2,
    CODEC_ID_NONE,
    mkv_write_header,
    mkv_write_packet,
    mkv_write_trailer,
    .codec_tag = (const AVCodecTag*[]){codec_wav_tags, 0},
}

Definition at line 832 of file matroskaenc.c.

Initial value:

 {
    "matroska",
    "Matroska File Format",
    "video/x-matroska",
    "mkv",
    sizeof(MatroskaMuxContext),
    CODEC_ID_MP2,
    CODEC_ID_MPEG4,
    mkv_write_header,
    mkv_write_packet,
    mkv_write_trailer,
    .codec_tag = (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
    .subtitle_codec = CODEC_ID_TEXT,
}

Definition at line 817 of file matroskaenc.c.


Generated on Thu Apr 2 07:16:14 2009 for ffmpeg by  doxygen 1.5.6