FFmpeg
Loading...
Searching...
No Matches
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/mastering_display_metadata.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  DemuxStreamGroup
 
struct  DemuxStream
 
struct  Demuxer
 
struct  DemuxThreadContext
 

Macros

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

Functions

static DemuxStreamGroupdsg_from_istg (InputStreamGroup *istg)
 
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.
 
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 do_bsf_graph (Demuxer *d, DemuxThreadContext *dt, DemuxStreamGroup *dsg, DemuxStream *ds, AVPacket *pkt)
 
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)
 
static void istg_free (InputStreamGroup **pistg)
 
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 int add_mastering_display_to_stream (const OptionsContext *o, AVFormatContext *ctx, InputStream *ist)
 
static int add_content_light_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 const char * input_stream_group_item_name (void *obj)
 
static DemuxStreamGroupdemux_stream_group_alloc (Demuxer *d, AVStreamGroup *stg)
 
static int istg_parse_tile_grid (const OptionsContext *o, Demuxer *d, InputStreamGroup *istg)
 
static int istg_parse_lcevc (const OptionsContext *o, Demuxer *d, DemuxStreamGroup *dsg)
 
static int istg_add (const OptionsContext *o, Demuxer *d, AVStreamGroup *stg)
 
static int is_windows_reserved_device_name (const char *f)
 
static int safe_filename (const char *f, int allow_subdir)
 
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_stream_group_class
 
static const AVClass input_file_class
 

Macro Definition Documentation

◆ DECODING_FOR_OST

#define DECODING_FOR_OST   1

Definition at line 70 of file ffmpeg_demux.c.

Referenced by ist_filter_add(), and ist_use().

◆ DECODING_FOR_FILTER

#define DECODING_FOR_FILTER   2

Definition at line 71 of file ffmpeg_demux.c.

Referenced by ist_filter_add(), and ist_use().

◆ 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), \
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \
}
static AVPacket * pkt
int debug_ts
Definition ffmpeg_opt.c:67
#define AV_LOG_INFO
Standard information.
Definition log.h:221
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
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition timestamp.h:54
#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

Referenced by ts_fixup().

Function Documentation

◆ dsg_from_istg()

static DemuxStreamGroup * dsg_from_istg ( InputStreamGroup * istg)
static

Definition at line 176 of file ffmpeg_demux.c.

Referenced by istg_free().

◆ ds_from_ist()

◆ demuxer_from_ifile()

static Demuxer * demuxer_from_ifile ( InputFile * f)
static

Definition at line 186 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 191 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 202 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 215 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 242 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 310 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 330 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 390 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 481 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ readrate_sleep()

static void readrate_sleep ( Demuxer * d)
static

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

Referenced by demux_send(), and do_bsf_graph().

◆ do_bsf_graph()

static int do_bsf_graph ( Demuxer * d,
DemuxThreadContext * dt,
DemuxStreamGroup * dsg,
DemuxStream * ds,
AVPacket * pkt )
static

Definition at line 615 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 673 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 759 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ discard_unused_programs()

static void discard_unused_programs ( InputFile * ifile)
static

Definition at line 795 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ thread_set_name()

static void thread_set_name ( InputFile * f)
static

Definition at line 813 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_uninit()

static void demux_thread_uninit ( DemuxThreadContext * dt)
static

Definition at line 820 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ demux_thread_init()

static int demux_thread_init ( DemuxThreadContext * dt)
static

Definition at line 828 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ input_thread()

static int input_thread ( void * arg)
static

Definition at line 843 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ demux_final_stats()

static void demux_final_stats ( Demuxer * d)
static

Definition at line 951 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ist_free()

static void ist_free ( InputStream ** pist)
static

Definition at line 991 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ istg_free()

static void istg_free ( InputStreamGroup ** pistg)
static

Definition at line 1016 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ifile_close()

void ifile_close ( InputFile ** pf)

Definition at line 1031 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 1057 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 1210 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 1308 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 1355 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 1372 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ add_mastering_display_to_stream()

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

Definition at line 1416 of file ffmpeg_demux.c.

Referenced by ist_add().

◆ add_content_light_to_stream()

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

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

◆ demux_stream_alloc()

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

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

Referenced by ifile_open().

◆ input_stream_group_item_name()

static const char * input_stream_group_item_name ( void * obj)
static

Definition at line 1911 of file ffmpeg_demux.c.

◆ demux_stream_group_alloc()

static DemuxStreamGroup * demux_stream_group_alloc ( Demuxer * d,
AVStreamGroup * stg )
static

Definition at line 1925 of file ffmpeg_demux.c.

Referenced by istg_add().

◆ istg_parse_tile_grid()

static int istg_parse_tile_grid ( const OptionsContext * o,
Demuxer * d,
InputStreamGroup * istg )
static

Definition at line 1945 of file ffmpeg_demux.c.

Referenced by istg_add().

◆ istg_parse_lcevc()

static int istg_parse_lcevc ( const OptionsContext * o,
Demuxer * d,
DemuxStreamGroup * dsg )
static

Definition at line 2029 of file ffmpeg_demux.c.

Referenced by istg_add().

◆ istg_add()

static int istg_add ( const OptionsContext * o,
Demuxer * d,
AVStreamGroup * stg )
static

Definition at line 2080 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ is_windows_reserved_device_name()

static int is_windows_reserved_device_name ( const char * f)
static

Definition at line 2124 of file ffmpeg_demux.c.

Referenced by safe_filename().

◆ safe_filename()

static int safe_filename ( const char * f,
int allow_subdir )
static

Definition at line 2152 of file ffmpeg_demux.c.

Referenced by add_file(), and dump_attachment().

◆ dump_attachment()

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

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

◆ demux_alloc()

static Demuxer * demux_alloc ( void )
static

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

Referenced by ffmpeg_parse_options().

Variable Documentation

◆ input_stream_class

const AVClass input_stream_class
static
Initial value:
= {
.class_name = "InputStream",
.item_name = input_stream_item_name,
}
static const char * input_stream_item_name(void *obj)
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
@ AV_CLASS_CATEGORY_DEMUXER
Definition log.h:33

Definition at line 1542 of file ffmpeg_demux.c.

Referenced by demux_stream_alloc().

◆ input_stream_group_class

const AVClass input_stream_group_class
static
Initial value:
= {
.class_name = "InputStreamGroup",
}
static const char * input_stream_group_item_name(void *obj)

Definition at line 1918 of file ffmpeg_demux.c.

Referenced by demux_stream_group_alloc().

◆ input_file_class

const AVClass input_file_class
static
Initial value:
= {
.class_name = "InputFile",
.item_name = input_file_item_name,
}
static const char * input_file_item_name(void *obj)

Definition at line 2224 of file ffmpeg_demux.c.

Referenced by demux_alloc().