mux.c File Reference

muxing functions for use within Libav More...

#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "libavcodec/internal.h"
#include "libavcodec/bytestream.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
#include "libavutil/pixdesc.h"
#include "metadata.h"
#include "id3v2.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/mathematics.h"
#include "libavutil/parseutils.h"
#include "libavutil/time.h"
#include "riff.h"
#include "audiointerleave.h"
#include "url.h"
#include <stdarg.h>
#include <assert.h>

Go to the source code of this file.

Functions

static void frac_init (AVFrac *f, int64_t val, int64_t num, int64_t den)
 f = val + (num / den) + 0.5. More...
 
static void frac_add (AVFrac *f, int64_t incr)
 Fractional addition to f: f = f + (incr / f->den). More...
 
static int validate_codec_tag (AVFormatContext *s, AVStream *st)
 
static int init_muxer (AVFormatContext *s, AVDictionary **options)
 
static int init_pts (AVFormatContext *s)
 
int avformat_write_header (AVFormatContext *s, AVDictionary **options)
 Allocate the stream private data and write the stream header to an output media file. More...
 
static int compute_pkt_fields2 (AVFormatContext *s, AVStream *st, AVPacket *pkt)
 
int av_write_frame (AVFormatContext *s, AVPacket *pkt)
 Write a packet to an output media file. More...
 
void ff_interleave_add_packet (AVFormatContext *s, AVPacket *pkt, int(*compare)(AVFormatContext *, AVPacket *, AVPacket *))
 Add packet to AVFormatContext->packet_buffer list, determining its interleaved position using compare() function argument. More...
 
static int ff_interleave_compare_dts (AVFormatContext *s, AVPacket *next, AVPacket *pkt)
 
int ff_interleave_packet_per_dts (AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 Interleave a packet per dts in an output media file. More...
 
static int interleave_packet (AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
 Interleave an AVPacket correctly so it can be muxed. More...
 
int av_interleaved_write_frame (AVFormatContext *s, AVPacket *pkt)
 Write a packet to an output media file ensuring correct interleaving. More...
 
int av_write_trailer (AVFormatContext *s)
 Write the stream trailer to an output media file and free the file private data. More...
 

Detailed Description

muxing functions for use within Libav

Definition in file mux.c.

Function Documentation

static int compute_pkt_fields2 ( AVFormatContext s,
AVStream st,
AVPacket pkt 
)
static

Definition at line 315 of file mux.c.

Referenced by av_interleaved_write_frame(), and av_write_frame().

void ff_interleave_add_packet ( AVFormatContext s,
AVPacket pkt,
int(*)(AVFormatContext *, AVPacket *, AVPacket *)  compare 
)

Add packet to AVFormatContext->packet_buffer list, determining its interleaved position using compare() function argument.

Definition at line 416 of file mux.c.

Referenced by ff_audio_rechunk_interleave(), and ff_interleave_packet_per_dts().

static int ff_interleave_compare_dts ( AVFormatContext s,
AVPacket next,
AVPacket pkt 
)
static

Definition at line 451 of file mux.c.

Referenced by ff_interleave_packet_per_dts().

int ff_interleave_packet_per_dts ( AVFormatContext s,
AVPacket out,
AVPacket pkt,
int  flush 
)

Interleave a packet per dts in an output media file.

Packets with pkt->destruct == av_destruct_packet will be freed inside this function, so they cannot be used after it. Note that calling av_free_packet() on them is still safe.

Parameters
smedia file handle
outthe interleaved packet will be output here
pktthe input packet
flush1 if no further packets are available as input and all remaining packets should be output
Returns
1 if a packet was output, 0 if no packet could be output, < 0 if an error occurred

Definition at line 463 of file mux.c.

Referenced by gxf_interleave_packet(), and interleave_packet().

static void frac_add ( AVFrac f,
int64_t  incr 
)
static

Fractional addition to f: f = f + (incr / f->den).

Parameters
ffractional number
incrincrement, can be positive or negative

Definition at line 85 of file mux.c.

Referenced by compute_pkt_fields2().

static void frac_init ( AVFrac f,
int64_t  val,
int64_t  num,
int64_t  den 
)
static

f = val + (num / den) + 0.5.

'num' is normalized so that it is such as 0 <= num < den.

Parameters
ffractional number
valinteger value
nummust be >= 0
denmust be >= 1

Definition at line 67 of file mux.c.

Referenced by init_pts().

static int init_muxer ( AVFormatContext s,
AVDictionary **  options 
)
static

Definition at line 139 of file mux.c.

Referenced by avformat_write_header().

static int init_pts ( AVFormatContext s)
static

Definition at line 264 of file mux.c.

Referenced by avformat_write_header().

static int interleave_packet ( AVFormatContext s,
AVPacket out,
AVPacket in,
int  flush 
)
static

Interleave an AVPacket correctly so it can be muxed.

Parameters
outthe interleaved packet will be output here
inthe input packet
flush1 if no further packets are available as input and all remaining packets should be output
Returns
1 if a packet was output, 0 if no packet could be output, < 0 if an error occurred

Definition at line 513 of file mux.c.

Referenced by av_interleaved_write_frame(), and av_write_trailer().

static int validate_codec_tag ( AVFormatContext s,
AVStream st 
)
static

Check that tag + id is in the table If neither is in the table -> OK If tag is in the table with another id -> FAIL If id is in the table with another tag -> FAIL unless strict < normal

Definition at line 105 of file mux.c.

Referenced by init_muxer().