diff --git a/src/AVDemuxer.cpp b/src/AVDemuxer.cpp index 314f4f84b..d48ac8cf2 100644 --- a/src/AVDemuxer.cpp +++ b/src/AVDemuxer.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2017 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -326,7 +326,9 @@ AVDemuxer::AVDemuxer(QObject *parent) class AVInitializer { public: AVInitializer() { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); +#endif #if QTAV_HAVE(AVDEVICE) avdevice_register_all(); #endif diff --git a/src/QtAV/private/AVCompat.h b/src/QtAV/private/AVCompat.h index 944cfd7de..51afbb780 100644 --- a/src/QtAV/private/AVCompat.h +++ b/src/QtAV/private/AVCompat.h @@ -1,7 +1,7 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg solve the version problem and diffirent api in FFmpeg and libav - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -61,6 +61,8 @@ extern "C" #include #include +#define AVCODEC_STATIC_REGISTER FFMPEG_MODULE_CHECK(LIBAVCODEC, 58, 10, 100) + #if !FFMPEG_MODULE_CHECK(LIBAVUTIL, 51, 73, 101) #include #endif diff --git a/src/QtAV_Global.cpp b/src/QtAV_Global.cpp index 56d66b9bb..07ea14a29 100644 --- a/src/QtAV_Global.cpp +++ b/src/QtAV_Global.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2017 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -190,7 +190,7 @@ QString aboutQtAV_HTML() { static QString about = QString::fromLatin1("

QtAV " QTAV_VERSION_STR_LONG "

\n" "

%1

%2

%3

" - "

Copyright (C) 2012-2017 Wang Bin (aka. Lucas Wang) wbsecg1@gmail.com

\n" + "

Copyright (C) 2012-2018 Wang Bin (aka. Lucas Wang) wbsecg1@gmail.com

\n" "

%4: http://qtav.org/donate.html

\n" "

%5: https://github.com/wang-bin/QtAV

\n" "

%6: http://qtav.org

" @@ -305,9 +305,14 @@ QString avcodecOptions() void* obj = const_cast(reinterpret_cast(avcodec_get_class())); opts = Internal::optionsToString((void*)&obj); opts.append(ushort('\n')); + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else avcodec_register_all(); - AVCodec* c = NULL; - while ((c=av_codec_next(c))) { + while ((c = av_codec_next(c))) { +#endif QString opt(Internal::optionsToString((void*)&c->priv_class).trimmed()); if (opt.isEmpty()) continue; diff --git a/src/codec/AVDecoder.cpp b/src/codec/AVDecoder.cpp index 4c3fce690..440504d01 100644 --- a/src/codec/AVDecoder.cpp +++ b/src/codec/AVDecoder.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -47,7 +47,9 @@ static AVCodec* get_codec(const QString &name, const QString& hwa, AVCodecID cid AVDecoder::AVDecoder(AVDecoderPrivate &d) :DPTR_INIT(&d) { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); // avcodec_find_decoder will always be used +#endif } AVDecoder::~AVDecoder() diff --git a/src/codec/audio/AudioDecoder.cpp b/src/codec/audio/AudioDecoder.cpp index f847657a7..70ae555d9 100644 --- a/src/codec/audio/AudioDecoder.cpp +++ b/src/codec/audio/AudioDecoder.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -43,9 +43,14 @@ QStringList AudioDecoder::supportedCodecs() static QStringList codecs; if (!codecs.isEmpty()) return codecs; + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else avcodec_register_all(); - AVCodec* c = NULL; - while ((c=av_codec_next(c))) { + while ((c = av_codec_next(c))) { +#endif if (!av_codec_is_decoder(c) || c->type != AVMEDIA_TYPE_AUDIO) continue; codecs.append(QString::fromLatin1(c->name)); diff --git a/src/codec/audio/AudioDecoderFFmpeg.cpp b/src/codec/audio/AudioDecoderFFmpeg.cpp index 54985467b..d783588ae 100644 --- a/src/codec/audio/AudioDecoderFFmpeg.cpp +++ b/src/codec/audio/AudioDecoderFFmpeg.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -63,7 +63,9 @@ class AudioDecoderFFmpegPrivate Q_DECL_FINAL: public AudioDecoderPrivate : AudioDecoderPrivate() , frame(av_frame_alloc()) { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); +#endif } ~AudioDecoderFFmpegPrivate() { if (frame) { diff --git a/src/codec/audio/AudioEncoder.cpp b/src/codec/audio/AudioEncoder.cpp index 56da0f1c3..6bed83ad0 100644 --- a/src/codec/audio/AudioEncoder.cpp +++ b/src/codec/audio/AudioEncoder.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2015) @@ -45,9 +45,14 @@ QStringList AudioEncoder::supportedCodecs() static QStringList codecs; if (!codecs.isEmpty()) return codecs; + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else avcodec_register_all(); - AVCodec* c = NULL; - while ((c=av_codec_next(c))) { + while ((c = av_codec_next(c))) { +#endif if (!av_codec_is_encoder(c) || c->type != AVMEDIA_TYPE_AUDIO) continue; codecs.append(QString::fromLatin1(c->name)); diff --git a/src/codec/video/VideoDecoder.cpp b/src/codec/video/VideoDecoder.cpp index bd7c4f914..a78940c99 100644 --- a/src/codec/video/VideoDecoder.cpp +++ b/src/codec/video/VideoDecoder.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV @@ -93,9 +93,14 @@ QStringList VideoDecoder::supportedCodecs() static QStringList codecs; if (!codecs.isEmpty()) return codecs; + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else avcodec_register_all(); - AVCodec* c = NULL; - while ((c=av_codec_next(c))) { + while ((c = av_codec_next(c))) { +#endif if (!av_codec_is_decoder(c) || c->type != AVMEDIA_TYPE_VIDEO) continue; codecs.append(QString::fromLatin1(c->name)); diff --git a/src/codec/video/VideoDecoderD3D.cpp b/src/codec/video/VideoDecoderD3D.cpp index bf3811fe5..bfaafb429 100644 --- a/src/codec/video/VideoDecoderD3D.cpp +++ b/src/codec/video/VideoDecoderD3D.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2016) @@ -34,7 +34,9 @@ namespace QtAV { static bool check_ffmpeg_hevc_dxva2() { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); +#endif AVHWAccel *hwa = av_hwaccel_next(0); while (hwa) { if (strncmp("hevc_dxva2", hwa->name, 10) == 0) diff --git a/src/codec/video/VideoDecoderFFmpegBase.h b/src/codec/video/VideoDecoderFFmpegBase.h index f59e97a65..dfae49ff7 100644 --- a/src/codec/video/VideoDecoderFFmpegBase.h +++ b/src/codec/video/VideoDecoderFFmpegBase.h @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2017 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2014) @@ -51,7 +51,9 @@ class VideoDecoderFFmpegBasePrivate : public VideoDecoderPrivate , width(0) , height(0) { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); +#endif frame = av_frame_alloc(); } virtual ~VideoDecoderFFmpegBasePrivate() { diff --git a/src/codec/video/VideoEncoder.cpp b/src/codec/video/VideoEncoder.cpp index 353085d26..fa7ff7dfb 100644 --- a/src/codec/video/VideoEncoder.cpp +++ b/src/codec/video/VideoEncoder.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2015) @@ -46,9 +46,14 @@ QStringList VideoEncoder::supportedCodecs() static QStringList codecs; if (!codecs.isEmpty()) return codecs; + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else avcodec_register_all(); - AVCodec* c = NULL; - while ((c=av_codec_next(c))) { + while ((c = av_codec_next(c))) { +#endif if (!av_codec_is_encoder(c) || c->type != AVMEDIA_TYPE_VIDEO) continue; codecs.append(QString::fromLatin1(c->name)); diff --git a/src/codec/video/VideoEncoderFFmpeg.cpp b/src/codec/video/VideoEncoderFFmpeg.cpp index 671efa7d3..c0c902cb0 100644 --- a/src/codec/video/VideoEncoderFFmpeg.cpp +++ b/src/codec/video/VideoEncoderFFmpeg.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2015) @@ -90,7 +90,9 @@ class VideoEncoderFFmpegPrivate Q_DECL_FINAL: public VideoEncoderPrivate : VideoEncoderPrivate() , nb_encoded(0) { +#if !AVCODEC_STATIC_REGISTER avcodec_register_all(); +#endif // NULL: codec-specific defaults won't be initialized, which may result in suboptimal default settings (this is important mainly for encoders, e.g. libx264). avctx = avcodec_alloc_context3(NULL); } diff --git a/src/subtitle/SubtitleProcessorFFmpeg.cpp b/src/subtitle/SubtitleProcessorFFmpeg.cpp index 1755c3816..32d9c8ffd 100644 --- a/src/subtitle/SubtitleProcessorFFmpeg.cpp +++ b/src/subtitle/SubtitleProcessorFFmpeg.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Multimedia framework based on Qt and FFmpeg - Copyright (C) 2012-2016 Wang Bin + Copyright (C) 2012-2018 Wang Bin * This file is part of QtAV (from 2014) @@ -80,12 +80,16 @@ QString SubtitleProcessorFFmpeg::name() const QStringList ffmpeg_supported_sub_extensions_by_codec() { QStringList exts; - AVCodec *c = av_codec_next(NULL); - while (c) { - if (c->type != AVMEDIA_TYPE_SUBTITLE) { - c = av_codec_next(c); + const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else + avcodec_register_all(); + while ((c = av_codec_next(c))) { +#endif + if (c->type != AVMEDIA_TYPE_SUBTITLE) continue; - } qDebug("sub codec: %s", c->name); AVInputFormat *i = av_iformat_next(NULL); while (i) { @@ -105,7 +109,6 @@ QStringList ffmpeg_supported_sub_extensions_by_codec() //qDebug("codec name '%s' is not found in AVInputFormat, just append codec name", c->name); //exts.append(c->name); } - c = av_codec_next(c); } return exts; } @@ -127,7 +130,13 @@ QStringList ffmpeg_supported_sub_extensions() // AVCodecDescriptor.name and AVCodec.name may be different. avcodec_get_name() use AVCodecDescriptor if possible QStringList codecs; const AVCodec* c = NULL; +#if AVCODEC_STATIC_REGISTER + void* it = NULL; + while ((c = av_codec_iterate(&it))) { +#else + avcodec_register_all(); while ((c = av_codec_next(c))) { +#endif if (c->type == AVMEDIA_TYPE_SUBTITLE) codecs.append(QString::fromLatin1(c->name)); }