@@ -35,20 +35,20 @@
#include "thread_queue.h"
typedef struct DecoderPriv {
- Decoder dec;
+ Decoder dec;
- AVCodecContext *dec_ctx;
+ AVCodecContext *dec_ctx;
- AVFrame *frame;
- AVPacket *pkt;
+ AVFrame *frame;
+ AVPacket *pkt;
// override output video sample aspect ratio with this value
- AVRational sar_override;
+ AVRational sar_override;
- AVRational framerate_in;
+ AVRational framerate_in;
// a combination of DECODER_FLAG_*, provided to dec_open()
- int flags;
+ int flags;
enum AVPixelFormat hwaccel_pix_fmt;
enum HWAccelID hwaccel_id;
@@ -58,22 +58,22 @@ typedef struct DecoderPriv {
// pts/estimated duration of the last decoded frame
// * in decoder timebase for video,
// * in last_frame_tb (may change during decoding) for audio
- int64_t last_frame_pts;
- int64_t last_frame_duration_est;
- AVRational last_frame_tb;
- int64_t last_filter_in_rescale_delta;
- int last_frame_sample_rate;
+ int64_t last_frame_pts;
+ int64_t last_frame_duration_est;
+ AVRational last_frame_tb;
+ int64_t last_filter_in_rescale_delta;
+ int last_frame_sample_rate;
/* previous decoded subtitles */
- AVFrame *sub_prev[2];
- AVFrame *sub_heartbeat;
+ AVFrame *sub_prev[2];
+ AVFrame *sub_heartbeat;
- Scheduler *sch;
- unsigned sch_idx;
+ Scheduler *sch;
+ unsigned sch_idx;
- void *log_parent;
- char log_name[32];
- char *parent_name;
+ void *log_parent;
+ char log_name[32];
+ char *parent_name;
} DecoderPriv;
static DecoderPriv *dp_from_dec(Decoder *d)
@@ -40,41 +40,41 @@
#include "libavformat/avformat.h"
typedef struct DemuxStream {
- InputStream ist;
+ InputStream ist;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int sch_idx_stream;
- int sch_idx_dec;
+ int sch_idx_stream;
+ int sch_idx_dec;
- double ts_scale;
+ double ts_scale;
/* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
- int decoding_needed;
+ int decoding_needed;
#define DECODING_FOR_OST 1
#define DECODING_FOR_FILTER 2
/* true if stream data should be discarded */
- int discard;
+ int discard;
// scheduler returned EOF for this stream
- int finished;
+ int finished;
- int streamcopy_needed;
- int have_sub2video;
- int reinit_filters;
+ int streamcopy_needed;
+ int have_sub2video;
+ int reinit_filters;
- int wrap_correction_done;
- int saw_first_ts;
+ int wrap_correction_done;
+ int saw_first_ts;
///< dts of the first packet read for this stream (in AV_TIME_BASE units)
- int64_t first_dts;
+ int64_t first_dts;
/* predicted dts of the next packet read for this stream or (when there are
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
- int64_t next_dts;
+ int64_t next_dts;
///< dts of the last packet read for this stream (in AV_TIME_BASE units)
- int64_t dts;
+ int64_t dts;
const AVCodecDescriptor *codec_desc;
@@ -82,45 +82,45 @@ typedef struct DemuxStream {
DecoderOpts dec_opts;
char dec_name[16];
- AVBSFContext *bsf;
+ AVBSFContext *bsf;
/* number of packets successfully read for this stream */
- uint64_t nb_packets;
+ uint64_t nb_packets;
// combined size of all the packets read
- uint64_t data_size;
+ uint64_t data_size;
} DemuxStream;
typedef struct Demuxer {
- InputFile f;
+ InputFile f;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int64_t wallclock_start;
+ int64_t wallclock_start;
/**
* Extra timestamp offset added by discontinuity handling.
*/
- int64_t ts_offset_discont;
- int64_t last_ts;
+ int64_t ts_offset_discont;
+ int64_t last_ts;
- int64_t recording_time;
- int accurate_seek;
+ int64_t recording_time;
+ int accurate_seek;
/* number of times input stream should be looped */
- int loop;
- int have_audio_dec;
+ int loop;
+ int have_audio_dec;
/* duration of the looped segment of the input file */
- Timestamp duration;
+ Timestamp duration;
/* pts with the smallest/largest values ever seen */
- Timestamp min_pts;
- Timestamp max_pts;
+ Timestamp min_pts;
+ Timestamp max_pts;
/* number of streams that the user was warned of */
- int nb_streams_warn;
+ int nb_streams_warn;
- float readrate;
- double readrate_initial_burst;
+ float readrate;
+ double readrate_initial_burst;
Scheduler *sch;
@@ -43,27 +43,27 @@
#include "libavcodec/mathops.h"
typedef struct FilterGraphPriv {
- FilterGraph fg;
+ FilterGraph fg;
// name used for logging
- char log_name[32];
+ char log_name[32];
- int is_simple;
+ int is_simple;
// true when the filtergraph contains only meta filters
// that do not modify the frame data
- int is_meta;
+ int is_meta;
// source filters are present in the graph
- int have_sources;
- int disable_conversions;
+ int have_sources;
+ int disable_conversions;
- unsigned nb_outputs_done;
+ unsigned nb_outputs_done;
- const char *graph_desc;
+ const char *graph_desc;
// frame for temporarily holding output from the filtergraph
- AVFrame *frame;
+ AVFrame *frame;
// frame for sending output to the encoder
- AVFrame *frame_enc;
+ AVFrame *frame_enc;
Scheduler *sch;
unsigned sch_idx;
@@ -81,69 +81,69 @@ static const FilterGraphPriv *cfgp_from_cfg(const FilterGraph *fg)
// data that is local to the filter thread and not visible outside of it
typedef struct FilterGraphThread {
- AVFilterGraph *graph;
+ AVFilterGraph *graph;
- AVFrame *frame;
+ AVFrame *frame;
// Temporary buffer for output frames, since on filtergraph reset
// we cannot send them to encoders immediately.
// The output index is stored in frame opaque.
- AVFifo *frame_queue_out;
+ AVFifo *frame_queue_out;
// index of the next input to request from the scheduler
- unsigned next_in;
+ unsigned next_in;
// set to 1 after at least one frame passed through this output
- int got_frame;
+ int got_frame;
// EOF status of each input/output, as received by the thread
- uint8_t *eof_in;
- uint8_t *eof_out;
+ uint8_t *eof_in;
+ uint8_t *eof_out;
} FilterGraphThread;
typedef struct InputFilterPriv {
- InputFilter ifilter;
+ InputFilter ifilter;
- InputFilterOptions opts;
+ InputFilterOptions opts;
- int index;
+ int index;
- AVFilterContext *filter;
+ AVFilterContext *filter;
// used to hold submitted input
- AVFrame *frame;
+ AVFrame *frame;
/* for filters that are not yet bound to an input stream,
* this stores the input linklabel, if any */
- uint8_t *linklabel;
+ uint8_t *linklabel;
// filter data type
- enum AVMediaType type;
+ enum AVMediaType type;
// source data type: AVMEDIA_TYPE_SUBTITLE for sub2video,
// same as type otherwise
- enum AVMediaType type_src;
+ enum AVMediaType type_src;
- int bound;
- int eof;
+ int bound;
+ int eof;
// parameters configured for this input
- int format;
+ int format;
- int width, height;
- AVRational sample_aspect_ratio;
- enum AVColorSpace color_space;
- enum AVColorRange color_range;
+ int width, height;
+ AVRational sample_aspect_ratio;
+ enum AVColorSpace color_space;
+ enum AVColorRange color_range;
- int sample_rate;
- AVChannelLayout ch_layout;
+ int sample_rate;
+ AVChannelLayout ch_layout;
- AVRational time_base;
+ AVRational time_base;
- AVFifo *frame_queue;
+ AVFifo *frame_queue;
- AVBufferRef *hw_frames_ctx;
+ AVBufferRef *hw_frames_ctx;
- int displaymatrix_present;
- int32_t displaymatrix[9];
+ int displaymatrix_present;
+ int32_t displaymatrix[9];
// fallback parameters to use when no input is ever sent
struct {
@@ -178,15 +178,15 @@ static InputFilterPriv *ifp_from_ifilter(InputFilter *ifilter)
}
typedef struct FPSConvContext {
- AVFrame *last_frame;
+ AVFrame *last_frame;
/* number of frames emitted by the video-encoding sync code */
- int64_t frame_number;
+ int64_t frame_number;
/* history of nb_frames_prev, i.e. the number of times the
* previous frame was duplicated by vsync code in recent
* do_video_out() calls */
- int64_t frames_prev_hist[3];
+ int64_t frames_prev_hist[3];
- uint64_t dup_warning;
+ uint64_t dup_warning;
int last_dropped;
int dropped_keyframe;
@@ -198,38 +198,38 @@ typedef struct FPSConvContext {
} FPSConvContext;
typedef struct OutputFilterPriv {
- OutputFilter ofilter;
+ OutputFilter ofilter;
- int index;
+ int index;
- AVFilterContext *filter;
+ AVFilterContext *filter;
/* desired output stream properties */
- int format;
- int width, height;
- int sample_rate;
- AVChannelLayout ch_layout;
+ int format;
+ int width, height;
+ int sample_rate;
+ AVChannelLayout ch_layout;
// time base in which the output is sent to our downstream
// does not need to match the filtersink's timebase
- AVRational tb_out;
+ AVRational tb_out;
// at least one frame with the above timebase was sent
// to our downstream, so it cannot change anymore
- int tb_out_locked;
+ int tb_out_locked;
- AVRational sample_aspect_ratio;
+ AVRational sample_aspect_ratio;
// those are only set if no format is specified and the encoder gives us multiple options
// They point directly to the relevant lists of the encoder.
- const int *formats;
- const AVChannelLayout *ch_layouts;
- const int *sample_rates;
+ const int *formats;
+ const AVChannelLayout *ch_layouts;
+ const int *sample_rates;
- AVRational enc_timebase;
+ AVRational enc_timebase;
// offset for output timestamps, in AV_TIME_BASE_Q
- int64_t ts_offset;
- int64_t next_pts;
- FPSConvContext fps;
+ int64_t ts_offset;
+ int64_t next_pts;
+ FPSConvContext fps;
} OutputFilterPriv;
static OutputFilterPriv *ofp_from_ofilter(OutputFilter *ofilter)
@@ -34,73 +34,73 @@
#include "libavutil/fifo.h"
typedef struct MuxStream {
- OutputStream ost;
+ OutputStream ost;
// name used for logging
- char log_name[32];
+ char log_name[32];
- AVBSFContext *bsf_ctx;
- AVPacket *bsf_pkt;
+ AVBSFContext *bsf_ctx;
+ AVPacket *bsf_pkt;
- AVPacket *pkt;
+ AVPacket *pkt;
- EncStats stats;
+ EncStats stats;
- int sch_idx;
- int sch_idx_enc;
- int sch_idx_src;
+ int sch_idx;
+ int sch_idx_enc;
+ int sch_idx_src;
- int sq_idx_mux;
+ int sq_idx_mux;
- int64_t max_frames;
+ int64_t max_frames;
// timestamp from which the streamcopied streams should start,
// in AV_TIME_BASE_Q;
// everything before it should be discarded
- int64_t ts_copy_start;
+ int64_t ts_copy_start;
/* dts of the last packet sent to the muxer, in the stream timebase
* used for making up missing dts values */
- int64_t last_mux_dts;
+ int64_t last_mux_dts;
- int64_t stream_duration;
- AVRational stream_duration_tb;
+ int64_t stream_duration;
+ AVRational stream_duration_tb;
// state for av_rescale_delta() call for audio in write_packet()
- int64_t ts_rescale_delta_last;
+ int64_t ts_rescale_delta_last;
// combined size of all the packets sent to the muxer
- uint64_t data_size_mux;
+ uint64_t data_size_mux;
- int copy_initial_nonkeyframes;
- int copy_prior_start;
- int streamcopy_started;
+ int copy_initial_nonkeyframes;
+ int copy_prior_start;
+ int streamcopy_started;
} MuxStream;
typedef struct Muxer {
- OutputFile of;
+ OutputFile of;
// name used for logging
- char log_name[32];
+ char log_name[32];
- AVFormatContext *fc;
+ AVFormatContext *fc;
- Scheduler *sch;
- unsigned sch_idx;
+ Scheduler *sch;
+ unsigned sch_idx;
// OutputStream indices indexed by scheduler stream indices
- int *sch_stream_idx;
- int nb_sch_stream_idx;
+ int *sch_stream_idx;
+ int nb_sch_stream_idx;
- AVDictionary *opts;
+ AVDictionary *opts;
/* filesize limit expressed in bytes */
- int64_t limit_filesize;
- atomic_int_least64_t last_filesize;
- int header_written;
+ int64_t limit_filesize;
+ atomic_int_least64_t last_filesize;
+ int header_written;
- SyncQueue *sq_mux;
- AVPacket *sq_pkt;
+ SyncQueue *sq_mux;
+ AVPacket *sq_pkt;
} Muxer;
int mux_check_init(void *arg);