[FFmpeg-devel] [PATCH 3/6] lavf: add new API for iterating muxers and demuxers

Josh de Kock josh at itanimul.li
Wed Jan 3 02:42:53 EET 2018


---
 configure                |   6 +-
 doc/APIchanges           |   5 +
 libavformat/allformats.c | 870 ++++++++++++++++++++++++++++-------------------
 libavformat/avformat.h   |  31 ++
 libavformat/format.c     |  56 +--
 libavformat/version.h    |   3 +
 6 files changed, 564 insertions(+), 407 deletions(-)

diff --git a/configure b/configure
index bfe4bdf..7b46e5c 100755
--- a/configure
+++ b/configure
@@ -3525,8 +3525,6 @@ find_things(){
     sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
 }
 
-MUXER_LIST=$(find_things    muxer    _MUX     libavformat/allformats.c)
-DEMUXER_LIST=$(find_things  demuxer  DEMUX    libavformat/allformats.c)
 OUTDEV_LIST=$(find_things   outdev   OUTDEV   libavdevice/alldevices.c)
 INDEV_LIST=$(find_things    indev    _IN      libavdevice/alldevices.c)
 FILTER_LIST=$(find_things   filter   FILTER   libavfilter/allfilters.c)
@@ -3538,6 +3536,8 @@ find_things_extern(){
     sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
 }
 
+MUXER_LIST=$(find_things_extern muxer AVOutputFormat libavformat/allformats.c)
+DEMUXER_LIST=$(find_things_extern demuxer AVInputFormat libavformat/allformats.c)
 ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c)
 DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c)
 CODEC_LIST="
