FFmpeg
Data Structures | Macros | Functions | Variables
ffmpeg_demux.c File Reference
#include <float.h>
#include <stdint.h>
#include "ffmpeg.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 "libavutil/thread.h"
#include "libavutil/threadmessage.h"
#include "libavcodec/packet.h"
#include "libavformat/avformat.h"

Go to the source code of this file.

Data Structures

struct  DemuxStream
 
struct  Demuxer
 
struct  DemuxMsg
 

Macros

#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 void ifile_duration_update (Demuxer *d, DemuxStream *ds, int64_t last_duration)
 
static int seek_to_start (Demuxer *d)
 
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)
 
static int ts_fixup (Demuxer *d, AVPacket *pkt)
 
static int input_packet_process (Demuxer *d, DemuxMsg *msg, AVPacket *src)
 
static void readrate_sleep (Demuxer *d)
 
static void discard_unused_programs (InputFile *ifile)
 
static void thread_set_name (InputFile *f)
 
static void * input_thread (void *arg)
 
static void thread_stop (Demuxer *d)
 
static int thread_start (Demuxer *d)
 
int ifile_get_packet (InputFile *f, AVPacket **pkt)
 Get next input packet from the demuxer. More...
 
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)
 
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, 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)
 

Variables

static const char *const opt_name_discard [] = {"discard", NULL}
 
static const char *const opt_name_reinit_filters [] = {"reinit_filter", NULL}
 
static const char *const opt_name_fix_sub_duration [] = {"fix_sub_duration", NULL}
 
static const char *const opt_name_canvas_sizes [] = {"canvas_size", NULL}
 
static const char *const opt_name_guess_layout_max [] = {"guess_layout_max", NULL}
 
static const char *const opt_name_ts_scale [] = {"itsscale", NULL}
 
static const char *const opt_name_hwaccels [] = {"hwaccel", NULL}
 
static const char *const opt_name_hwaccel_devices [] = {"hwaccel_device", NULL}
 
static const char *const opt_name_hwaccel_output_formats [] = {"hwaccel_output_format", NULL}
 
static const char *const opt_name_autorotate [] = {"autorotate", NULL}
 
static const char *const opt_name_display_rotations [] = {"display_rotation", NULL}
 
static const char *const opt_name_display_hflips [] = {"display_hflip", NULL}
 
static const char *const opt_name_display_vflips [] = {"display_vflip", NULL}
 
static const AVClass input_stream_class
 
static const AVClass input_file_class
 

Macro Definition Documentation

◆ 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 130 of file ffmpeg_demux.c.

Referenced by ifile_close(), and ifile_get_packet().

◆ ist_find_unused()

InputStream* ist_find_unused ( enum AVMediaType  type)

Find an unused input stream of given type.

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

Referenced by input_thread().

◆ ifile_duration_update()

static void ifile_duration_update ( Demuxer d,
DemuxStream ds,
int64_t  last_duration 
)
static

Definition at line 158 of file ffmpeg_demux.c.

Referenced by seek_to_start().

◆ seek_to_start()

static int seek_to_start ( Demuxer d)
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 226 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 294 of file ffmpeg_demux.c.

Referenced by ts_fixup().

◆ ist_dts_update()

static int ist_dts_update ( DemuxStream ds,
AVPacket pkt 
)
static

Definition at line 314 of file ffmpeg_demux.c.

Referenced by ts_fixup().

◆ ts_fixup()

static int ts_fixup ( Demuxer d,
AVPacket pkt 
)
static

Definition at line 384 of file ffmpeg_demux.c.

Referenced by input_packet_process().

◆ input_packet_process()

static int input_packet_process ( Demuxer d,
DemuxMsg msg,
AVPacket src 
)
static

Definition at line 461 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ readrate_sleep()

static void readrate_sleep ( Demuxer d)
static

Definition at line 503 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ discard_unused_programs()

static void discard_unused_programs ( InputFile ifile)
static

Definition at line 523 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ thread_set_name()

static void thread_set_name ( InputFile f)
static

Definition at line 538 of file ffmpeg_demux.c.

Referenced by input_thread().

◆ input_thread()

static void* input_thread ( void *  arg)
static

Definition at line 545 of file ffmpeg_demux.c.

Referenced by thread_start().

◆ thread_stop()

static void thread_stop ( Demuxer d)
static

Definition at line 658 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ thread_start()

static int thread_start ( Demuxer d)
static

Definition at line 674 of file ffmpeg_demux.c.

Referenced by ifile_get_packet().

