X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fallformats.c;h=adcc8d90a7da6a2e35328b17aca60e47367f56ce;hb=d25c945247979a88fac6bb3b7a26370262b96ef1;hp=e748faf4e60a1901b3093b9cae81c6c35d8735df;hpb=d8ae40611bc01257776b71f20d774eb720151906;p=ffmpeg diff --git a/libavformat/allformats.c b/libavformat/allformats.c index e748faf4e60..adcc8d90a7d 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -20,6 +20,7 @@ */ #include "libavutil/thread.h" +#include "libavformat/internal.h" #include "avformat.h" #include "rtp.h" #include "rdt.h" @@ -361,6 +362,7 @@ extern AVInputFormat ff_sdr2_demuxer; extern AVInputFormat ff_sds_demuxer; extern AVInputFormat ff_sdx_demuxer; extern AVInputFormat ff_segafilm_demuxer; +extern AVOutputFormat ff_segafilm_muxer; extern AVOutputFormat ff_segment_muxer; extern AVOutputFormat ff_stream_segment_muxer; extern AVInputFormat ff_shorten_demuxer; @@ -474,34 +476,57 @@ 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; +extern AVInputFormat ff_image_xwd_pipe_demuxer; /* external libraries */ extern AVOutputFormat ff_chromaprint_muxer; extern AVInputFormat ff_libgme_demuxer; extern AVInputFormat ff_libmodplug_demuxer; extern AVInputFormat ff_libopenmpt_demuxer; +extern AVInputFormat ff_vapoursynth_demuxer; #include "libavformat/muxer_list.c" #include "libavformat/demuxer_list.c" +static const AVInputFormat * const *indev_list = NULL; +static const AVOutputFormat * const *outdev_list = NULL; + const AVOutputFormat *av_muxer_iterate(void **opaque) { + static const uintptr_t size = sizeof(muxer_list)/sizeof(muxer_list[0]) - 1; uintptr_t i = (uintptr_t)*opaque; - const AVOutputFormat *f = muxer_list[i]; + const AVOutputFormat *f = NULL; + + if (i < size) { + f = muxer_list[i]; + } else if (indev_list) { + f = outdev_list[i - size]; + } + if (f) *opaque = (void*)(i + 1); return f; } -const AVInputFormat *av_demuxer_iterate(void **opaque){ +const AVInputFormat *av_demuxer_iterate(void **opaque) +{ + static const uintptr_t size = sizeof(demuxer_list)/sizeof(demuxer_list[0]) - 1; uintptr_t i = (uintptr_t)*opaque; - const AVInputFormat *f = demuxer_list[i]; + const AVInputFormat *f = NULL; + + if (i < size) { + f = demuxer_list[i]; + } else if (outdev_list) { + f = indev_list[i - size]; + } if (f) *opaque = (void*)(i + 1); return f; } +static AVMutex avpriv_register_devices_mutex = AV_MUTEX_INITIALIZER; + #if FF_API_NEXT FF_DISABLE_DEPRECATION_WARNINGS static AVOnce av_format_next_init = AV_ONCE_INIT; @@ -510,38 +535,62 @@ static void av_format_init_next(void) { AVOutputFormat *prevout = NULL, *out; AVInputFormat *previn = NULL, *in; - void *i = 0; - while ((out = (AVOutputFormat*)av_muxer_iterate(&i))) { + ff_mutex_lock(&avpriv_register_devices_mutex); + + for (int i = 0; (out = (AVOutputFormat*)muxer_list[i]); i++) { if (prevout) prevout->next = out; prevout = out; } - i = 0; - while ((in = (AVInputFormat*)av_demuxer_iterate(&i))) { + if (outdev_list) { + for (int i = 0; (out = (AVOutputFormat*)outdev_list[i]); i++) { + if (prevout) + prevout->next = out; + prevout = out; + } + } + + for (int i = 0; (in = (AVInputFormat*)demuxer_list[i]); i++) { if (previn) previn->next = in; previn = in; } + + if (indev_list) { + for (int i = 0; (in = (AVInputFormat*)indev_list[i]); i++) { + if (previn) + previn->next = in; + previn = in; + } + } + + ff_mutex_unlock(&avpriv_register_devices_mutex); } AVInputFormat *av_iformat_next(const AVInputFormat *f) { ff_thread_once(&av_format_next_init, av_format_init_next); + if (f) return f->next; - else - return demuxer_list[0]; + else { + void *opaque = NULL; + return (AVInputFormat *)av_demuxer_iterate(&opaque); + } } AVOutputFormat *av_oformat_next(const AVOutputFormat *f) { ff_thread_once(&av_format_next_init, av_format_init_next); + if (f) return f->next; - else - return muxer_list[0]; + else { + void *opaque = NULL; + return (AVOutputFormat *)av_muxer_iterate(&opaque); + } } void av_register_all(void) @@ -560,3 +609,14 @@ void av_register_output_format(AVOutputFormat *format) } FF_ENABLE_DEPRECATION_WARNINGS #endif + +void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]) +{ + ff_mutex_lock(&avpriv_register_devices_mutex); + outdev_list = o; + indev_list = i; + ff_mutex_unlock(&avpriv_register_devices_mutex); +#if FF_API_NEXT + av_format_init_next(); +#endif +}