FFmpeg
Macros | Functions
avformat.c File Reference
#include <math.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/frame.h"
#include "libavutil/iamf.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixfmt.h"
#include "libavutil/samplefmt.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/codec.h"
#include "libavcodec/bsf.h"
#include "libavcodec/codec_desc.h"
#include "libavcodec/packet_internal.h"
#include "avformat.h"
#include "avio.h"
#include "demux.h"
#include "mux.h"
#include "internal.h"

Go to the source code of this file.

Macros

#define OFF(field)   offsetof(AVFormatContext, field)
 

Functions

void ff_free_stream (AVStream **pst)
 Frees a stream without modifying the corresponding AVFormatContext. More...
 
void ff_free_stream_group (AVStreamGroup **pstg)
 Frees a stream group without modifying the corresponding AVFormatContext. More...
 
void ff_remove_stream (AVFormatContext *s, AVStream *st)
 Remove a stream from its AVFormatContext and free it. More...
 
void ff_remove_stream_group (AVFormatContext *s, AVStreamGroup *stg)
 Remove a stream group from its AVFormatContext and free it. More...
 
void ff_flush_packet_queue (AVFormatContext *s)
 
void avformat_free_context (AVFormatContext *s)
 Free an AVFormatContext and all its streams. More...
 
static int stream_params_copy (AVStream *dst, const AVStream *src)
 Copy all stream parameters from source to destination stream, with the exception of the index field, which is usually set by avformat_new_stream(). More...
 
AVStreamff_stream_clone (AVFormatContext *dst_ctx, const AVStream *src)
 Create a new stream and copy to it all parameters from a source stream, with the exception of the index field, which is set when the new stream is created. More...
 
const char * avformat_stream_group_name (enum AVStreamGroupParamsType type)
 
AVProgramav_new_program (AVFormatContext *ac, int id)
 
void av_program_add_stream_index (AVFormatContext *ac, int progid, unsigned idx)
 
AVProgramav_find_program_from_stream (AVFormatContext *ic, AVProgram *last, int s)
 Find the programs which belong to a given stream. More...
 
int av_find_default_stream_index (AVFormatContext *s)
 
int av_find_best_stream (AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, const AVCodec **decoder_ret, int flags)
 
static int match_stream_specifier (const AVFormatContext *s, const AVStream *st, const char *spec, const char **indexptr, const AVStreamGroup **g, const AVProgram **p)
 Matches a stream specifier (but ignores requested index). More...
 
int avformat_match_stream_specifier (AVFormatContext *s, AVStream *st, const char *spec)
 Check if the stream st contained in s is matched by the stream specifier spec. More...
 
AVRational av_guess_sample_aspect_ratio (AVFormatContext *format, AVStream *stream, AVFrame *frame)
 Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio. More...
 
AVRational av_guess_frame_rate (AVFormatContext *format, AVStream *st, AVFrame *frame)
 Guess the frame rate, based on both the container and codec information. More...
 
int avformat_transfer_internal_stream_timing_info (const AVOutputFormat *ofmt, AVStream *ost, const AVStream *ist, enum AVTimebaseSource copy_tb)
 Transfer internal timing information from one stream to another. More...
 
AVRational av_stream_get_codec_timebase (const AVStream *st)
 Get the internal codec timebase from a stream. More...
 
