Based on an unfinished patch by atomnuker.tags/n4.0
| @@ -142,7 +142,8 @@ distclean:: clean | |||||
| $(RM) .version avversion.h config.asm config.h mapfile \ | $(RM) .version avversion.h config.asm config.h mapfile \ | ||||
| ffbuild/.config ffbuild/config.* libavutil/avconfig.h \ | ffbuild/.config ffbuild/config.* libavutil/avconfig.h \ | ||||
| version.h libavutil/ffversion.h libavcodec/codec_names.h \ | version.h libavutil/ffversion.h libavcodec/codec_names.h \ | ||||
| libavcodec/bsf_list.c libavformat/protocol_list.c | |||||
| libavcodec/bsf_list.c libavformat/protocol_list.c \ | |||||
| libavcodec/codec_list.c libavcodec/parser_list.c | |||||
| ifeq ($(SRC_LINK),src) | ifeq ($(SRC_LINK),src) | ||||
| $(RM) src | $(RM) src | ||||
| endif | endif | ||||
| @@ -3525,9 +3525,6 @@ find_things(){ | |||||
| sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file" | sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file" | ||||
| } | } | ||||
| ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c) | |||||
| DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c) | |||||
| PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c) | |||||
| MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c) | MUXER_LIST=$(find_things muxer _MUX libavformat/allformats.c) | ||||
| DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c) | DEMUXER_LIST=$(find_things demuxer DEMUX libavformat/allformats.c) | ||||
| OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) | OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) | ||||
| @@ -3541,6 +3538,13 @@ find_things_extern(){ | |||||
| sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file" | sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file" | ||||
| } | } | ||||
| ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c) | |||||
| DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c) | |||||
| CODEC_LIST=" | |||||
| $ENCODER_LIST | |||||
| $DECODER_LIST | |||||
| " | |||||
| PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c) | |||||
| BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c) | BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c) | ||||
| HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h) | HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h) | ||||
| PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c) | PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c) | ||||
| @@ -7029,6 +7033,8 @@ print_enabled_components(){ | |||||
| cp_if_changed $TMPH $file | cp_if_changed $TMPH $file | ||||
| } | } | ||||
| 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 libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST | ||||
| print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST | print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST | ||||
| @@ -15,6 +15,10 @@ libavutil: 2017-10-21 | |||||
| API changes, most recent first: | API changes, most recent first: | ||||
| 2018-01-xx - xxxxxxx - lavc 58.9.100 - avcodec.h | |||||
| Deprecate use of avcodec_register(), avcodec_register_all(), and | |||||
| av_codec_next(). Add av_codec_iterate(). | |||||
| 2018-02-xx - xxxxxxx - lavf 58.8.100 - avformat.h | 2018-02-xx - xxxxxxx - lavf 58.8.100 - avformat.h | ||||
| Deprecate the current names of the RTSP "timeout", "stimeout", "user-agent" | Deprecate the current names of the RTSP "timeout", "stimeout", "user-agent" | ||||
| options. Introduce "listen_timeout" as replacement for the current "timeout" | options. Introduce "listen_timeout" as replacement for the current "timeout" | ||||
| @@ -2,3 +2,5 @@ | |||||
| /*_tables.c | /*_tables.c | ||||
| /*_tables.h | /*_tables.h | ||||
| /bsf_list.c | /bsf_list.c | ||||
| /codec_list.c | |||||
| /parser_list.c | |||||
| @@ -3978,12 +3978,26 @@ typedef struct AVCodecParameters { | |||||
| int seek_preroll; | int seek_preroll; | ||||
| } AVCodecParameters; | } AVCodecParameters; | ||||
| /** | |||||
| * Iterate over all registered codecs. | |||||
| * | |||||
| * @param opaque a pointer where libavcodec will store the iteration state. Must | |||||
| * point to NULL to start the iteration. | |||||
| * | |||||
| * @return the next registered codec or NULL when the iteration is | |||||
| * finished | |||||
| */ | |||||
| const AVCodec *av_codec_iterate(void **opaque); | |||||
| #if FF_API_NEXT | |||||
| /** | /** | ||||
| * If c is NULL, returns the first registered codec, | * If c is NULL, returns the first registered codec, | ||||
| * if c is non-NULL, returns the next registered codec after c, | * if c is non-NULL, returns the next registered codec after c, | ||||
| * or NULL if c is the last one. | * or NULL if c is the last one. | ||||
| */ | */ | ||||
| attribute_deprecated | |||||
| AVCodec *av_codec_next(const AVCodec *c); | AVCodec *av_codec_next(const AVCodec *c); | ||||
| #endif | |||||
| /** | /** | ||||
| * Return the LIBAVCODEC_VERSION_INT constant. | * Return the LIBAVCODEC_VERSION_INT constant. | ||||
| @@ -4000,6 +4014,7 @@ const char *avcodec_configuration(void); | |||||
| */ | */ | ||||
| const char *avcodec_license(void); | const char *avcodec_license(void); | ||||
| #if FF_API_NEXT | |||||
| /** | /** | ||||
| * Register the codec codec and initialize libavcodec. | * Register the codec codec and initialize libavcodec. | ||||
| * | * | ||||
| @@ -4008,6 +4023,7 @@ const char *avcodec_license(void); | |||||
| * | * | ||||
| * @see avcodec_register_all() | * @see avcodec_register_all() | ||||
| */ | */ | ||||
| attribute_deprecated | |||||
| void avcodec_register(AVCodec *codec); | void avcodec_register(AVCodec *codec); | ||||
| /** | /** | ||||
| @@ -4020,7 +4036,9 @@ void avcodec_register(AVCodec *codec); | |||||
| * @see av_register_codec_parser | * @see av_register_codec_parser | ||||
| * @see av_register_bitstream_filter | * @see av_register_bitstream_filter | ||||
| */ | */ | ||||
| attribute_deprecated | |||||
| void avcodec_register_all(void); | void avcodec_register_all(void); | ||||
| #endif | |||||
| /** | /** | ||||
| * Allocate an AVCodecContext and set its fields to default values. The | * Allocate an AVCodecContext and set its fields to default values. The | ||||
| @@ -5120,8 +5138,21 @@ typedef struct AVCodecParser { | |||||
| struct AVCodecParser *next; | struct AVCodecParser *next; | ||||
| } AVCodecParser; | } AVCodecParser; | ||||
| /** | |||||
| * Iterate over all registered codec parsers. | |||||
| * | |||||
| * @param opaque a pointer where libavcodec will store the iteration state. Must | |||||
| * point to NULL to start the iteration. | |||||
| * | |||||
| * @return the next registered codec parser or NULL when the iteration is | |||||
| * finished | |||||
| */ | |||||
| const AVCodecParser *av_parser_iterate(void **opaque); | |||||
| attribute_deprecated | |||||
| AVCodecParser *av_parser_next(const AVCodecParser *c); | AVCodecParser *av_parser_next(const AVCodecParser *c); | ||||
| attribute_deprecated | |||||
| void av_register_codec_parser(AVCodecParser *parser); | void av_register_codec_parser(AVCodecParser *parser); | ||||
| AVCodecParserContext *av_parser_init(int codec_id); | AVCodecParserContext *av_parser_init(int codec_id); | ||||
| @@ -32,36 +32,100 @@ | |||||
| #include "internal.h" | #include "internal.h" | ||||
| #include "parser.h" | #include "parser.h" | ||||
| static AVCodecParser *av_first_parser = NULL; | |||||
| /* Parsers */ | |||||
| extern AVCodecParser ff_aac_parser; | |||||
| extern AVCodecParser ff_aac_latm_parser; | |||||
| extern AVCodecParser ff_ac3_parser; | |||||
| extern AVCodecParser ff_adx_parser; | |||||
| extern AVCodecParser ff_bmp_parser; | |||||
| extern AVCodecParser ff_cavsvideo_parser; | |||||
| extern AVCodecParser ff_cook_parser; | |||||
| extern AVCodecParser ff_dca_parser; | |||||
| extern AVCodecParser ff_dirac_parser; | |||||
| extern AVCodecParser ff_dnxhd_parser; | |||||
| extern AVCodecParser ff_dpx_parser; | |||||
| extern AVCodecParser ff_dvaudio_parser; | |||||
| extern AVCodecParser ff_dvbsub_parser; | |||||
| extern AVCodecParser ff_dvdsub_parser; | |||||
| extern AVCodecParser ff_dvd_nav_parser; | |||||
| extern AVCodecParser ff_flac_parser; | |||||
| extern AVCodecParser ff_g729_parser; | |||||
| extern AVCodecParser ff_gsm_parser; | |||||
| extern AVCodecParser ff_h261_parser; | |||||
| extern AVCodecParser ff_h263_parser; | |||||
| extern AVCodecParser ff_h264_parser; | |||||
| extern AVCodecParser ff_hevc_parser; | |||||
| extern AVCodecParser ff_mjpeg_parser; | |||||
| extern AVCodecParser ff_mlp_parser; | |||||
| extern AVCodecParser ff_mpeg4video_parser; | |||||
| extern AVCodecParser ff_mpegaudio_parser; | |||||
| extern AVCodecParser ff_mpegvideo_parser; | |||||
| extern AVCodecParser ff_opus_parser; | |||||
| extern AVCodecParser ff_png_parser; | |||||
| extern AVCodecParser ff_pnm_parser; | |||||
| extern AVCodecParser ff_rv30_parser; | |||||
| extern AVCodecParser ff_rv40_parser; | |||||
| extern AVCodecParser ff_sipr_parser; | |||||
| extern AVCodecParser ff_tak_parser; | |||||
| extern AVCodecParser ff_vc1_parser; | |||||
| extern AVCodecParser ff_vorbis_parser; | |||||
| extern AVCodecParser ff_vp3_parser; | |||||
| extern AVCodecParser ff_vp8_parser; | |||||
| extern AVCodecParser ff_vp9_parser; | |||||
| extern AVCodecParser ff_xma_parser; | |||||
| #include "libavcodec/parser_list.c" | |||||
| static AVOnce av_parser_next_init = AV_ONCE_INIT; | |||||
| static void av_parser_init_next(void) | |||||
| { | |||||
| AVCodecParser *prev = NULL, *p; | |||||
| int i = 0; | |||||
| while ((p = (AVCodecParser*)parser_list[i++])) { | |||||
| if (prev) | |||||
| prev->next = p; | |||||
| prev = p; | |||||
| } | |||||
| } | |||||
| AVCodecParser *av_parser_next(const AVCodecParser *p) | AVCodecParser *av_parser_next(const AVCodecParser *p) | ||||
| { | { | ||||
| ff_thread_once(&av_parser_next_init, av_parser_init_next); | |||||
| if (p) | if (p) | ||||
| return p->next; | return p->next; | ||||
| else | else | ||||
| return av_first_parser; | |||||
| return (AVCodecParser*)parser_list[0]; | |||||
| } | } | ||||
| static AVMutex parser_register_mutex = AV_MUTEX_INITIALIZER; | |||||
| const AVCodecParser *av_parser_iterate(void **opaque) | |||||
| { | |||||
| uintptr_t i = (uintptr_t)*opaque; | |||||
| const AVCodecParser *p = parser_list[i]; | |||||
| if (p) | |||||
| *opaque = (void*)(i + 1); | |||||
| return p; | |||||
| } | |||||
| void av_register_codec_parser(AVCodecParser *parser) | void av_register_codec_parser(AVCodecParser *parser) | ||||
| { | { | ||||
| ff_mutex_lock(&parser_register_mutex); | |||||
| parser->next = av_first_parser; | |||||
| av_first_parser = parser; | |||||
| ff_mutex_unlock(&parser_register_mutex); | |||||
| ff_thread_once(&av_parser_next_init, av_parser_init_next); | |||||
| } | } | ||||
| AVCodecParserContext *av_parser_init(int codec_id) | AVCodecParserContext *av_parser_init(int codec_id) | ||||
| { | { | ||||
| AVCodecParserContext *s = NULL; | AVCodecParserContext *s = NULL; | ||||
| AVCodecParser *parser; | |||||
| const AVCodecParser *parser; | |||||
| void *i = 0; | |||||
| int ret; | int ret; | ||||
| if (codec_id == AV_CODEC_ID_NONE) | if (codec_id == AV_CODEC_ID_NONE) | ||||
| return NULL; | return NULL; | ||||
| for (parser = av_first_parser; parser; parser = parser->next) { | |||||
| while ((parser = av_parser_iterate(&i))) { | |||||
| if (parser->codec_ids[0] == codec_id || | if (parser->codec_ids[0] == codec_id || | ||||
| parser->codec_ids[1] == codec_id || | parser->codec_ids[1] == codec_id || | ||||
| parser->codec_ids[2] == codec_id || | parser->codec_ids[2] == codec_id || | ||||
| @@ -75,7 +139,7 @@ found: | |||||
| s = av_mallocz(sizeof(AVCodecParserContext)); | s = av_mallocz(sizeof(AVCodecParserContext)); | ||||
| if (!s) | if (!s) | ||||
| goto err_out; | goto err_out; | ||||
| s->parser = parser; | |||||
| s->parser = (AVCodecParser*)parser; | |||||
| s->priv_data = av_mallocz(parser->priv_data_size); | s->priv_data = av_mallocz(parser->priv_data_size); | ||||
| if (!s->priv_data) | if (!s->priv_data) | ||||
| goto err_out; | goto err_out; | ||||
| @@ -46,7 +46,6 @@ | |||||
| #include "decode.h" | #include "decode.h" | ||||
| #include "hwaccel.h" | #include "hwaccel.h" | ||||
| #include "libavutil/opt.h" | #include "libavutil/opt.h" | ||||
| #include "me_cmp.h" | |||||
| #include "mpegvideo.h" | #include "mpegvideo.h" | ||||
| #include "thread.h" | #include "thread.h" | ||||
| #include "frame_thread_encoder.h" | #include "frame_thread_encoder.h" | ||||
| @@ -92,18 +91,6 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size) | |||||
| memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE); | memset(*p, 0, min_size + AV_INPUT_BUFFER_PADDING_SIZE); | ||||
| } | } | ||||
| /* encoder management */ | |||||
| static AVCodec *first_avcodec = NULL; | |||||
| static AVCodec **last_avcodec = &first_avcodec; | |||||
| AVCodec *av_codec_next(const AVCodec *c) | |||||
| { | |||||
| if (c) | |||||
| return c->next; | |||||
| else | |||||
| return first_avcodec; | |||||
| } | |||||
| int av_codec_is_encoder(const AVCodec *codec) | int av_codec_is_encoder(const AVCodec *codec) | ||||
| { | { | ||||
| return codec && (codec->encode_sub || codec->encode2 ||codec->send_frame); | return codec && (codec->encode_sub || codec->encode2 ||codec->send_frame); | ||||
| @@ -114,27 +101,6 @@ int av_codec_is_decoder(const AVCodec *codec) | |||||
| return codec && (codec->decode || codec->receive_frame); | return codec && (codec->decode || codec->receive_frame); | ||||
| } | } | ||||
| static AVMutex codec_register_mutex = AV_MUTEX_INITIALIZER; | |||||
| av_cold void avcodec_register(AVCodec *codec) | |||||
| { | |||||
| AVCodec **p; | |||||
| ff_mutex_lock(&codec_register_mutex); | |||||
| p = last_avcodec; | |||||
| while (*p) | |||||
| p = &(*p)->next; | |||||
| *p = codec; | |||||
| codec->next = NULL; | |||||
| last_avcodec = &codec->next; | |||||
| ff_mutex_unlock(&codec_register_mutex); | |||||
| if (codec->init_static_data) | |||||
| codec->init_static_data(codec); | |||||
| } | |||||
| int ff_set_dimensions(AVCodecContext *s, int width, int height) | int ff_set_dimensions(AVCodecContext *s, int width, int height) | ||||
| { | { | ||||
| int ret = av_image_check_size2(width, height, s->max_pixels, AV_PIX_FMT_NONE, 0, s); | int ret = av_image_check_size2(width, height, s->max_pixels, AV_PIX_FMT_NONE, 0, s); | ||||
| @@ -1155,71 +1121,6 @@ FF_ENABLE_DEPRECATION_WARNINGS | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) | |||||
| { | |||||
| switch(id){ | |||||
| //This is for future deprecatec codec ids, its empty since | |||||
| //last major bump but will fill up again over time, please don't remove it | |||||
| default : return id; | |||||
| } | |||||
| } | |||||
| static AVCodec *find_encdec(enum AVCodecID id, int encoder) | |||||
| { | |||||
| AVCodec *p, *experimental = NULL; | |||||
| p = first_avcodec; | |||||
| id= remap_deprecated_codec_id(id); | |||||
| while (p) { | |||||
| if ((encoder ? av_codec_is_encoder(p) : av_codec_is_decoder(p)) && | |||||
| p->id == id) { | |||||
| if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) { | |||||
| experimental = p; | |||||
| } else | |||||
| return p; | |||||
| } | |||||
| p = p->next; | |||||
| } | |||||
| return experimental; | |||||
| } | |||||
| AVCodec *avcodec_find_encoder(enum AVCodecID id) | |||||
| { | |||||
| return find_encdec(id, 1); | |||||
| } | |||||
| AVCodec *avcodec_find_encoder_by_name(const char *name) | |||||
| { | |||||
| AVCodec *p; | |||||
| if (!name) | |||||
| return NULL; | |||||
| p = first_avcodec; | |||||
| while (p) { | |||||
| if (av_codec_is_encoder(p) && strcmp(name, p->name) == 0) | |||||
| return p; | |||||
| p = p->next; | |||||
| } | |||||
| return NULL; | |||||
| } | |||||
| AVCodec *avcodec_find_decoder(enum AVCodecID id) | |||||
| { | |||||
| return find_encdec(id, 0); | |||||
| } | |||||
| AVCodec *avcodec_find_decoder_by_name(const char *name) | |||||
| { | |||||
| AVCodec *p; | |||||
| if (!name) | |||||
| return NULL; | |||||
| p = first_avcodec; | |||||
| while (p) { | |||||
| if (av_codec_is_decoder(p) && strcmp(name, p->name) == 0) | |||||
| return p; | |||||
| p = p->next; | |||||
| } | |||||
| return NULL; | |||||
| } | |||||
| const char *avcodec_get_name(enum AVCodecID id) | const char *avcodec_get_name(enum AVCodecID id) | ||||
| { | { | ||||
| const AVCodecDescriptor *cd; | const AVCodecDescriptor *cd; | ||||
| @@ -129,6 +129,9 @@ | |||||
| #ifndef FF_API_LOCKMGR | #ifndef FF_API_LOCKMGR | ||||
| #define FF_API_LOCKMGR (LIBAVCODEC_VERSION_MAJOR < 59) | #define FF_API_LOCKMGR (LIBAVCODEC_VERSION_MAJOR < 59) | ||||
| #endif | #endif | ||||
| #ifndef FF_API_NEXT | |||||
| #define FF_API_NEXT (LIBAVCODEC_VERSION_MAJOR < 59) | |||||
| #endif | |||||
| #endif /* AVCODEC_VERSION_H */ | #endif /* AVCODEC_VERSION_H */ | ||||