@@ -7041,6 +7041,8 @@ print_enabled_components(){
 print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST
 print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST
 print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST
+print_enabled_components libavformat/demuxer_list.c AVInputFormat demuxer_list $DEMUXER_LIST
+print_enabled_components libavformat/muxer_list.c AVOutputFormat muxer_list $MUXER_LIST
 print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST
 
 # Settings for pkg-config files
diff --git a/doc/APIchanges b/doc/APIchanges
index 3d28d85..4e82213 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xxxxxxx - lavf 58.9.100 - avformat.h
+  Deprecate use of av_register_input_format(), av_register_output_format(),
+  avformat_register_all(), av_iformat_next(), av_oformat_next().
+  Add av_demuxer_iterate(), and av_muxer_iterate().
+
 2018-xx-xx - xxxxxxx - lavc 58.9.100 - avcodec.h
   Deprecate use of avcodec_register(), avcodec_register_all(), and
   av_codec_next(). Add av_codec_iterate().
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 593baf3..c6fdbce 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -26,371 +26,531 @@
 #include "url.h"
 #include "version.h"
 
-#define REGISTER_MUXER(X, x)                                            \
-    {                                                                   \
-        extern AVOutputFormat ff_##x##_muxer;                           \
-        if (CONFIG_##X##_MUXER)                                         \
-            av_register_output_format(&ff_##x##_muxer);                 \
-    }
+/* (de)muxers */
+extern AVOutputFormat ff_a64_muxer;
+extern AVInputFormat  ff_aa_demuxer;
+extern AVInputFormat  ff_aac_demuxer;
+extern AVInputFormat  ff_ac3_demuxer;
+extern AVOutputFormat ff_ac3_muxer;
+extern AVInputFormat  ff_acm_demuxer;
+extern AVInputFormat  ff_act_demuxer;
+extern AVInputFormat  ff_adf_demuxer;
+extern AVInputFormat  ff_adp_demuxer;
+extern AVInputFormat  ff_ads_demuxer;
+extern AVOutputFormat ff_adts_muxer;
+extern AVInputFormat  ff_adx_demuxer;
+extern AVOutputFormat ff_adx_muxer;
+extern AVInputFormat  ff_aea_demuxer;
+extern AVInputFormat  ff_afc_demuxer;
+extern AVInputFormat  ff_aiff_demuxer;
+extern AVOutputFormat ff_aiff_muxer;
+extern AVInputFormat  ff_aix_demuxer;
+extern AVInputFormat  ff_amr_demuxer;
+extern AVOutputFormat ff_amr_muxer;
+extern AVInputFormat  ff_amrnb_demuxer;
+extern AVInputFormat  ff_amrwb_demuxer;
+extern AVInputFormat  ff_anm_demuxer;
+extern AVInputFormat  ff_apc_demuxer;
+extern AVInputFormat  ff_ape_demuxer;
+extern AVInputFormat  ff_apng_demuxer;
+extern AVOutputFormat ff_apng_muxer;
+extern AVInputFormat  ff_aptx_demuxer;
+extern AVOutputFormat ff_aptx_muxer;
+extern AVInputFormat  ff_aqtitle_demuxer;
+extern AVInputFormat  ff_asf_demuxer;
+extern AVOutputFormat ff_asf_muxer;
+extern AVInputFormat  ff_asf_o_demuxer;
+extern AVInputFormat  ff_ass_demuxer;
+extern AVOutputFormat ff_ass_muxer;
+extern AVInputFormat  ff_ast_demuxer;
+extern AVOutputFormat ff_ast_muxer;
+extern AVOutputFormat ff_asf_stream_muxer;
+extern AVInputFormat  ff_au_demuxer;
+extern AVOutputFormat ff_au_muxer;
+extern AVInputFormat  ff_avi_demuxer;
+extern AVOutputFormat ff_avi_muxer;
+extern AVInputFormat  ff_avisynth_demuxer;
+extern AVOutputFormat ff_avm2_muxer;
+extern AVInputFormat  ff_avr_demuxer;
+extern AVInputFormat  ff_avs_demuxer;
+extern AVInputFormat  ff_bethsoftvid_demuxer;
+extern AVInputFormat  ff_bfi_demuxer;
+extern AVInputFormat  ff_bintext_demuxer;
+extern AVInputFormat  ff_bink_demuxer;
+extern AVInputFormat  ff_bit_demuxer;
+extern AVOutputFormat ff_bit_muxer;
+extern AVInputFormat  ff_bmv_demuxer;
+extern AVInputFormat  ff_bfstm_demuxer;
+extern AVInputFormat  ff_brstm_demuxer;
+extern AVInputFormat  ff_boa_demuxer;
+extern AVInputFormat  ff_c93_demuxer;
+extern AVInputFormat  ff_caf_demuxer;
+extern AVOutputFormat ff_caf_muxer;
+extern AVInputFormat  ff_cavsvideo_demuxer;
+extern AVOutputFormat ff_cavsvideo_muxer;
+extern AVInputFormat  ff_cdg_demuxer;
+extern AVInputFormat  ff_cdxl_demuxer;
+extern AVInputFormat  ff_cine_demuxer;
+extern AVInputFormat  ff_concat_demuxer;
+extern AVOutputFormat ff_crc_muxer;
+extern AVInputFormat  ff_dash_demuxer;
+extern AVOutputFormat ff_dash_muxer;
+extern AVInputFormat  ff_data_demuxer;
+extern AVOutputFormat ff_data_muxer;
+extern AVInputFormat  ff_daud_demuxer;
+extern AVOutputFormat ff_daud_muxer;
+extern AVInputFormat  ff_dcstr_demuxer;
+extern AVInputFormat  ff_dfa_demuxer;
+extern AVInputFormat  ff_dirac_demuxer;
+extern AVOutputFormat ff_dirac_muxer;
+extern AVInputFormat  ff_dnxhd_demuxer;
+extern AVOutputFormat ff_dnxhd_muxer;
+extern AVInputFormat  ff_dsf_demuxer;
+extern AVInputFormat  ff_dsicin_demuxer;
+extern AVInputFormat  ff_dss_demuxer;
+extern AVInputFormat  ff_dts_demuxer;
+extern AVOutputFormat ff_dts_muxer;
+extern AVInputFormat  ff_dtshd_demuxer;
+extern AVInputFormat  ff_dv_demuxer;
+extern AVOutputFormat ff_dv_muxer;
+extern AVInputFormat  ff_dvbsub_demuxer;
+extern AVInputFormat  ff_dvbtxt_demuxer;
+extern AVInputFormat  ff_dxa_demuxer;
+extern AVInputFormat  ff_ea_demuxer;
+extern AVInputFormat  ff_ea_cdata_demuxer;
+extern AVInputFormat  ff_eac3_demuxer;
+extern AVOutputFormat ff_eac3_muxer;
+extern AVInputFormat  ff_epaf_demuxer;
+extern AVOutputFormat ff_f4v_muxer;
+extern AVInputFormat  ff_ffm_demuxer;
+extern AVOutputFormat ff_ffm_muxer;
+extern AVInputFormat  ff_ffmetadata_demuxer;
+extern AVOutputFormat ff_ffmetadata_muxer;
+extern AVOutputFormat ff_fifo_muxer;
+extern AVInputFormat  ff_filmstrip_demuxer;
+extern AVOutputFormat ff_filmstrip_muxer;
+extern AVInputFormat  ff_fits_demuxer;
+extern AVOutputFormat ff_fits_muxer;
+extern AVInputFormat  ff_flac_demuxer;
+extern AVOutputFormat ff_flac_muxer;
+extern AVInputFormat  ff_flic_demuxer;
+extern AVInputFormat  ff_flv_demuxer;
+extern AVOutputFormat ff_flv_muxer;
+extern AVInputFormat  ff_live_flv_demuxer;
+extern AVInputFormat  ff_fourxm_demuxer;
+extern AVOutputFormat ff_framecrc_muxer;
+extern AVOutputFormat ff_framehash_muxer;
+extern AVOutputFormat ff_framemd5_muxer;
+extern AVInputFormat  ff_frm_demuxer;
+extern AVInputFormat  ff_fsb_demuxer;
+extern AVInputFormat  ff_g722_demuxer;
+extern AVOutputFormat ff_g722_muxer;
+extern AVInputFormat  ff_g723_1_demuxer;
+extern AVOutputFormat ff_g723_1_muxer;
+extern AVInputFormat  ff_g726_demuxer;
+extern AVOutputFormat ff_g726_muxer;
+extern AVInputFormat  ff_g726le_demuxer;
+extern AVOutputFormat ff_g726le_muxer;
+extern AVInputFormat  ff_g729_demuxer;
+extern AVInputFormat  ff_gdv_demuxer;
+extern AVInputFormat  ff_genh_demuxer;
+extern AVInputFormat  ff_gif_demuxer;
+extern AVOutputFormat ff_gif_muxer;
+extern AVInputFormat  ff_gsm_demuxer;
+extern AVOutputFormat ff_gsm_muxer;
+extern AVInputFormat  ff_gxf_demuxer;
+extern AVOutputFormat ff_gxf_muxer;
+extern AVInputFormat  ff_h261_demuxer;
+extern AVOutputFormat ff_h261_muxer;
+extern AVInputFormat  ff_h263_demuxer;
+extern AVOutputFormat ff_h263_muxer;
+extern AVInputFormat  ff_h264_demuxer;
+extern AVOutputFormat ff_h264_muxer;
+extern AVOutputFormat ff_hash_muxer;
+extern AVOutputFormat ff_hds_muxer;
+extern AVInputFormat  ff_hevc_demuxer;
+extern AVOutputFormat ff_hevc_muxer;
+extern AVInputFormat  ff_hls_demuxer;
+extern AVOutputFormat ff_hls_muxer;
+extern AVInputFormat  ff_hnm_demuxer;
+extern AVInputFormat  ff_ico_demuxer;
+extern AVOutputFormat ff_ico_muxer;
+extern AVInputFormat  ff_idcin_demuxer;
+extern AVInputFormat  ff_idf_demuxer;
+extern AVInputFormat  ff_iff_demuxer;
+extern AVInputFormat  ff_ilbc_demuxer;
+extern AVOutputFormat ff_ilbc_muxer;
+extern AVInputFormat  ff_image2_demuxer;
+extern AVOutputFormat ff_image2_muxer;
+extern AVInputFormat  ff_image2pipe_demuxer;
+extern AVOutputFormat ff_image2pipe_muxer;
+extern AVInputFormat  ff_image2_alias_pix_demuxer;
+extern AVInputFormat  ff_image2_brender_pix_demuxer;
+extern AVInputFormat  ff_ingenient_demuxer;
+extern AVInputFormat  ff_ipmovie_demuxer;
+extern AVOutputFormat ff_ipod_muxer;
+extern AVInputFormat  ff_ircam_demuxer;
+extern AVOutputFormat ff_ircam_muxer;
+extern AVOutputFormat ff_ismv_muxer;
+extern AVInputFormat  ff_iss_demuxer;
+extern AVInputFormat  ff_iv8_demuxer;
+extern AVInputFormat  ff_ivf_demuxer;
+extern AVOutputFormat ff_ivf_muxer;
+extern AVInputFormat  ff_ivr_demuxer;
+extern AVInputFormat  ff_jacosub_demuxer;
+extern AVOutputFormat ff_jacosub_muxer;
+extern AVInputFormat  ff_jv_demuxer;
+extern AVOutputFormat ff_latm_muxer;
+extern AVInputFormat  ff_lmlm4_demuxer;
+extern AVInputFormat  ff_loas_demuxer;
+extern AVInputFormat  ff_lrc_demuxer;
+extern AVOutputFormat ff_lrc_muxer;
+extern AVInputFormat  ff_lvf_demuxer;
+extern AVInputFormat  ff_lxf_demuxer;
+extern AVInputFormat  ff_m4v_demuxer;
+extern AVOutputFormat ff_m4v_muxer;
+extern AVOutputFormat ff_md5_muxer;
+extern AVInputFormat  ff_matroska_demuxer;
+extern AVOutputFormat ff_matroska_muxer;
+extern AVOutputFormat ff_matroska_audio_muxer;
+extern AVInputFormat  ff_mgsts_demuxer;
+extern AVInputFormat  ff_microdvd_demuxer;
+extern AVOutputFormat ff_microdvd_muxer;
+extern AVInputFormat  ff_mjpeg_demuxer;
+extern AVOutputFormat ff_mjpeg_muxer;
+extern AVInputFormat  ff_mjpeg_2000_demuxer;
+extern AVInputFormat  ff_mlp_demuxer;
+extern AVOutputFormat ff_mlp_muxer;
+extern AVInputFormat  ff_mlv_demuxer;
+extern AVInputFormat  ff_mm_demuxer;
+extern AVInputFormat  ff_mmf_demuxer;
+extern AVOutputFormat ff_mmf_muxer;
+extern AVInputFormat  ff_mov_demuxer;
+extern AVOutputFormat ff_mov_muxer;
+extern AVOutputFormat ff_mp2_muxer;
+extern AVInputFormat  ff_mp3_demuxer;
+extern AVOutputFormat ff_mp3_muxer;
+extern AVOutputFormat ff_mp4_muxer;
+extern AVInputFormat  ff_mpc_demuxer;
+extern AVInputFormat  ff_mpc8_demuxer;
+extern AVOutputFormat ff_mpeg1system_muxer;
+extern AVOutputFormat ff_mpeg1vcd_muxer;
+extern AVOutputFormat ff_mpeg1video_muxer;
+extern AVOutputFormat ff_mpeg2dvd_muxer;
+extern AVOutputFormat ff_mpeg2svcd_muxer;
+extern AVOutputFormat ff_mpeg2video_muxer;
+extern AVOutputFormat ff_mpeg2vob_muxer;
+extern AVInputFormat  ff_mpegps_demuxer;
+extern AVInputFormat  ff_mpegts_demuxer;
+extern AVOutputFormat ff_mpegts_muxer;
+extern AVInputFormat  ff_mpegtsraw_demuxer;
+extern AVInputFormat  ff_mpegvideo_demuxer;
+extern AVInputFormat  ff_mpjpeg_demuxer;
+extern AVOutputFormat ff_mpjpeg_muxer;
+extern AVInputFormat  ff_mpl2_demuxer;
+extern AVInputFormat  ff_mpsub_demuxer;
+extern AVInputFormat  ff_msf_demuxer;
+extern AVInputFormat  ff_msnwc_tcp_demuxer;
+extern AVInputFormat  ff_mtaf_demuxer;
+extern AVInputFormat  ff_mtv_demuxer;
+extern AVInputFormat  ff_musx_demuxer;
+extern AVInputFormat  ff_mv_demuxer;
+extern AVInputFormat  ff_mvi_demuxer;
+extern AVInputFormat  ff_mxf_demuxer;
+extern AVOutputFormat ff_mxf_muxer;
+extern AVOutputFormat ff_mxf_d10_muxer;
+extern AVOutputFormat ff_mxf_opatom_muxer;
+extern AVInputFormat  ff_mxg_demuxer;
+extern AVInputFormat  ff_nc_demuxer;
+extern AVInputFormat  ff_nistsphere_demuxer;
+extern AVInputFormat  ff_nsp_demuxer;
+extern AVInputFormat  ff_nsv_demuxer;
+extern AVOutputFormat ff_null_muxer;
+extern AVInputFormat  ff_nut_demuxer;
+extern AVOutputFormat ff_nut_muxer;
+extern AVInputFormat  ff_nuv_demuxer;
+extern AVOutputFormat ff_oga_muxer;
+extern AVInputFormat  ff_ogg_demuxer;
+extern AVOutputFormat ff_ogg_muxer;
+extern AVOutputFormat ff_ogv_muxer;
+extern AVInputFormat  ff_oma_demuxer;
+extern AVOutputFormat ff_oma_muxer;
+extern AVOutputFormat ff_opus_muxer;
+extern AVInputFormat  ff_paf_demuxer;
+extern AVInputFormat  ff_pcm_alaw_demuxer;
+extern AVOutputFormat ff_pcm_alaw_muxer;
+extern AVInputFormat  ff_pcm_mulaw_demuxer;
+extern AVOutputFormat ff_pcm_mulaw_muxer;
+extern AVInputFormat  ff_pcm_f64be_demuxer;
+extern AVOutputFormat ff_pcm_f64be_muxer;
+extern AVInputFormat  ff_pcm_f64le_demuxer;
+extern AVOutputFormat ff_pcm_f64le_muxer;
+extern AVInputFormat  ff_pcm_f32be_demuxer;
+extern AVOutputFormat ff_pcm_f32be_muxer;
+extern AVInputFormat  ff_pcm_f32le_demuxer;
+extern AVOutputFormat ff_pcm_f32le_muxer;
+extern AVInputFormat  ff_pcm_s32be_demuxer;
+extern AVOutputFormat ff_pcm_s32be_muxer;
+extern AVInputFormat  ff_pcm_s32le_demuxer;
+extern AVOutputFormat ff_pcm_s32le_muxer;
+extern AVInputFormat  ff_pcm_s24be_demuxer;
+extern AVOutputFormat ff_pcm_s24be_muxer;
+extern AVInputFormat  ff_pcm_s24le_demuxer;
+extern AVOutputFormat ff_pcm_s24le_muxer;
+extern AVInputFormat  ff_pcm_s16be_demuxer;
+extern AVOutputFormat ff_pcm_s16be_muxer;
+extern AVInputFormat  ff_pcm_s16le_demuxer;
+extern AVOutputFormat ff_pcm_s16le_muxer;
+extern AVInputFormat  ff_pcm_s8_demuxer;
+extern AVOutputFormat ff_pcm_s8_muxer;
+extern AVInputFormat  ff_pcm_u32be_demuxer;
+extern AVOutputFormat ff_pcm_u32be_muxer;
+extern AVInputFormat  ff_pcm_u32le_demuxer;
+extern AVOutputFormat ff_pcm_u32le_muxer;
+extern AVInputFormat  ff_pcm_u24be_demuxer;
+extern AVOutputFormat ff_pcm_u24be_muxer;
+extern AVInputFormat  ff_pcm_u24le_demuxer;
+extern AVOutputFormat ff_pcm_u24le_muxer;
+extern AVInputFormat  ff_pcm_u16be_demuxer;
+extern AVOutputFormat ff_pcm_u16be_muxer;
+extern AVInputFormat  ff_pcm_u16le_demuxer;
+extern AVOutputFormat ff_pcm_u16le_muxer;
+extern AVInputFormat  ff_pcm_u8_demuxer;
+extern AVOutputFormat ff_pcm_u8_muxer;
+extern AVInputFormat  ff_pjs_demuxer;
+extern AVInputFormat  ff_pmp_demuxer;
+extern AVOutputFormat ff_psp_muxer;
+extern AVInputFormat  ff_pva_demuxer;
+extern AVInputFormat  ff_pvf_demuxer;
+extern AVInputFormat  ff_qcp_demuxer;
+extern AVInputFormat  ff_r3d_demuxer;
+extern AVInputFormat  ff_rawvideo_demuxer;
+extern AVOutputFormat ff_rawvideo_muxer;
+extern AVInputFormat  ff_realtext_demuxer;
+extern AVInputFormat  ff_redspark_demuxer;
+extern AVInputFormat  ff_rl2_demuxer;
+extern AVInputFormat  ff_rm_demuxer;
+extern AVOutputFormat ff_rm_muxer;
+extern AVInputFormat  ff_roq_demuxer;
+extern AVOutputFormat ff_roq_muxer;
+extern AVInputFormat  ff_rpl_demuxer;
+extern AVInputFormat  ff_rsd_demuxer;
+extern AVInputFormat  ff_rso_demuxer;
+extern AVOutputFormat ff_rso_muxer;
+extern AVInputFormat  ff_rtp_demuxer;
+extern AVOutputFormat ff_rtp_muxer;
+extern AVOutputFormat ff_rtp_mpegts_muxer;
+extern AVInputFormat  ff_rtsp_demuxer;
+extern AVOutputFormat ff_rtsp_muxer;
+extern AVInputFormat  ff_s337m_demuxer;
+extern AVInputFormat  ff_sami_demuxer;
+extern AVInputFormat  ff_sap_demuxer;
+extern AVOutputFormat ff_sap_muxer;
+extern AVInputFormat  ff_sbg_demuxer;
+extern AVInputFormat  ff_scc_demuxer;
+extern AVOutputFormat ff_scc_muxer;
+extern AVInputFormat  ff_sdp_demuxer;
+extern AVInputFormat  ff_sdr2_demuxer;
+extern AVInputFormat  ff_sds_demuxer;
+extern AVInputFormat  ff_sdx_demuxer;
+extern AVInputFormat  ff_segafilm_demuxer;
+extern AVOutputFormat ff_segment_muxer;
+extern AVOutputFormat ff_stream_segment_muxer;
+extern AVInputFormat  ff_shorten_demuxer;
+extern AVInputFormat  ff_siff_demuxer;
+extern AVOutputFormat ff_singlejpeg_muxer;
+extern AVInputFormat  ff_sln_demuxer;
+extern AVInputFormat  ff_smacker_demuxer;
+extern AVInputFormat  ff_smjpeg_demuxer;
+extern AVOutputFormat ff_smjpeg_muxer;
+extern AVOutputFormat ff_smoothstreaming_muxer;
+extern AVInputFormat  ff_smush_demuxer;
+extern AVInputFormat  ff_sol_demuxer;
+extern AVInputFormat  ff_sox_demuxer;
+extern AVOutputFormat ff_sox_muxer;
+extern AVOutputFormat ff_spx_muxer;
+extern AVInputFormat  ff_spdif_demuxer;
+extern AVOutputFormat ff_spdif_muxer;
+extern AVInputFormat  ff_srt_demuxer;
+extern AVOutputFormat ff_srt_muxer;
+extern AVInputFormat  ff_str_demuxer;
+extern AVInputFormat  ff_stl_demuxer;
+extern AVInputFormat  ff_subviewer1_demuxer;
+extern AVInputFormat  ff_subviewer_demuxer;
+extern AVInputFormat  ff_sup_demuxer;
+extern AVOutputFormat ff_sup_muxer;
+extern AVInputFormat  ff_svag_demuxer;
+extern AVInputFormat  ff_swf_demuxer;
+extern AVOutputFormat ff_swf_muxer;
+extern AVInputFormat  ff_tak_demuxer;
+extern AVOutputFormat ff_tee_muxer;
+extern AVInputFormat  ff_tedcaptions_demuxer;
+extern AVOutputFormat ff_tg2_muxer;
+extern AVOutputFormat ff_tgp_muxer;
+extern AVInputFormat  ff_thp_demuxer;
+extern AVInputFormat  ff_threedostr_demuxer;
+extern AVInputFormat  ff_tiertexseq_demuxer;
+extern AVOutputFormat ff_mkvtimestamp_v2_muxer;
+extern AVInputFormat  ff_tmv_demuxer;
+extern AVInputFormat  ff_truehd_demuxer;
+extern AVOutputFormat ff_truehd_muxer;
+extern AVInputFormat  ff_tta_demuxer;
+extern AVOutputFormat ff_tta_muxer;
+extern AVInputFormat  ff_txd_demuxer;
+extern AVInputFormat  ff_tty_demuxer;
+extern AVInputFormat  ff_ty_demuxer;
+extern AVOutputFormat ff_uncodedframecrc_muxer;
+extern AVInputFormat  ff_v210_demuxer;
+extern AVInputFormat  ff_v210x_demuxer;
+extern AVInputFormat  ff_vag_demuxer;
+extern AVInputFormat  ff_vc1_demuxer;
+extern AVOutputFormat ff_vc1_muxer;
+extern AVInputFormat  ff_vc1t_demuxer;
+extern AVOutputFormat ff_vc1t_muxer;
+extern AVInputFormat  ff_vivo_demuxer;
+extern AVInputFormat  ff_vmd_demuxer;
+extern AVInputFormat  ff_vobsub_demuxer;
+extern AVInputFormat  ff_voc_demuxer;
+extern AVOutputFormat ff_voc_muxer;
+extern AVInputFormat  ff_vpk_demuxer;
+extern AVInputFormat  ff_vplayer_demuxer;
+extern AVInputFormat  ff_vqf_demuxer;
+extern AVInputFormat  ff_w64_demuxer;
+extern AVOutputFormat ff_w64_muxer;
+extern AVInputFormat  ff_wav_demuxer;
+extern AVOutputFormat ff_wav_muxer;
+extern AVInputFormat  ff_wc3_demuxer;
+extern AVOutputFormat ff_webm_muxer;
+extern AVInputFormat  ff_webm_dash_manifest_demuxer;
+extern AVOutputFormat ff_webm_dash_manifest_muxer;
+extern AVOutputFormat ff_webm_chunk_muxer;
+extern AVOutputFormat ff_webp_muxer;
+extern AVInputFormat  ff_webvtt_demuxer;
+extern AVOutputFormat ff_webvtt_muxer;
+extern AVInputFormat  ff_wsaud_demuxer;
+extern AVInputFormat  ff_wsd_demuxer;
+extern AVInputFormat  ff_wsvqa_demuxer;
+extern AVInputFormat  ff_wtv_demuxer;
+extern AVOutputFormat ff_wtv_muxer;
+extern AVInputFormat  ff_wve_demuxer;
+extern AVInputFormat  ff_wv_demuxer;
+extern AVOutputFormat ff_wv_muxer;
+extern AVInputFormat  ff_xa_demuxer;
+extern AVInputFormat  ff_xbin_demuxer;
+extern AVInputFormat  ff_xmv_demuxer;
+extern AVInputFormat  ff_xvag_demuxer;
+extern AVInputFormat  ff_xwma_demuxer;
+extern AVInputFormat  ff_yop_demuxer;
+extern AVInputFormat  ff_yuv4mpegpipe_demuxer;
+extern AVOutputFormat ff_yuv4mpegpipe_muxer;
+/* image demuxers */
+extern AVInputFormat  ff_image_bmp_pipe_demuxer;
+extern AVInputFormat  ff_image_dds_pipe_demuxer;
+extern AVInputFormat  ff_image_dpx_pipe_demuxer;
+extern AVInputFormat  ff_image_exr_pipe_demuxer;
+extern AVInputFormat  ff_image_j2k_pipe_demuxer;
+extern AVInputFormat  ff_image_jpeg_pipe_demuxer;
+extern AVInputFormat  ff_image_jpegls_pipe_demuxer;
+extern AVInputFormat  ff_image_pam_pipe_demuxer;
+extern AVInputFormat  ff_image_pbm_pipe_demuxer;
+extern AVInputFormat  ff_image_pcx_pipe_demuxer;
+extern AVInputFormat  ff_image_pgmyuv_pipe_demuxer;
+extern AVInputFormat  ff_image_pgm_pipe_demuxer;
+extern AVInputFormat  ff_image_pictor_pipe_demuxer;
+extern AVInputFormat  ff_image_png_pipe_demuxer;
+extern AVInputFormat  ff_image_ppm_pipe_demuxer;
+extern AVInputFormat  ff_image_psd_pipe_demuxer;
+extern AVInputFormat  ff_image_qdraw_pipe_demuxer;
+extern AVInputFormat  ff_image_sgi_pipe_demuxer;
+extern AVInputFormat  ff_image_svg_pipe_demuxer;
+extern AVInputFormat  ff_image_sunrast_pipe_demuxer;
+extern AVInputFormat  ff_image_tiff_pipe_demuxer;
+extern AVInputFormat  ff_image_webp_pipe_demuxer;
+extern AVInputFormat  ff_image_xpm_pipe_demuxer;
 
-#define REGISTER_DEMUXER(X, x)                                          \
-    {                                                                   \
-        extern AVInputFormat ff_##x##_demuxer;                          \
-        if (CONFIG_##X##_DEMUXER)                                       \
-            av_register_input_format(&ff_##x##_demuxer);                \
-    }
+/* external libraries */
+extern AVOutputFormat ff_chromaprint_muxer;
+extern AVInputFormat  ff_libgme_demuxer;
+extern AVInputFormat  ff_libmodplug_demuxer;
+extern AVInputFormat  ff_libopenmpt_demuxer;
+
+#include "muxer_list.c"
+#include "demuxer_list.c"
+
+const AVOutputFormat *av_muxer_iterate(void **opaque)
+{
+    uintptr_t i = (uintptr_t)*opaque;
+    const AVOutputFormat *f = muxer_list[i];
+    if (f)
+        *opaque = (void*)(i + 1);
+    return f;
+}
+
+const AVInputFormat *av_demuxer_iterate(void **opaque){
+    uintptr_t i = (uintptr_t)*opaque;
+    const AVInputFormat *f = demuxer_list[i];
 
-#define REGISTER_MUXDEMUX(X, x) REGISTER_MUXER(X, x); REGISTER_DEMUXER(X, x)
+    if (f)
+        *opaque = (void*)(i + 1);
+    return f;
+}
 
-static void register_all(void)
+#if FF_API_NEXT
+pthread_once_t av_format_next_init = PTHREAD_ONCE_INIT;
+
+static void av_format_init_next(void)
 {
-    avcodec_register_all();
+    AVOutputFormat *prevout = NULL, *out;
+    AVInputFormat *previn = NULL, *in;
+    void *i = 0;
+    while ((out = (AVOutputFormat*)av_muxer_iterate(&i))) {
+        if (prevout)
+            prevout->next = out;
+        prevout = out;
+    }
+    if (prevout)
+        prevout->next = NULL;
 
-    /* (de)muxers */
-    REGISTER_MUXER   (A64,              a64);
-    REGISTER_DEMUXER (AA,               aa);
-    REGISTER_DEMUXER (AAC,              aac);
-    REGISTER_MUXDEMUX(AC3,              ac3);
-    REGISTER_DEMUXER (ACM,              acm);
-    REGISTER_DEMUXER (ACT,              act);
-    REGISTER_DEMUXER (ADF,              adf);
-    REGISTER_DEMUXER (ADP,              adp);
-    REGISTER_DEMUXER (ADS,              ads);
-    REGISTER_MUXER   (ADTS,             adts);
-    REGISTER_MUXDEMUX(ADX,              adx);
-    REGISTER_DEMUXER (AEA,              aea);
-    REGISTER_DEMUXER (AFC,              afc);
-    REGISTER_MUXDEMUX(AIFF,             aiff);
-    REGISTER_DEMUXER (AIX,              aix);
-    REGISTER_MUXDEMUX(AMR,              amr);
-    REGISTER_DEMUXER (AMRNB,            amrnb);
-    REGISTER_DEMUXER (AMRWB,            amrwb);
-    REGISTER_DEMUXER (ANM,              anm);
-    REGISTER_DEMUXER (APC,              apc);
-    REGISTER_DEMUXER (APE,              ape);
-    REGISTER_MUXDEMUX(APNG,             apng);
-    REGISTER_MUXDEMUX(APTX,             aptx);
-    REGISTER_DEMUXER (AQTITLE,          aqtitle);
-    REGISTER_MUXDEMUX(ASF,              asf);
-    REGISTER_DEMUXER (ASF_O,            asf_o);
-    REGISTER_MUXDEMUX(ASS,              ass);
-    REGISTER_MUXDEMUX(AST,              ast);
-    REGISTER_MUXER   (ASF_STREAM,       asf_stream);
-    REGISTER_MUXDEMUX(AU,               au);
-    REGISTER_MUXDEMUX(AVI,              avi);
-    REGISTER_DEMUXER (AVISYNTH,         avisynth);
-    REGISTER_MUXER   (AVM2,             avm2);
-    REGISTER_DEMUXER (AVR,              avr);
-    REGISTER_DEMUXER (AVS,              avs);
-    REGISTER_DEMUXER (BETHSOFTVID,      bethsoftvid);
-    REGISTER_DEMUXER (BFI,              bfi);
-    REGISTER_DEMUXER (BINTEXT,          bintext);
-    REGISTER_DEMUXER (BINK,             bink);
-    REGISTER_MUXDEMUX(BIT,              bit);
-    REGISTER_DEMUXER (BMV,              bmv);
-    REGISTER_DEMUXER (BFSTM,            bfstm);
-    REGISTER_DEMUXER (BRSTM,            brstm);
-    REGISTER_DEMUXER (BOA,              boa);
-    REGISTER_DEMUXER (C93,              c93);
-    REGISTER_MUXDEMUX(CAF,              caf);
-    REGISTER_MUXDEMUX(CAVSVIDEO,        cavsvideo);
-    REGISTER_DEMUXER (CDG,              cdg);
-    REGISTER_DEMUXER (CDXL,             cdxl);
-    REGISTER_DEMUXER (CINE,             cine);
-    REGISTER_DEMUXER (CONCAT,           concat);
-    REGISTER_MUXER   (CRC,              crc);
-    REGISTER_MUXDEMUX(DASH,             dash);
-    REGISTER_MUXDEMUX(DATA,             data);
-    REGISTER_MUXDEMUX(DAUD,             daud);
-    REGISTER_DEMUXER (DCSTR,            dcstr);
-    REGISTER_DEMUXER (DFA,              dfa);
-    REGISTER_MUXDEMUX(DIRAC,            dirac);
-    REGISTER_MUXDEMUX(DNXHD,            dnxhd);
-    REGISTER_DEMUXER (DSF,              dsf);
-    REGISTER_DEMUXER (DSICIN,           dsicin);
-    REGISTER_DEMUXER (DSS,              dss);
-    REGISTER_MUXDEMUX(DTS,              dts);
-    REGISTER_DEMUXER (DTSHD,            dtshd);
-    REGISTER_MUXDEMUX(DV,               dv);
-    REGISTER_DEMUXER (DVBSUB,           dvbsub);
-    REGISTER_DEMUXER (DVBTXT,           dvbtxt);
-    REGISTER_DEMUXER (DXA,              dxa);
-    REGISTER_DEMUXER (EA,               ea);
-    REGISTER_DEMUXER (EA_CDATA,         ea_cdata);
-    REGISTER_MUXDEMUX(EAC3,             eac3);
-    REGISTER_DEMUXER (EPAF,             epaf);
-    REGISTER_MUXER   (F4V,              f4v);
-    REGISTER_MUXDEMUX(FFM,              ffm);
-    REGISTER_MUXDEMUX(FFMETADATA,       ffmetadata);
-    REGISTER_MUXER   (FIFO,             fifo);
-    REGISTER_MUXDEMUX(FILMSTRIP,        filmstrip);
-    REGISTER_MUXDEMUX(FITS,             fits);
-    REGISTER_MUXDEMUX(FLAC,             flac);
-    REGISTER_DEMUXER (FLIC,             flic);
-    REGISTER_MUXDEMUX(FLV,              flv);
-    REGISTER_DEMUXER (LIVE_FLV,         live_flv);
-    REGISTER_DEMUXER (FOURXM,           fourxm);
-    REGISTER_MUXER   (FRAMECRC,         framecrc);
-    REGISTER_MUXER   (FRAMEHASH,        framehash);
-    REGISTER_MUXER   (FRAMEMD5,         framemd5);
-    REGISTER_DEMUXER (FRM,              frm);
-    REGISTER_DEMUXER (FSB,              fsb);
-    REGISTER_MUXDEMUX(G722,             g722);
-    REGISTER_MUXDEMUX(G723_1,           g723_1);
-    REGISTER_MUXDEMUX(G726,             g726);
-    REGISTER_MUXDEMUX(G726LE,           g726le);
-    REGISTER_DEMUXER (G729,             g729);
-    REGISTER_DEMUXER (GDV,              gdv);
-    REGISTER_DEMUXER (GENH,             genh);
-    REGISTER_MUXDEMUX(GIF,              gif);
-    REGISTER_MUXDEMUX(GSM,              gsm);
-    REGISTER_MUXDEMUX(GXF,              gxf);
-    REGISTER_MUXDEMUX(H261,             h261);
-    REGISTER_MUXDEMUX(H263,             h263);
-    REGISTER_MUXDEMUX(H264,             h264);
-    REGISTER_MUXER   (HASH,             hash);
-    REGISTER_MUXER   (HDS,              hds);
-    REGISTER_MUXDEMUX(HEVC,             hevc);
-    REGISTER_MUXDEMUX(HLS,              hls);
-    REGISTER_DEMUXER (HNM,              hnm);
-    REGISTER_MUXDEMUX(ICO,              ico);
-    REGISTER_DEMUXER (IDCIN,            idcin);
-    REGISTER_DEMUXER (IDF,              idf);
-    REGISTER_DEMUXER (IFF,              iff);
-    REGISTER_MUXDEMUX(ILBC,             ilbc);
-    REGISTER_MUXDEMUX(IMAGE2,           image2);
-    REGISTER_MUXDEMUX(IMAGE2PIPE,       image2pipe);
-    REGISTER_DEMUXER (IMAGE2_ALIAS_PIX, image2_alias_pix);
-    REGISTER_DEMUXER (IMAGE2_BRENDER_PIX, image2_brender_pix);
-    REGISTER_DEMUXER (INGENIENT,        ingenient);
-    REGISTER_DEMUXER (IPMOVIE,          ipmovie);
-    REGISTER_MUXER   (IPOD,             ipod);
-    REGISTER_MUXDEMUX(IRCAM,            ircam);
-    REGISTER_MUXER   (ISMV,             ismv);
-    REGISTER_DEMUXER (ISS,              iss);
-    REGISTER_DEMUXER (IV8,              iv8);
-    REGISTER_MUXDEMUX(IVF,              ivf);
-    REGISTER_DEMUXER (IVR,              ivr);
-    REGISTER_MUXDEMUX(JACOSUB,          jacosub);
-    REGISTER_DEMUXER (JV,               jv);
-    REGISTER_MUXER   (LATM,             latm);
-    REGISTER_DEMUXER (LMLM4,            lmlm4);
-    REGISTER_DEMUXER (LOAS,             loas);
-    REGISTER_MUXDEMUX(LRC,              lrc);
-    REGISTER_DEMUXER (LVF,              lvf);
-    REGISTER_DEMUXER (LXF,              lxf);
-    REGISTER_MUXDEMUX(M4V,              m4v);
-    REGISTER_MUXER   (MD5,              md5);
-    REGISTER_MUXDEMUX(MATROSKA,         matroska);
-    REGISTER_MUXER   (MATROSKA_AUDIO,   matroska_audio);
-    REGISTER_DEMUXER (MGSTS,            mgsts);
-    REGISTER_MUXDEMUX(MICRODVD,         microdvd);
-    REGISTER_MUXDEMUX(MJPEG,            mjpeg);
-    REGISTER_DEMUXER (MJPEG_2000,       mjpeg_2000);
-    REGISTER_MUXDEMUX(MLP,              mlp);
-    REGISTER_DEMUXER (MLV,              mlv);
-    REGISTER_DEMUXER (MM,               mm);
-    REGISTER_MUXDEMUX(MMF,              mmf);
-    REGISTER_MUXDEMUX(MOV,              mov);
-    REGISTER_MUXER   (MP2,              mp2);
-    REGISTER_MUXDEMUX(MP3,              mp3);
-    REGISTER_MUXER   (MP4,              mp4);
-    REGISTER_DEMUXER (MPC,              mpc);
-    REGISTER_DEMUXER (MPC8,             mpc8);
-    REGISTER_MUXER   (MPEG1SYSTEM,      mpeg1system);
-    REGISTER_MUXER   (MPEG1VCD,         mpeg1vcd);
-    REGISTER_MUXER   (MPEG1VIDEO,       mpeg1video);
-    REGISTER_MUXER   (MPEG2DVD,         mpeg2dvd);
-    REGISTER_MUXER   (MPEG2SVCD,        mpeg2svcd);
-    REGISTER_MUXER   (MPEG2VIDEO,       mpeg2video);
-    REGISTER_MUXER   (MPEG2VOB,         mpeg2vob);
-    REGISTER_DEMUXER (MPEGPS,           mpegps);
-    REGISTER_MUXDEMUX(MPEGTS,           mpegts);
-    REGISTER_DEMUXER (MPEGTSRAW,        mpegtsraw);
-    REGISTER_DEMUXER (MPEGVIDEO,        mpegvideo);
-    REGISTER_MUXDEMUX(MPJPEG,           mpjpeg);
-    REGISTER_DEMUXER (MPL2,             mpl2);
-    REGISTER_DEMUXER (MPSUB,            mpsub);
-    REGISTER_DEMUXER (MSF,              msf);
-    REGISTER_DEMUXER (MSNWC_TCP,        msnwc_tcp);
-    REGISTER_DEMUXER (MTAF,             mtaf);
-    REGISTER_DEMUXER (MTV,              mtv);
-    REGISTER_DEMUXER (MUSX,             musx);
-    REGISTER_DEMUXER (MV,               mv);
-    REGISTER_DEMUXER (MVI,              mvi);
-    REGISTER_MUXDEMUX(MXF,              mxf);
-    REGISTER_MUXER   (MXF_D10,          mxf_d10);
-    REGISTER_MUXER   (MXF_OPATOM,       mxf_opatom);
-    REGISTER_DEMUXER (MXG,              mxg);
-    REGISTER_DEMUXER (NC,               nc);
-    REGISTER_DEMUXER (NISTSPHERE,       nistsphere);
-    REGISTER_DEMUXER (NSP,              nsp);
-    REGISTER_DEMUXER (NSV,              nsv);
-    REGISTER_MUXER   (NULL,             null);
-    REGISTER_MUXDEMUX(NUT,              nut);
-    REGISTER_DEMUXER (NUV,              nuv);
-    REGISTER_MUXER   (OGA,              oga);
-    REGISTER_MUXDEMUX(OGG,              ogg);
-    REGISTER_MUXER   (OGV,              ogv);
-    REGISTER_MUXDEMUX(OMA,              oma);
-    REGISTER_MUXER   (OPUS,             opus);
-    REGISTER_DEMUXER (PAF,              paf);
-    REGISTER_MUXDEMUX(PCM_ALAW,         pcm_alaw);
-    REGISTER_MUXDEMUX(PCM_MULAW,        pcm_mulaw);
-    REGISTER_MUXDEMUX(PCM_F64BE,        pcm_f64be);
-    REGISTER_MUXDEMUX(PCM_F64LE,        pcm_f64le);
-    REGISTER_MUXDEMUX(PCM_F32BE,        pcm_f32be);
-    REGISTER_MUXDEMUX(PCM_F32LE,        pcm_f32le);
-    REGISTER_MUXDEMUX(PCM_S32BE,        pcm_s32be);
-    REGISTER_MUXDEMUX(PCM_S32LE,        pcm_s32le);
-    REGISTER_MUXDEMUX(PCM_S24BE,        pcm_s24be);
-    REGISTER_MUXDEMUX(PCM_S24LE,        pcm_s24le);
-    REGISTER_MUXDEMUX(PCM_S16BE,        pcm_s16be);
-    REGISTER_MUXDEMUX(PCM_S16LE,        pcm_s16le);
-    REGISTER_MUXDEMUX(PCM_S8,           pcm_s8);
-    REGISTER_MUXDEMUX(PCM_U32BE,        pcm_u32be);
-    REGISTER_MUXDEMUX(PCM_U32LE,        pcm_u32le);
-    REGISTER_MUXDEMUX(PCM_U24BE,        pcm_u24be);
-    REGISTER_MUXDEMUX(PCM_U24LE,        pcm_u24le);
-    REGISTER_MUXDEMUX(PCM_U16BE,        pcm_u16be);
-    REGISTER_MUXDEMUX(PCM_U16LE,        pcm_u16le);
-    REGISTER_MUXDEMUX(PCM_U8,           pcm_u8);
-    REGISTER_DEMUXER (PJS,              pjs);
-    REGISTER_DEMUXER (PMP,              pmp);
-    REGISTER_MUXER   (PSP,              psp);
-    REGISTER_DEMUXER (PVA,              pva);
-    REGISTER_DEMUXER (PVF,              pvf);
-    REGISTER_DEMUXER (QCP,              qcp);
-    REGISTER_DEMUXER (R3D,              r3d);
-    REGISTER_MUXDEMUX(RAWVIDEO,         rawvideo);
-    REGISTER_DEMUXER (REALTEXT,         realtext);
-    REGISTER_DEMUXER (REDSPARK,         redspark);
-    REGISTER_DEMUXER (RL2,              rl2);
-    REGISTER_MUXDEMUX(RM,               rm);
-    REGISTER_MUXDEMUX(ROQ,              roq);
-    REGISTER_DEMUXER (RPL,              rpl);
-    REGISTER_DEMUXER (RSD,              rsd);
-    REGISTER_MUXDEMUX(RSO,              rso);
-    REGISTER_MUXDEMUX(RTP,              rtp);
-    REGISTER_MUXER   (RTP_MPEGTS,       rtp_mpegts);
-    REGISTER_MUXDEMUX(RTSP,             rtsp);
-    REGISTER_DEMUXER (S337M,            s337m);
-    REGISTER_DEMUXER (SAMI,             sami);
-    REGISTER_MUXDEMUX(SAP,              sap);
-    REGISTER_DEMUXER (SBG,              sbg);
-    REGISTER_MUXDEMUX(SCC,              scc);
-    REGISTER_DEMUXER (SDP,              sdp);
-    REGISTER_DEMUXER (SDR2,             sdr2);
-    REGISTER_DEMUXER (SDS,              sds);
-    REGISTER_DEMUXER (SDX,              sdx);
-    REGISTER_DEMUXER (SEGAFILM,         segafilm);
-    REGISTER_MUXER   (SEGMENT,          segment);
-    REGISTER_MUXER   (SEGMENT,          stream_segment);
-    REGISTER_DEMUXER (SHORTEN,          shorten);
-    REGISTER_DEMUXER (SIFF,             siff);
-    REGISTER_MUXER   (SINGLEJPEG,       singlejpeg);
-    REGISTER_DEMUXER (SLN,              sln);
-    REGISTER_DEMUXER (SMACKER,          smacker);
-    REGISTER_MUXDEMUX(SMJPEG,           smjpeg);
-    REGISTER_MUXER   (SMOOTHSTREAMING,  smoothstreaming);
-    REGISTER_DEMUXER (SMUSH,            smush);
-    REGISTER_DEMUXER (SOL,              sol);
-    REGISTER_MUXDEMUX(SOX,              sox);
-    REGISTER_MUXER   (SPX,              spx);
-    REGISTER_MUXDEMUX(SPDIF,            spdif);
-    REGISTER_MUXDEMUX(SRT,              srt);
-    REGISTER_DEMUXER (STR,              str);
-    REGISTER_DEMUXER (STL,              stl);
-    REGISTER_DEMUXER (SUBVIEWER1,       subviewer1);
-    REGISTER_DEMUXER (SUBVIEWER,        subviewer);
-    REGISTER_MUXDEMUX(SUP,              sup);
-    REGISTER_DEMUXER (SVAG,             svag);
-    REGISTER_MUXDEMUX(SWF,              swf);
-    REGISTER_DEMUXER (TAK,              tak);
-    REGISTER_MUXER   (TEE,              tee);
-    REGISTER_DEMUXER (TEDCAPTIONS,      tedcaptions);
-    REGISTER_MUXER   (TG2,              tg2);
-    REGISTER_MUXER   (TGP,              tgp);
-    REGISTER_DEMUXER (THP,              thp);
-    REGISTER_DEMUXER (THREEDOSTR,       threedostr);
-    REGISTER_DEMUXER (TIERTEXSEQ,       tiertexseq);
-    REGISTER_MUXER   (MKVTIMESTAMP_V2,  mkvtimestamp_v2);
-    REGISTER_DEMUXER (TMV,              tmv);
-    REGISTER_MUXDEMUX(TRUEHD,           truehd);
-    REGISTER_MUXDEMUX(TTA,              tta);
-    REGISTER_DEMUXER (TXD,              txd);
-    REGISTER_DEMUXER (TTY,              tty);
-    REGISTER_DEMUXER (TY,               ty);
-    REGISTER_MUXER   (UNCODEDFRAMECRC,  uncodedframecrc);
-    REGISTER_DEMUXER (V210,             v210);
-    REGISTER_DEMUXER (V210X,            v210x);
-    REGISTER_DEMUXER (VAG,              vag);
-    REGISTER_MUXDEMUX(VC1,              vc1);
-    REGISTER_MUXDEMUX(VC1T,             vc1t);
-    REGISTER_DEMUXER (VIVO,             vivo);
-    REGISTER_DEMUXER (VMD,              vmd);
-    REGISTER_DEMUXER (VOBSUB,           vobsub);
-    REGISTER_MUXDEMUX(VOC,              voc);
-    REGISTER_DEMUXER (VPK,              vpk);
-    REGISTER_DEMUXER (VPLAYER,          vplayer);
-    REGISTER_DEMUXER (VQF,              vqf);
-    REGISTER_MUXDEMUX(W64,              w64);
-    REGISTER_MUXDEMUX(WAV,              wav);
-    REGISTER_DEMUXER (WC3,              wc3);
-    REGISTER_MUXER   (WEBM,             webm);
-    REGISTER_MUXDEMUX(WEBM_DASH_MANIFEST, webm_dash_manifest);
-    REGISTER_MUXER   (WEBM_CHUNK,       webm_chunk);
-    REGISTER_MUXER   (WEBP,             webp);
-    REGISTER_MUXDEMUX(WEBVTT,           webvtt);
-    REGISTER_DEMUXER (WSAUD,            wsaud);
-    REGISTER_DEMUXER (WSD,              wsd);
-    REGISTER_DEMUXER (WSVQA,            wsvqa);
-    REGISTER_MUXDEMUX(WTV,              wtv);
-    REGISTER_DEMUXER (WVE,              wve);
-    REGISTER_MUXDEMUX(WV,               wv);
-    REGISTER_DEMUXER (XA,               xa);
-    REGISTER_DEMUXER (XBIN,             xbin);
-    REGISTER_DEMUXER (XMV,              xmv);
-    REGISTER_DEMUXER (XVAG,             xvag);
-    REGISTER_DEMUXER (XWMA,             xwma);
-    REGISTER_DEMUXER (YOP,              yop);
-    REGISTER_MUXDEMUX(YUV4MPEGPIPE,     yuv4mpegpipe);
+    i = 0;
+    while ((in = (AVInputFormat*)av_demuxer_iterate(&i))) {
+        if (previn)
+            previn->next = in;
+        previn = in;
+    }
+    if (previn)
+        previn->next = NULL;
+}
 
-    /* image demuxers */
-    REGISTER_DEMUXER (IMAGE_BMP_PIPE,        image_bmp_pipe);
-    REGISTER_DEMUXER (IMAGE_DDS_PIPE,        image_dds_pipe);
-    REGISTER_DEMUXER (IMAGE_DPX_PIPE,        image_dpx_pipe);
-    REGISTER_DEMUXER (IMAGE_EXR_PIPE,        image_exr_pipe);
-    REGISTER_DEMUXER (IMAGE_J2K_PIPE,        image_j2k_pipe);
-    REGISTER_DEMUXER (IMAGE_JPEG_PIPE,       image_jpeg_pipe);
-    REGISTER_DEMUXER (IMAGE_JPEGLS_PIPE,     image_jpegls_pipe);
-    REGISTER_DEMUXER (IMAGE_PAM_PIPE,        image_pam_pipe);
-    REGISTER_DEMUXER (IMAGE_PBM_PIPE,        image_pbm_pipe);
-    REGISTER_DEMUXER (IMAGE_PCX_PIPE,        image_pcx_pipe);
-    REGISTER_DEMUXER (IMAGE_PGMYUV_PIPE,     image_pgmyuv_pipe);
-    REGISTER_DEMUXER (IMAGE_PGM_PIPE,        image_pgm_pipe);
-    REGISTER_DEMUXER (IMAGE_PICTOR_PIPE,     image_pictor_pipe);
-    REGISTER_DEMUXER (IMAGE_PNG_PIPE,        image_png_pipe);
-    REGISTER_DEMUXER (IMAGE_PPM_PIPE,        image_ppm_pipe);
-    REGISTER_DEMUXER (IMAGE_PSD_PIPE,        image_psd_pipe);
-    REGISTER_DEMUXER (IMAGE_QDRAW_PIPE,      image_qdraw_pipe);
-    REGISTER_DEMUXER (IMAGE_SGI_PIPE,        image_sgi_pipe);
-    REGISTER_DEMUXER (IMAGE_SVG_PIPE,        image_svg_pipe);
-    REGISTER_DEMUXER (IMAGE_SUNRAST_PIPE,    image_sunrast_pipe);
-    REGISTER_DEMUXER (IMAGE_TIFF_PIPE,       image_tiff_pipe);
-    REGISTER_DEMUXER (IMAGE_WEBP_PIPE,       image_webp_pipe);
-    REGISTER_DEMUXER (IMAGE_XPM_PIPE,        image_xpm_pipe);
+AVInputFormat *av_iformat_next(const AVInputFormat *f)
+{
+    pthread_once(&av_format_next_init, av_format_init_next);
+    if (f)
+        return f->next;
+    else
+        return demuxer_list[0];
+}
 
-    /* external libraries */
-    REGISTER_MUXER   (CHROMAPRINT,      chromaprint);
-    REGISTER_DEMUXER (LIBGME,           libgme);
-    REGISTER_DEMUXER (LIBMODPLUG,       libmodplug);
-    REGISTER_DEMUXER (LIBOPENMPT,       libopenmpt);
+AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
+{
+    pthread_once(&av_format_next_init, av_format_init_next);
+    if (f)
+        return f->next;
+    else
+        return muxer_list[0];
 }
 
 void av_register_all(void)
 {
-    static AVOnce control = AV_ONCE_INIT;
+    pthread_once(&av_format_next_init, av_format_init_next);
+}
 
-    ff_thread_once(&control, register_all);
+void av_register_input_format(AVInputFormat *format)
+{
+    pthread_once(&av_format_next_init, av_format_init_next);
+}
+
+void av_register_output_format(AVOutputFormat *format)
+{
+    pthread_once(&av_format_next_init, av_format_init_next);
 }
+#endif
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 4f2798a..d38ca4e 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1979,6 +1979,7 @@ const char *avformat_configuration(void);
  */
 const char *avformat_license(void);
 
+#if FF_API_NEXT
 /**
  * Initialize libavformat and register all the muxers, demuxers and
  * protocols. If you do not call this function, then you can select
@@ -1987,10 +1988,14 @@ const char *avformat_license(void);
  * @see av_register_input_format()
  * @see av_register_output_format()
  */
+attribute_deprecated
 void av_register_all(void);
 
+attribute_deprecated
 void av_register_input_format(AVInputFormat *format);
+attribute_deprecated
 void av_register_output_format(AVOutputFormat *format);
+#endif
 
 /**
  * Do global initialization of network components. This is optional,
@@ -2007,11 +2012,13 @@ int avformat_network_init(void);
  */
 int avformat_network_deinit(void);
 
+#if FF_API_NEXT
 /**
  * If f is NULL, returns the first registered input format,
  * if f is non-NULL, returns the next registered input format after f
  * or NULL if f is the last one.
  */
+attribute_deprecated
 AVInputFormat  *av_iformat_next(const AVInputFormat  *f);
 
 /**
@@ -2019,7 +2026,31 @@ AVInputFormat  *av_iformat_next(const AVInputFormat  *f);
  * if f is non-NULL, returns the next registered output format after f
  * or NULL if f is the last one.
  */
+attribute_deprecated
 AVOutputFormat *av_oformat_next(const AVOutputFormat *f);
+#endif
+
+/**
+ * Iterate over all registered muxers.
+ *
+ * @param opaque a pointer where libavformat will store the iteration state. Must
+ *               point to NULL to start the iteration.
+ *
+ * @return the next registered muxer or NULL when the iteration is
+ *         finished
+ */
+const AVOutputFormat *av_muxer_iterate(void **opaque);
+
+/**
+ * Iterate over all registered demuxers.
+ *
+ * @param opaque a pointer where libavformat will store the iteration state. Must
+ *               point to NULL to start the iteration.
+ *
+ * @return the next registered demuxer or NULL when the iteration is
+ *         finished
+ */
+const AVInputFormat *av_demuxer_iterate(void **opaque);
 
 /**
  * Allocate an AVFormatContext.
diff --git a/libavformat/format.c b/libavformat/format.c
index 38ca2a3..f2691e8 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -34,53 +34,6 @@
  * @file
  * Format register and lookup
  */
-/** head of registered input format linked list */
-static AVInputFormat *first_iformat = NULL;
-/** head of registered output format linked list */
-static AVOutputFormat *first_oformat = NULL;
-
-static AVInputFormat **last_iformat = &first_iformat;
-static AVOutputFormat **last_oformat = &first_oformat;
-
-AVInputFormat *av_iformat_next(const AVInputFormat *f)
-{
-    if (f)
-        return f->next;
-    else
-        return first_iformat;
-}
-
-AVOutputFormat *av_oformat_next(const AVOutputFormat *f)
-{
-    if (f)
-        return f->next;
-    else
-        return first_oformat;
-}
-
-void av_register_input_format(AVInputFormat *format)
-{
-    AVInputFormat **p = last_iformat;
-
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
-
-    if (!format->next)
-        last_iformat = &format->next;
-}
-
-void av_register_output_format(AVOutputFormat *format)
-{
-    AVOutputFormat **p = last_oformat;
-
-    // Note, format could be added after the first 2 checks but that implies that *p is no longer NULL
-    while(p != &format->next && !format->next && avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format))
-        p = &(*p)->next;
-
-    if (!format->next)
-        last_oformat = &format->next;
-}
 
 int av_match_ext(const char *filename, const char *extensions)
 {
@@ -99,6 +52,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
                                 const char *mime_type)
 {
     AVOutputFormat *fmt = NULL, *fmt_found;
+    void *i = 0;
     int score_max, score;
 
     /* specific test for image sequences */
@@ -112,7 +66,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
     /* Find the proper file type. */
     fmt_found = NULL;
     score_max = 0;
-    while ((fmt = av_oformat_next(fmt))) {
+    while ((fmt = av_muxer_iterate(&i))) {
         score = 0;
         if (fmt->name && short_name && av_match_name(short_name, fmt->name))
             score += 100;
@@ -164,7 +118,8 @@ enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
 AVInputFormat *av_find_input_format(const char *short_name)
 {
     AVInputFormat *fmt = NULL;
-    while ((fmt = av_iformat_next(fmt)))
+    void *i = 0;
+    while ((fmt = av_demuxer_iterate(&i)))
         if (av_match_name(short_name, fmt->name))
             return fmt;
     return NULL;
@@ -176,6 +131,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
     AVProbeData lpd = *pd;
     AVInputFormat *fmt1 = NULL, *fmt;
     int score, score_max = 0;
+    void *i = 0;
     const static uint8_t zerobuffer[AVPROBE_PADDING_SIZE];
     enum nodat {
         NO_ID3,
@@ -201,7 +157,7 @@ AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened,
     }
 
     fmt = NULL;
-    while ((fmt1 = av_iformat_next(fmt1))) {
+    while ((fmt1 = av_demuxer_iterate(&i))) {
         if (!is_opened == !(fmt1->flags & AVFMT_NOFILE) && strcmp(fmt1->name, "image2"))
             continue;
         score = 0;
diff --git a/libavformat/version.h b/libavformat/version.h
index 3b2a188..455872d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -85,6 +85,9 @@
 #ifndef FF_API_RTP_NEXT
 #define FF_API_RTP_NEXT                 (LIBAVFORMAT_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_NEXT
+#define FF_API_NEXT                     (LIBAVFORMAT_VERSION_MAJOR < 59)
+#endif
 
 #ifndef FF_API_R_FRAME_RATE
 #define FF_API_R_FRAME_RATE            1
-- 
2.7.4


More information about the ffmpeg-devel mailing list