Commit 65452bcd authored by Josh de Kock's avatar Josh de Kock

lavd: remove linked lists

Signed-off-by: 's avatarJosh de Kock <josh@itanimul.li>
parent d8ae4061
......@@ -3622,21 +3622,12 @@ for v in "$@"; do
FFMPEG_CONFIGURATION="${FFMPEG_CONFIGURATION# } ${l}${r}"
done
find_things(){
thing=$1
pattern=$2
file=$source_path/$3
sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file"
}
OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c)
INDEV_LIST=$(find_things indev _IN libavdevice/alldevices.c)
find_things_extern(){
thing=$1
pattern=$2
file=$source_path/$3
sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file"
out=${4:-$thing}
sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$out/p" "$file"
}
find_filters_extern(){
......@@ -3646,6 +3637,8 @@ find_filters_extern(){
}
FILTER_LIST=$(find_filters_extern libavfilter/allfilters.c)
OUTDEV_LIST=$(find_things_extern muxer AVOutputFormat libavdevice/alldevices.c outdev)
INDEV_LIST=$(find_things_extern demuxer AVInputFormat libavdevice/alldevices.c indev)
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)
......@@ -7179,6 +7172,12 @@ print_enabled_components(){
filter_list)
c=$(full_filter_name $(remove_suffix _filter $c))
;;
indev_list)
c=$(add_suffix _demuxer $(remove_suffix _indev $c))
;;
outdev_list)
c=$(add_suffix _muxer $(remove_suffix _outdev $c))
;;
esac
printf " &ff_%s,\n" $c >> $TMPH
fi
......@@ -7198,6 +7197,8 @@ print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PAR
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 libavdevice/indev_list.c AVInputFormat indev_list $INDEV_LIST
print_enabled_components libavdevice/outdev_list.c AVOutputFormat outdev_list $OUTDEV_LIST
print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST
# Settings for pkg-config files
......
......@@ -22,57 +22,48 @@
#include "libavutil/thread.h"
#include "avdevice.h"
#define REGISTER_OUTDEV(X, x) \
{ \
extern AVOutputFormat ff_##x##_muxer; \
if (CONFIG_##X##_OUTDEV) \
av_register_output_format(&ff_##x##_muxer); \
}
/* devices */
extern AVInputFormat ff_alsa_demuxer;
extern AVOutputFormat ff_alsa_muxer;
extern AVInputFormat ff_android_camera_demuxer;
extern AVInputFormat ff_avfoundation_demuxer;
extern AVInputFormat ff_bktr_demuxer;
extern AVOutputFormat ff_caca_muxer;
extern AVInputFormat ff_decklink_demuxer;
extern AVOutputFormat ff_decklink_muxer;
extern AVInputFormat ff_libndi_newtek_demuxer;
extern AVOutputFormat ff_libndi_newtek_muxer;
extern AVInputFormat ff_dshow_demuxer;
extern AVInputFormat ff_fbdev_demuxer;
extern AVOutputFormat ff_fbdev_muxer;
extern AVInputFormat ff_gdigrab_demuxer;
extern AVInputFormat ff_iec61883_demuxer;
extern AVInputFormat ff_jack_demuxer;
extern AVInputFormat ff_kmsgrab_demuxer;
extern AVInputFormat ff_lavfi_demuxer;
extern AVInputFormat ff_openal_demuxer;
extern AVOutputFormat ff_opengl_muxer;
extern AVInputFormat ff_oss_demuxer;
extern AVOutputFormat ff_oss_muxer;
extern AVInputFormat ff_pulse_demuxer;
extern AVOutputFormat ff_pulse_muxer;
extern AVOutputFormat ff_sdl2_muxer;
extern AVInputFormat ff_sndio_demuxer;
extern AVOutputFormat ff_sndio_muxer;
extern AVInputFormat ff_v4l2_demuxer;
extern AVOutputFormat ff_v4l2_muxer;
extern AVInputFormat ff_vfwcap_demuxer;
extern AVInputFormat ff_xcbgrab_demuxer;
extern AVOutputFormat ff_xv_muxer;
#define REGISTER_INDEV(X, x) \
{ \
extern AVInputFormat ff_##x##_demuxer; \
if (CONFIG_##X##_INDEV) \
av_register_input_format(&ff_##x##_demuxer); \
}
/* external libraries */
extern AVInputFormat ff_libcdio_demuxer;
extern AVInputFormat ff_libdc1394_demuxer;
#define REGISTER_INOUTDEV(X, x) REGISTER_OUTDEV(X, x); REGISTER_INDEV(X, x)
static void register_all(void)
{
/* devices */
REGISTER_INOUTDEV(ALSA, alsa);
REGISTER_INDEV (AVFOUNDATION, avfoundation);
REGISTER_INDEV (BKTR, bktr);
REGISTER_OUTDEV (CACA, caca);
REGISTER_INOUTDEV(DECKLINK, decklink);
REGISTER_INOUTDEV(LIBNDI_NEWTEK, libndi_newtek);
REGISTER_INDEV (DSHOW, dshow);
REGISTER_INOUTDEV(FBDEV, fbdev);
REGISTER_INDEV (GDIGRAB, gdigrab);
REGISTER_INDEV (IEC61883, iec61883);
REGISTER_INDEV (JACK, jack);
REGISTER_INDEV (KMSGRAB, kmsgrab);
REGISTER_INDEV (LAVFI, lavfi);
REGISTER_INDEV (OPENAL, openal);
REGISTER_OUTDEV (OPENGL, opengl);
REGISTER_INOUTDEV(OSS, oss);
REGISTER_INOUTDEV(PULSE, pulse);
REGISTER_OUTDEV (SDL2, sdl2);
REGISTER_INOUTDEV(SNDIO, sndio);
REGISTER_INOUTDEV(V4L2, v4l2);
REGISTER_INDEV (VFWCAP, vfwcap);
REGISTER_INDEV (XCBGRAB, xcbgrab);
REGISTER_OUTDEV (XV, xv);
/* external libraries */
REGISTER_INDEV (LIBCDIO, libcdio);
REGISTER_INDEV (LIBDC1394, libdc1394);
}
#include "libavdevice/outdev_list.c"
#include "libavdevice/indev_list.c"
void avdevice_register_all(void)
{
static AVOnce control = AV_ONCE_INIT;
ff_thread_once(&control, register_all);
avpriv_register_devices(outdev_list, indev_list);
}
......@@ -484,24 +484,45 @@ extern AVInputFormat ff_libopenmpt_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 - 1) {
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 +531,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 +605,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
}
......@@ -3060,6 +3060,8 @@ int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
*/
AVRational av_stream_get_codec_timebase(const AVStream *st);
void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputFormat * const i[]);
/**
* @}
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment