[FFmpeg-cvslog] avformat: make avformat_network_init() explicitly optional
ffmpeg | branch: master | wm4 | Tue Jan 16 12:57:04 2018 +0100| [631c56a8e46dea41585f3e7b3ef9c52b49faa385] | committer: wm4 avformat: make avformat_network_init() explicitly optional It was sort of optional before - if you didn't call it, networking was initialized on demand, and an ugly warning was logged. Also, the doxygen comments threatened that it would be made strictly required one day. Make it explicitly optional. I would prefer to deprecate it fully, but there might still be legitimate reasons to use this. But the average user won't need it. This is needed only for two reasons: to initialize TLS libraries like OpenSSL and GnuTLS, and winsock. OpenSSL and GnuTLS were already silently initialized on demand if the global network init function was not called. They also have various thread-safety acrobatics, which make concurrent initialization within libavformat safe. In addition, the libraries are moving towards making their global init functions safe, which removes all need for central global init. In particular, GnuTLS 3.5.16 and OpenSSL 1.1.0g have been found to have safe init functions. In all cases, they use internal reference counters to avoid that the global uninit functions interfere with concurrent uses of the library by other API users who called global init. winsock should be thread-safe as well, and maintains an internal reference counter as well. Since we still support ancient TLS libraries, which do not have this fixed, and since it's unknown whether winsock and GnuTLS reinitialization is costly in any way, don't deprecate the libavformat functions yet. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=631c56a8e46dea41585f3e7b3ef9c52b49faa385 --- doc/APIchanges | 6 ++ libavformat/avformat.h | 19 +-- libavformat/network.c | 9 - libavformat/network.h | 1 - libavformat/utils.c| 2 -- libavformat/version.h | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0184815224..7699365879 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,12 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-01-xx - xxx - lavf 58.5.100 - avformat.h + Explicitly make avformat_network_init() and avformat_network_deinit() optional. + If these are not called, network initialization and deinitialization is + automatic, and unlike in older versions, fully supported, unless libavformat + is linked to ancient GnuTLS and OpenSSL. + 2018-01-xx - xxx - lavf 58.4.100 - avformat.h Deprecate AVStream.recommended_encoder_configuration. It was useful only for FFserver, which has been removed. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8556f80372..b0387214c5 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1998,17 +1998,24 @@ void av_register_input_format(AVInputFormat *format); void av_register_output_format(AVOutputFormat *format); /** - * Do global initialization of network components. This is optional, - * but recommended, since it avoids the overhead of implicitly - * doing the setup for each session. + * Do global initialization of network libraries. This is optional, + * and not recommended anymore. * - * Calling this function will become mandatory if using network - * protocols at some major version bump. + * This functions only exists to work around thread-safety issues + * with older GnuTLS or OpenSSL libraries. If libavformat is linked + * to newer versions of those libraries, or if you do not use them, + * calling this function is unnecessary. Otherwise, you need to call + * this function before any other threads using them are started. + * + * This function will be deprecated once support for older GnuTLS and + * OpenSSL libraries is removed, and this function has no purpose + * anymore. */ int avformat_network_init(void); /** - * Undo the initialization done by avformat_network_init. + * Undo the initialization done by avformat_network_init. Call it only + * once for each time you called avformat_network_init. */ int avformat_network_deinit(void); diff --git a/libavformat/network.c b/libavformat/network.c index e9eb4b443a..d5c82e9ab9 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -54,20 +54,11 @@ void ff_tls_deinit(void) #endif } -int ff_network_inited_globally; - int ff_network_init(void) { #if HAVE_WINSOCK2_H WSADATA wsaData; -#endif -if (!ff_network_inited_globally) -av_log(NULL, AV_LOG_WARNING, "Using network protocols without global " - "network initialization. Please use " - "avformat_network_init(), this will " - "become mandatory later.\n"); -#if HAVE_WINSOCK2_H if (WSAStartup(MAKEWORD(1,1), &wsaData)) return 0; #endif diff --git a/libavformat/network.h b/libavformat/network.h index 3c0f873279..e3fda4d5e2
[FFmpeg-cvslog] avformat: deprecate another ffserver API leftover
ffmpeg | branch: master | wm4 | Mon Jan 15 13:09:31 2018 +0100| [6512ff72f9cc058e27646604caeacc4ef0dbd93e] | committer: wm4 avformat: deprecate another ffserver API leftover > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6512ff72f9cc058e27646604caeacc4ef0dbd93e --- doc/APIchanges | 4 libavformat/avformat.h | 5 + libavformat/utils.c| 12 libavformat/version.h | 5 - 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index d66c842521..0184815224 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-01-xx - xxx - lavf 58.4.100 - avformat.h + Deprecate AVStream.recommended_encoder_configuration. It was useful only for + FFserver, which has been removed. + 2018-01-xx - xxx - lavfi 7.11.101 - avfilter.h Deprecate avfilter_link_get_channels(). Use av_buffersink_get_channels(). diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 4f2798a871..8556f80372 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -986,12 +986,15 @@ typedef struct AVStream { */ AVRational r_frame_rate; +#if FF_API_LAVF_FFSERVER /** * String containing pairs of key and values describing recommended encoder configuration. * Pairs are separated by ','. * Keys are separated from values by '='. */ +attribute_deprecated char *recommended_encoder_configuration; +#endif /** * Codec parameters associated with this stream. Allocated and freed by @@ -1218,10 +1221,12 @@ AVRational av_stream_get_r_frame_rate(const AVStream *s); attribute_deprecated void av_stream_set_r_frame_rate(AVStream *s, AVRational r); attribute_deprecated +#if FF_API_LAVF_FFSERVER char* av_stream_get_recommended_encoder_configuration(const AVStream *s); attribute_deprecated void av_stream_set_recommended_encoder_configuration(AVStream *s, char *configuration); #endif +#endif struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); diff --git a/libavformat/utils.c b/libavformat/utils.c index 2185a6f05b..0022639573 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -119,7 +119,11 @@ static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp) #if FF_API_FORMAT_GET_SET MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate) +#if FF_API_LAVF_FFSERVER +FF_DISABLE_DEPRECATION_WARNINGS MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration) +FF_ENABLE_DEPRECATION_WARNINGS +#endif MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec) MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec) @@ -4256,6 +4260,8 @@ int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src) } } +#if FF_API_LAVF_FFSERVER +FF_DISABLE_DEPRECATION_WARNINGS av_freep(&dst->recommended_encoder_configuration); if (src->recommended_encoder_configuration) { const char *conf_str = src->recommended_encoder_configuration; @@ -4263,6 +4269,8 @@ int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src) if (!dst->recommended_encoder_configuration) return AVERROR(ENOMEM); } +FF_ENABLE_DEPRECATION_WARNINGS +#endif return 0; } @@ -4310,7 +4318,11 @@ FF_ENABLE_DEPRECATION_WARNINGS if (st->info) av_freep(&st->info->duration_error); av_freep(&st->info); +#if FF_API_LAVF_FFSERVER +FF_DISABLE_DEPRECATION_WARNINGS av_freep(&st->recommended_encoder_configuration); +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_freep(pst); } diff --git a/libavformat/version.h b/libavformat/version.h index 5ced041f0a..d566e255e5 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 3 +#define LIBAVFORMAT_VERSION_MINOR 4 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -82,6 +82,9 @@ #ifndef FF_API_OLD_AVIO_EOF_0 #define FF_API_OLD_AVIO_EOF_0 (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_LAVF_FFSERVER +#define FF_API_LAVF_FFSERVER(LIBAVFORMAT_VERSION_MAJOR < 59) +#endif #ifndef FF_API_R_FRAME_RATE ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_d3d11va: implement av_hwdevice_get_hwframe_constraints()
ffmpeg | branch: master | wm4 | Tue Jan 16 13:23:55 2018 +0100| [27b9f82e2c5dca3ad642ed13c2360032a17687ec] | committer: wm4 hwcontext_d3d11va: implement av_hwdevice_get_hwframe_constraints() D3D11 has rather fine grained per format capabilities for different uses that can be queried at runtime. Since we don't know what the user wants to do with the formats when av_hwdevice_get_hwframe_constraints() is called, we simply return all formats that have the most basic support. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=27b9f82e2c5dca3ad642ed13c2360032a17687ec --- libavutil/hwcontext_d3d11va.c | 33 + 1 file changed, 33 insertions(+) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 2f97156a54..960883c9d8 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -120,6 +120,38 @@ static void d3d11va_frames_uninit(AVHWFramesContext *ctx) s->staging_texture = NULL; } +static int d3d11va_frames_get_constraints(AVHWDeviceContext *ctx, + const void *hwconfig, + AVHWFramesConstraints *constraints) +{ +AVD3D11VADeviceContext *device_hwctx = ctx->hwctx; +int nb_sw_formats = 0; +HRESULT hr; +int i; + +constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(supported_formats) + 1, + sizeof(*constraints->valid_sw_formats)); +if (!constraints->valid_sw_formats) +return AVERROR(ENOMEM); + +for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++) { +UINT format_support = 0; +hr = ID3D11Device_CheckFormatSupport(device_hwctx->device, supported_formats[i].d3d_format, &format_support); +if (SUCCEEDED(hr) && (format_support & D3D11_FORMAT_SUPPORT_TEXTURE2D)) +constraints->valid_sw_formats[nb_sw_formats++] = supported_formats[i].pix_fmt; +} +constraints->valid_sw_formats[nb_sw_formats] = AV_PIX_FMT_NONE; + +constraints->valid_hw_formats = av_malloc_array(2, sizeof(*constraints->valid_hw_formats)); +if (!constraints->valid_hw_formats) +return AVERROR(ENOMEM); + +constraints->valid_hw_formats[0] = AV_PIX_FMT_D3D11; +constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE; + +return 0; +} + static void free_texture(void *opaque, uint8_t *data) { ID3D11Texture2D_Release((ID3D11Texture2D *)opaque); @@ -576,6 +608,7 @@ const HWContextType ff_hwcontext_type_d3d11va = { .device_create= d3d11va_device_create, .device_init = d3d11va_device_init, .device_uninit= d3d11va_device_uninit, +.frames_get_constraints = d3d11va_frames_get_constraints, .frames_init = d3d11va_frames_init, .frames_uninit= d3d11va_frames_uninit, .frames_get_buffer= d3d11va_get_buffer, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/snow_dwt: add struct MpegEncContext to fix headers check.
ffmpeg | branch: master | Jun Zhao | Mon Jan 15 18:57:33 2018 +0800| [a919ab853efcecf89516e703df8018d0649e1143] | committer: Michael Niedermayer lavc/snow_dwt: add struct MpegEncContext to fix headers check. add missing struct MpegEncContext, use make checkheaders found this warning. Signed-off-by: Jun Zhao Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a919ab853efcecf89516e703df8018d0649e1143 --- libavcodec/snow_dwt.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/snow_dwt.h b/libavcodec/snow_dwt.h index e2d7528056..ee699de35e 100644 --- a/libavcodec/snow_dwt.h +++ b/libavcodec/snow_dwt.h @@ -24,6 +24,8 @@ #include #include +struct MpegEncContext; + typedef int DWTELEM; typedef short IDWTELEM; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] examples/qsvdec: do not set the deprecated field refcounted_frames
ffmpeg | branch: master | Zhong Li | Thu Dec 28 17:38:33 2017 +0800| [1efbbfedcaf4a3cecab980273ad809ba3ade2f74] | committer: Luca Barbato examples/qsvdec: do not set the deprecated field refcounted_frames It is used by the deprecated API avcodec_decode_video2 and ignored by the new decode APIs (avcodec_send_packet/avcodec_receive_frame). Signed-off-by: Zhong Li Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1efbbfedcaf4a3cecab980273ad809ba3ade2f74 --- doc/examples/qsvdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c index 46e6ddcb0d..cede6153be 100644 --- a/doc/examples/qsvdec.c +++ b/doc/examples/qsvdec.c @@ -210,7 +210,6 @@ int main(int argc, char **argv) video_st->codecpar->extradata_size); decoder_ctx->extradata_size = video_st->codecpar->extradata_size; } -decoder_ctx->refcounted_frames = 1; decoder_ctx->opaque = &decode; decoder_ctx->get_format = get_format; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit 'e23190269fb6e8217d080918893641ba3e0e3556'
ffmpeg | branch: master | Mark Thompson | Tue Jan 16 22:57:02 2018 +| [d204b7ff610cb8dac1116e7a4fd3068733cb5adf] | committer: Mark Thompson Merge commit 'e23190269fb6e8217d080918893641ba3e0e3556' * commit 'e23190269fb6e8217d080918893641ba3e0e3556': lavu/qsv: add log message for libmfx version Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d204b7ff610cb8dac1116e7a4fd3068733cb5adf --- libavutil/hwcontext_qsv.c | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 9b6040ba9e..6228c04de5 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1035,6 +1035,10 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, goto fail; } +av_log(ctx, AV_LOG_VERBOSE, + "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n", + MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor); + MFXClose(hwctx->session); err = MFXInit(implementation, &ver, &hwctx->session); == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavu/qsv: add log message for libmfx version
ffmpeg | branch: master | Zhong Li | Thu Dec 28 17:38:32 2017 +0800| [e23190269fb6e8217d080918893641ba3e0e3556] | committer: Luca Barbato lavu/qsv: add log message for libmfx version It is benefit to diagnose issues related to different libmfx version. Signed-off-by: Zhong Li Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e23190269fb6e8217d080918893641ba3e0e3556 --- libavutil/hwcontext_qsv.c | 4 1 file changed, 4 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 5018a05b9a..9270b2258f 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1036,6 +1036,10 @@ static int qsv_device_derive_from_child(AVHWDeviceContext *ctx, goto fail; } +av_log(ctx, AV_LOG_VERBOSE, + "Initialize MFX session: API version is %d.%d, implementation version is %d.%d\n", + MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor); + MFXClose(hwctx->session); err = MFXInit(implementation, &ver, &hwctx->session); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '1efbbfedcaf4a3cecab980273ad809ba3ade2f74'
ffmpeg | branch: master | Mark Thompson | Tue Jan 16 22:57:09 2018 +| [725ae0e2d0222f81b5cca3b0b226116ec6fd0494] | committer: Mark Thompson Merge commit '1efbbfedcaf4a3cecab980273ad809ba3ade2f74' * commit '1efbbfedcaf4a3cecab980273ad809ba3ade2f74': examples/qsvdec: do not set the deprecated field refcounted_frames Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=725ae0e2d0222f81b5cca3b0b226116ec6fd0494 --- doc/examples/qsvdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c index 46e6ddcb0d..cede6153be 100644 --- a/doc/examples/qsvdec.c +++ b/doc/examples/qsvdec.c @@ -210,7 +210,6 @@ int main(int argc, char **argv) video_st->codecpar->extradata_size); decoder_ctx->extradata_size = video_st->codecpar->extradata_size; } -decoder_ctx->refcounted_frames = 1; decoder_ctx->opaque = &decode; decoder_ctx->get_format = get_format; == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] cmdutils: update copyright year to 2018
ffmpeg | branch: master | Sean McGovern | Mon Jan 1 02:51:51 2018 -0500| [7b0b5bc810cdb9ef100492c9a9f2d30602c04336] | committer: Sean McGovern cmdutils: update copyright year to 2018 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b0b5bc810cdb9ef100492c9a9f2d30602c04336 --- avtools/cmdutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/avtools/cmdutils.c b/avtools/cmdutils.c index 727e2835eb..cf8a4c8c1c 100644 --- a/avtools/cmdutils.c +++ b/avtools/cmdutils.c @@ -59,7 +59,7 @@ struct SwsContext *sws_opts; AVDictionary *format_opts, *codec_opts, *resample_opts; -static const int this_year = 2017; +static const int this_year = 2018; void init_opts(void) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '7b0b5bc810cdb9ef100492c9a9f2d30602c04336'
ffmpeg | branch: master | Mark Thompson | Tue Jan 16 23:01:20 2018 +| [68de778ccc35bea885a989e47358089da006a8b6] | committer: Mark Thompson Merge commit '7b0b5bc810cdb9ef100492c9a9f2d30602c04336' * commit '7b0b5bc810cdb9ef100492c9a9f2d30602c04336': cmdutils: update copyright year to 2018 This commit is a noop, see bddf31ba7570325dd2c8d033eae3d0dd74127f96 Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68de778ccc35bea885a989e47358089da006a8b6 --- ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Merge commit '34c113335b53d83ed343de49741f0823aa1f8cc6'
ffmpeg | branch: master | Mark Thompson | Tue Jan 16 23:25:27 2018 +| [3895fce26ec7f6d2b1642f96ecaddede6521228e] | committer: Mark Thompson Merge commit '34c113335b53d83ed343de49741f0823aa1f8cc6' * commit '34c113335b53d83ed343de49741f0823aa1f8cc6': Add support for H.264 and HEVC hardware encoding for AMD GPUs based on AMF SDK Most of this was already present from 9ea6607d294526688ab1b1342cb36ee159683e88, this just applies some minor fixups and adds the general documentation. Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3895fce26ec7f6d2b1642f96ecaddede6521228e --- doc/general.texi | 12 libavcodec/amfenc.c | 4 ++-- libavcodec/amfenc_h264.c | 6 +++--- libavcodec/amfenc_hevc.c | 6 +++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index 26919c9287..3b73e31310 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -225,6 +225,18 @@ The dispatcher is open source and can be downloaded from with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to locate the dispatcher's @code{.pc} files. +@section AMD VCE + +FFmpeg can use the AMD Advanced Media Framework library for accelerated H.264 +and HEVC encoding on VCE enabled hardware under Windows. + +To enable support you must obtain the AMF framework header files from +@url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}. + +Create an @code{AMF/} directory in the system include path. +Copy the contents of @code{AMF/amf/public/include/} into that directory. +Then configure FFmpeg with @code{--enable-amf}. + @chapter Supported File Formats, Codecs or Features diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index f8b68070ae..89a10ff253 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -157,7 +157,7 @@ static int amf_init_context(AVCodecContext *avctx) AmfContext *ctx = avctx->priv_data; AMF_RESULT res = AMF_OK; -// confugure AMF logger +// configure AMF logger // the return of these functions indicates old state and do not affect behaviour ctx->trace->pVtbl->EnableWriter(ctx->trace, AMF_TRACE_WRITER_DEBUG_OUTPUT, ctx->log_to_dbg != 0 ); if (ctx->log_to_dbg) @@ -414,7 +414,7 @@ static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt, AMFBuffer *buff return 0; } -// amfenc API implmentation +// amfenc API implementation int ff_amf_encode_init(AVCodecContext *avctx) { AmfContext *ctx = avctx->priv_data; diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c index 96e4e952da..2c082e93bd 100644 --- a/libavcodec/amfenc_h264.c +++ b/libavcodec/amfenc_h264.c @@ -361,7 +361,6 @@ static av_cold int amf_encode_init_h264(AVCodecContext *avctx) static const AVCodecDefault defaults[] = { { "refs", "-1" }, { "aspect", "0" }, -{ "sar","0" }, { "qmin", "-1" }, { "qmax", "-1" }, { "b", "2M" }, @@ -376,7 +375,7 @@ static const AVClass h264_amf_class = { .option = options, .version = LIBAVUTIL_VERSION_INT, }; -//TODO declare as HW encoder when available + AVCodec ff_h264_amf_encoder = { .name = "h264_amf", .long_name = NULL_IF_CONFIG_SMALL("AMD AMF H.264 Encoder"), @@ -389,7 +388,8 @@ AVCodec ff_h264_amf_encoder = { .priv_data_size = sizeof(AmfContext), .priv_class = &h264_amf_class, .defaults = defaults, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_amf_pix_fmts, +.wrapper_name = "amf", }; diff --git a/libavcodec/amfenc_hevc.c b/libavcodec/amfenc_hevc.c index 3956b2d178..7c9a33ab33 100644 --- a/libavcodec/amfenc_hevc.c +++ b/libavcodec/amfenc_hevc.c @@ -295,7 +295,6 @@ static av_cold int amf_encode_init_hevc(AVCodecContext *avctx) static const AVCodecDefault defaults[] = { { "refs", "-1" }, { "aspect", "0" }, -{ "sar","0" }, { "b", "2M" }, { "g", "250" }, { "slices", "1" }, @@ -307,7 +306,7 @@ static const AVClass hevc_amf_class = { .option = options, .version = LIBAVUTIL_VERSION_INT, }; -//TODO declare as HW encoder when available + AVCodec ff_hevc_amf_encoder = { .name = "hevc_amf", .long_name = NULL_IF_CONFIG_SMALL("AMD AMF HEVC encoder"), @@ -320,7 +319,8 @@ AVCodec ff_hevc_amf_encoder = { .priv_data_size = sizeof(AmfContext), .priv_class = &hevc_amf_class, .defaults = defaults, -.capabilities = AV_CODEC_CAP_DELAY, +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = ff_amf_pix_fmts, +.wrapper_name = "amf", }; ==
[FFmpeg-cvslog] Add support for H.264 and HEVC hardware encoding for AMD GPUs based on AMF SDK
ffmpeg | branch: master | Michael Wootton | Wed Jan 3 12:55:53 2018 -0500| [34c113335b53d83ed343de49741f0823aa1f8cc6] | committer: Luca Barbato Add support for H.264 and HEVC hardware encoding for AMD GPUs based on AMF SDK Requires AMF headers for at least version 1.4.4.1. Signed-off-by: Mikhail Mironov Signed-off-by: Luca Barbato > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34c113335b53d83ed343de49741f0823aa1f8cc6 --- configure| 10 + doc/general.texi | 10 + libavcodec/Makefile | 4 + libavcodec/allcodecs.c | 2 + libavcodec/amfenc.c | 608 +++ libavcodec/amfenc.h | 158 libavcodec/amfenc_h264.c | 400 +++ libavcodec/amfenc_hevc.c | 332 ++ 8 files changed, 1524 insertions(+) diff --git a/configure b/configure index d31cb56588..593064f878 100755 --- a/configure +++ b/configure @@ -231,6 +231,7 @@ External library support: --enable-zlib compression [autodetect] The following libraries provide various hardware acceleration features: + --enable-amf AMF video encoding code [auto] --enable-cudaNvidia CUDA (dynamically linked) --enable-cuvid Nvidia CUVID video decode acceleration --enable-d3d11va Microsoft Direct3D 11 video acceleration [auto] @@ -1255,6 +1256,7 @@ HWACCEL_LIBRARY_NONFREE_LIST=" " HWACCEL_LIBRARY_LIST=" $HWACCEL_LIBRARY_NONFREE_LIST +amf d3d11va dxva2 libmfx @@ -2238,6 +2240,7 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # hardware-accelerated codecs +amf_deps_any="libdl LoadLibrary" nvenc_deps_any="libdl LoadLibrary" omx_deps="libdl pthreads" omx_rpi_select="omx" @@ -2250,6 +2253,7 @@ vaapi_encode_deps="vaapi" hwupload_cuda_filter_deps="cuda" scale_npp_filter_deps="cuda libnpp" +h264_amf_encoder_deps="amf" h264_mmal_decoder_deps="mmal" h264_nvenc_encoder_deps="nvenc" h264_omx_encoder_deps="omx" @@ -2257,6 +2261,7 @@ h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec" h264_qsv_encoder_select="qsvenc" h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264" h264_vaapi_encoder_select="cbs_h264 vaapi_encode" +hevc_amf_encoder_deps="amf" hevc_nvenc_encoder_deps="nvenc" hevc_qsv_decoder_select="hevc_mp4toannexb_bsf hevc_parser qsvdec" hevc_qsv_encoder_select="hevcparse qsvenc" @@ -4573,6 +4578,11 @@ for func in $MATH_FUNCS; do done # these are off by default, so fail if requested and not available + +enabled amf && +check_cpp_condition "AMF/core/Version.h" \ +"(AMF_VERSION_MAJOR << 48 | AMF_VERSION_MINOR << 32 | AMF_VERSION_RELEASE << 16 | AMF_VERSION_BUILD_NUM) >= 0x0001000400040001" || +disable amf enabled avisynth && require_header avisynth/avisynth_c.h enabled avxsynth && require_header avxsynth/avxsynth_c.h enabled cuda && require cuda cuda.h cuInit -lcuda diff --git a/doc/general.texi b/doc/general.texi index 6e39d5c1a0..0c92761a49 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -237,6 +237,16 @@ The dispatcher is open source and can be downloaded from with the @code{--enable-libmfx} option and @code{pkg-config} needs to be able to locate the dispatcher's @code{.pc} files. +@section AMD VCE + +Libav can use the AMD Advanced Media Framework library for accelerated H.264 and HEVC encoding on VCE enabled hardware under Windows. + +To enable support you must obtain the AMF framework header files from @url{https://github.com/GPUOpen-LibrariesAndSDKs/AMF.git}. + +Create an @code{AMF/} directory in the system include path. +Copy the contents of @code{AMF/amf/public/include/} into that directory. +Then Configure Libav with @code{--enable-amf}. + @chapter Supported File Formats and Codecs You can use the @code{-formats} and @code{-codecs} options to have an exhaustive list. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index d04902be08..99969ac779 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -48,6 +48,7 @@ OBJS = ac3_parser.o \ OBJS-$(CONFIG_AANDCTTABLES)+= aandcttab.o OBJS-$(CONFIG_AC3DSP) += ac3dsp.o OBJS-$(CONFIG_ADTS_HEADER) += adts_header.o mpeg4audio.o +OBJS-$(CONFIG_AMF) += amfenc.o OBJS-$(CONFIG_AUDIO_FRAME_QUEUE) += audio_frame_queue.o OBJS-$(CONFIG_AUDIODSP)+= audiodsp.o OBJS-$(CONFIG_BLOCKDSP)+= blockdsp.o @@ -271,6 +272,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o h264_cabac.o h264_cavlc.o \ h264_mb.o h264_picture.o \ h264_refs.o h264_sei.o \ h264_slice.o h264data.o +OBJS-$(CONFIG_H264_AMF_ENCODER)+= amfenc_h264.o OBJS-$(CONFIG_H264_MMAL_DECODER) += m
[FFmpeg-cvslog] Merge commit 'cbe28bc069dde1d53d937ee10700bb123279c7c8'
ffmpeg | branch: master | Mark Thompson | Tue Jan 16 23:29:36 2018 +| [96cf0d8a9cf35f3c49860bf1c000c382dd661607] | committer: Mark Thompson Merge commit 'cbe28bc069dde1d53d937ee10700bb123279c7c8' * commit 'cbe28bc069dde1d53d937ee10700bb123279c7c8': qsv: better to use alignment by 16 and HEVC 10b requires alignment by 32 Merged-by: Mark Thompson > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96cf0d8a9cf35f3c49860bf1c000c382dd661607 --- libavcodec/qsvdec.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 55fe59b531..abbede5d97 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -475,6 +475,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, uint8_t *dummy_data; int dummy_size; int ret; +const AVPixFmtDescriptor *desc; if (!q->avctx_internal) { q->avctx_internal = avcodec_alloc_context3(NULL); @@ -501,8 +502,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, /* TODO: flush delayed frames on reinit */ if (q->parser->format != q->orig_pix_fmt|| -q->parser->coded_width != avctx->coded_width || -q->parser->coded_height != avctx->coded_height) { +FFALIGN(q->parser->coded_width, 16) != FFALIGN(avctx->coded_width, 16) || +FFALIGN(q->parser->coded_height, 16) != FFALIGN(avctx->coded_height, 16)) { enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV, AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; @@ -521,8 +522,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->pix_fmt = pix_fmts[1] = qsv_format; avctx->width= q->parser->width; avctx->height = q->parser->height; -avctx->coded_width = q->parser->coded_width; -avctx->coded_height = q->parser->coded_height; +avctx->coded_width = FFALIGN(q->parser->coded_width, 16); +avctx->coded_height = FFALIGN(q->parser->coded_height, 16); avctx->field_order = q->parser->field_order; avctx->level= q->avctx_internal->level; avctx->profile = q->avctx_internal->profile; @@ -533,6 +534,15 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->pix_fmt = ret; +desc = av_pix_fmt_desc_get(avctx->pix_fmt); +if (!desc) +goto reinit_fail; + + if (desc->comp[0].depth > 8) { +avctx->coded_width = FFALIGN(q->parser->coded_width, 32); +avctx->coded_height = FFALIGN(q->parser->coded_height, 32); +} + ret = qsv_decode_init(avctx, q); if (ret < 0) goto reinit_fail; == ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] qsv: better to use alignment by 16 and HEVC 10b requires alignment by 32
ffmpeg | branch: master | Maxym Dmytrychenko | Mon Jan 8 15:10:23 2018 +0100| [cbe28bc069dde1d53d937ee10700bb123279c7c8] | committer: Maxym Dmytrychenko qsv: better to use alignment by 16 and HEVC 10b requires alignment by 32 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbe28bc069dde1d53d937ee10700bb123279c7c8 --- libavcodec/qsvdec.c | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index c74ec68369..9741f33109 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -475,6 +475,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, uint8_t *dummy_data; int dummy_size; int ret; +const AVPixFmtDescriptor *desc; if (!q->avctx_internal) { q->avctx_internal = avcodec_alloc_context3(NULL); @@ -511,8 +512,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, /* TODO: flush delayed frames on reinit */ if (q->parser->format != q->orig_pix_fmt|| -q->parser->coded_width != avctx->coded_width || -q->parser->coded_height != avctx->coded_height) { +FFALIGN(q->parser->coded_width, 16) != FFALIGN(avctx->coded_width, 16) || +FFALIGN(q->parser->coded_height, 16) != FFALIGN(avctx->coded_height, 16)) { enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV, AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; @@ -531,8 +532,8 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->pix_fmt = pix_fmts[1] = qsv_format; avctx->width= q->parser->width; avctx->height = q->parser->height; -avctx->coded_width = q->parser->coded_width; -avctx->coded_height = q->parser->coded_height; +avctx->coded_width = FFALIGN(q->parser->coded_width, 16); +avctx->coded_height = FFALIGN(q->parser->coded_height, 16); avctx->field_order = q->parser->field_order; avctx->level= q->avctx_internal->level; avctx->profile = q->avctx_internal->profile; @@ -543,6 +544,15 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext *q, avctx->pix_fmt = ret; +desc = av_pix_fmt_desc_get(avctx->pix_fmt); +if (!desc) +goto reinit_fail; + + if (desc->comp[0].depth > 8) { +avctx->coded_width = FFALIGN(q->parser->coded_width, 32); +avctx->coded_height = FFALIGN(q->parser->coded_height, 32); +} + ret = qsv_decode_init(avctx, q); if (ret < 0) goto reinit_fail; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog