FFmpeg
Loading...
Searching...
No Matches
concatdec.c File Reference
#include "libavutil/attributes_internal.h"
#include "libavutil/avstring.h"
#include "libavutil/avassert.h"
#include "libavutil/bprint.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/timestamp.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/bsf.h"
#include "avformat.h"
#include "avio_internal.h"
#include "demux.h"
#include "internal.h"
#include "url.h"

Go to the source code of this file.

Data Structures

struct  ConcatStream
 
struct  ConcatFile
 
struct  ConcatContext
 
struct  ParseSyntax
 

Macros

#define FAIL(retcode)
 
#define MAX_ARGS   3
 
#define NEEDS_UNSAFE   (1 << 0)
 
#define NEEDS_FILE   (1 << 1)
 
#define NEEDS_STREAM   (1 << 2)
 
#define OFFSET(x)
 
#define DEC   AV_OPT_FLAG_DECODING_PARAM
 

Enumerations

enum  ConcatMatchMode { MATCH_ONE_TO_ONE , MATCH_EXACT_ID }
 
enum  ParseDirective {
  DIR_FFCONCAT , DIR_FILE , DIR_DURATION , DIR_INPOINT ,
  DIR_OUTPOINT , DIR_FPMETA , DIR_FPMETAS , DIR_OPTION ,
  DIR_STREAM , DIR_EXSID , DIR_STMETA , DIR_STCODEC ,
  DIR_STEDATA , DIR_CHAPTER
}
 

Functions

static int concat_probe (const AVProbeData *probe)
 
static char * get_keyword (uint8_t **cursor)
 
static int safe_filename (const char *f)
 
static int add_file (AVFormatContext *avf, char *filename, ConcatFile **rfile, unsigned *nb_files_alloc)
 
static int copy_stream_props (AVStream *st, AVStream *source_st)
 
static int detect_stream_specific (AVFormatContext *avf, int idx)
 
static int match_streams_one_to_one (AVFormatContext *avf)
 
static int match_streams_exact_id (AVFormatContext *avf)
 
static int match_streams (AVFormatContext *avf)
 
static int64_t get_best_effort_duration (ConcatFile *file, AVFormatContext *avf)
 
static int probe_file (AVFormatContext *avf, unsigned fileno)
 
static int open_file (AVFormatContext *avf, unsigned fileno)
 
static int concat_read_close (AVFormatContext *avf)
 
static int concat_parse_script (AVFormatContext *avf)
 
static int compare_chapter_starts (const void *a, const void *b)
 
static int add_file_chapters (AVFormatContext *avf)
 
static int concat_read_header (AVFormatContext *avf)
 
static int open_next_file (AVFormatContext *avf)
 