◆ ifile_get_packet()

int ifile_get_packet ( InputFile f,
AVPacket **  pkt 
)

Get next input packet from the demuxer.

Parameters
pktthe packet is written here when this function returns 0
Returns
  • 0 when a packet has been read successfully
  • 1 when stream end was reached, but the stream is looped; caller should flush decoders and read from this demuxer again
  • a negative error code on failure

Definition at line 723 of file ffmpeg_demux.c.

Referenced by process_input().

◆ demux_final_stats()

static void demux_final_stats ( Demuxer d)
static

Definition at line 747 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ist_free()

static void ist_free ( InputStream **  pist)
static

Definition at line 787 of file ffmpeg_demux.c.

Referenced by ifile_close().

◆ ifile_close()

void ifile_close ( InputFile **  pf)

Definition at line 807 of file ffmpeg_demux.c.

Referenced by ffmpeg_cleanup().

◆ ist_use()

static int ist_use ( InputStream ist,
int  decoding_needed 
)
static

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

Referenced by ost_add().

◆ ist_filter_add()

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

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

Referenced by ifile_open(), and ist_add().

◆ guess_input_channel_layout()

static int guess_input_channel_layout ( InputStream ist,
int  guess_layout_max 
)
static

Definition at line 938 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 956 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 997 of file ffmpeg_demux.c.

◆ demux_stream_alloc()

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

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

Referenced by ifile_open().

◆ dump_attachment()

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

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

◆ demux_alloc()

static Demuxer* demux_alloc ( void  )
static

Definition at line 1335 of file ffmpeg_demux.c.

Referenced by ifile_open().

◆ ifile_open()

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

Definition at line 1350 of file ffmpeg_demux.c.

Variable Documentation

◆ opt_name_discard

const char* const opt_name_discard[] = {"discard", NULL}
static

Definition at line 41 of file ffmpeg_demux.c.

◆ opt_name_reinit_filters

const char* const opt_name_reinit_filters[] = {"reinit_filter", NULL}
static

Definition at line 42 of file ffmpeg_demux.c.

◆ opt_name_fix_sub_duration

const char* const opt_name_fix_sub_duration[] = {"fix_sub_duration", NULL}
static

Definition at line 43 of file ffmpeg_demux.c.

◆ opt_name_canvas_sizes

const char* const opt_name_canvas_sizes[] = {"canvas_size", NULL}
static

Definition at line 44 of file ffmpeg_demux.c.

◆ opt_name_guess_layout_max

const char* const opt_name_guess_layout_max[] = {"guess_layout_max", NULL}
static

Definition at line 45 of file ffmpeg_demux.c.

◆ opt_name_ts_scale

const char* const opt_name_ts_scale[] = {"itsscale", NULL}
static

Definition at line 46 of file ffmpeg_demux.c.

◆ opt_name_hwaccels

const char* const opt_name_hwaccels[] = {"hwaccel", NULL}
static

Definition at line 47 of file ffmpeg_demux.c.

◆ opt_name_hwaccel_devices

const char* const opt_name_hwaccel_devices[] = {"hwaccel_device", NULL}
static

Definition at line 48 of file ffmpeg_demux.c.

◆ opt_name_hwaccel_output_formats

const char* const opt_name_hwaccel_output_formats[] = {"hwaccel_output_format", NULL}
static

Definition at line 49 of file ffmpeg_demux.c.

◆ opt_name_autorotate

const char* const opt_name_autorotate[] = {"autorotate", NULL}
static

Definition at line 50 of file ffmpeg_demux.c.

◆ opt_name_display_rotations

const char* const opt_name_display_rotations[] = {"display_rotation", NULL}
static

Definition at line 51 of file ffmpeg_demux.c.

◆ opt_name_display_hflips

const char* const opt_name_display_hflips[] = {"display_hflip", NULL}
static

Definition at line 52 of file ffmpeg_demux.c.

◆ opt_name_display_vflips

const char* const opt_name_display_vflips[] = {"display_vflip", NULL}
static

Definition at line 53 of file ffmpeg_demux.c.

◆ input_stream_class

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

Definition at line 1004 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 1328 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:509
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:81
input_file_item_name
static const char * input_file_item_name(void *obj)
Definition: ffmpeg_demux.c:1321
pkt
AVPacket * pkt
Definition: movenc.c:59
input_stream_item_name
static const char * input_stream_item_name(void *obj)
Definition: ffmpeg_demux.c:997
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:76
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:490
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:484
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:493
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:535