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/mem.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 int input_thread (void *arg)
 
static void demux_final_stats (Demuxer *d)
 
static void ist_free (InputStream **pist)
 
void ifile_close (InputFile **pf)
 
int ist_use (InputStream *ist, int decoding_needed, const ViewSpecifier *vs, SchedulerNode *src)
 
int ist_filter_add (InputStream *ist, InputFilter *ifilter, int is_simple, const ViewSpecifier *vs, InputFilterOptions *opts, SchedulerNode *src)
 
static int choose_decoder (const OptionsContext *o, void *logctx, 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, AVDictionary **opts_used)
 
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 56 of file ffmpeg_demux.c.

◆ DECODING_FOR_FILTER

#define DECODING_FOR_FILTER   2

Definition at line 57 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 152 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 157 of file ffmpeg_demux.c.

Referenced by fg_complex_bind_input().

◆ report_new_stream()

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

Definition at line 168 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 181 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 208 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 276 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 296 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 356 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 447 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ readrate_sleep()

static void readrate_sleep ( Demuxer d)
static

Definition at line 491 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 511 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 540 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 609 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ discard_unused_programs()

static void discard_unused_programs ( InputFile ifile)
static

Definition at line 634 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ thread_set_name()

static void thread_set_name ( InputFile f)
static

Definition at line 652 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_uninit()

static void demux_thread_uninit ( DemuxThreadContext dt)
static

Definition at line 659 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_init()

static int demux_thread_init ( DemuxThreadContext dt)
static

Definition at line 667 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ input_thread()

static int input_thread ( void *  arg)
static

Definition at line 682 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ demux_final_stats()

static void demux_final_stats ( Demuxer d)
static

Definition at line 790 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ist_free()

static void ist_free ( InputStream **  pist)
static

Definition at line 830 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ifile_close()

void ifile_close ( InputFile **  pf)

Definition at line 854 of file ffmpeg_demux.c.

Referenced by ffmpeg_cleanup().

◆ ist_use()

int ist_use ( InputStream ist,
int  decoding_needed,
const ViewSpecifier vs,
SchedulerNode src 
)

Definition at line 876 of file ffmpeg_demux.c.

Referenced by ist_filter_add(), and ost_add().

◆ ist_filter_add()

int ist_filter_add ( InputStream ist,
InputFilter ifilter,
int  is_simple,
const ViewSpecifier vs,
InputFilterOptions opts,
SchedulerNode src 
)

Definition at line 977 of file ffmpeg_demux.c.

Referenced by ifilter_bind_ist().

◆ choose_decoder()

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

Definition at line 1074 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 1121 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 1138 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 1179 of file ffmpeg_demux.c.

◆ demux_stream_alloc()

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

Definition at line 1193 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ ist_add()

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

Definition at line 1218 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ dump_attachment()

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

Definition at line 1521 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 1559 of file ffmpeg_demux.c.

◆ demux_alloc()

static Demuxer* demux_alloc ( void  )
static

Definition at line 1573 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 1588 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 1186 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 1566 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:557
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:70
input_file_item_name
static const char * input_file_item_name(void *obj)
Definition: ffmpeg_demux.c:1559
pkt
AVPacket * pkt
Definition: movenc.c:60
input_stream_item_name
static const char * input_stream_item_name(void *obj)
Definition: ffmpeg_demux.c:1179
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:83
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:538
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:220
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:532
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:541
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:583