static int filter_packet (AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
 
static int packet_after_outpoint (ConcatContext *cat, AVPacket *pkt)
 
static int concat_read_packet (AVFormatContext *avf, AVPacket *pkt)
 
static int try_seek (AVFormatContext *avf, int stream, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 
static int real_seek (AVFormatContext *avf, int stream, int64_t min_ts, int64_t ts, int64_t max_ts, int flags, AVFormatContext *cur_avf)
 
static int concat_seek (AVFormatContext *avf, int stream, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 

Variables

static const ParseSyntax syntax []
 
static const AVOption options []
 
static const AVClass concat_class
 
const FFInputFormat ff_concat_demuxer
 

Macro Definition Documentation

◆ FAIL

#define FAIL ( retcode)
Value:
do { ret = (retcode); goto fail; } while(0)
#define fail
Definition test.h:479

Definition at line 115 of file concatdec.c.

Referenced by add_file(), and concat_parse_script().

◆ MAX_ARGS

#define MAX_ARGS   3

Definition at line 428 of file concatdec.c.

Referenced by concat_parse_script().

◆ NEEDS_UNSAFE

#define NEEDS_UNSAFE   (1 << 0)

Definition at line 429 of file concatdec.c.

Referenced by concat_parse_script().

◆ NEEDS_FILE

#define NEEDS_FILE   (1 << 1)

Definition at line 430 of file concatdec.c.

Referenced by concat_parse_script().

◆ NEEDS_STREAM

#define NEEDS_STREAM   (1 << 2)

Definition at line 431 of file concatdec.c.

Referenced by concat_parse_script().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 989 of file concatdec.c.

◆ DEC

#define DEC   AV_OPT_FLAG_DECODING_PARAM

Definition at line 990 of file concatdec.c.

Enumeration Type Documentation

◆ ConcatMatchMode

Enumerator
MATCH_ONE_TO_ONE 
MATCH_EXACT_ID 

Definition at line 38 of file concatdec.c.

◆ ParseDirective

Enumerator
DIR_FFCONCAT 
DIR_FILE 
DIR_DURATION 
DIR_INPOINT 
DIR_OUTPOINT 
DIR_FPMETA 
DIR_FPMETAS 
DIR_OPTION 
DIR_STREAM 
DIR_EXSID 
DIR_STMETA 
DIR_STCODEC 
DIR_STEDATA 
DIR_CHAPTER 

Definition at line 439 of file concatdec.c.

Function Documentation

◆ concat_probe()

static int concat_probe ( const AVProbeData * probe)
static

Definition at line 79 of file concatdec.c.

◆ get_keyword()

static char * get_keyword ( uint8_t ** cursor)
static

Definition at line 85 of file concatdec.c.

Referenced by concat_parse_script().

◆ safe_filename()

static int safe_filename ( const char * f)
static

Definition at line 96 of file concatdec.c.

◆ add_file()

static int add_file ( AVFormatContext * avf,
char * filename,
ConcatFile ** rfile,
unsigned * nb_files_alloc )
static

Definition at line 117 of file concatdec.c.

Referenced by concat_parse_script().

◆ copy_stream_props()

static int copy_stream_props ( AVStream * st,
AVStream * source_st )
static

Definition at line 176 of file concatdec.c.

Referenced by match_streams_exact_id(), and match_streams_one_to_one().

◆ detect_stream_specific()

static int detect_stream_specific ( AVFormatContext * avf,
int idx )
static

Definition at line 203 of file concatdec.c.

Referenced by match_streams().

◆ match_streams_one_to_one()

static int match_streams_one_to_one ( AVFormatContext * avf)
static

Definition at line 245 of file concatdec.c.

Referenced by match_streams().

◆ match_streams_exact_id()

static int match_streams_exact_id ( AVFormatContext * avf)
static

Definition at line 265 of file concatdec.c.

Referenced by match_streams().

◆ match_streams()

static int match_streams ( AVFormatContext * avf)
static

Definition at line 287 of file concatdec.c.

Referenced by concat_read_packet(), and open_file().

◆ get_best_effort_duration()

static int64_t get_best_effort_duration ( ConcatFile * file,
AVFormatContext * avf )
static

Definition at line 324 of file concatdec.c.

Referenced by open_next_file(), and probe_file().

◆ probe_file()

static int probe_file ( AVFormatContext * avf,
unsigned fileno )
static

Definition at line 338 of file concatdec.c.

Referenced by add_file_chapters(), and open_file().

◆ open_file()

static int open_file ( AVFormatContext * avf,
unsigned fileno )
static

Definition at line 384 of file concatdec.c.

Referenced by concat_read_header(), open_files(), open_next_file(), and real_seek().

◆ concat_read_close()

static int concat_read_close ( AVFormatContext * avf)
static

Definition at line 407 of file concatdec.c.

◆ concat_parse_script()

static int concat_parse_script ( AVFormatContext * avf)
static

Definition at line 473 of file concatdec.c.

Referenced by concat_read_header().

◆ compare_chapter_starts()

static int compare_chapter_starts ( const void * a,
const void * b )
static

Definition at line 673 of file concatdec.c.

Referenced by add_file_chapters().

◆ add_file_chapters()

static int add_file_chapters ( AVFormatContext * avf)
static

Definition at line 680 of file concatdec.c.

Referenced by concat_read_header().

◆ concat_read_header()

static int concat_read_header ( AVFormatContext * avf)
static

Definition at line 715 of file concatdec.c.

◆ open_next_file()

static int open_next_file ( AVFormatContext * avf)
static

Definition at line 762 of file concatdec.c.

Referenced by concat_read_packet().

◆ filter_packet()

static int filter_packet ( AVFormatContext * avf,
ConcatStream * cs,
AVPacket * pkt )
static

Definition at line 776 of file concatdec.c.

Referenced by concat_read_packet().

◆ packet_after_outpoint()

static int packet_after_outpoint ( ConcatContext * cat,
AVPacket * pkt )
static

Definition at line 801 of file concatdec.c.

Referenced by concat_read_packet().

◆ concat_read_packet()

static int concat_read_packet ( AVFormatContext * avf,
AVPacket * pkt )
static

Definition at line 810 of file concatdec.c.

◆ try_seek()

static int try_seek ( AVFormatContext * avf,
int stream,
int64_t min_ts,
int64_t ts,
int64_t max_ts,
int flags )
static

Definition at line 894 of file concatdec.c.

Referenced by real_seek().

◆ real_seek()

static int real_seek ( AVFormatContext * avf,
int stream,
int64_t min_ts,
int64_t ts,
int64_t max_ts,
int flags,
AVFormatContext * cur_avf )
static

Definition at line 912 of file concatdec.c.

Referenced by concat_seek().

◆ concat_seek()

static int concat_seek ( AVFormatContext * avf,
int stream,
int64_t min_ts,
int64_t ts,
int64_t max_ts,
int flags )
static

Definition at line 962 of file concatdec.c.

Variable Documentation

◆ syntax

const ParseSyntax syntax[]
static
Initial value:
= {
[DIR_FFCONCAT ] = { "ffconcat", "kk", 0 },
[DIR_FILE ] = { "file", "s", 0 },
[DIR_DURATION ] = { "duration", "d", NEEDS_FILE },
[DIR_INPOINT ] = { "inpoint", "d", NEEDS_FILE },
[DIR_OUTPOINT ] = { "outpoint", "d", NEEDS_FILE },
[DIR_FPMETA ] = { "file_packet_meta", "ks", NEEDS_FILE },
[DIR_FPMETAS ] = { "file_packet_metadata", "s", NEEDS_FILE },
[DIR_OPTION ] = { "option", "ks", NEEDS_FILE | NEEDS_UNSAFE },
[DIR_STREAM ] = { "stream", "", 0 },
[DIR_EXSID ] = { "exact_stream_id", "i", NEEDS_STREAM },
[DIR_STMETA ] = { "stream_meta", "ks", NEEDS_STREAM },
[DIR_STCODEC ] = { "stream_codec", "k", NEEDS_STREAM },
[DIR_STEDATA ] = { "stream_extradata", "k", NEEDS_STREAM },
[DIR_CHAPTER ] = { "chapter", "idd", 0 },
}
#define NEEDS_FILE
Definition concatdec.c:430
#define NEEDS_STREAM
Definition concatdec.c:431
@ DIR_FPMETA
Definition concatdec.c:445
@ DIR_STCODEC
Definition concatdec.c:451
@ DIR_INPOINT
Definition concatdec.c:443
@ DIR_FPMETAS
Definition concatdec.c:446
@ DIR_STMETA
Definition concatdec.c:450
@ DIR_OUTPOINT
Definition concatdec.c:444
@ DIR_EXSID
Definition concatdec.c:449
@ DIR_FFCONCAT
Definition concatdec.c:440
@ DIR_STREAM
Definition concatdec.c:448
@ DIR_OPTION
Definition concatdec.c:447
@ DIR_STEDATA
Definition concatdec.c:452
@ DIR_DURATION
Definition concatdec.c:442
@ DIR_FILE
Definition concatdec.c:441
@ DIR_CHAPTER
Definition concatdec.c:453
#define NEEDS_UNSAFE
Definition concatdec.c:429

Definition at line 456 of file concatdec.c.

Referenced by concat_parse_script(), ebml_parse_nest(), and is_ebml_id_valid().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "safe", "enable safe mode",
OFFSET(safe), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
{ "auto_convert", "automatically convert bitstream format",
OFFSET(auto_convert), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC },
{ "segment_time_metadata", "output file segment start time and duration as packet metadata",
OFFSET(segment_time_metadata), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC },
{ "chapter_per_file", "add a chapter for each file, opening them all up front to learn their durations",
OFFSET(chapter_per_file), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC },
{ NULL }
}
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
#define DEC
Definition librsvgdec.c:149

Definition at line 992 of file concatdec.c.

◆ concat_class

const AVClass concat_class
static
Initial value:
= {
.class_name = "concat demuxer",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 1004 of file concatdec.c.

◆ ff_concat_demuxer

const FFInputFormat ff_concat_demuxer
Initial value:
= {
.p.name = "concat",
.p.long_name = NULL_IF_CONFIG_SMALL("Virtual concatenation script"),
.p.priv_class = &concat_class,
.priv_data_size = sizeof(ConcatContext),
.flags_internal = FF_INFMT_FLAG_INIT_CLEANUP,
.read_seek2 = concat_seek,
}
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
Definition concat.c:168
static int concat_read_header(AVFormatContext *avf)
Definition concatdec.c:715
static int concat_probe(const AVProbeData *probe)
Definition concatdec.c:79
static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
Definition concatdec.c:810
static const AVClass concat_class
Definition concatdec.c:1004
static int concat_read_close(AVFormatContext *avf)
Definition concatdec.c:407
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition demux.h:35
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143

Definition at line 1012 of file concatdec.c.