FFmpeg
Data Structures | Macros | Functions | Variables
ffmpeg_demux.c File Reference
#include <float.h>
#include <stdint.h>
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/display.h"
#include "libavutil/error.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/time.h"
#include "libavutil/timestamp.h"
#include "libavcodec/bsf.h"
#include "libavcodec/packet.h"
#include "libavformat/avformat.h"

Go to the source code of this file.

Data Structures

struct  DemuxStream
 
struct  Demuxer
 
struct  DemuxThreadContext
 

Macros

#define DECODING_FOR_OST   1
 
#define DECODING_FOR_FILTER   2
 
#define SHOW_TS_DEBUG(tag_)
 

Functions

static DemuxStreamds_from_ist (InputStream *ist)
 
static Demuxerdemuxer_from_ifile (InputFile *f)
 
InputStreamist_find_unused (enum AVMediaType type)
 Find an unused input stream of given type. More...
 
static void report_new_stream (Demuxer *d, const AVPacket *pkt)
 
static int seek_to_start (Demuxer *d, Timestamp end_pts)
 
static void ts_discontinuity_detect (Demuxer *d, InputStream *ist, AVPacket *pkt)
 
static void ts_discontinuity_process (Demuxer *d, InputStream *ist, AVPacket *pkt)
 
static int ist_dts_update (DemuxStream *ds, AVPacket *pkt, FrameData *fd)
 
static int ts_fixup (Demuxer *d, AVPacket *pkt, FrameData *fd)
 
static int input_packet_process (Demuxer *d, AVPacket *pkt, unsigned *send_flags)
 
static void readrate_sleep (Demuxer *d)
 
static int do_send (Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags, const char *pkt_desc)
 
static int demux_send (Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds, AVPacket *pkt, unsigned flags)
 
static int demux_bsf_flush (Demuxer *d, DemuxThreadContext *dt)
 
static void discard_unused_programs (InputFile *ifile)
 
static void thread_set_name (InputFile *f)
 
static void demux_thread_uninit (DemuxThreadContext *dt)
 
static int demux_thread_init (DemuxThreadContext *dt)
 
static void * input_thread (void *arg)
 
static void demux_final_stats (Demuxer *d)
 
static void ist_free (InputStream **pist)
 
void ifile_close (InputFile **pf)
 
static int ist_use (InputStream *ist, int decoding_needed)
 
int ist_output_add (InputStream *ist, OutputStream *ost)
 
int ist_filter_add (InputStream *ist, InputFilter *ifilter, int is_simple, InputFilterOptions *opts)
 
static int choose_decoder (const OptionsContext *o, AVFormatContext *s, AVStream *st, enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type, const AVCodec **pcodec)
 
static int guess_input_channel_layout (InputStream *ist, AVCodecParameters *par, int guess_layout_max)
 
static int add_display_matrix_to_stream (const OptionsContext *o, AVFormatContext *ctx, InputStream *ist)
 
static const char * input_stream_item_name (void *obj)
 
static DemuxStreamdemux_stream_alloc (Demuxer *d, AVStream *st)
 
static int ist_add (const OptionsContext *o, Demuxer *d, AVStream *st)
 
static int dump_attachment (InputStream *ist, const char *filename)
 
static const char * input_file_item_name (void *obj)
 
static Demuxerdemux_alloc (void)
 
int ifile_open (const OptionsContext *o, const char *filename, Scheduler *sch)
 

Variables

static const AVClass input_stream_class
 
static const AVClass input_file_class
 

Macro Definition Documentation

◆ DECODING_FOR_OST

#define DECODING_FOR_OST   1

Definition at line 55 of file ffmpeg_demux.c.

◆ DECODING_FOR_FILTER

#define DECODING_FOR_FILTER   2

Definition at line 56 of file ffmpeg_demux.c.

◆ SHOW_TS_DEBUG