void avpriv_set_pts_info (AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
 Set the time base and wrapping info for a given stream. More...
 
const AVCodecff_find_decoder (AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
 
int ff_copy_whiteblacklists (AVFormatContext *dst, const AVFormatContext *src)
 Copies the whilelists from one context to the other. More...
 
int ff_is_intra_only (enum AVCodecID id)
 
void ff_format_set_url (AVFormatContext *s, char *url)
 Set AVFormatContext url field to the provided pointer. More...
 
int ff_format_io_close (AVFormatContext *s, AVIOContext **pb)
 

Macro Definition Documentation

◆ OFF

#define OFF (   field)    offsetof(AVFormatContext, field)

Function Documentation

◆ ff_free_stream()

void ff_free_stream ( AVStream **  st)

Frees a stream without modifying the corresponding AVFormatContext.

Must only be called if the latter doesn't matter or if the stream is not yet attached to an AVFormatContext.

Definition at line 44 of file avformat.c.

Referenced by avformat_free_context(), avformat_new_stream(), and ff_remove_stream().

◆ ff_free_stream_group()

void ff_free_stream_group ( AVStreamGroup **  pstg)

Frees a stream group without modifying the corresponding AVFormatContext.

Must only be called if the latter doesn't matter or if the stream is not yet attached to an AVFormatContext.

Definition at line 83 of file avformat.c.

Referenced by avformat_free_context(), avformat_stream_group_create(), and ff_remove_stream_group().

◆ ff_remove_stream()

void ff_remove_stream ( AVFormatContext s,
AVStream st 
)

Remove a stream from its AVFormatContext and free it.

The stream must be the last stream of the AVFormatContext.

Definition at line 114 of file avformat.c.

Referenced by avi_read_header(), ff_add_attached_pic(), ff_rm_read_mdpr_codecdata(), ff_stream_clone(), and mov_read_iinf().

◆ ff_remove_stream_group()

void ff_remove_stream_group ( AVFormatContext s,
AVStreamGroup stg 
)

Remove a stream group from its AVFormatContext and free it.

The stream group must be the last stream group of the AVFormatContext.

Definition at line 122 of file avformat.c.

Referenced by mov_parse_tiles().

◆ ff_flush_packet_queue()

void ff_flush_packet_queue ( AVFormatContext s)

◆ stream_params_copy()

static int stream_params_copy ( AVStream dst,
const AVStream src 
)
static

Copy all stream parameters from source to destination stream, with the exception of the index field, which is usually set by avformat_new_stream().

Parameters
dstpointer to destination AVStream
srcpointer to source AVStream
Returns
>=0 on success, AVERROR code on error

Definition at line 270 of file avformat.c.

Referenced by ff_stream_clone().

◆ ff_stream_clone()

AVStream* ff_stream_clone ( AVFormatContext dst_ctx,
const AVStream src 
)

Create a new stream and copy to it all parameters from a source stream, with the exception of the index field, which is set when the new stream is created.

Parameters
dst_ctxpointer to the context in which the new stream is created
srcpointer to source AVStream
Returns
pointer to the new stream or NULL on error

Definition at line 306 of file avformat.c.

Referenced by fifo_mux_init(), open_slave(), segment_mux_init(), set_context_streams_from_tracks(), and webm_chunk_init().

◆ av_program_add_stream_index()

void av_program_add_stream_index ( AVFormatContext ac,
int  progid,
unsigned  idx 
)

Definition at line 365 of file avformat.c.

Referenced by add_stream_to_programs(), dash_read_header(), of_add_programs(), and pmt_cb().

◆ av_find_best_stream()

int av_find_best_stream ( AVFormatContext ic,
enum AVMediaType  type,
int  wanted_stream_nb,
int  related_stream,
const AVCodec **  decoder_ret,
int  flags 
)

◆ match_stream_specifier()

static int match_stream_specifier ( const AVFormatContext s,
const AVStream st,
const char *  spec,
const char **  indexptr,
const AVStreamGroup **  g,
const AVProgram **  p 
)
static

Matches a stream specifier (but ignores requested index).

Parameters
indexptrset to point to the requested stream index if there is one
Returns
<0 on error 0 if st is NOT a matching stream >0 if st is a matching stream

Definition at line 518 of file avformat.c.

Referenced by avformat_match_stream_specifier().

◆ avpriv_set_pts_info()

void avpriv_set_pts_info ( AVStream st,
int  pts_wrap_bits,
unsigned int  pts_num,
unsigned int  pts_den 
)

Set the time base and wrapping info for a given stream.

This will be used to interpret the stream's timestamps. If the new time base is invalid (numerator or denominator are non-positive), it leaves the stream unchanged.

Parameters
ststream
pts_wrap_bitsnumber of bits effectively used by the pts (used for wrap control)
pts_numtime base numerator
pts_dentime base denominator

Definition at line 853 of file avformat.c.

Referenced by aa_read_header(), aax_read_header(), ace_read_header(), acm_read_header(), add_video_stream(), adp_read_header(), ads_read_header(), adts_aac_read_header(), adx_read_header(), aea_read_header(), afc_read_header(), aiff_read_header(), aiff_write_header(), aix_read_header(), apac_read_header(), ape_read_header(), apng_read_header(), aqt_read_header(), argo_brp_read_header(), asf_read_stream_properties(), asf_write_header1(), asfrtp_parse_sdp_line(), ass_read_header(), ast_read_header(), audio_read_header(), audio_write_header(), av1_read_header(), avformat_new_stream(), avi_read_header(), avi_write_header(), avisynth_create_stream_audio(), avisynth_create_stream_video(), avr_read_header(), bfi_read_header(), binka_read_header(), bmv_read_header(), bonk_read_header(), cdata_read_header(), cdxl_read_packet(), celt_header(), cin_read_header(), cine_read_header(), codec2_read_header_common(), copy_stream_props(), create_audio_stream(), create_new_audio_stream(), create_stream(), dat_read_packet(), daud_header(), dc1394_read_common(), dcstr_read_header(), decklink_setup_audio(), decklink_setup_video(), decode_stream_header(), derf_read_header(), dfa_read_header(), dfpwm_read_header(), dhav_read_packet(), dirac_header(), dsf_read_header(), dshow_add_device(), dss_read_header(), dtshd_read_header(), dvdvideo_audio_stream_add(), dvdvideo_subp_stream_add(), dvdvideo_video_stream_add(), dxa_read_header(), ea_read_header(), epaf_read_header(), evc_read_header(), fbdev_read_header(), ff_argo_asf_fill_stream(), ff_decklink_read_header(), ff_decklink_write_header(), ff_img_read_header(), ff_raw_video_read_header(), ff_rm_read_mdpr_codecdata(), ff_voc_get_packet(), film_read_header(), fits_read_header(), flac_header(), flac_read_header(), flv_init(), fsb_read_header(), fwse_read_header(), g722_read_header(), g723_1_init(), g729_read_header(), gdigrab_read_header(), gdv_read_header(), genh_read_header(), get_audio_config(), get_packet_header(), get_video_config(), gif_init(), gif_read_header(), grab_read_header(), gsm_read_header(), gxf_header(), gxf_write_header(), hca_read_header(), hcom_read_header(), hls_write_header(), hnm_read_header(), iamf_read_header(), idcin_read_header(), iff_read_header(), ifv_read_header(), ilbc_read_header(), init_audio(), init_muxer(), init_stream(), init_video_stream(), ipmovie_read_header(), ipu_read_header(), ircam_read_header(), iss_read_header(), jacosub_read_header(), jpegxl_anim_read_header(), kmsgrab_read_header(), laf_read_header(), lavfi_read_header(), lmlm4_read_header(), loas_read_header(), lrc_read_header(), lrc_write_header(), lvf_read_header(), lxf_read_header(), mcc_read_header(), microdvd_read_header(), microdvd_write_header(), mkv_init(), mlp_read_header(), mmf_read_header(), modplug_read_header(), mods_read_header(), moflex_read_sync(), mov_init(), mov_read_iacb(), mov_read_trak(), mp3_read_header(), mpc8_read_header(), mpc_read_header(), mpeg_mux_init(), mpegts_init(), mpegts_read_header(), mpegts_set_stream_info(), mpjpeg_read_header(), mpl2_read_header(), mpsub_read_header(), msf_read_header(), msnwc_tcp_read_header(), mtaf_read_header(), mtv_read_header(), musx_read_header(), mv_read_header(), mxf_init(), mxf_parse_structural_metadata(), mxg_read_header(), nc_read_header(), new_stream(), nist_read_header(), nsv_parse_NSVs_header(), nut_write_header(), nuv_header(), ogg_build_vp8_headers(), ogg_init(), ogg_new_stream(), ogm_dshow_header(), ogm_header(), old_dirac_header(), old_flac_header(), oma_read_header(), open_demux_for_component(), opus_header(), osq_read_header(), parse_audio_var(), parse_chunk(), parse_strk(), parse_video_var(), parse_vtrk(), pcm_read_header(), pdv_read_header(), pjs_read_header(), pmp_header(), pp_bnk_read_header(), pulse_read_header(), pulse_write_header(), pva_read_header(), pvf_read_header(), qoa_read_header(), qt_rtp_parse_packet(), r3d_read_red1(), r3d_read_reda(), rawvideo_read_header(), rcwt_write_header(), read_frame(), read_gab2_sub(), read_header(), read_header_gme(), read_header_openmpt(), read_header_vs(), read_sl_header(), realtext_read_header(), redspark_read_header(), rka_read_header(), rl2_read_header(), roq_read_packet(), rpl_read_header(), rsd_read_header(), rso_read_header(), rtp_write_header(), sami_read_header(), sbg_read_header(), scc_read_header(), scc_write_header(), scd_read_track(), sdns_read_header(), sdr2_read_header(), sds_read_header(), seg_init(), seq_read_header(), ser_read_header(), set_context_streams_from_tracks(), set_stream_info_from_input_stream(), sga_audio_packet(), sga_video_packet(), siff_parse_vbv1(), simbiosis_imx_read_header(), skeleton_header(), smacker_read_header(), smjpeg_read_header(), smjpeg_write_header(), smush_read_header(), sol_read_header(), sox_read_header(), speex_header(), srt_read_header(), srt_write_header(), stl_read_header(), str_read_packet(), subviewer1_read_header(), subviewer_read_header(), sup_init(), sup_read_header(), svag_read_header(), svs_read_header(), swf_read_packet(), tak_read_header(), tedcaptions_read_header(), theora_header(), thp_read_header(), threedostr_read_header(), tmv_read_header(), track_header(), tta_init(), tta_read_header(), ttml_write_header(), txd_read_header(), ty_read_header(), v4l2_read_header(), vag_read_header(), vc1t_read_header(), vc1test_write_header(), vfw_read_header(), vid_read_packet(), vivo_read_header(), vmd_read_header(), vorbis_header(), vp8_header(), vpk_read_header(), vplayer_read_header(), vqf_read_header(), wady_read_header(), wavarc_read_header(), wc3_read_header(), webm_chunk_init(), webp_init(), webvtt_read_header(), webvtt_write_header(), write_header(), write_stream_data(), wsaud_read_header(), wsvqa_read_header(), wsvqa_read_packet(), wv_read_header(), wve_read_header(), xa_read_header(), xmd_read_header(), xmv_process_packet_header(), xvag_read_header(), xwma_read_header(), yop_read_header(), and yuv4_read_header().

◆ ff_find_decoder()

const AVCodec* ff_find_decoder ( AVFormatContext s,
const AVStream st,
enum AVCodecID  codec_id 
)

Definition at line 880 of file avformat.c.

Referenced by av_find_best_stream(), and find_probe_decoder().

◆ ff_copy_whiteblacklists()

int ff_copy_whiteblacklists ( AVFormatContext dst,
const AVFormatContext src 
)

◆ ff_is_intra_only()

int ff_is_intra_only ( enum AVCodecID  id)

Definition at line 926 of file avformat.c.

Referenced by compute_pkt_fields(), and init_muxer().

◆ ff_format_set_url()

void ff_format_set_url ( AVFormatContext s,
char *  url 
)

Set AVFormatContext url field to the provided pointer.

The pointer must point to a valid string. The existing url field is freed if necessary. Also set the legacy filename field to the same string which was provided in url.

Definition at line 937 of file avformat.c.

Referenced by hls_start(), parse_playlist(), sap_write_header(), set_segment_filename(), sls_flag_use_localtime_filename(), sls_flags_filename_process(), and webm_chunk_init().

◆ ff_format_io_close()

int ff_format_io_close ( AVFormatContext s,
AVIOContext **  pb 
)