#define SHOW_TS_DEBUG (   tag_)
Value:
if (debug_ts) { \
av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \
"pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \
tag_, ifile->index, pkt->stream_index, \
av_get_media_type_string(ist->st->codecpar->codec_type), \
}

Function Documentation

◆ ds_from_ist()

static DemuxStream* ds_from_ist ( InputStream ist)
static

◆ demuxer_from_ifile()

static Demuxer* demuxer_from_ifile ( InputFile f)
static

Definition at line 146 of file ffmpeg_demux.c.

Referenced by ifile_close(), ist_filter_add(), and ist_use().

◆ ist_find_unused()

InputStream* ist_find_unused ( enum AVMediaType  type)

Find an unused input stream of given type.

Definition at line 151 of file ffmpeg_demux.c.

Referenced by init_input_filter().

◆ report_new_stream()

static void report_new_stream ( Demuxer d,
const AVPacket pkt 
)
static

Definition at line 162 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ seek_to_start()

static int seek_to_start ( Demuxer d,
Timestamp  end_pts 
)
static

Definition at line 175 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ ts_discontinuity_detect()

static void ts_discontinuity_detect ( Demuxer d,
InputStream ist,
AVPacket pkt 
)
static

Definition at line 202 of file ffmpeg_demux.c.

Referenced by ts_discontinuity_process().

◆ ts_discontinuity_process()

static void ts_discontinuity_process ( Demuxer d,
InputStream ist,
AVPacket pkt 
)
static

Definition at line 270 of file ffmpeg_demux.c.

Referenced by ts_fixup().

◆ ist_dts_update()

static int ist_dts_update ( DemuxStream ds,
AVPacket pkt,
FrameData fd 
)
static

Definition at line 290 of file ffmpeg_demux.c.

Referenced by ts_fixup().

◆ ts_fixup()

static int ts_fixup ( Demuxer d,
AVPacket pkt,
FrameData fd 
)
static

Definition at line 350 of file ffmpeg_demux.c.

Referenced by input_packet_process().

◆ input_packet_process()

static int input_packet_process ( Demuxer d,
AVPacket pkt,
unsigned *  send_flags 
)
static

Definition at line 441 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ readrate_sleep()

static void readrate_sleep ( Demuxer d)
static

Definition at line 485 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ do_send()

static int do_send ( Demuxer d,
DemuxStream ds,
AVPacket pkt,
unsigned  flags,
const char *  pkt_desc 
)
static

Definition at line 505 of file ffmpeg_demux.c.

Referenced by demux_send().

◆ demux_send()

static int demux_send ( Demuxer d,
DemuxThreadContext dt,
DemuxStream ds,
AVPacket pkt,
unsigned  flags 
)
static

Definition at line 534 of file ffmpeg_demux.c.

Referenced by demux_bsf_flush(), and input_thread().

◆ demux_bsf_flush()

static int demux_bsf_flush ( Demuxer d,
DemuxThreadContext dt 
)
static

Definition at line 603 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ discard_unused_programs()

static void discard_unused_programs ( InputFile ifile)
static

Definition at line 628 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ thread_set_name()

static void thread_set_name ( InputFile f)
static

Definition at line 646 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_uninit()

static void demux_thread_uninit ( DemuxThreadContext dt)
static

Definition at line 653 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_init()

static int demux_thread_init ( DemuxThreadContext dt)
static

Definition at line 661 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ input_thread()

static void* input_thread ( void *  arg)
static

Definition at line 676 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ demux_final_stats()

static void demux_final_stats ( Demuxer d)
static

Definition at line 784 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ist_free()

static void ist_free ( InputStream **  pist)
static

Definition at line 824 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ifile_close()

void ifile_close ( InputFile **  pf)

Definition at line 847 of file ffmpeg_demux.c.

Referenced by ffmpeg_cleanup().

◆ ist_use()

static int ist_use ( InputStream ist,
int  decoding_needed 
)
static

Definition at line 869 of file ffmpeg_demux.c.

Referenced by ist_filter_add(), and ist_output_add().

◆ ist_output_add()

int ist_output_add ( InputStream ist,
OutputStream ost 
)

Definition at line 955 of file ffmpeg_demux.c.

Referenced by ost_add().

◆ ist_filter_add()

int ist_filter_add ( InputStream ist,
InputFilter ifilter,
int  is_simple,
InputFilterOptions opts 
)

Definition at line 973 of file ffmpeg_demux.c.

Referenced by ifilter_bind_ist().

◆ choose_decoder()

static int choose_decoder ( const OptionsContext o,
AVFormatContext s,
AVStream st,
enum HWAccelID  hwaccel_id,
enum AVHWDeviceType  hwaccel_device_type,
const AVCodec **  pcodec 
)
static

Definition at line 1049 of file ffmpeg_demux.c.

Referenced by ifile_open(), and ist_add().

◆ guess_input_channel_layout()

static int guess_input_channel_layout ( InputStream ist,
AVCodecParameters par,
int  guess_layout_max 
)
static

Definition at line 1095 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ add_display_matrix_to_stream()

static int add_display_matrix_to_stream ( const OptionsContext o,
AVFormatContext ctx,
InputStream ist 
)
static

Definition at line 1112 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ input_stream_item_name()

static const char* input_stream_item_name ( void *  obj)
static

Definition at line 1153 of file ffmpeg_demux.c.

◆ demux_stream_alloc()

static DemuxStream* demux_stream_alloc ( Demuxer d,
AVStream st 
)
static

Definition at line 1167 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ ist_add()

static int ist_add ( const OptionsContext o,
Demuxer d,
AVStream st 
)
static

Definition at line 1192 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ dump_attachment()

static int dump_attachment ( InputStream ist,
const char *  filename 
)
static

Definition at line 1441 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ input_file_item_name()

static const char* input_file_item_name ( void *  obj)
static

Definition at line 1479 of file ffmpeg_demux.c.

◆ demux_alloc()

static Demuxer* demux_alloc ( void  )
static

Definition at line 1493 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ ifile_open()

int ifile_open ( const OptionsContext o,
const char *  filename,
Scheduler sch 
)

Definition at line 1508 of file ffmpeg_demux.c.

Variable Documentation

◆ input_stream_class

const AVClass input_stream_class
static
Initial value:
= {
.class_name = "InputStream",
.item_name = input_stream_item_name,
}

Definition at line 1160 of file ffmpeg_demux.c.

Referenced by demux_stream_alloc().

◆ input_file_class

const AVClass input_file_class
static
Initial value:
= {
.class_name = "InputFile",
.item_name = input_file_item_name,
}

Definition at line 1486 of file ffmpeg_demux.c.

Referenced by demux_alloc().

AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:540
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:76
input_file_item_name
static const char * input_file_item_name(void *obj)
Definition: ffmpeg_demux.c:1479
pkt
AVPacket * pkt
Definition: movenc.c:59
input_stream_item_name
static const char * input_stream_item_name(void *obj)
Definition: ffmpeg_demux.c:1153
AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_DEMUXER
Definition: log.h:33
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:77
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
av_get_media_type_string
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:28
AVPacket::stream_index
int stream_index
Definition: packet.h:524
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:566