[FFmpeg-cvslog] avcodec: Add MediaFoundation encoder wrapper
ffmpeg | branch: master | wm4 | Tue Apr 4 07:45:41 2017 +0200| [050b72ab5ef318605b305aa6cb920e8b52f1002e] | committer: Martin Storsjö avcodec: Add MediaFoundation encoder wrapper This contains encoder wrappers for H264, HEVC, AAC, AC3 and MP3. This is based on top of an original patch by wm4 . The original patch supported both encoding and decoding, but this patch only includes encoding. The patch contains further changes by Paweł Wegner (primarily for splitting out the encoding parts of the original patch) and further cleanup, build compatibility fixes and tweaks for use with Qualcomm encoders by Martin Storsjö. Signed-off-by: Martin Storsjö > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=050b72ab5ef318605b305aa6cb920e8b52f1002e --- Changelog |1 + configure | 11 + doc/encoders.texi |8 + libavcodec/Makefile|6 + libavcodec/allcodecs.c |5 + libavcodec/mf_utils.c | 680 +++ libavcodec/mf_utils.h | 159 +++ libavcodec/mfenc.c | 1192 libavcodec/version.h |2 +- 9 files changed, 2063 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 69c5dacda7..e9781131a3 100644 --- a/Changelog +++ b/Changelog @@ -69,6 +69,7 @@ version : - scdet filter - NotchLC decoder - gradients source video filter +- MediaFoundation encoder wrapper version 4.2: diff --git a/configure b/configure index 34afdaad28..f97cad0298 100755 --- a/configure +++ b/configure @@ -304,6 +304,7 @@ External library support: --enable-mbedtls enable mbedTLS, needed for https support if openssl, gnutls or libtls is not used [no] --enable-mediacodec enable Android MediaCodec support [no] + --enable-mediafoundation enable encoding via MediaFoundation [auto] --enable-libmysofa enable libmysofa, needed for sofalizer filter [no] --enable-openal enable OpenAL 1.1 capture support [no] --enable-opencl enable OpenCL processing [no] @@ -1704,6 +1705,7 @@ EXTERNAL_AUTODETECT_LIBRARY_LIST=" libxcb_shape libxcb_xfixes lzma +mediafoundation schannel sdl2 securetransport @@ -3011,6 +3013,8 @@ wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel" # hardware-accelerated codecs +mediafoundation_deps="mftransform_h MFCreateAlignedMemoryBuffer" +mediafoundation_extralibs="-lmfplat -lmfuuid -lole32 -lstrmiids" omx_deps="libdl pthreads" omx_rpi_select="omx" qsv_deps="libmfx" @@ -3035,6 +3039,8 @@ nvenc_deps="ffnvcodec" nvenc_deps_any="libdl LoadLibrary" nvenc_encoder_deps="nvenc" +aac_mf_encoder_deps="mediafoundation" +ac3_mf_encoder_deps="mediafoundation" h263_v4l2m2m_decoder_deps="v4l2_m2m h263_v4l2_m2m" h263_v4l2m2m_encoder_deps="v4l2_m2m h263_v4l2_m2m" h264_amf_encoder_deps="amf" @@ -3043,6 +3049,7 @@ h264_cuvid_decoder_deps="cuvid" h264_cuvid_decoder_select="h264_mp4toannexb_bsf" h264_mediacodec_decoder_deps="mediacodec" h264_mediacodec_decoder_select="h264_mp4toannexb_bsf h264_parser" +h264_mf_encoder_deps="mediafoundation" h264_mmal_decoder_deps="mmal" h264_nvenc_encoder_deps="nvenc" h264_omx_encoder_deps="omx" @@ -3059,6 +3066,7 @@ hevc_cuvid_decoder_deps="cuvid" hevc_cuvid_decoder_select="hevc_mp4toannexb_bsf" hevc_mediacodec_decoder_deps="mediacodec" hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser" +hevc_mf_encoder_deps="mediafoundation" hevc_nvenc_encoder_deps="nvenc" hevc_qsv_decoder_select="hevc_mp4toannexb_bsf qsvdec" hevc_qsv_encoder_select="hevcparse qsvenc" @@ -3075,6 +3083,7 @@ mjpeg_qsv_encoder_deps="libmfx" mjpeg_qsv_encoder_select="qsvenc" mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG" mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode" +mp3_mf_encoder_deps="mediafoundation" mpeg1_cuvid_decoder_deps="cuvid" mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m" mpeg2_crystalhd_decoder_select="crystalhd" @@ -6101,6 +6110,7 @@ check_headers io.h check_headers linux/perf_event.h check_headers libcrystalhd/libcrystalhd_if.h check_headers malloc.h +check_headers mftransform.h check_headers net/udplite.h check_headers poll.h check_headers sys/param.h @@ -6163,6 +6173,7 @@ check_type "windows.h dxva.h" "DXVA_PicParams_VP9" -DWINAPI_FAMILY=WINAPI_FAMILY check_type "windows.h d3d11.h" "ID3D11VideoDecoder" check_type "windows.h d3d11.h" "ID3D11VideoContext" check_type "d3d9.h dxva2ap
[FFmpeg-cvslog] avconv: make sure packets put into the muxing FIFO are refcounted
ffmpeg | branch: master | wm4 | Wed Feb 8 09:53:26 2017 +0100| [c011beda2611acfeb6f67d4fdf30d1eceed9e62f] | committer: Martin Storsjö avconv: make sure packets put into the muxing FIFO are refcounted Some callers (like do_subtitle_out(), or do_streamcopy()) call this with an AVPacket that is not refcounted. This can cause undefined behavior. Calling av_packet_move_ref() does not make a packet refcounted if it isn't yet. (And it can't be made to, because it always succeeds, and can't return ENOMEM.) Call av_packet_ref() instead to make sure it's refcounted. Cc: libav-sta...@libav.org Signed-off-by: Martin Storsjö > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c011beda2611acfeb6f67d4fdf30d1eceed9e62f --- avtools/avconv.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/avtools/avconv.c b/avtools/avconv.c index ac15464a8d..3abb7f872f 100644 --- a/avtools/avconv.c +++ b/avtools/avconv.c @@ -281,7 +281,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) int ret; if (!of->header_written) { -AVPacket tmp_pkt; +AVPacket tmp_pkt = {0}; /* the muxer is not initialized yet, buffer the packet */ if (!av_fifo_space(ost->muxing_queue)) { int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue), @@ -296,8 +296,11 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) if (ret < 0) exit_program(1); } -av_packet_move_ref(_pkt, pkt); +ret = av_packet_ref(_pkt, pkt); +if (ret < 0) +exit_program(1); av_fifo_generic_write(ost->muxing_queue, _pkt, sizeof(tmp_pkt), NULL); +av_packet_unref(pkt); return; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat: add vapoursynth wrapper
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Fri Apr 27 21:35:56 2018 +0200| [7074a7ccd9a4d4e445252780fd182aa0b3778b79] | committer: wm4 avformat: add vapoursynth wrapper This can "demux" .vpy files. Autodetection of .vpy scripts is intentionally not done, because it would be a major security issue. You need to force the format, for example with "-f vapoursynth" for the FFmpeg CLI tools. Some minor code copied from other LGPL parts of FFmpeg. I did not find a good way to test a few of the more obscure VS features, like VFR nodes, compat pixel formats, or nodes with dynamic size/format changes. These can be easily implemented on demand. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7074a7ccd9a4d4e445252780fd182aa0b3778b79 --- configure | 5 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/vapoursynth.c | 496 ++ libavformat/version.h | 2 +- 5 files changed, 504 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 7f199c634d..f78853cc6c 100755 --- a/configure +++ b/configure @@ -303,6 +303,7 @@ External library support: --disable-sdl2 disable sdl2 [autodetect] --disable-securetransport disable Secure Transport, needed for TLS support on OSX if openssl and gnutls are not used [autodetect] + --enable-vapoursynth enable VapourSynth demuxer [no] --disable-xlib disable xlib [autodetect] --disable-zlib disable zlib [autodetect] @@ -1724,6 +1725,7 @@ EXTERNAL_LIBRARY_LIST=" mediacodec openal opengl +vapoursynth " HWACCEL_AUTODETECT_LIBRARY_LIST=" @@ -3091,6 +3093,7 @@ libx265_encoder_deps="libx265" libxavs_encoder_deps="libxavs" libxvid_encoder_deps="libxvid" libzvbi_teletext_decoder_deps="libzvbi" +vapoursynth_demuxer_deps="vapoursynth" videotoolbox_suggest="coreservices" videotoolbox_deps="corefoundation coremedia corevideo" videotoolbox_encoder_deps="videotoolbox VTCompressionSessionPrepareToEncodeFrames" @@ -6133,6 +6136,8 @@ enabled rkmpp && { require_pkg_config rkmpp rockchip_mpp rockchip/r { enabled libdrm || die "ERROR: rkmpp requires --enable-libdrm"; } } +enabled vapoursynth && require_pkg_config vapoursynth "vapoursynth-script >= 42" VSScript.h vsscript_init + if enabled gcrypt; then GCRYPT_CONFIG="${cross_prefix}libgcrypt-config" diff --git a/libavformat/Makefile b/libavformat/Makefile index 3eeca5091d..e1e74a8f43 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -570,6 +570,7 @@ OBJS-$(CONFIG_LIBRTMPTE_PROTOCOL)+= librtmp.o OBJS-$(CONFIG_LIBSRT_PROTOCOL) += libsrt.o OBJS-$(CONFIG_LIBSSH_PROTOCOL) += libssh.o OBJS-$(CONFIG_LIBSMBCLIENT_PROTOCOL) += libsmbclient.o +OBJS-$(CONFIG_VAPOURSYNTH_DEMUXER) += vapoursynth.o # protocols I/O OBJS-$(CONFIG_ASYNC_PROTOCOL)+= async.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index d582778b3b..a94364f41d 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -482,6 +482,7 @@ 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" diff --git a/libavformat/vapoursynth.c b/libavformat/vapoursynth.c new file mode 100644 index 00..f3ad6910e5 --- /dev/null +++ b/libavformat/vapoursynth.c @@ -0,0 +1,496 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** +* @file +* VapourSynth demuxer +* +* Synthesizes vapour (?) +*/ + +#include + +#include +#include + +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/eval.h" +#include "libavutil/imgutils.
[FFmpeg-cvslog] avformat/hls: don't propagate deprecated "user-agent" AVOption
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Apr 28 20:36:49 2018 +0200| [1d642ebfdb31b7c55ba02500a76f3febf04ce434] | committer: wm4 avformat/hls: don't propagate deprecated "user-agent" AVOption This code will print a warning if any user agent is set - even if the API user used the proper non-deprecated "user_agent" option. This change should not even break anything, because even if the user sets the deprecated "user-agent" option, http.c copies it to the "user_agent" option anyway. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1d642ebfdb31b7c55ba02500a76f3febf04ce434 --- libavformat/hls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index ffec124818..4ee4be769d 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1593,7 +1593,7 @@ static int save_avio_options(AVFormatContext *s) { HLSContext *c = s->priv_data; static const char * const opts[] = { -"headers", "http_proxy", "user_agent", "user-agent", "cookies", "referer", "rw_timeout", NULL }; +"headers", "http_proxy", "user_agent", "cookies", "referer", "rw_timeout", NULL }; const char * const * opt = opts; uint8_t *buf; int ret = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/matroskaenc: do not write timebase as framerate
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Apr 28 19:24:12 2018 +0200| [022d4a2114d2586d4807f5810160f0f565ab80d7] | committer: wm4 avformat/matroskaenc: do not write timebase as framerate If the API user doesn't set avg_frame_rate, matroskaenc will write the current timebase as "default duration" for the video track. This makes no sense, because the "default duration" implies the framerate of the video. Since the timebase is forced to 1/1000, this will make the resulting file claim 1000fps. Drop it and don't write the element. It's optional, so it's better not to write it if the framerate is unknown. Strangely does not require FATE changes. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=022d4a2114d2586d4807f5810160f0f565ab80d7 --- libavformat/matroskaenc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 5950b4de44..b7ff1950d3 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -1304,8 +1304,6 @@ static int mkv_write_track(AVFormatContext *s, MatroskaMuxContext *mkv, if( st->avg_frame_rate.num > 0 && st->avg_frame_rate.den > 0 && av_cmp_q(av_inv_q(st->avg_frame_rate), st->time_base) > 0) put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 10LL * st->avg_frame_rate.den / st->avg_frame_rate.num); -else -put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 10LL * st->time_base.num / st->time_base.den); if (!native_id && ff_codec_get_tag(ff_codec_movvideo_tags, par->codec_id) && ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/decode: fix warning when decoding pseudo paletted formats
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Apr 4 18:07:03 2018 +0200| [709e0291d659d089527ec7c048f9b2608183df64] | committer: wm4 avcodec/decode: fix warning when decoding pseudo paletted formats The pseudo palette allocation is optional now. But if it's still allocated (like the internal get_buffer2 implementation does, for compatibility), it shouldn't print a warning. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=709e0291d659d089527ec7c048f9b2608183df64 --- libavcodec/decode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index d883a5f9fc..421a8f1a35 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1779,6 +1779,8 @@ static void validate_avframe_allocation(AVCodecContext *avctx, AVFrame *frame) int flags = desc ? desc->flags : 0; if (num_planes == 1 && (flags & AV_PIX_FMT_FLAG_PAL)) num_planes = 2; +if ((flags & FF_PSEUDOPAL) && frame->data[1]) +num_planes = 2; for (i = 0; i < num_planes; i++) { av_assert0(frame->data[i]); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/xwdenc: do not rely on AV_PIX_FMT_FLAG_PSEUDOPAL palettes
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 29 15:10:15 2018 +0200| [e53d3348d10feda300a4d906c136a4ce438369eb] | committer: wm4 avcodec/xwdenc: do not rely on AV_PIX_FMT_FLAG_PSEUDOPAL palettes This is the only code I found within FFmpeg that still inherently requires AV_PIX_FMT_FLAG_PSEUDOPAL. It's easily changed not to require it. Preparation for the next patch. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e53d3348d10feda300a4d906c136a4ce438369eb --- libavcodec/xwdenc.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 43bca89033..81cca6c963 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -41,6 +41,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int i, out_size, ret; uint8_t *ptr, *buf; AVFrame * const p = (AVFrame *)pict; +uint32_t pal[256]; pixdepth = av_get_bits_per_pixel(desc); if (desc->flags & AV_PIX_FMT_FLAG_BE) @@ -180,11 +181,17 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream_put_be32(, 0); // window border width bytestream_put_buffer(, WINDOW_NAME, WINDOW_NAME_SIZE); +if (pix_fmt == AV_PIX_FMT_PAL8) { +memcpy(pal, p->data[1], sizeof(pal)); +} else { +avpriv_set_systematic_pal2(pal, pix_fmt); +} + for (i = 0; i < ncolors; i++) { uint32_t val; uint8_t red, green, blue; -val = AV_RN32A(p->data[1] + i * 4); +val = pal[i]; red = (val >> 16) & 0xFF; green = (val >> 8) & 0xFF; blue = val& 0xFF; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPAL
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 29 15:18:28 2018 +0200| [d6fc031caf64eed921bbdef86d79d56bfc2633b0] | committer: wm4 avutil/pixdesc: deprecate AV_PIX_FMT_FLAG_PSEUDOPAL PSEUDOPAL pixel formats are not paletted, but carried a palette with the intention of allowing code to treat unpaletted formats as paletted. The palette simply mapped the byte values to the resulting RGB values, making it some sort of LUT for RGB conversion. It was used for 1 byte formats only: RGB4_BYTE, BGR4_BYTE, RGB8, BGR8, GRAY8. The first 4 are awfully obscure, used only by some ancient bitmap formats. The last one, GRAY8, is more common, but its treatment is grossly incorrect. It considers full range GRAY8 only, so GRAY8 coming from typical Y video planes was not mapped to the correct RGB values. This cannot be fixed, because AVFrame.color_range can be freely changed at runtime, and there is nothing to ensure the pseudo palette is updated. Also, nothing actually used the PSEUDOPAL palette data, except xwdenc (trivially changed in the previous commit). All other code had to treat it as a special case, just to ignore or to propagate palette data. In conclusion, this was just a very strange old mechnaism that has no real justification to exist anymore (although it may have been nice and useful in the past). Now it's an artifact that makes the API harder to use: API users who allocate their own pixel data have to be aware that they need to allocate the palette, or FFmpeg will crash on them in _some_ situations. On top of this, there was no API to allocate the pseuo palette outside of av_frame_get_buffer(). This patch not only deprecates AV_PIX_FMT_FLAG_PSEUDOPAL, but also makes the pseudo palette optional. Nothing accesses it anymore, though if it's set, it's propagated. It's still allocated and initialized for compatibility with API users that rely on this feature. But new API users do not need to allocate it. This was an explicit goal of this patch. Most changes replace AV_PIX_FMT_FLAG_PSEUDOPAL with FF_PSEUDOPAL. I first tried #ifdefing all code, but it was a mess. The FF_PSEUDOPAL macro reduces the mess, and still allows defining FF_API_PSEUDOPAL to 0. Passes FATE with FF_API_PSEUDOPAL enabled and disabled. In addition, FATE passes with FF_API_PSEUDOPAL set to 1, but with allocation functions manually changed to not allocating a palette. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6fc031caf64eed921bbdef86d79d56bfc2633b0 --- doc/APIchanges | 4 fftools/ffprobe.c | 2 ++ libavcodec/decode.c| 5 + libavcodec/ffv1dec.c | 2 +- libavcodec/rawdec.c| 6 -- libavcodec/smvjpegdec.c| 2 +- libavfilter/drawutils.c| 2 +- libavfilter/framepool.c| 4 ++-- libavfilter/vf_crop.c | 2 +- libavfilter/vf_pixdesctest.c | 2 +- libavfilter/vf_scale.c | 5 ++--- libavfilter/vf_shuffleplanes.c | 2 +- libavutil/frame.c | 4 ++-- libavutil/imgutils.c | 13 +++-- libavutil/internal.h | 9 + libavutil/pixdesc.c| 10 +- libavutil/pixdesc.h| 8 libavutil/version.h| 5 - libswscale/swscale_internal.h | 14 +++--- 19 files changed, 67 insertions(+), 34 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 121fbee9ce..f6ad2169a2 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-04-03 - xxx - lavu 56.13.100 - pixdesc.h + Deprecate AV_PIX_FMT_FLAG_PSEUDOPAL and make allocating a pseudo palette + optional for API users (see AV_PIX_FMT_FLAG_PSEUDOPAL doxygen for details). + 2018-04-01 - xxx - lavc 58.17.100 - avcodec.h Add av_packet_make_refcounted(). diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 2582649fd3..82dfe4f58a 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -3118,7 +3118,9 @@ static void ffprobe_show_pixel_formats(WriterContext *w) PRINT_PIX_FMT_FLAG(HWACCEL, "hwaccel"); PRINT_PIX_FMT_FLAG(PLANAR,"planar"); PRINT_PIX_FMT_FLAG(RGB, "rgb"); +#if FF_API_PSEUDOPAL PRINT_PIX_FMT_FLAG(PSEUDOPAL, "pseudopal"); +#endif PRINT_PIX_FMT_FLAG(ALPHA, "alpha"); writer_print_section_footer(w); } diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 40c8a8855c..d883a5f9fc 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1614,7 +1614,7 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic) pic->linesize[i] = 0; } if (desc->flags & AV_PIX_FMT_FLAG_PAL || -desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) +((desc->flags & FF_PSEUDOPAL) && pic->data[1])) avpriv_set_systematic_p
[FFmpeg-cvslog] movtextdec: fix handling of UTF-8 subtitles
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Mar 24 15:41:54 2018 +0100| [b0644c3e1a96397ee5e2448c542fa4c3bc319537] | committer: wm4 movtextdec: fix handling of UTF-8 subtitles Subtitles which contained styled UTF-8 subtitles (i.e. not just 7 bit ASCII characters) were not handled correctly. The spec mandates that styling start/end ranges are in "characters". It's not quite clear what a "character" is supposed to be, but maybe they mean unicode codepoints. FFmpeg's decoder treated the style ranges as byte idexes, which could lead to UTF-8 sequences being broken, and the common code dropping the whole subtitle line. Change this and count the codepoint instead. This also means that even if this is somehow wrong, the decoder won't break UTF-8 sequences anymore. The sample which led me to investigate this now appears to work correctly. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b0644c3e1a96397ee5e2448c542fa4c3bc319537 --- libavcodec/movtextdec.c | 50 - 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index bd19577724..89ac791602 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -326,9 +326,24 @@ static const Box box_types[] = { const static size_t box_count = FF_ARRAY_ELEMS(box_types); +// Return byte length of the UTF-8 sequence starting at text[0]. 0 on error. +static int get_utf8_length_at(const char *text, const char *text_end) +{ +const char *start = text; +int err = 0; +uint32_t c; +GET_UTF8(c, text < text_end ? (uint8_t)*text++ : (err = 1, 0), goto error;); +if (err) +goto error; +return text - start; +error: +return 0; +} + static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, -MovTextContext *m) + AVCodecContext *avctx) { +MovTextContext *m = avctx->priv_data; int i = 0; int j = 0; int text_pos = 0; @@ -342,6 +357,8 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, } while (text < text_end) { +int len; + if (m->box_flags & STYL_BOX) { for (i = 0; i < m->style_entries; i++) { if (m->s[i]->style_flag && text_pos == m->s[i]->style_end) { @@ -388,17 +405,24 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end, } } -switch (*text) { -case '\r': -break; -case '\n': -av_bprintf(buf, "\\N"); -break; -default: -av_bprint_chars(buf, *text, 1); -break; +len = get_utf8_length_at(text, text_end); +if (len < 1) { +av_log(avctx, AV_LOG_ERROR, "invalid UTF-8 byte in subtitle\n"); +len = 1; +} +for (i = 0; i < len; i++) { +switch (*text) { +case '\r': +break; +case '\n': +av_bprintf(buf, "\\N"); +break; +default: +av_bprint_chars(buf, *text, 1); +break; +} +text++; } -text++; text_pos++; } @@ -507,10 +531,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx, } m->tracksize = m->tracksize + tsmb_size; } -text_to_ass(, ptr, end, m); +text_to_ass(, ptr, end, avctx); mov_text_cleanup(m); } else -text_to_ass(, ptr, end, m); +text_to_ass(, ptr, end, avctx); ret = ff_ass_add_rect(sub, buf.str, m->readorder++, 0, NULL, NULL); av_bprint_finalize(, NULL); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec: add a subcharenc mode that disables UTF-8 check
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Mar 24 13:37:00 2018 +0100| [b7d0d912ef9b60eae962e4622d72860af31a8b00] | committer: wm4 avcodec: add a subcharenc mode that disables UTF-8 check This is for applications which want to explicitly check for invalid UTF-8 manually, and take actions that are better than dropping invalid subtitles silently. (It's pretty much silent because sporadic avcodec error messages are so common that you can't reasonably display them in a prominent and meaningful way in a application GUI.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7d0d912ef9b60eae962e4622d72860af31a8b00 --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 1 + libavcodec/decode.c| 3 ++- libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a099afd9bc..95b5cd772f 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-03-xx - xxx - lavc 58.16.100 - avcodec.h + Add FF_SUB_CHARENC_MODE_IGNORE. + 2018-xx-xx - xxx - lavu 56.8.100 - encryption_info.h Add AVEncryptionInitInfo and AVEncryptionInfo structures to hold new side-data for encryption info. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 495242faf0..50c34dbff9 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3092,6 +3092,7 @@ typedef struct AVCodecContext { #define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance) #define FF_SUB_CHARENC_MODE_AUTOMATIC0 ///< libavcodec will select the mode itself #define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv +#define FF_SUB_CHARENC_MODE_IGNORE 2 ///< neither convert the subtitles, nor check them for valid UTF-8 /** * Skip processing alpha if supported by codec. diff --git a/libavcodec/decode.c b/libavcodec/decode.c index ea2168ad0c..40c8a8855c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1057,7 +1057,8 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, sub->format = 1; for (i = 0; i < sub->num_rects; i++) { -if (sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { +if (avctx->sub_charenc_mode != FF_SUB_CHARENC_MODE_IGNORE && +sub->rects[i]->ass && !utf8_check(sub->rects[i]->ass)) { av_log(avctx, AV_LOG_ERROR, "Invalid UTF-8 in decoded subtitles text; " "maybe missing -sub_charenc option\n"); diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 5a5eae65fb..099261e168 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -447,6 +447,7 @@ static const AVOption avcodec_options[] = { {"do_nothing", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_DO_NOTHING}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, {"auto",NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_AUTOMATIC}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, {"pre_decoder", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_PRE_DECODER}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, +{"ignore", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_SUB_CHARENC_MODE_IGNORE}, INT_MIN, INT_MAX, S|D, "sub_charenc_mode"}, #if FF_API_ASS_TIMING {"sub_text_format", "set decoded text subtitle format", OFFSET(sub_text_format), AV_OPT_TYPE_INT, {.i64 = FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS}, 0, 1, S|D, "sub_text_format"}, #else diff --git a/libavcodec/version.h b/libavcodec/version.h index a5b7f752d1..8ac4626da7 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 15 +#define LIBAVCODEC_VERSION_MINOR 16 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavu/frame: add QP side data
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 1 15:57:01 2018 +0100| [4b86ac27a017ccd1d166f0bdd38c08720c561f7d] | committer: wm4 lavu/frame: add QP side data This adds a way for an API user to transfer QP data and metadata without having to keep the reference to AVFrame, and without having to explicitly care about QP APIs. It might also provide a way to finally remove the deprecated QP related fields. In the end, the QP table should be handled in a very similar way to e.g. AV_FRAME_DATA_MOTION_VECTORS. There are two side data types, because I didn't care about having to repack the QP data so the table and the metadata are in a single AVBufferRef. Otherwise it would have either required a copy on decoding (extra slowdown for something as obscure as the QP data), or would have required making intrusive changes to the codecs which support export of this data. The new side data types are added under deprecation guards, because I don't intend to change the status of the QP export as being deprecated (as it was before this patch too). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b86ac27a017ccd1d166f0bdd38c08720c561f7d --- doc/APIchanges | 3 ++ libavutil/frame.c | 59 ++ libavutil/frame.h | 17 +++ libavutil/version.h| 2 +- tests/ref/fate/exif-image-embedded | 6 tests/ref/fate/exif-image-jpg | 6 6 files changed, 86 insertions(+), 7 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f757f5063e..4c0ee7147a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-03-18 - xxx - lavu 56.11.100 - frame.h + Add AV_FRAME_DATA_QP_TABLE_PROPERTIES and AV_FRAME_DATA_QP_TABLE_DATA. + 2018-03-15 - e0e72539cf - lavu 56.10.100 - opt.h Add AV_OPT_FLAG_BSF_PARAM diff --git a/libavutil/frame.c b/libavutil/frame.c index 0db2a2d57b..ea13cd3ed6 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -46,8 +46,17 @@ MAKE_ACCESSORS(AVFrame, frame, enum AVColorRange, color_range) av_get_channel_layout_nb_channels((frame)->channel_layout)) #if FF_API_FRAME_QP +struct qp_properties { +int stride; +int type; +}; + int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type) { +struct qp_properties *p; +AVFrameSideData *sd; +AVBufferRef *ref; + FF_DISABLE_DEPRECATION_WARNINGS av_buffer_unref(>qp_table_buf); @@ -57,20 +66,56 @@ FF_DISABLE_DEPRECATION_WARNINGS f->qscale_type = qp_type; FF_ENABLE_DEPRECATION_WARNINGS +av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); +av_frame_remove_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); + +ref = av_buffer_ref(buf); +if (!av_frame_new_side_data_from_buf(f, AV_FRAME_DATA_QP_TABLE_DATA, ref)) { +av_buffer_unref(); +return AVERROR(ENOMEM); +} + +sd = av_frame_new_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES, +sizeof(struct qp_properties)); +if (!sd) +return AVERROR(ENOMEM); + +p = (struct qp_properties *)sd->data; +p->stride = stride; +p->type = qp_type; + return 0; } int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) { -FF_DISABLE_DEPRECATION_WARNINGS -*stride = f->qstride; -*type = f->qscale_type; +AVBufferRef *buf = NULL; -if (!f->qp_table_buf) -return NULL; +*stride = 0; +*type = 0; -return f->qp_table_buf->data; +FF_DISABLE_DEPRECATION_WARNINGS +if (f->qp_table_buf) { +*stride = f->qstride; +*type = f->qscale_type; +buf = f->qp_table_buf; FF_ENABLE_DEPRECATION_WARNINGS +} else { +AVFrameSideData *sd; +struct qp_properties *p; +sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_PROPERTIES); +if (!sd) +return NULL; +p = (struct qp_properties *)sd->data; +sd = av_frame_get_side_data(f, AV_FRAME_DATA_QP_TABLE_DATA); +if (!sd) +return NULL; +*stride = p->stride; +*type = p->type; +buf = sd->buf; +} + +return buf ? buf->data : NULL; } #endif @@ -787,6 +832,8 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type) case AV_FRAME_DATA_CONTENT_LIGHT_LEVEL: return "Content light level metadata"; case AV_FRAME_DATA_GOP_TIMECODE:return "GOP timecode"; case AV_FRAME_DATA_ICC_PROFILE: return "ICC profile"; +case AV_FRAME_DATA_QP_TABLE_PROPERTIES: return "QP table properties"; +case AV_FRAME_DATA_QP_TABLE_DATA: return "QP table data"; } return NULL; } diff --git a/libavutil/frame.h b/
[FFmpeg-cvslog] http: do not print a warning message for expired cookies
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 8 04:30:35 2018 +0100| [39c1d170a3474a06f4805589d642f605f7ef1436] | committer: wm4 http: do not print a warning message for expired cookies libavformat prints a warning that the cookie couldn't be parsed (see callers of parse_cookie()). This is obviously not true - it could be parsed, but was simply ignored. Don't return an error to avoid the warning. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39c1d170a3474a06f4805589d642f605f7ef1436 --- libavformat/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 344fd603cb..d7a72e7129 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -802,7 +802,7 @@ static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies) // if the cookie has already expired ignore it if (av_timegm(_tm) < av_gettime() / 100) { av_dict_free(_params); -return -1; +return 0; } // only replace an older cookie with the same name ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] http: fix potentially dangerous whitespace skipping code
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 8 04:52:36 2018 +0100| [b7d842c554b1fec051ca906f446f7311139c5725] | committer: wm4 http: fix potentially dangerous whitespace skipping code If the string consists entirely of whitespace, this could in theory continue to write '\0' before the start of the memory allocation. In practice, it didn't really happen: the generic HTTP header parsing code already skips leading whitespaces, so the string is either empty, or consists a non-whitespace. (The generic code and the cookie code actually have different ideas about what bytes are whitespace: the former uses av_isspace(), the latter uses WHITESPACES. Fortunately, av_isspace() is a super set of the http.c specific WHITESPACES, so there's probably no case where the above assumption could have been broken.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7d842c554b1fec051ca906f446f7311139c5725 --- libavformat/http.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 59f90ac603..983034f083 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -760,6 +760,8 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict) back = [strlen(cstr)-1]; while (strchr(WHITESPACES, *back)) { *back='\0'; +if (back == cstr) +break; back--; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavu/frame: fix inconsistent qp_table_buf deprecation
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 1 15:50:56 2018 +0100| [36855abc0eb96d5caa992304f3417a0f8a62960c] | committer: wm4 lavu/frame: fix inconsistent qp_table_buf deprecation Everything related to the QP data is deprecated, with qp_table_buf being an inconsistent exception. Some parts were under the deprecation guards, some not. It probably didn't even compile. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=36855abc0eb96d5caa992304f3417a0f8a62960c --- libavutil/frame.c | 7 --- libavutil/frame.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 61c45f0f53..0db2a2d57b 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -48,11 +48,10 @@ MAKE_ACCESSORS(AVFrame, frame, enum AVColorRange, color_range) #if FF_API_FRAME_QP int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int qp_type) { +FF_DISABLE_DEPRECATION_WARNINGS av_buffer_unref(>qp_table_buf); f->qp_table_buf = buf; - -FF_DISABLE_DEPRECATION_WARNINGS f->qscale_table = buf->data; f->qstride = stride; f->qscale_type = qp_type; @@ -66,12 +65,12 @@ int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type) FF_DISABLE_DEPRECATION_WARNINGS *stride = f->qstride; *type = f->qscale_type; -FF_ENABLE_DEPRECATION_WARNINGS if (!f->qp_table_buf) return NULL; return f->qp_table_buf->data; +FF_ENABLE_DEPRECATION_WARNINGS } #endif @@ -520,7 +519,9 @@ void av_frame_unref(AVFrame *frame) av_freep(>extended_buf); av_dict_free(>metadata); #if FF_API_FRAME_QP +FF_DISABLE_DEPRECATION_WARNINGS av_buffer_unref(>qp_table_buf); +FF_ENABLE_DEPRECATION_WARNINGS #endif av_buffer_unref(>hw_frames_ctx); diff --git a/libavutil/frame.h b/libavutil/frame.h index 59cee8ceab..ddbac3156d 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -529,6 +529,7 @@ typedef struct AVFrame { attribute_deprecated int qscale_type; +attribute_deprecated AVBufferRef *qp_table_buf; #endif /** ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] http: avoid out of bound accesses on broken Set-Cookie headers
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Mar 8 04:47:40 2018 +0100| [c0687acbf6094053834af6a20e9d71b455842c8c] | committer: wm4 http: avoid out of bound accesses on broken Set-Cookie headers It's trivial to craft a HTTP response that will make the code for skipping trailing whitespace access and possibly overwrite bytes outside of the memory allocation. Why this can happen is blindingly obvious: it accesses cstr[strlen(cstr)-1] without checking whether the string is empty. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0687acbf6094053834af6a20e9d71b455842c8c --- libavformat/http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index d7a72e7129..59f90ac603 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -750,6 +750,9 @@ static int parse_set_cookie(const char *set_cookie, AVDictionary **dict) { char *param, *next_param, *cstr, *back; +if (!set_cookie[0]) +return 0; + if (!(cstr = av_strdup(set_cookie))) return AVERROR(EINVAL); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avutil/opt: remove ABI hacks
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Feb 13 04:11:27 2018 +0100| [474194a8d0f2812802c275f6ed4f0fd5cd58ae0e] | committer: wm4 avutil/opt: remove ABI hacks These were needed for ABI compatibility with Libav. We don't need them anymore. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=474194a8d0f2812802c275f6ed4f0fd5cd58ae0e --- libavutil/opt.h | 18 +- libavutil/version.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/libavutil/opt.h b/libavutil/opt.h index 555929dd6b..391720f2e2 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -229,15 +229,15 @@ enum AVOptionType{ AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length AV_OPT_TYPE_DICT, AV_OPT_TYPE_UINT64, -AV_OPT_TYPE_CONST = 128, -AV_OPT_TYPE_IMAGE_SIZE = MKBETAG('S','I','Z','E'), ///< offset must point to two consecutive integers -AV_OPT_TYPE_PIXEL_FMT = MKBETAG('P','F','M','T'), -AV_OPT_TYPE_SAMPLE_FMT = MKBETAG('S','F','M','T'), -AV_OPT_TYPE_VIDEO_RATE = MKBETAG('V','R','A','T'), ///< offset must point to AVRational -AV_OPT_TYPE_DURATION = MKBETAG('D','U','R',' '), -AV_OPT_TYPE_COLOR = MKBETAG('C','O','L','R'), -AV_OPT_TYPE_CHANNEL_LAYOUT = MKBETAG('C','H','L','A'), -AV_OPT_TYPE_BOOL = MKBETAG('B','O','O','L'), +AV_OPT_TYPE_CONST, +AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers +AV_OPT_TYPE_PIXEL_FMT, +AV_OPT_TYPE_SAMPLE_FMT, +AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational +AV_OPT_TYPE_DURATION, +AV_OPT_TYPE_COLOR, +AV_OPT_TYPE_CHANNEL_LAYOUT, +AV_OPT_TYPE_BOOL, }; /** diff --git a/libavutil/version.h b/libavutil/version.h index d81ec6fa7b..a2a820aebf 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 56 #define LIBAVUTIL_VERSION_MINOR 7 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] id3v2: fix unsynchronization
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jan 30 13:22:53 2018 +0100| [48bc9fffd11c05e75b9125d8cd90e9263108bd83] | committer: wm4 id3v2: fix unsynchronization The ID3v2 "unsynchronization scheme" requires replacing any 0xFF 0x00 sequences with 0xFF. This has to be done on every byte of the source data, while the current code skipped a byte after a replacement. This meant 0xFF 0x00 0xFF 00 was translated to 0xFF 0xFF 0x00 instead of 0xFF 0xFF. It feels a bit messy to do this correctly with the avio use. But fortunately, this translation can be done in-place, so we can just do it in memory. Inspired by what taglib does. Also see 9ae80e6a9cefcab61e867256ba19ef78a4bfe0cb. (The sample file for that commit is gone, so it could not be retested.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48bc9fffd11c05e75b9125d8cd90e9263108bd83 --- libavformat/id3v2.c | 26 ++ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index b80178d67a..f7de26a1d8 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -976,19 +976,21 @@ static void id3v2_parse(AVIOContext *pb, AVDictionary **metadata, } } if (unsync || tunsync) { -int64_t end = avio_tell(pb) + tlen; -uint8_t *b; - -b = buffer; -while (avio_tell(pb) < end && b - buffer < tlen && !pb->eof_reached) { -*b++ = avio_r8(pb); -if (*(b - 1) == 0xff && avio_tell(pb) < end - 1 && -b - buffer < tlen && -!pb->eof_reached ) { -uint8_t val = avio_r8(pb); -*b++ = val ? val : avio_r8(pb); -} +uint8_t *b = buffer; +uint8_t *t = buffer; +uint8_t *end = t + tlen; + +if (avio_read(pb, buffer, tlen) != tlen) { +av_log(s, AV_LOG_ERROR, "Failed to read tag data\n"); +goto seek; } + +while (t != end) { +*b++ = *t++; +if (t != end && t[-1] == 0xff && !t[0]) +t++; +} + ffio_init_context(_local, buffer, b - buffer, 0, NULL, NULL, NULL, NULL); tlen = b - buffer; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] rtsp: rename certain options after a deprecation period
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jan 25 18:57:26 2018 +0100| [ff46124b0df17a1d35249e09ae8eae9a61f16e04] | committer: wm4 rtsp: rename certain options after a deprecation period The "timeout" option name inherently clashes with the meaning of the HTTP libavformat protocol option with the same name. Rename it after a deprecation period to make it compatible with the HTTP one. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff46124b0df17a1d35249e09ae8eae9a61f16e04 --- doc/APIchanges| 7 +++ libavformat/rtsp.c| 12 ++-- libavformat/version.h | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6185545d56..b802f62d4d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,13 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-02-xx - xxx - lavf 58.8.100 - avformat.h + Deprecate the current names of the RTSP "timeout", "stimeout", "user-agent" + options. Introduce "listen_timeout" as replacement for the current "timeout" + option, and "user_agent" as replacement for "user-agent". Once the deprecation + is over, the old "timeout" option will be removed, and "stimeout" will be + renamed to "stimeout" (the "timeout" option will essentially change semantics). + 2018-01-xx - xxx - lavf 58.7.100 - avformat.h Deprecate AVFormatContext filename field which had limited length, use the new dynamically allocated url field instead. diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 89fc1e293c..b3cfbb874f 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -93,10 +93,18 @@ const AVOption ff_rtsp_options[] = { RTSP_MEDIATYPE_OPTS("allowed_media_types", "set media types to accept from the server"), { "min_port", "set minimum local UDP port", OFFSET(rtp_port_min), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MIN}, 0, 65535, DEC|ENC }, { "max_port", "set maximum local UDP port", OFFSET(rtp_port_max), AV_OPT_TYPE_INT, {.i64 = RTSP_RTP_PORT_MAX}, 0, 65535, DEC|ENC }, -{ "timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC }, +{ "listen_timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC }, +#if FF_API_OLD_RTSP_OPTIONS +{ "timeout", "set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen) (deprecated, use listen_timeout)", OFFSET(initial_timeout), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, DEC }, { "stimeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC }, +#else +{ "timeout", "set timeout (in microseconds) of socket TCP I/O operations", OFFSET(stimeout), AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX, DEC }, +#endif COMMON_OPTS(), -{ "user-agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC }, +{ "user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC }, +#if FF_API_OLD_RTSP_OPTIONS +{ "user-agent", "override User-Agent header (deprecated, use user_agent)", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, DEC }, +#endif { NULL }, }; diff --git a/libavformat/version.h b/libavformat/version.h index 897be0c2fe..a42ab7056d 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -88,6 +88,9 @@ #ifndef FF_API_FORMAT_FILENAME #define FF_API_FORMAT_FILENAME (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_OLD_RTSP_OPTIONS +#define FF_API_OLD_RTSP_OPTIONS (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] hls: don't print a certain warning if playlist loading is aborted
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Jan 24 08:04:38 2018 +0100| [23ffeb91fe46f6f95348731396ccfdb7fbff0337] | committer: wm4 hls: don't print a certain warning if playlist loading is aborted AVERROR_EXIT happens when the user's interrupt callback signals that playback should be aborted. In this case, the demuxer shouldn't print a warning, as it's expected that all network accesses are stopped. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=23ffeb91fe46f6f95348731396ccfdb7fbff0337 --- libavformat/hls.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 6e1a2e3f1e..02e764f932 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1422,8 +1422,9 @@ reload: if (!v->finished && av_gettime_relative() - v->last_load_time >= reload_interval) { if ((ret = parse_playlist(c, v->url, v, NULL)) < 0) { -av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", - v->index); +if (ret != AVERROR_EXIT) +av_log(v->parent, AV_LOG_WARNING, "Failed to reload playlist %d\n", + v->index); return ret; } /* If we need to reload the playlist again below (if ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat, hls: add a flag to signal unavailability of seeking
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Jan 24 08:02:25 2018 +0100| [6194d7e56454897b9c5d9d52e82376b2a6e6b85c] | committer: wm4 avformat, hls: add a flag to signal unavailability of seeking The seek function can just return an error if seeking is unavailable, but often this is too late. Add a flag that signals that the stream is unseekable, and use it in HLS. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6194d7e56454897b9c5d9d52e82376b2a6e6b85c --- doc/APIchanges | 3 +++ libavformat/avformat.h | 5 + libavformat/hls.c | 8 ++-- libavformat/version.h | 4 ++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index c27f104c95..59e3b20c08 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2017-10-21 API changes, most recent first: +2018-01-xx - xxx - lavf 58.6.100 - avformat.h + Add AVFMTCTX_UNSEEKABLE (for HLS demuxer). + 2018-xx-xx - xxx - lavu 56.9.100 - aes_ctr.h Add method to set the 16-byte IV. diff --git a/libavformat/avformat.h b/libavformat/avformat.h index e5740be2b4..60ab9fbc80 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1275,6 +1275,11 @@ typedef struct AVProgram { #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present (streams are added dynamically) */ +#define AVFMTCTX_UNSEEKABLE0x0002 /**< signal that the stream is definitely + not seekable, and attempts to call the + seek function will fail. For some + network protocols (e.g. HLS), this can + change dynamically at runtime. */ typedef struct AVChapter { int id; ///< unique ID to identify the chapter diff --git a/libavformat/hls.c b/libavformat/hls.c index ff7bdecc93..6e1a2e3f1e 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -930,6 +930,11 @@ fail: av_free(new_url); if (close_in) ff_format_io_close(c->ctx, ); +c->ctx->ctx_flags = c->ctx->ctx_flags & ~(unsigned)AVFMTCTX_UNSEEKABLE; +if (!c->n_variants || !c->variants[0]->n_playlists || +!(c->variants[0]->playlists[0]->finished || + c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT)) +c->ctx->ctx_flags |= AVFMTCTX_UNSEEKABLE; return ret; } @@ -2213,8 +2218,7 @@ static int hls_read_seek(AVFormatContext *s, int stream_index, int stream_subdemuxer_index; int64_t first_timestamp, seek_timestamp, duration; -if ((flags & AVSEEK_FLAG_BYTE) || -!(c->variants[0]->playlists[0]->finished || c->variants[0]->playlists[0]->type == PLS_TYPE_EVENT)) +if ((flags & AVSEEK_FLAG_BYTE) || (c->ctx->ctx_flags & AVFMTCTX_UNSEEKABLE)) return AVERROR(ENOSYS); first_timestamp = c->first_timestamp == AV_NOPTS_VALUE ? diff --git a/libavformat/version.h b/libavformat/version.h index 148fc75faa..5ff8a89ae0 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // 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 5 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 6 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hls: do not allow fallback to generic seeking
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Jan 24 07:58:52 2018 +0100| [637dfa39421c2806616d1aa454c9182db1aac3d9] | committer: wm4 hls: do not allow fallback to generic seeking This makes little sense due to how HLS works, and only causes some additional annoyances if the HLS read_seek function fails (for example if it's a live stream). It was most likely unintended. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=637dfa39421c2806616d1aa454c9182db1aac3d9 --- libavformat/hls.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 950cc4c3bd..ff7bdecc93 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2333,6 +2333,7 @@ AVInputFormat ff_hls_demuxer = { .long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming"), .priv_class = _class, .priv_data_size = sizeof(HLSContext), +.flags = AVFMT_NOGENSEARCH, .read_probe = hls_probe, .read_header= hls_read_header, .read_packet= hls_read_packet, ___ 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 <nfx...@googlemail.com> | 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, _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] avformat: deprecate another ffserver API leftover
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | 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(>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(>info->duration_error); av_freep(>info); +#if FF_API_LAVF_FFSERVER +FF_DISABLE_DEPRECATION_WARNINGS av_freep(>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] avformat: make avformat_network_init() explicitly optional
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | 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), )) return 0; #endif diff --git a/li
[FFmpeg-cvslog] hwcontext_vdpau: implement av_hwdevice_get_hwframe_constraints()
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jan 13 07:05:09 2018 +0100| [cbbb2067341d7c2d98f560f81c6fb103af33a490] | committer: wm4 hwcontext_vdpau: implement av_hwdevice_get_hwframe_constraints() In addition, this does not allow creating frames contexts with sw_format for which no known transfer formats exist. In theory, we should check whether the chroma format (i.e. the sw_format) is supported at all by the vdpau driver, but checking for transfer formats has the same effect. Note that the pre-existing code adds 1 to priv->nb_pix_fmts[i] for unknown reason, and some checks need to account for that to check for empty lists. They are not off-by-one errors. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbbb2067341d7c2d98f560f81c6fb103af33a490 --- libavutil/hwcontext_vdpau.c | 55 - 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/libavutil/hwcontext_vdpau.c b/libavutil/hwcontext_vdpau.c index 9b8f839647..c11c3cfdab 100644 --- a/libavutil/hwcontext_vdpau.c +++ b/libavutil/hwcontext_vdpau.c @@ -79,11 +79,12 @@ static const VDPAUPixFmtMap pix_fmts_444[] = { static const struct { VdpChromaType chroma_type; +enum AVPixelFormat frames_sw_format; const VDPAUPixFmtMap *map; } vdpau_pix_fmts[] = { -{ VDP_CHROMA_TYPE_420, pix_fmts_420 }, -{ VDP_CHROMA_TYPE_422, pix_fmts_422 }, -{ VDP_CHROMA_TYPE_444, pix_fmts_444 }, +{ VDP_CHROMA_TYPE_420, AV_PIX_FMT_YUV420P, pix_fmts_420 }, +{ VDP_CHROMA_TYPE_422, AV_PIX_FMT_YUV422P, pix_fmts_422 }, +{ VDP_CHROMA_TYPE_444, AV_PIX_FMT_YUV444P, pix_fmts_444 }, }; static int count_pixfmts(const VDPAUPixFmtMap *map) @@ -170,6 +171,35 @@ static void vdpau_device_uninit(AVHWDeviceContext *ctx) av_freep(>pix_fmts[i]); } +static int vdpau_frames_get_constraints(AVHWDeviceContext *ctx, +const void *hwconfig, +AVHWFramesConstraints *constraints) +{ +VDPAUDeviceContext *priv = ctx->internal->priv; +int nb_sw_formats = 0; +int i; + +constraints->valid_sw_formats = av_malloc_array(FF_ARRAY_ELEMS(vdpau_pix_fmts) + 1, + sizeof(*constraints->valid_sw_formats)); +if (!constraints->valid_sw_formats) +return AVERROR(ENOMEM); + +for (i = 0; i < FF_ARRAY_ELEMS(vdpau_pix_fmts); i++) { +if (priv->nb_pix_fmts[i] > 1) +constraints->valid_sw_formats[nb_sw_formats++] = vdpau_pix_fmts[i].frames_sw_format; +} +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_VDPAU; +constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE; + +return 0; +} + static void vdpau_buffer_free(void *opaque, uint8_t *data) { AVHWFramesContext *ctx = opaque; @@ -214,26 +244,18 @@ static int vdpau_frames_init(AVHWFramesContext *ctx) int i; -switch (ctx->sw_format) { -case AV_PIX_FMT_YUV420P: priv->chroma_type = VDP_CHROMA_TYPE_420; break; -case AV_PIX_FMT_YUV422P: priv->chroma_type = VDP_CHROMA_TYPE_422; break; -case AV_PIX_FMT_YUV444P: priv->chroma_type = VDP_CHROMA_TYPE_444; break; -default: -av_log(ctx, AV_LOG_ERROR, "Unsupported data layout: %s\n", - av_get_pix_fmt_name(ctx->sw_format)); -return AVERROR(ENOSYS); -} - for (i = 0; i < FF_ARRAY_ELEMS(vdpau_pix_fmts); i++) { -if (vdpau_pix_fmts[i].chroma_type == priv->chroma_type) { +if (vdpau_pix_fmts[i].frames_sw_format == ctx->sw_format) { +priv->chroma_type = vdpau_pix_fmts[i].chroma_type; priv->chroma_idx = i; priv->pix_fmts= device_priv->pix_fmts[i]; priv->nb_pix_fmts = device_priv->nb_pix_fmts[i]; break; } } -if (!priv->pix_fmts) { -av_log(ctx, AV_LOG_ERROR, "Unsupported chroma type: %d\n", priv->chroma_type); +if (priv->nb_pix_fmts < 2) { +av_log(ctx, AV_LOG_ERROR, "Unsupported sw format: %s\n", + av_get_pix_fmt_name(ctx->sw_format)); return AVERROR(ENOSYS); } @@ -468,6 +490,7 @@ const HWContextType ff_hwcontext_type_vdpau = { #endif .device_init = vdpau_device_init, .device_uninit= vdpau_device_uninit, +.frames_get_constraints = vdpau_frames_get_constraints, .frames_init = vdpau_frames_init, .frames_get_buffer= vdpau_get_buffer, .transfer_get_formats = vdpau_transfer_get_formats, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] http: cosmetics: reformat reconnect check for better readability
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jan 11 02:27:20 2018 +0100| [43e1ccfea186080b1c4cb4cd1e59ac1a3c3dc446] | committer: wm4 http: cosmetics: reformat reconnect check for better readability The condition was a bit too long, and most editors will break the line and turn it into an unreadable mess. Move out some of the conditions. This should not change the behavior. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43e1ccfea186080b1c4cb4cd1e59ac1a3c3dc446 --- libavformat/http.c | 12 +--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 510b23375a..aa80e314df 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1449,12 +1449,18 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) return http_buf_read_compressed(h, buf, size); #endif /* CONFIG_ZLIB */ read_ret = http_buf_read(h, buf, size); -while ((read_ret < 0 && s->reconnect&& (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize) -|| (read_ret == AVERROR_EOF && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) { +while (read_ret < 0) { uint64_t target = h->is_streamed ? 0 : s->off; if (read_ret == AVERROR_EXIT) -return read_ret; +break; + +if (h->is_streamed && !s->reconnect_streamed) +break; + +if (!(s->reconnect && s->filesize > 0 && s->off < s->filesize) && +!(s->reconnect_at_eof && read_ret == AVERROR_EOF)) +break; if (reconnect_delay > s->reconnect_delay_max) return AVERROR(EIO); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_dxva2: initialize D3DDISPLAYMODEEX correctly
ffmpeg | branch: release/3.4 | wm4 <nfx...@googlemail.com> | Thu Jan 4 15:52:46 2018 +0100| [4a53ecb12ead1a2e6735ad3365381516e6e2d3f6] | committer: James Almer hwcontext_dxva2: initialize D3DDISPLAYMODEEX correctly (cherry picked from commit 18fbfd7bf86effb49c0341b37b9c1d73940d688e) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a53ecb12ead1a2e6735ad3365381516e6e2d3f6 --- libavutil/hwcontext_dxva2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c index 44ebdbca95..665c2d6d74 100644 --- a/libavutil/hwcontext_dxva2.c +++ b/libavutil/hwcontext_dxva2.c @@ -485,6 +485,7 @@ static int dxva2_device_create9ex(AVHWDeviceContext *ctx, UINT adapter) if (FAILED(hr)) return AVERROR_UNKNOWN; +modeex.Size = sizeof(D3DDISPLAYMODEEX); hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, adapter, , NULL); if (FAILED(hr)) { IDirect3D9Ex_Release(d3d9ex); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] http: avoid logging reconnect warning if stream was aborted
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jan 4 17:06:52 2018 +0100| [2477bfe22121f04eff9e4ba2475f1f999c17ea36] | committer: wm4 http: avoid logging reconnect warning if stream was aborted If the stream was aborted using the libavformat interrupt callback, we don't want it to log the reconnect warning. (Exiting after logging this warning worked well, so this is only for avoiding the ugly warning.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2477bfe22121f04eff9e4ba2475f1f999c17ea36 --- libavformat/http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index eb029e33a0..4806b1e59b 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1452,6 +1452,9 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) || (read_ret == AVERROR_EOF && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) { uint64_t target = h->is_streamed ? 0 : s->off; +if (read_ret == AVERROR_EXIT) +return read_ret; + if (reconnect_delay > s->reconnect_delay_max) return AVERROR(EIO); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_dxva2: initialize D3DDISPLAYMODEEX correctly
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jan 4 15:52:46 2018 +0100| [18fbfd7bf86effb49c0341b37b9c1d73940d688e] | committer: wm4 hwcontext_dxva2: initialize D3DDISPLAYMODEEX correctly > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18fbfd7bf86effb49c0341b37b9c1d73940d688e --- libavutil/hwcontext_dxva2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c index 44ebdbca95..665c2d6d74 100644 --- a/libavutil/hwcontext_dxva2.c +++ b/libavutil/hwcontext_dxva2.c @@ -485,6 +485,7 @@ static int dxva2_device_create9ex(AVHWDeviceContext *ctx, UINT adapter) if (FAILED(hr)) return AVERROR_UNKNOWN; +modeex.Size = sizeof(D3DDISPLAYMODEEX); hr = IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, adapter, , NULL); if (FAILED(hr)) { IDirect3D9Ex_Release(d3d9ex); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] http: block while waiting for reconnecting
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jan 2 17:05:03 2018 +0100| [8a108bdea06fac43af9f44b6d2538f357451167a] | committer: wm4 http: block while waiting for reconnecting It makes no sense to return an error after the first reconnect, and then somehow resume the next time it's called. Usually this will lead to demuxer errors. Make reconnecting block instead, until it has either successfully reconnected, or given up. Also make the wait reasonably interruptible. Since there is no mechanism for this in the API, polling is the best we can do. This behaves roughly the same as other interruptible network functions in libavformat. (The original code would work if it returned AVERROR(EAGAIN) or so, which would make retry_transfer_wrapper() repeat the read call. But I think having an explicit loop for this is better anyway.) I also snuck in a fix for reconnect_at_eof. It has to check for AVERROR_EOF, not 0. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a108bdea06fac43af9f44b6d2538f357451167a --- libavformat/http.c| 19 ++- libavformat/network.c | 18 ++ libavformat/network.h | 9 + 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/libavformat/http.c b/libavformat/http.c index 8f7e56de54..5eff87f8bb 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -117,7 +117,6 @@ typedef struct HTTPContext { int reconnect; int reconnect_at_eof; int reconnect_streamed; -int reconnect_delay; int reconnect_delay_max; int listen; char *resource; @@ -1433,6 +1432,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) HTTPContext *s = h->priv_data; int err, new_location, read_ret; int64_t seek_ret; +int reconnect_delay = 0; if (!s->hd) return AVERROR_EOF; @@ -1448,25 +1448,26 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) return http_buf_read_compressed(h, buf, size); #endif /* CONFIG_ZLIB */ read_ret = http_buf_read(h, buf, size); -if ( (read_ret < 0 && s->reconnect&& (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize) -|| (read_ret == 0 && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) { +while ((read_ret < 0 && s->reconnect&& (!h->is_streamed || s->reconnect_streamed) && s->filesize > 0 && s->off < s->filesize) +|| (read_ret == AVERROR_EOF && s->reconnect_at_eof && (!h->is_streamed || s->reconnect_streamed))) { uint64_t target = h->is_streamed ? 0 : s->off; -if (s->reconnect_delay > s->reconnect_delay_max) +if (reconnect_delay > s->reconnect_delay_max) return AVERROR(EIO); av_log(h, AV_LOG_INFO, "Will reconnect at %"PRIu64" error=%s.\n", s->off, av_err2str(read_ret)); -av_usleep(1000U*1000*s->reconnect_delay); -s->reconnect_delay = 1 + 2*s->reconnect_delay; +err = ff_network_sleep_interruptible(1000U*1000*reconnect_delay, >interrupt_callback); +if (err != AVERROR(ETIMEDOUT)) +return err; +reconnect_delay = 1 + 2*reconnect_delay; seek_ret = http_seek_internal(h, target, SEEK_SET, 1); -if (seek_ret != target) { +if (seek_ret >= 0 && seek_ret != target) { av_log(h, AV_LOG_ERROR, "Failed to reconnect at %"PRIu64".\n", target); return read_ret; } read_ret = http_buf_read(h, buf, size); -} else -s->reconnect_delay = 0; +} return read_ret; } diff --git a/libavformat/network.c b/libavformat/network.c index 6c3d9def3b..e9eb4b443a 100644 --- a/libavformat/network.c +++ b/libavformat/network.c @@ -103,6 +103,24 @@ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterrupt } } +int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb) +{ +int64_t wait_start = av_gettime_relative(); + +while (1) { +int64_t time_left; + +if (ff_check_interrupt(int_cb)) +return AVERROR_EXIT; + +time_left = timeout - (av_gettime_relative() - wait_start); +if (time_left <= 0) +return AVERROR(ETIMEDOUT); + +av_usleep(FFMIN(time_left, POLLING_TIME * 1000)); +} +} + void ff_network_close(void) { #if HAVE_WINSOCK2_H diff --git a/libavformat/network.h b/libavformat/network.h index b78e3ad6ed..a663115541 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -96,6 +96,15 @@ int ff_network_wait_fd(int fd, int write); */ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterruptCB *int_cb); +/*
[FFmpeg-cvslog] http: bump message level for reconnect message and log timeout
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jan 2 17:17:41 2018 +0100| [1b283c4a0dde1060ca1745f59a15cb8b77dfdaa5] | committer: wm4 http: bump message level for reconnect message and log timeout > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b283c4a0dde1060ca1745f59a15cb8b77dfdaa5 --- libavformat/http.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/http.c b/libavformat/http.c index 5eff87f8bb..eb029e33a0 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1455,7 +1455,7 @@ static int http_read_stream(URLContext *h, uint8_t *buf, int size) if (reconnect_delay > s->reconnect_delay_max) return AVERROR(EIO); -av_log(h, AV_LOG_INFO, "Will reconnect at %"PRIu64" error=%s.\n", s->off, av_err2str(read_ret)); +av_log(h, AV_LOG_WARNING, "Will reconnect at %"PRIu64" in %d second(s), error=%s.\n", s->off, reconnect_delay, av_err2str(read_ret)); err = ff_network_sleep_interruptible(1000U*1000*reconnect_delay, >interrupt_callback); if (err != AVERROR(ETIMEDOUT)) return err; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] tcp: properly return EOF
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Dec 30 17:44:03 2017 +0100| [0e1f771d2200d14d298df09c91e14f51e418fd3a] | committer: wm4 tcp: properly return EOF There is no POSIX error code for EOF - recv() signals EOF by simply returning 0. But libavformat recently changed its conventions and requires an explicit AVERROR_EOF, or it might get into an endless retry loop, consuming 100% CPU while doing nothing. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0e1f771d2200d14d298df09c91e14f51e418fd3a --- libavformat/tcp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/tcp.c b/libavformat/tcp.c index fef0729da6..8773493df1 100644 --- a/libavformat/tcp.c +++ b/libavformat/tcp.c @@ -225,6 +225,8 @@ static int tcp_read(URLContext *h, uint8_t *buf, int size) return ret; } ret = recv(s->fd, buf, size, 0); +if (ret == 0) +return AVERROR_EOF; return ret < 0 ? ff_neterrno() : ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: remove uneffective attribute_deprecated on enum
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Dec 27 03:47:28 2017 +0100| [8f9024f2ca4740c4ed80dea1e9c890c9217013bd] | committer: wm4 lavc: remove uneffective attribute_deprecated on enum Does not work. Even emits a warning with some compilers that the attribute does not work on enums. It's likely that there is way to make it work, but not worth the trouble. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f9024f2ca4740c4ed80dea1e9c890c9217013bd --- libavcodec/avcodec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index a9182a9e3d..c13deb599f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5933,8 +5933,9 @@ AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); #if FF_API_LOCKMGR /** * Lock operation used by lockmgr + * + * @deprecated Deprecated together with av_lockmgr_register(). */ -attribute_deprecated enum AVLockOp { AV_LOCK_CREATE, ///< Create a mutex AV_LOCK_OBTAIN, ///< Lock the mutex ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] h264: add AVOption to set x264_build default
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Dec 23 03:13:00 2017 +0100| [cf57cb3ae4364ab8e70af37beea7a45a86de90e9] | committer: wm4 h264: add AVOption to set x264_build default This provides a generic way to the API user to deal with files that either lack this SEI, or which have the SEI only in packets not passed to the decoder (such as the common case of the SEI being in the very firsat video packet, but decoding is started somewhere in the middle of the file). Bugs like 840b41b2a643fc8f0617c0370125a19c02c6b586 make this somewhat of a necessity. This intentionally uses the version in the SEI instead, if any is found. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cf57cb3ae4364ab8e70af37beea7a45a86de90e9 --- libavcodec/h264dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 1e98765439..8c9c6d9f3b 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -315,7 +315,6 @@ static int h264_init_context(AVCodecContext *avctx, H264Context *h) h->flags = avctx->flags; h->poc.prev_poc_msb = 1 << 16; h->recovery_frame= -1; -h->x264_build= -1; h->frame_recovered = 0; h->poc.prev_frame_num= -1; h->sei.frame_packing.arrangement_cancel_flag = -1; @@ -1037,6 +1036,7 @@ static const AVOption h264_options[] = { { "is_avc", "is avc", OFFSET(is_avc), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, 0 }, { "nal_length_size", "nal_length_size", OFFSET(nal_length_size), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, 0 }, { "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VD }, +{ "x264_build", "Assume this x264 version if no x264 version found in any SEI", OFFSET(x264_build), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VD }, { NULL }, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] w32pthreads: always use Vista+ API, drop XP support
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 21 20:23:14 2017 +0100| [9b121dfc32810250938021952aab4172a988cb56] | committer: wm4 w32pthreads: always use Vista+ API, drop XP support This removes the XP compatibility code, and switches entirely to SWR locks, which are available starting at Windows Vista. This removes CRITICAL_SECTION use, which allows us to add PTHREAD_MUTEX_INITIALIZER, which will be useful later. Windows XP is hereby not a supported build target anymore. It was decided in a project vote that this is OK. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b121dfc32810250938021952aab4172a988cb56 --- Changelog | 2 + compat/w32pthreads.h | 266 ++--- configure | 13 ++- libavcodec/pthread_frame.c | 4 - libavcodec/pthread_slice.c | 4 - libavfilter/pthread.c | 4 - libavutil/slicethread.c| 4 - 7 files changed, 19 insertions(+), 278 deletions(-) diff --git a/Changelog b/Changelog index f44cec679f..2ebdf00ff1 100644 --- a/Changelog +++ b/Changelog @@ -28,6 +28,8 @@ version : - nsp demuxer - support LibreSSL (via libtls) - AVX-512/ZMM support added +- Dropped support for building for Windows XP. The minimum supported Windows + version is Windows Vista. version 3.4: diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index eeead6051f..237cab5677 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -56,19 +56,12 @@ typedef struct pthread_t { void *ret; } pthread_t; -/* the conditional variable api for windows 6.0+ uses critical sections and - * not mutexes */ -typedef CRITICAL_SECTION pthread_mutex_t; - -/* This is the CONDITION_VARIABLE typedef for using Windows' native - * conditional variables on kernels 6.0+. */ -#if HAVE_CONDITION_VARIABLE_PTR +/* use light weight mutex/condition variable API for Windows Vista and later */ +typedef SRWLOCK pthread_mutex_t; typedef CONDITION_VARIABLE pthread_cond_t; -#else -typedef struct pthread_cond_t { -void *Ptr; -} pthread_cond_t; -#endif + +#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT +#define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT #if _WIN32_WINNT >= 0x0600 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) @@ -114,26 +107,25 @@ static av_unused int pthread_join(pthread_t thread, void **value_ptr) static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr) { -InitializeCriticalSection(m); +InitializeSRWLock(m); return 0; } static inline int pthread_mutex_destroy(pthread_mutex_t *m) { -DeleteCriticalSection(m); +/* Unlocked SWR locks use no resources */ return 0; } static inline int pthread_mutex_lock(pthread_mutex_t *m) { -EnterCriticalSection(m); +AcquireSRWLockExclusive(m); return 0; } static inline int pthread_mutex_unlock(pthread_mutex_t *m) { -LeaveCriticalSection(m); +ReleaseSRWLockExclusive(m); return 0; } -#if _WIN32_WINNT >= 0x0600 typedef INIT_ONCE pthread_once_t; #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT @@ -167,7 +159,7 @@ static inline int pthread_cond_broadcast(pthread_cond_t *cond) static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { -SleepConditionVariableCS(cond, mutex, INFINITE); +SleepConditionVariableSRW(cond, mutex, INFINITE, 0); return 0; } @@ -177,242 +169,4 @@ static inline int pthread_cond_signal(pthread_cond_t *cond) return 0; } -#else // _WIN32_WINNT < 0x0600 - -/* atomic init state of dynamically loaded functions */ -static LONG w32thread_init_state = 0; -static av_unused void w32thread_init(void); - -/* for pre-Windows 6.0 platforms, define INIT_ONCE struct, - * compatible to the one used in the native API */ - -typedef union pthread_once_t { -void * Ptr;///< For the Windows 6.0+ native functions -LONG state;///< For the pre-Windows 6.0 compat code -} pthread_once_t; - -#define PTHREAD_ONCE_INIT {0} - -/* function pointers to init once API on windows 6.0+ kernels */ -static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD dwFlags, BOOL *fPending, void **lpContext); -static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD dwFlags, void *lpContext); - -/* pre-Windows 6.0 compat using a spin-lock */ -static inline void w32thread_once_fallback(LONG volatile *state, void (*init_routine)(void)) -{ -switch (InterlockedCompareExchange(state, 1, 0)) { -/* Initial run */ -case 0: -init_routine(); -InterlockedExchange(state, 2); -break; -/* Another thread is running init */ -case 1: -while (1) { -MemoryBarrier(); -if (*state == 2) -break; -Sleep(0); -} -break; -/* Initialization complete */ -case 2: -break; -} -} - -static av_unused int pthread_once(pthread_on
[FFmpeg-cvslog] lavc: replace and deprecate the lock manager
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 21 22:39:24 2017 +0100| [a04c2c707de2ce850f79870e84ac9d7ec7aa9143] | committer: wm4 lavc: replace and deprecate the lock manager Use static mutexes instead of requiring a lock manager. The behavior should be roughly the same before and after this change for API users which did not set the lock manager at all (except that a minor memory leak disappears). > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a04c2c707de2ce850f79870e84ac9d7ec7aa9143 --- doc/APIchanges | 5 +++ libavcodec/avcodec.h | 8 +++- libavcodec/utils.c | 107 +-- libavcodec/version.h | 5 ++- libavutil/thread.h | 2 + 5 files changed, 28 insertions(+), 99 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index df79758e86..3c9f237596 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2017-10-21 API changes, most recent first: +2017-xx-xx - xxx - lavc 58.9.100 - avcodec.h + Deprecate av_lockmgr_register(). You need to build FFmpeg with threading + support enabled to get basic thread-safety (which is the default build + configuration). + 2017-12-xx - xxx - lavu 56.7.100 - cpu.h AVX-512 flags added. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce089b7c4a..a9182a9e3d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5930,10 +5930,11 @@ attribute_deprecated AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); #endif - +#if FF_API_LOCKMGR /** * Lock operation used by lockmgr */ +attribute_deprecated enum AVLockOp { AV_LOCK_CREATE, ///< Create a mutex AV_LOCK_OBTAIN, ///< Lock the mutex @@ -5963,8 +5964,13 @@ enum AVLockOp { * mechanism (i.e. do not use a single static object to * implement your lock manager). If cb is set to NULL the * lockmgr will be unregistered. + * + * @deprecated This function does nothing, and always returns 0. Be sure to + * build with thread support to get basic thread safety. */ +attribute_deprecated int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); +#endif /** * Get the type of the given codec. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 873f39f9bd..eec4437693 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -67,58 +67,10 @@ #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; -#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS -static int default_lockmgr_cb(void **arg, enum AVLockOp op) -{ -void * volatile * mutex = arg; -int err; - -switch (op) { -case AV_LOCK_CREATE: -return 0; -case AV_LOCK_OBTAIN: -if (!*mutex) { -pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t)); -if (!tmp) -return AVERROR(ENOMEM); -if ((err = pthread_mutex_init(tmp, NULL))) { -av_free(tmp); -return AVERROR(err); -} -if (avpriv_atomic_ptr_cas(mutex, NULL, tmp)) { -pthread_mutex_destroy(tmp); -av_free(tmp); -} -} - -if ((err = pthread_mutex_lock(*mutex))) -return AVERROR(err); - -return 0; -case AV_LOCK_RELEASE: -if ((err = pthread_mutex_unlock(*mutex))) -return AVERROR(err); - -return 0; -case AV_LOCK_DESTROY: -if (*mutex) -pthread_mutex_destroy(*mutex); -av_free(*mutex); -avpriv_atomic_ptr_cas(mutex, *mutex, NULL); -return 0; -} -return 1; -} -static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = default_lockmgr_cb; -#else -static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL; -#endif - - volatile int ff_avcodec_locked; static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); -static void *codec_mutex; -static void *avformat_mutex; +static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; +static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { @@ -1909,55 +1861,26 @@ void av_register_hwaccel(AVHWAccel *hwaccel) } #endif +#if FF_API_LOCKMGR int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) { -if (lockmgr_cb) { -// There is no good way to rollback a failure to destroy the -// mutex, so we ignore failures. -lockmgr_cb(_mutex,AV_LOCK_DESTROY); -lockmgr_cb(_mutex, AV_LOCK_DESTROY); -lockmgr_cb = NULL; -codec_mutex= NULL; -avformat_mutex = NULL; -} - -if (cb) { -void *new_codec_mutex= NULL; -void *new_avformat_mutex = NULL; -int err; -if (err = cb(_codec_mutex, AV_LOCK_CREATE)) { -return err > 0 ? AVERROR_UNKNOWN : err; -}
[FFmpeg-cvslog] ffplay: drop lock manager use
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 21 22:43:43 2017 +0100| [e24f192a9fd6013e272df1bfaeaba31e8ca49f92] | committer: wm4 ffplay: drop lock manager use Deprecated and useless. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e24f192a9fd6013e272df1bfaeaba31e8ca49f92 --- fftools/ffplay.c | 27 --- 1 file changed, 27 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 10a917194d..9bfa3e6cea 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1284,7 +1284,6 @@ static void do_exit(VideoState *is) SDL_DestroyRenderer(renderer); if (window) SDL_DestroyWindow(window); -av_lockmgr_register(NULL); uninit_opts(); #if CONFIG_AVFILTER av_freep(_list); @@ -3641,27 +3640,6 @@ void show_help_default(const char *opt, const char *arg) ); } -static int lockmgr(void **mtx, enum AVLockOp op) -{ - switch(op) { - case AV_LOCK_CREATE: - *mtx = SDL_CreateMutex(); - if(!*mtx) { - av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError()); - return 1; - } - return 0; - case AV_LOCK_OBTAIN: - return !!SDL_LockMutex(*mtx); - case AV_LOCK_RELEASE: - return !!SDL_UnlockMutex(*mtx); - case AV_LOCK_DESTROY: - SDL_DestroyMutex(*mtx); - return 0; - } - return 1; -} - /* Called from the main */ int main(int argc, char **argv) { @@ -3723,11 +3701,6 @@ int main(int argc, char **argv) SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE); -if (av_lockmgr_register(lockmgr)) { -av_log(NULL, AV_LOG_FATAL, "Could not initialize lock manager!\n"); -do_exit(NULL); -} - av_init_packet(_pkt); flush_pkt.data = (uint8_t *)_pkt; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: remove complex debug code around avcodec init locking
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 21 23:03:24 2017 +0100| [4ed66517c62c599701b3793fa2843d5a8530a4f4] | committer: wm4 lavc: remove complex debug code around avcodec init locking This is just a lot of complicated and confusing code that had no purpose anymore. Also, the functions return values were checked only sometimes. Locking shouldn't fail anyway, so remove the return values. Barely any other pthread lock calls check the return value (including more important code that is more likely to fail horribly if locking fails). It could be argued that it might be helpful in some debugging situations, or when the user built FFmpeg without thread support against all good advice. But there are dummy atomics too, so the atomic check won't help with ensuring correctness absolutely. You gain very little. Also, for debugging, you can just raise the ASSERT_LEVEL, and then libavutil/thread.h will redefine the locking functions to explicitly check the return values. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ed66517c62c599701b3793fa2843d5a8530a4f4 --- libavcodec/internal.h | 4 libavcodec/utils.c| 55 +-- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 30614bb2b1..16bd101284 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -243,10 +243,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame); void ff_color_frame(AVFrame *frame, const int color[4]); -extern volatile int ff_avcodec_locked; -int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec); -int ff_unlock_avcodec(const AVCodec *codec); - /** * Maximum size in bytes of extradata. * This value was chosen such that every bit of the buffer is diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9c631c4fb0..dfbfe98d63 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -67,8 +67,6 @@ #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; -volatile int ff_avcodec_locked; -static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) @@ -550,6 +548,19 @@ static int64_t get_bit_rate(AVCodecContext *ctx) return bit_rate; } + +static void ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_lock(_mutex); +} + +static void ff_unlock_avcodec(const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_unlock(_mutex); +} + int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) { int ret = 0; @@ -589,9 +600,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (options) av_dict_copy(, *options, 0); -ret = ff_lock_avcodec(avctx, codec); -if (ret < 0) -return ret; +ff_lock_avcodec(avctx, codec); avctx->internal = av_mallocz(sizeof(AVCodecInternal)); if (!avctx->internal) { @@ -1867,42 +1876,6 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) } #endif -int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) -{ -if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) -return 0; - -if (ff_mutex_lock(_mutex)) -return -1; - -if (atomic_fetch_add(_thread_counter, 1)) { -av_log(log_ctx, AV_LOG_ERROR, - "Insufficient thread locking. At least %d threads are " - "calling avcodec_open2() at the same time right now.\n", - atomic_load(_thread_counter)); -ff_avcodec_locked = 1; -ff_unlock_avcodec(codec); -return AVERROR(EINVAL); -} -av_assert0(!ff_avcodec_locked); -ff_avcodec_locked = 1; -return 0; -} - -int ff_unlock_avcodec(const AVCodec *codec) -{ -if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) -return 0; - -av_assert0(ff_avcodec_locked); -ff_avcodec_locked = 0; -atomic_fetch_add(_thread_counter, -1); -if (ff_mutex_unlock(_mutex)) -return -1; - -return 0; -} - unsigned int avpriv_toupper4(unsigned int x) { return av_toupper(x & 0xFF) + ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc, lavf: move avformat static mutex from avcodec to avformat
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 21 22:54:06 2017 +0100| [86a13bf2ffb40d44260d5747a4782a42a43a1ed8] | committer: wm4 lavc, lavf: move avformat static mutex from avcodec to avformat It's completely absurd that libavcodec would care about libavformat locking, but it was there because the lock manager was in libavcodec. This is more stright forward. Changes ABI, but we don't require ABI compatibility currently. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=86a13bf2ffb40d44260d5747a4782a42a43a1ed8 --- libavcodec/internal.h | 3 --- libavcodec/utils.c| 11 --- libavformat/avisynth.c| 10 +- libavformat/chromaprint.c | 9 + libavformat/internal.h| 4 libavformat/tls_gnutls.c | 8 libavformat/tls_openssl.c | 10 +- libavformat/utils.c | 13 + 8 files changed, 36 insertions(+), 32 deletions(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index fcbdb6c04d..30614bb2b1 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -247,9 +247,6 @@ extern volatile int ff_avcodec_locked; int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec); int ff_unlock_avcodec(const AVCodec *codec); -int avpriv_lock_avformat(void); -int avpriv_unlock_avformat(void); - /** * Maximum size in bytes of extradata. * This value was chosen such that every bit of the buffer is diff --git a/libavcodec/utils.c b/libavcodec/utils.c index eec4437693..9c631c4fb0 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -70,7 +70,6 @@ const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; volatile int ff_avcodec_locked; static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; -static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { @@ -1904,16 +1903,6 @@ int ff_unlock_avcodec(const AVCodec *codec) return 0; } -int avpriv_lock_avformat(void) -{ -return ff_mutex_lock(_mutex) ? -1 : 0; -} - -int avpriv_unlock_avformat(void) -{ -return ff_mutex_unlock(_mutex) ? -1 : 0; -} - unsigned int avpriv_toupper4(unsigned int x) { return av_toupper(x & 0xFF) + diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 56700288f7..250a489321 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -774,15 +774,15 @@ static av_cold int avisynth_read_header(AVFormatContext *s) int ret; // Calling library must implement a lock for thread-safe opens. -if (ret = avpriv_lock_avformat()) +if (ret = ff_lock_avformat()) return ret; if (ret = avisynth_open_file(s)) { -avpriv_unlock_avformat(); +ff_unlock_avformat(); return ret; } -avpriv_unlock_avformat(); +ff_unlock_avformat(); return 0; } @@ -818,11 +818,11 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt) static av_cold int avisynth_read_close(AVFormatContext *s) { -if (avpriv_lock_avformat()) +if (ff_lock_avformat()) return AVERROR_UNKNOWN; avisynth_context_destroy(s->priv_data); -avpriv_unlock_avformat(); +ff_unlock_avformat(); return 0; } diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c index 4da02bef76..f39c09ddb9 100644 --- a/libavformat/chromaprint.c +++ b/libavformat/chromaprint.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "libavutil/opt.h" #include "libavcodec/internal.h" #include @@ -49,9 +50,9 @@ typedef struct ChromaprintMuxContext { static void cleanup(ChromaprintMuxContext *cpr) { if (cpr->ctx) { -avpriv_lock_avformat(); +ff_lock_avformat(); chromaprint_free(cpr->ctx); -avpriv_unlock_avformat(); +ff_unlock_avformat(); } } @@ -60,9 +61,9 @@ static int write_header(AVFormatContext *s) ChromaprintMuxContext *cpr = s->priv_data; AVStream *st; -avpriv_lock_avformat(); +ff_lock_avformat(); cpr->ctx = chromaprint_new(cpr->algorithm); -avpriv_unlock_avformat(); +ff_unlock_avformat(); if (!cpr->ctx) { av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n"); diff --git a/libavformat/internal.h b/libavformat/internal.h index e76ac12371..30715b3f50 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -684,4 +684,8 @@ int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf int ff_interleaved_peek(AVFormatContext *s, int stream, AVPacket *pkt, int add_offset); + +int ff_lock_avformat(void); +int ff_unlock_avformat(void); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c index 0cef9575ec..e3c43683be 100644 --
[FFmpeg-cvslog] rkmppdec: move AV_CODEC_CAP_AVOID_PROBING to the correct field
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 14 19:47:18 2017 +0100| [1083859cb8c9d9b3bcee970dd33b71015a0a11bc] | committer: wm4 rkmppdec: move AV_CODEC_CAP_AVOID_PROBING to the correct field AVCodec.caps_internal doesn't hold this field. (Untested.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1083859cb8c9d9b3bcee970dd33b71015a0a11bc --- libavcodec/rkmppdec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c index fa522ce2ed..c57a6ded38 100644 --- a/libavcodec/rkmppdec.c +++ b/libavcodec/rkmppdec.c @@ -588,8 +588,7 @@ static const AVCodecHWConfigInternal *rkmpp_hw_configs[] = { .receive_frame = rkmpp_receive_frame, \ .flush = rkmpp_flush, \ .priv_class = _##NAME##_dec_class, \ -.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, \ -.caps_internal = AV_CODEC_CAP_AVOID_PROBING, \ +.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE, \ .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_DRM_PRIME, \ AV_PIX_FMT_NONE}, \ .hw_configs = rkmpp_hw_configs, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] v4l_m2m: add missing AV_CODEC_CAP_DELAY flags
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Dec 14 19:46:52 2017 +0100| [55eebf2a11d28146658565948d6649311f20c0e1] | committer: wm4 v4l_m2m: add missing AV_CODEC_CAP_DELAY flags This is pretty much a requirement for any codec that handles modern codecs like h264, but it was missing. Potentially could lead to issues like missing frames at the end of a stream. Tested-by: Jorge Ramirez <jorge.ramirez-or...@linaro.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55eebf2a11d28146658565948d6649311f20c0e1 --- libavcodec/v4l2_m2m_dec.c | 2 +- libavcodec/v4l2_m2m_enc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c index c4ea20ea83..8308613978 100644 --- a/libavcodec/v4l2_m2m_dec.c +++ b/libavcodec/v4l2_m2m_dec.c @@ -215,7 +215,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_decoder = { \ .receive_frame = v4l2_receive_frame,\ .close = ff_v4l2_m2m_codec_end,\ .bsfs = bsf_name, \ -.capabilities = AV_CODEC_CAP_HARDWARE, \ +.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \ .wrapper_name = "v4l2m2m", \ }; diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c index f62ce7cdb5..7e88f4d2e6 100644 --- a/libavcodec/v4l2_m2m_enc.c +++ b/libavcodec/v4l2_m2m_enc.c @@ -335,7 +335,7 @@ AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \ .send_frame = v4l2_send_frame,\ .receive_packet = v4l2_receive_packet,\ .close = ff_v4l2_m2m_codec_end,\ -.capabilities = AV_CODEC_CAP_HARDWARE, \ +.capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \ .wrapper_name = "v4l2m2m", \ }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec: add metadata to identify wrappers and hardware decoders
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Dec 12 11:03:43 2017 +0100| [47687a2f8aca3f65b6fdd117b1cb66a7409a7fd1] | committer: Luca Barbato avcodec: add metadata to identify wrappers and hardware decoders Explicitly identify decoder/encoder wrappers with a common name. This saves API users from guessing by the name suffix. For example, they don't have to guess that "h264_qsv" is the h264 QSV implementation, and instead they can just check the AVCodec .codec and .wrapper_name fields. Explicitly mark AVCodec entries that are hardware decoders or most likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing API users listing hardware decoders in a more generic way. The proposed AVCodecHWConfig does not provide this information fully, because it's concerned with decoder configuration, not information about the fact whether the hardware is used or not. AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software implementations in case the hardware is not capable. Based on a patch by Philip Langdale <phil...@overt.org>. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47687a2f8aca3f65b6fdd117b1cb66a7409a7fd1 --- libavcodec/avcodec.h| 25 + libavcodec/libdcadec.c | 1 + libavcodec/libfaac.c| 1 + libavcodec/libfdk-aacdec.c | 1 + libavcodec/libfdk-aacenc.c | 1 + libavcodec/libgsmdec.c | 2 ++ libavcodec/libgsmenc.c | 2 ++ libavcodec/libilbc.c| 1 + libavcodec/libkvazaar.c | 2 ++ libavcodec/libmp3lame.c | 1 + libavcodec/libopencore-amr.c| 1 + libavcodec/libopenh264dec.c | 1 + libavcodec/libopenh264enc.c | 1 + libavcodec/libopenjpegdec.c | 1 + libavcodec/libopenjpegenc.c | 1 + libavcodec/libopusdec.c | 1 + libavcodec/libopusenc.c | 1 + libavcodec/libschroedingerdec.c | 1 + libavcodec/libschroedingerenc.c | 1 + libavcodec/libspeexdec.c| 1 + libavcodec/libspeexenc.c| 1 + libavcodec/libtheoraenc.c | 1 + libavcodec/libtwolame.c | 1 + libavcodec/libvo-aacenc.c | 1 + libavcodec/libvo-amrwbenc.c | 1 + libavcodec/libvorbis.c | 1 + libavcodec/libvpxdec.c | 2 ++ libavcodec/libvpxenc.c | 2 ++ libavcodec/libwavpackenc.c | 1 + libavcodec/libwebpenc.c | 1 + libavcodec/libx264.c| 2 ++ libavcodec/libx265.c| 1 + libavcodec/libxavs.c| 1 + libavcodec/libxvid.c| 1 + libavcodec/mmaldec.c| 3 ++- libavcodec/qsvdec_h2645.c | 6 -- libavcodec/qsvdec_other.c | 9 ++--- libavcodec/qsvenc_h264.c| 3 ++- libavcodec/qsvenc_hevc.c| 3 ++- libavcodec/qsvenc_jpeg.c| 3 ++- libavcodec/qsvenc_mpeg2.c | 3 ++- libavcodec/vaapi_encode_h264.c | 3 ++- libavcodec/vaapi_encode_h265.c | 3 ++- libavcodec/vaapi_encode_mjpeg.c | 2 ++ libavcodec/vaapi_encode_mpeg2.c | 3 ++- libavcodec/vaapi_encode_vp8.c | 3 ++- libavcodec/vaapi_encode_vp9.c | 3 ++- 47 files changed, 96 insertions(+), 15 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 5624835023..ec952dd0e8 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -886,6 +886,19 @@ typedef struct RcOverride{ #define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16) /** + * Codec is backed by a hardware implementation. Typically used to + * identify a non-hwaccel hardware decoder. + */ +#define AV_CODEC_CAP_HARDWARE(1 << 17) + +/** + * Codec is potentially backed by a hardware implementation, but not + * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the + * implementation provides some sort of internal fallback. + */ +#define AV_CODEC_CAP_HYBRID (1 << 18) + +/** * Pan Scan area. * This specifies the area which should be displayed. * Note there may be multiple such areas for one frame. @@ -2770,6 +2783,18 @@ typedef struct AVCodec { const AVClass *priv_class; ///< AVClass for the private context const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} +/** + * Group name of the codec implementation. + * This is a short symbolic name of the wrapper backing this codec. A + * wrapper uses some kind of external implementation for the codec, such + * as an external library, or a codec implementation provided by the OS or + * the hardware. + * If this field is NULL, this is a builtin, libavcodec native decoder. + * If non-NULL, this will be the suffix in AVCodec.name in most cases + * (usually AVCodec.name will be of the form "_"). + */ +const char *wrapper_name; + /**
[FFmpeg-cvslog] avcodec: add metadata to identify wrappers and hardware decoders
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Dec 11 16:18:44 2017 +0100| [b945fed629a872d393f59d16fc5773574126ca88] | committer: wm4 avcodec: add metadata to identify wrappers and hardware decoders Explicitly identify decoder/encoder wrappers with a common name. This saves API users from guessing by the name suffix. For example, they don't have to guess that "h264_qsv" is the h264 QSV implementation, and instead they can just check the AVCodec .codec and .wrapper_name fields. Explicitly mark AVCodec entries that are hardware decoders or most likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing API users listing hardware decoders in a more generic way. The proposed AVCodecHWConfig does not provide this information fully, because it's concerned with decoder configuration, not information about the fact whether the hardware is used or not. AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software implementations in case the hardware is not capable. Based on a patch by Philip Langdale <phil...@overt.org>. Merges Libav commit 47687a2f8aca3f65b6fdd117b1cb66a7409a7fd1. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b945fed629a872d393f59d16fc5773574126ca88 --- doc/APIchanges | 4 libavcodec/audiotoolboxdec.c| 1 + libavcodec/audiotoolboxenc.c| 1 + libavcodec/avcodec.h| 26 ++ libavcodec/crystalhd.c | 3 ++- libavcodec/cuviddec.c | 3 ++- libavcodec/libcelt_dec.c| 1 + libavcodec/libfdk-aacdec.c | 1 + libavcodec/libfdk-aacenc.c | 1 + libavcodec/libgsmdec.c | 2 ++ libavcodec/libgsmenc.c | 2 ++ libavcodec/libilbc.c| 1 + libavcodec/libkvazaar.c | 2 ++ libavcodec/libmp3lame.c | 1 + libavcodec/libopencore-amr.c| 1 + libavcodec/libopenh264dec.c | 1 + libavcodec/libopenh264enc.c | 1 + libavcodec/libopenjpegdec.c | 1 + libavcodec/libopenjpegenc.c | 1 + libavcodec/libopusdec.c | 1 + libavcodec/libopusenc.c | 1 + libavcodec/librsvgdec.c | 1 + libavcodec/libshine.c | 1 + libavcodec/libspeexdec.c| 1 + libavcodec/libspeexenc.c| 1 + libavcodec/libtheoraenc.c | 1 + libavcodec/libtwolame.c | 1 + libavcodec/libvo-amrwbenc.c | 1 + libavcodec/libvorbisenc.c | 1 + libavcodec/libvpxdec.c | 2 ++ libavcodec/libvpxenc.c | 2 ++ libavcodec/libwavpackenc.c | 1 + libavcodec/libwebpenc.c | 1 + libavcodec/libwebpenc_animencoder.c | 1 + libavcodec/libx264.c| 3 +++ libavcodec/libx265.c| 1 + libavcodec/libxavs.c| 1 + libavcodec/libxvid.c| 1 + libavcodec/libzvbi-teletextdec.c| 1 + libavcodec/mediacodecdec.c | 18 -- libavcodec/mmaldec.c| 3 ++- libavcodec/nvenc_h264.c | 9 ++--- libavcodec/nvenc_hevc.c | 6 -- libavcodec/qsvdec_h2645.c | 6 -- libavcodec/qsvdec_other.c | 9 ++--- libavcodec/qsvenc_h264.c| 3 ++- libavcodec/qsvenc_hevc.c| 3 ++- libavcodec/qsvenc_jpeg.c| 3 ++- libavcodec/qsvenc_mpeg2.c | 3 ++- libavcodec/rkmppdec.c | 3 ++- libavcodec/v4l2_m2m_dec.c | 2 ++ libavcodec/v4l2_m2m_enc.c | 2 ++ libavcodec/vaapi_encode_h264.c | 3 ++- libavcodec/vaapi_encode_h265.c | 3 ++- libavcodec/vaapi_encode_mjpeg.c | 2 ++ libavcodec/vaapi_encode_mpeg2.c | 3 ++- libavcodec/vaapi_encode_vp8.c | 3 ++- libavcodec/vaapi_encode_vp9.c | 3 ++- libavcodec/version.h| 4 ++-- libavcodec/videotoolboxenc.c| 3 ++- 60 files changed, 140 insertions(+), 32 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4af69c64bd..b4451ab193 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,10 @@ libavutil: 2017-10-21 API changes, most recent first: +2017-xx-xx - xxc - lavc 58.7.100 - avcodec.h + Add AV_CODEC_CAP_HARDWARE, AV_CODEC_CAP_HYBRID, and AVCodec.wrapper_name, + and mark all AVCodecs accordingly. + 2017-xx-xx - xxx - lavu 56.4.100 / 56.7.0 - stereo3d.h Add view field to AVStereo3D structure and AVStereo3DView enum. diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c index 3711665bbd..5c0a9de8f6 100644 --- a/libavcodec/audiotoolboxdec.c +++ b/libavcodec/audiotoolboxdec.c @@ -597,6 +597,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx) .bsfs = bsf_name, \ .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, \ .caps_internal = FF_
[FFmpeg-cvslog] vp9_parser: don't split superframes into separate packets
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Nov 29 17:07:26 2017 +0100| [0c162854c1fa2a1e43ce5588b67842675f45e3c7] | committer: wm4 vp9_parser: don't split superframes into separate packets We did this for the sake of the decoder. With the vp9 change, it's not necessary anymore. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0c162854c1fa2a1e43ce5588b67842675f45e3c7 --- libavcodec/vp9_parser.c | 127 1 file changed, 10 insertions(+), 117 deletions(-) diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c index 9900e7ab1f..9531f34a32 100644 --- a/libavcodec/vp9_parser.c +++ b/libavcodec/vp9_parser.c @@ -25,21 +25,19 @@ #include "libavcodec/get_bits.h" #include "parser.h" -typedef struct VP9ParseContext { -int n_frames; // 1-8 -int size[8]; -int marker_size; -int64_t pts; -} VP9ParseContext; - -static int parse_frame(AVCodecParserContext *ctx, const uint8_t *buf, int size) +static int parse(AVCodecParserContext *ctx, + AVCodecContext *avctx, + const uint8_t **out_data, int *out_size, + const uint8_t *data, int size) { -VP9ParseContext *s = ctx->priv_data; GetBitContext gb; -int res, profile, keyframe, invisible; +int res, profile, keyframe; -if ((res = init_get_bits8(, buf, size)) < 0) -return res; +*out_data = data; +*out_size = size; + +if ((res = init_get_bits8(, data, size)) < 0) +return size; // parsers can't return errors get_bits(, 2); // frame marker profile = get_bits1(); profile |= get_bits1() << 1; @@ -47,10 +45,8 @@ static int parse_frame(AVCodecParserContext *ctx, const uint8_t *buf, int size) if (get_bits1()) { keyframe = 0; -invisible = 0; } else { keyframe = !get_bits1(); -invisible = !get_bits1(); } if (!keyframe) { @@ -61,113 +57,10 @@ static int parse_frame(AVCodecParserContext *ctx, const uint8_t *buf, int size) ctx->key_frame = 1; } -if (!invisible) { -if (ctx->pts == AV_NOPTS_VALUE) -ctx->pts = s->pts; -s->pts = AV_NOPTS_VALUE; -} else if (ctx->pts != AV_NOPTS_VALUE) { -s->pts = ctx->pts; -ctx->pts = AV_NOPTS_VALUE; -} - -return 0; -} - -static int parse(AVCodecParserContext *ctx, - AVCodecContext *avctx, - const uint8_t **out_data, int *out_size, - const uint8_t *data, int size) -{ -VP9ParseContext *s = ctx->priv_data; -int full_size = size; -int marker; - -if (size <= 0) { -*out_size = 0; -*out_data = data; - -return 0; -} - -if (s->n_frames > 0) { -int i; -int size_sum = 0; - -for (i = 0; i < s->n_frames ;i++) -size_sum += s->size[i]; -size_sum += s->marker_size; - -if (size_sum != size) { -av_log(avctx, AV_LOG_ERROR, "Inconsistent input frame sizes %d %d\n", - size_sum, size); -s->n_frames = 0; -} -} - -if (s->n_frames > 0) { -*out_data = data; -*out_size = s->size[--s->n_frames]; -parse_frame(ctx, *out_data, *out_size); - -return s->n_frames > 0 ? *out_size : size /* i.e. include idx tail */; -} - -marker = data[size - 1]; -if ((marker & 0xe0) == 0xc0) { -int nbytes = 1 + ((marker >> 3) & 0x3); -int n_frames = 1 + (marker & 0x7), idx_sz = 2 + n_frames * nbytes; - -if (size >= idx_sz && data[size - idx_sz] == marker) { -const uint8_t *idx = data + size + 1 - idx_sz; -int first = 1; - -switch (nbytes) { -#define case_n(a, rd) \ -case a: \ -while (n_frames--) { \ -unsigned sz = rd; \ -idx += a; \ -if (sz == 0 || sz > size) { \ -s->n_frames = 0; \ -*out_size = size; \ -*out_data = data; \ -av_log(avctx, AV_LOG_ERROR, \ - "Invalid superframe packet size: %u frame size: %d\n", \ - sz, size); \ -return full_size; \ -} \ -if (first) { \ -first = 0; \ -*out_data = data; \ -*out_size = sz; \ -s->n_frames = n_frames; \ -} else { \ -s->size[n_frames] = sz; \ -} \ -data += sz; \ -size -= sz; \ -} \ -s-&g
[FFmpeg-cvslog] vp9: use superframe split BSF
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Fri Nov 17 14:15:22 2017 +0100| [a5679933c1b8b6bef5c5c3eb7c70d06c695066cf] | committer: wm4 vp9: use superframe split BSF webm usually has invisible superframes merged with normal frames. (vpxenc muxes them in this form, which is evidence enough that this is the standard webm packet format. It's rather unclear whether ffmpeg is even allowed to remux them with split packets.) The vp9 decoder needs them to be in separate packets for multithreading to work. Add the BSF to the decoder, so the conversion happens automatically. This contains the important part of fa1749dd34c55fb9, which was apparently skipped in commit d417e95af76. This restores Libav API compatibility. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5679933c1b8b6bef5c5c3eb7c70d06c695066cf --- libavcodec/version.h | 2 +- libavcodec/vp9.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 55bb5c5e01..d67b689142 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 6 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 1ea2869c4c..6241f01de1 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1795,6 +1795,7 @@ AVCodec ff_vp9_decoder = { .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp9_decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp9_decode_update_thread_context), .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), +.bsfs = "vp9_superframe_split", .hw_configs= (const AVCodecHWConfigInternal*[]) { #if CONFIG_VP9_DXVA2_HWACCEL HWACCEL_DXVA2(vp9), ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/videotoolbox: fix opaque_ref handling
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 31 15:15:27 2017 +0100| [9283a4f19b762b25bc8e5e8f402fefb9097a1397] | committer: Aman Gupta avcodec/videotoolbox: fix opaque_ref handling This is a partial fix - to fix videotoolbox fully (with multithreaded hwaccel decoding), much more work would be required. Before this change, an assertion failure would trigger: $ ffmpeg -hwaccel videotoolbox -hwaccel_output_format videotoolbox_vld -i h264.ts -f null -y /dev/null Assertion (frame->private_ref && frame->private_ref->size == sizeof(FrameDecodeData)) || !(avctx->codec->capabilities & (1 << 1)) failed at libavcodec/decode.c:620 Signed-off-by: Aman Gupta <a...@tmm1.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9283a4f19b762b25bc8e5e8f402fefb9097a1397 --- libavcodec/videotoolbox.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 4547ffef34..9eeada30ba 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -27,6 +27,7 @@ #include "libavutil/avutil.h" #include "libavutil/hwcontext.h" #include "bytestream.h" +#include "decode.h" #include "h264dec.h" #include "hevcdec.h" #include "mpegvideo.h" @@ -70,6 +71,10 @@ static int videotoolbox_buffer_copy(VTContext *vtctx, int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame) { +int ret = ff_attach_decode_data(frame); +if (ret < 0) +return ret; + frame->width = avctx->width; frame->height = avctx->height; frame->format = avctx->pix_fmt; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] videotoolbox: add frame_params support
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 31 15:12:24 2017 +0100| [c31ce95f1c4c504ff9e3a90b1e4e37f695547c72] | committer: James Almer videotoolbox: add frame_params support Allows decoding with API users which require this API. Reviewed-by: Aman Gupta <ffm...@tmm1.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c31ce95f1c4c504ff9e3a90b1e4e37f695547c72 --- libavcodec/videotoolbox.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index ecb2502c1f..f0790e7353 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -947,6 +947,19 @@ fail: return err; } +static int videotoolbox_frame_params(AVCodecContext *avctx, + AVBufferRef *hw_frames_ctx) +{ +AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data; + +frames_ctx->format= AV_PIX_FMT_VIDEOTOOLBOX; +frames_ctx->width = avctx->coded_width; +frames_ctx->height= avctx->coded_height; +frames_ctx->sw_format = AV_PIX_FMT_NV12; + +return 0; +} + AVHWAccel ff_h263_videotoolbox_hwaccel = { .name = "h263_videotoolbox", .type = AVMEDIA_TYPE_VIDEO, @@ -956,6 +969,7 @@ AVHWAccel ff_h263_videotoolbox_hwaccel = { .start_frame= videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = videotoolbox_uninit, .priv_data_size = sizeof(VTContext), @@ -970,6 +984,7 @@ AVHWAccel ff_hevc_videotoolbox_hwaccel = { .start_frame= ff_videotoolbox_h264_start_frame, .decode_slice = ff_videotoolbox_h264_decode_slice, .end_frame = videotoolbox_hevc_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), @@ -984,6 +999,7 @@ AVHWAccel ff_h264_videotoolbox_hwaccel = { .start_frame= ff_videotoolbox_h264_start_frame, .decode_slice = ff_videotoolbox_h264_decode_slice, .end_frame = videotoolbox_h264_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = videotoolbox_uninit, .priv_data_size = sizeof(VTContext), @@ -998,6 +1014,7 @@ AVHWAccel ff_mpeg1_videotoolbox_hwaccel = { .start_frame= videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = videotoolbox_uninit, .priv_data_size = sizeof(VTContext), @@ -1012,6 +1029,7 @@ AVHWAccel ff_mpeg2_videotoolbox_hwaccel = { .start_frame= videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = videotoolbox_uninit, .priv_data_size = sizeof(VTContext), @@ -1026,6 +1044,7 @@ AVHWAccel ff_mpeg4_videotoolbox_hwaccel = { .start_frame= videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, +.frame_params = videotoolbox_frame_params, .init = videotoolbox_common_init, .uninit = videotoolbox_uninit, .priv_data_size = sizeof(VTContext), ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: fix hw_device_ctx operation
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 24 00:28:03 2017 +0200| [e724bdfffbd3c27aac53d1f32f20f105f37caef0] | committer: Mark Thompson lavc: fix hw_device_ctx operation Commit b46a77f19d accidentally broke this (requested change that was added to the patch later and which was not fully tested). Signed-off-by: Mark Thompson <s...@jkqxz.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e724bdfffbd3c27aac53d1f32f20f105f37caef0 --- libavcodec/decode.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 54cda530bb..27f75d73e3 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -698,11 +698,9 @@ int ff_decode_get_hw_frames_ctx(AVCodecContext *avctx, ret = avcodec_get_hw_frames_parameters(avctx, avctx->hw_device_ctx, avctx->hwaccel->pix_fmt, - avctx->hw_frames_ctx); -if (ret < 0) { -av_buffer_unref(>hw_frames_ctx); + >hw_frames_ctx); +if (ret < 0) return ret; -} frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] nvdec: add frames_params support
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Oct 28 19:53:38 2017 +0200| [7546964f96168cd6ac819ef4c3212ee586619f1a] | committer: James Almer nvdec: add frames_params support > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7546964f96168cd6ac819ef4c3212ee586619f1a --- libavcodec/nvdec.c | 74 - libavcodec/nvdec.h | 5 +++- libavcodec/nvdec_h264.c | 8 -- libavcodec/nvdec_hevc.c | 8 -- 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index db338accfa..e4babad43e 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -185,7 +185,7 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx) return 0; } -int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) +int ff_nvdec_decode_init(AVCodecContext *avctx) { NVDECContext *ctx = avctx->internal->hwaccel_priv_data; @@ -214,37 +214,12 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) return AVERROR(ENOSYS); } -if (avctx->thread_type & FF_THREAD_FRAME) -dpb_size += avctx->thread_count; - if (!avctx->hw_frames_ctx) { -AVHWFramesContext *frames_ctx; - -if (!avctx->hw_device_ctx) { -av_log(avctx, AV_LOG_ERROR, "A hardware device or frames context " - "is required for CUVID decoding.\n"); -return AVERROR(EINVAL); -} - -avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx); -if (!avctx->hw_frames_ctx) -return AVERROR(ENOMEM); -frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; - -frames_ctx->format= AV_PIX_FMT_CUDA; -frames_ctx->width = avctx->coded_width; -frames_ctx->height= avctx->coded_height; -frames_ctx->sw_format = AV_PIX_FMT_NV12; -frames_ctx->sw_format = sw_desc->comp[0].depth > 8 ? -AV_PIX_FMT_P010 : AV_PIX_FMT_NV12; -frames_ctx->initial_pool_size = dpb_size; - -ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); -if (ret < 0) { -av_log(avctx, AV_LOG_ERROR, "Error initializing internal frames context\n"); +ret = ff_decode_get_hw_frames_ctx(avctx, AV_HWDEVICE_TYPE_CUDA); +if (ret < 0) return ret; -} } + frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; params.ulWidth = avctx->coded_width; @@ -256,7 +231,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12; params.CodecType = cuvid_codec_type; params.ChromaFormat= cuvid_chroma_format; -params.ulNumDecodeSurfaces = dpb_size; +params.ulNumDecodeSurfaces = frames_ctx->initial_pool_size; params.ulNumOutputSurfaces = 1; ret = nvdec_decoder_create(>decoder_ref, frames_ctx->device_ref, , avctx); @@ -268,7 +243,7 @@ int ff_nvdec_decode_init(AVCodecContext *avctx, unsigned int dpb_size) ret = AVERROR(ENOMEM); goto fail; } -pool->dpb_size = dpb_size; +pool->dpb_size = frames_ctx->initial_pool_size; ctx->decoder_pool = av_buffer_pool_init2(sizeof(int), pool, nvdec_decoder_frame_alloc, av_free); @@ -430,3 +405,40 @@ finish: return ret; } + +int ff_nvdec_frame_params(AVCodecContext *avctx, + AVBufferRef *hw_frames_ctx, + int dpb_size) +{ +AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data; +const AVPixFmtDescriptor *sw_desc; +int cuvid_codec_type, cuvid_chroma_format; + +sw_desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); +if (!sw_desc) +return AVERROR_BUG; + +cuvid_codec_type = map_avcodec_id(avctx->codec_id); +if (cuvid_codec_type < 0) { +av_log(avctx, AV_LOG_ERROR, "Unsupported codec ID\n"); +return AVERROR_BUG; +} + +cuvid_chroma_format = map_chroma_format(avctx->sw_pix_fmt); +if (cuvid_chroma_format < 0) { +av_log(avctx, AV_LOG_VERBOSE, "Unsupported chroma format\n"); +return AVERROR(EINVAL); +} + +if (avctx->thread_type & FF_THREAD_FRAME) +dpb_size += avctx->thread_count; + +frames_ctx->format= AV_PIX_FMT_CUDA; +frames_ctx->width = avctx->coded_width; +frames_ctx->height= avctx->coded_height; +frames_ctx->sw_format = sw_desc->comp[0].depth > 8 ? +AV_PIX_FMT_P010 : AV_PIX_FMT_NV12; +
[FFmpeg-cvslog] lavc: external hardware frame pool initialization
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Oct 19 16:38:20 2017 +0200| [b46a77f19ddc4b2b5fa3187835ceb602a5244e24] | committer: Anton Khirnov lavc: external hardware frame pool initialization This adds a new API, which allows the API user to query the required AVHWFramesContext parameters. This also reduces code duplication across the hwaccels by introducing ff_decode_get_hw_frames_ctx(), which uses the new API function. It takes care of initializing the hw_frames_ctx if needed, and does additional error handling and API usage checking. Support for VDA and Cuvid missing. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b46a77f19ddc4b2b5fa3187835ceb602a5244e24 --- doc/APIchanges | 3 + libavcodec/avcodec.h| 113 +++ libavcodec/decode.c | 82 + libavcodec/decode.h | 9 ++ libavcodec/dxva2.c | 55 +-- libavcodec/dxva2_h264.c | 3 + libavcodec/dxva2_hevc.c | 3 + libavcodec/dxva2_internal.h | 3 + libavcodec/dxva2_mpeg2.c| 3 + libavcodec/dxva2_vc1.c | 5 + libavcodec/vaapi_decode.c | 216 +--- libavcodec/vaapi_decode.h | 5 +- libavcodec/vaapi_h264.c | 1 + libavcodec/vaapi_hevc.c | 1 + libavcodec/vaapi_mpeg2.c| 1 + libavcodec/vaapi_mpeg4.c| 2 + libavcodec/vaapi_vc1.c | 2 + libavcodec/vaapi_vp8.c | 1 + libavcodec/vdpau.c | 58 ++-- libavcodec/vdpau_h264.c | 1 + libavcodec/vdpau_hevc.c | 1 + libavcodec/vdpau_internal.h | 2 + libavcodec/vdpau_mpeg12.c | 1 + libavcodec/vdpau_mpeg4.c| 1 + libavcodec/vdpau_vc1.c | 2 + libavcodec/version.h| 2 +- 26 files changed, 395 insertions(+), 181 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index fa27007f44..9f3a1f2465 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-xx-xx - xxx - lavc 58.5.0 - avcodec.h + Add avcodec_get_hw_frames_parameters(). + 2017-xx-xx - xxx - lavu 56.6.0 - pixdesc.h Add av_color_range_from_name(), av_color_primaries_from_name(), av_color_transfer_from_name(), av_color_space_from_name(), and diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 162f1abe4b..5624835023 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2990,6 +2990,16 @@ typedef struct AVHWAccel { * Internal hwaccel capabilities. */ int caps_internal; + +/** + * Fill the given hw_frames context with current codec parameters. Called + * from get_format. Refer to avcodec_get_hw_frames_parameters() for + * details. + * + * This CAN be called before AVHWAccel.init is called, and you must assume + * that avctx->hwaccel_priv_data is invalid. + */ +int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx); } AVHWAccel; /** @@ -3984,6 +3994,109 @@ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); */ int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); +/** + * Create and return a AVHWFramesContext with values adequate for hardware + * decoding. This is meant to get called from the get_format callback, and is + * a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx. + * This API is for decoding with certain hardware acceleration modes/APIs only. + * + * The returned AVHWFramesContext is not initialized. The caller must do this + * with av_hwframe_ctx_init(). + * + * Calling this function is not a requirement, but makes it simpler to avoid + * codec or hardware API specific details when manually allocating frames. + * + * Alternatively to this, an API user can set AVCodecContext.hw_device_ctx, + * which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes + * it unnecessary to call this function or having to care about + * AVHWFramesContext initialization at all. + * + * There are a number of requirements for calling this function: + * + * - It must be called from get_format with the same avctx parameter that was + * passed to get_format. Calling it outside of get_format is not allowed, and + * can trigger undefined behavior. + * - The function is not always supported (see description of return values). + * Even if this function returns successfully, hwaccel initialization could + * fail later. (The degree to which implementations check whether the stream + * is actually supported varies. Some do this check only after the user's + * get_format callback returns.) + * - The hw_pix_fmt must be one of the choices suggested by get_format. If the + * user decides to use a AVHWFramesContext prepared with this API function, + * the user must return the same hw_pix_fmt from get_format. + * - The device_ref passed to this function must
[FFmpeg-cvslog] lavf: make avio_read_partial() public
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Aug 17 15:01:44 2017 +0200| [173b56218f39c6463be0e182259e2deead106936] | committer: Luca Barbato lavf: make avio_read_partial() public Main use-case is proxying avio through a foreign I/O layer and a custom AVIO context, without losing latency and performance characteristics. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=173b56218f39c6463be0e182259e2deead106936 --- doc/APIchanges | 3 +++ libavformat/avio.h | 9 + libavformat/avio_internal.h | 8 libavformat/aviobuf.c | 2 +- libavformat/rawdec.c| 2 +- libavformat/rtsp.c | 2 +- libavformat/version.h | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 463247f48e..ed90be890d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2016-xx-xx - xxx - lavf 58.1.0 - avio.h + Add avio_read_partial(). + 2017-xx-xx - xxx - lavu 56.4.0 - imgutils.h Add av_image_fill_black(). diff --git a/libavformat/avio.h b/libavformat/avio.h index e65135ed99..f604c4ad41 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -332,6 +332,15 @@ void avio_flush(AVIOContext *s); int avio_read(AVIOContext *s, unsigned char *buf, int size); /** + * Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed + * to read fewer bytes than requested. The missing bytes can be read in the next + * call. This always tries to read at least 1 byte. + * Useful to reduce latency in certain cases. + * @return number of bytes read or AVERROR + */ +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size); + +/** * @name Functions for reading from AVIOContext * @{ * diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 8616499867..dda1dad3dd 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -53,14 +53,6 @@ int ffio_init_context(AVIOContext *s, */ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data); -/** - * Read size bytes from AVIOContext into buf. - * This reads at most 1 packet. If that is not enough fewer bytes will be - * returned. - * @return number of bytes read or AVERROR - */ -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size); - void ffio_fill(AVIOContext *s, int b, int count); static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 31476d3f6d..98e35f776c 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -621,7 +621,7 @@ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsig } } -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size) +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size) { int len; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 3b1bea6429..a72a53d550 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -42,7 +42,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos= avio_tell(s->pb); pkt->stream_index = 0; -ret = ffio_read_partial(s->pb, pkt->data, size); +ret = avio_read_partial(s->pb, pkt->data, size); if (ret < 0) { av_packet_unref(pkt); return ret; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index fb6203d585..17a25a310e 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2077,7 +2077,7 @@ static int read_packet(AVFormatContext *s, wait_end && wait_end < av_gettime_relative()) len = AVERROR(EAGAIN); else -len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); +len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); len = pick_stream(s, rtsp_st, rt->recvbuf, len); if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, NULL, s->pb, len); diff --git a/libavformat/version.h b/libavformat/version.h index 7060375c1a..28fb076a31 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -30,7 +30,7 @@ #include "libavutil/version.h" #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 0 +#define LIBAVFORMAT_VERSION_MINOR 1 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/decode: add missing \n to log message
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 3 17:43:13 2017 +0200| [0aecc08e5fd15960639a75c43265539e70d0189e] | committer: Timo Rothenpieler avcodec/decode: add missing \n to log message > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0aecc08e5fd15960639a75c43265539e70d0189e --- libavcodec/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 9fdc7bb565..570799f6d7 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1115,7 +1115,7 @@ static int setup_hwaccel(AVCodecContext *avctx, if (!hwa) { av_log(avctx, AV_LOG_ERROR, - "Could not find an AVHWAccel for the pixel format: %s", + "Could not find an AVHWAccel for the pixel format: %s\n", name); return AVERROR(ENOENT); } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/cuvid: rename cuvid.c to cuviddec.c
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 3 15:15:16 2017 +0200| [5593049466bcd1d3f1ddbfe580be4f36123d7c3d] | committer: Timo Rothenpieler avcodec/cuvid: rename cuvid.c to cuviddec.c cuvid.c is used by Libav's CUVID hwaccel. Resolve the conflict and avoid future merge problems by renaming our decoder. Signed-off-by: Timo Rothenpieler <t...@rothenpieler.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5593049466bcd1d3f1ddbfe580be4f36123d7c3d --- libavcodec/Makefile| 10 +- libavcodec/{cuvid.c => cuviddec.c} | 0 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 95c843dee7..3704316d8c 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -338,7 +338,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_CUVID_DECODER) += cuvid.o +OBJS-$(CONFIG_H264_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_H264_MMAL_DECODER) += mmaldec.o OBJS-$(CONFIG_H264_NVENC_ENCODER) += nvenc_h264.o @@ -357,7 +357,7 @@ OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o hap.o OBJS-$(CONFIG_HEVC_DECODER)+= hevcdec.o hevc_mvs.o \ hevc_cabac.o hevc_refs.o hevcpred.o \ hevcdsp.o hevc_filter.o hevc_data.o -OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuvid.o +OBJS-$(CONFIG_HEVC_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o OBJS-$(CONFIG_NVENC_HEVC_ENCODER) += nvenc_hevc.o @@ -624,7 +624,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o vc1_block.o vc1_loopfilter.o vc1_mc.o vc1_pred.o vc1.o vc1data.o \ msmpeg4dec.o msmpeg4.o msmpeg4data.o \ wmv2dsp.o wmv2data.o -OBJS-$(CONFIG_VC1_CUVID_DECODER) += cuvid.o +OBJS-$(CONFIG_VC1_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_VC1_MMAL_DECODER)+= mmaldec.o OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec_other.o OBJS-$(CONFIG_VC1_V4L2M2M_DECODER) += v4l2_m2m_dec.o @@ -643,7 +643,7 @@ OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o \ vp6dsp.o vp56rac.o OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o -OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuvid.o +OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec_other.o OBJS-$(CONFIG_VP8_RKMPP_DECODER) += rkmppdec.o @@ -653,7 +653,7 @@ OBJS-$(CONFIG_VP8_V4L2M2M_ENCODER) += v4l2_m2m_enc.o OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o vp9recon.o \ vp9block.o vp9prob.o vp9mvs.o vp56rac.o \ vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o -OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuvid.o +OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuviddec.o OBJS-$(CONFIG_VP9_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_VP9_RKMPP_DECODER) += rkmppdec.o OBJS-$(CONFIG_VP9_VAAPI_ENCODER) += vaapi_encode_vp9.o diff --git a/libavcodec/cuvid.c b/libavcodec/cuviddec.c similarity index 100% rename from libavcodec/cuvid.c rename to libavcodec/cuviddec.c ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec: allow multiple hwaccels for the same codec/pixfmt
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Oct 3 15:04:45 2017 +0200| [ae5046e492cd87233111e994ca4ae3d74a233b51] | committer: Timo Rothenpieler avcodec: allow multiple hwaccels for the same codec/pixfmt Currently, AVHWAccels are looked up using a (codec_id, pixfmt) tuple. This means it's impossible to have 2 decoders for the same codec and using the same opaque hardware pixel format. This breaks merging Libav's CUVID hwaccel. FFmpeg has its own CUVID support, but it's a full stream decoder, using NVIDIA's codec parser. The Libav one is a true hwaccel, which is based on the builtin software decoders. Fix this by introducing another field to disambiguate AVHWAccels, and use it for our CUVID decoders. FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS makes this mechanism backwards compatible and optional. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ae5046e492cd87233111e994ca4ae3d74a233b51 --- libavcodec/avcodec.h | 7 +++ libavcodec/cuviddec.c | 2 ++ libavcodec/decode.c | 12 libavcodec/internal.h | 5 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 429d62a60a..15ca871b59 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3532,6 +3532,13 @@ typedef struct AVHWAccel { * Internal hwaccel capabilities. */ int caps_internal; + +/** + * Some hwaccels are ambiguous if only the id and pix_fmt fields are used. + * If non-NULL, the associated AVCodec must have + * FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS set. + */ +const AVClass *decoder_class; } AVHWAccel; /** diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c index 2ba8e00c6a..6370348639 100644 --- a/libavcodec/cuviddec.c +++ b/libavcodec/cuviddec.c @@ -1106,6 +1106,7 @@ static const AVOption options[] = { .type = AVMEDIA_TYPE_VIDEO, \ .id = AV_CODEC_ID_##X, \ .pix_fmt= AV_PIX_FMT_CUDA, \ +.decoder_class = ##_cuvid_class, \ }; \ AVCodec ff_##x##_cuvid_decoder = { \ .name = #x "_cuvid", \ @@ -1120,6 +1121,7 @@ static const AVOption options[] = { .receive_frame = cuvid_output_frame, \ .flush = cuvid_flush, \ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING, \ +.caps_internal = FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS, \ .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_CUDA, \ AV_PIX_FMT_NV12, \ AV_PIX_FMT_P010, \ diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 44b874d4f8..9fdc7bb565 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1090,15 +1090,19 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en return fmt[0]; } -static AVHWAccel *find_hwaccel(enum AVCodecID codec_id, +static AVHWAccel *find_hwaccel(AVCodecContext *avctx, enum AVPixelFormat pix_fmt) { AVHWAccel *hwaccel = NULL; +const AVClass *av_class = +(avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS) +? avctx->codec->priv_class : NULL; -while ((hwaccel = av_hwaccel_next(hwaccel))) -if (hwaccel->id == codec_id +while ((hwaccel = av_hwaccel_next(hwaccel))) { +if (hwaccel->decoder_class == av_class && hwaccel->id == avctx->codec_id && hwaccel->pix_fmt == pix_fmt) return hwaccel; +} return NULL; } @@ -1106,7 +1110,7 @@ static int setup_hwaccel(AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name) { -AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt); +AVHWAccel *hwa = find_hwaccel(avctx, fmt); int ret= 0; if (!hwa) { diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 7748f09f54..948d5461c1 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -69,6 +69,11 @@ */ #define FF_CODEC_CAP_SLICE_THREAD_HAS_MF(1 << 5) +/** + * Allow only AVHWAccels which have a matching decoder_class field. + */ +#define FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS (1 << 6) + #ifdef TRACE # define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__) #else ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] imgutils: add function to clear an image to black
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jul 22 23:05:14 2017 +0200| [45df7adc1d9b7e8fbae5af9328baa6ab3562002b] | committer: Anton Khirnov imgutils: add function to clear an image to black Black isn't always just memset(ptr, 0, size). Limited YUV in particular requires relatively non-obvious values, and filling a frame with repeating 0 bytes is disallowed in some contexts. With component sizes larger than 8 or packed YUV, this can become relatively complicated. So having a generic function for this seems helpful. In order to handle the complex cases in a generic way without destroying performance, this code attempts to compute a black pixel, and then uses that value to clear the image data quickly by using a function like memset. Common cases like yuv410p10 or rgba can't be handled with a simple memset, so there is some code to fill memory with 2/4/8 byte patterns. For the remaining cases, a generic slow fallback is used. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=45df7adc1d9b7e8fbae5af9328baa6ab3562002b --- doc/APIchanges | 3 + libavutil/imgutils.c | 167 +++ libavutil/imgutils.h | 27 + libavutil/version.h | 2 +- 4 files changed, 198 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 30a8f809d1..463247f48e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-xx-xx - xxx - lavu 56.4.0 - imgutils.h + Add av_image_fill_black(). + 2017-xx-xx - xxx - lavu 56.3.0 - frame.h Add av_frame_apply_cropping(). diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 84abb11656..662962252b 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -435,3 +435,170 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size, return size; } + +// Fill dst[0..dst_size] with the bytes in clear[0..clear_size]. The clear +// bytes are repeated until dst_size is reached. If dst_size is unaligned (i.e. +// dst_size%clear_size!=0), the remaining data will be filled with the beginning +// of the clear data only. +static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear, + size_t clear_size) +{ +size_t pos = 0; +int same = 1; +int i; + +if (!clear_size) +return; + +// Reduce to memset() if possible. +for (i = 0; i < clear_size; i++) { +if (clear[i] != clear[0]) { +same = 0; +break; +} +} +if (same) +clear_size = 1; + +if (clear_size == 1) { +memset(dst, clear[0], dst_size); +dst_size = 0; +} else if (clear_size == 2) { +uint16_t val = AV_RN16(clear); +for (; dst_size >= 2; dst_size -= 2) { +AV_WN16(dst, val); +dst += 2; +} +} else if (clear_size == 4) { +uint32_t val = AV_RN32(clear); +for (; dst_size >= 4; dst_size -= 4) { +AV_WN32(dst, val); +dst += 4; +} +} else if (clear_size == 8) { +uint32_t val = AV_RN64(clear); +for (; dst_size >= 8; dst_size -= 8) { +AV_WN64(dst, val); +dst += 8; +} +} + +for (; dst_size; dst_size--) +*dst++ = clear[pos++ % clear_size]; +} + +// Maximum size in bytes of a plane element (usually a pixel, or multiple pixels +// if it's a subsampled packed format). +#define MAX_BLOCK_SIZE 32 + +int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4], +enum AVPixelFormat pix_fmt, enum AVColorRange range, +int width, int height) +{ +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); +int nb_planes = av_pix_fmt_count_planes(pix_fmt); +// A pixel or a group of pixels on each plane, with a value that represents black. +// Consider e.g. AV_PIX_FMT_UYVY422 for non-trivial cases. +uint8_t clear_block[4][MAX_BLOCK_SIZE] = {0}; // clear padding with 0 +int clear_block_size[4] = {0}; +ptrdiff_t plane_line_bytes[4] = {0}; +int rgb, limited; +int plane, c; + +if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) +return AVERROR(EINVAL); + +rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB); +limited = !rgb && range != AVCOL_RANGE_JPEG; + +if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) { +ptrdiff_t bytewidth = av_image_get_linesize(pix_fmt, width, 0); +uint8_t *data; +int mono = pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK; +int fill = pix_fmt == AV_PIX_FMT_MONOWHITE ? 0xFF : 0; +if (nb_planes != 1 || !(rgb || mono) || bytewidth < 1) +return AVERROR(EINVAL); + +if (!dst_data) +
[FFmpeg-cvslog] lavc, lavu: move frame cropping to a convenience function
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jul 22 23:05:13 2017 +0200| [47399ccdfd93d337c96c76fbf591f0e3637131ef] | committer: Anton Khirnov lavc, lavu: move frame cropping to a convenience function Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=47399ccdfd93d337c96c76fbf591f0e3637131ef --- doc/APIchanges | 3 ++ libavcodec/decode.c | 89 ++ libavutil/frame.c | 100 libavutil/frame.h | 34 ++ libavutil/version.h | 2 +- 5 files changed, 140 insertions(+), 88 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 0f7c839573..30a8f809d1 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-xx-xx - xxx - lavu 56.3.0 - frame.h + Add av_frame_apply_cropping(). + 2017-xx-xx - xxx - lavc 58.4.0 - avcodec.h DXVA2 and D3D11 hardware accelerated decoding now supports the new hwaccel API, which can create the decoder context and allocate hardware frame automatically. diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 175a6fae4c..9644e89f48 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -446,44 +446,8 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke return 0; } -static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame, - const AVPixFmtDescriptor *desc) -{ -int i, j; - -for (i = 0; frame->data[i]; i++) { -const AVComponentDescriptor *comp = NULL; -int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0; -int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; - -if (desc->flags & (AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_PSEUDOPAL) && i == 1) { -offsets[i] = 0; -break; -} - -/* find any component descriptor for this plane */ -for (j = 0; j < desc->nb_components; j++) { -if (desc->comp[j].plane == i) { -comp = >comp[j]; -break; -} -} -if (!comp) -return AVERROR_BUG; - -offsets[i] = (frame->crop_top >> shift_y) * frame->linesize[i] + - (frame->crop_left >> shift_x) * comp->step; -} - -return 0; -} - static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) { -const AVPixFmtDescriptor *desc; -size_t offsets[4]; -int i; - /* make sure we are noisy about decoders returning invalid cropping data */ if (frame->crop_left >= INT_MAX - frame->crop_right|| frame->crop_top >= INT_MAX - frame->crop_bottom || @@ -504,57 +468,8 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) if (!avctx->apply_cropping) return 0; -desc = av_pix_fmt_desc_get(frame->format); -if (!desc) -return AVERROR_BUG; - -/* Apply just the right/bottom cropping for hwaccel formats. Bitstream - * formats cannot be easily handled here either (and corresponding decoders - * should not export any cropping anyway), so do the same for those as well. - * */ -if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL)) { -frame->width -= frame->crop_right; -frame->height -= frame->crop_bottom; -frame->crop_right = 0; -frame->crop_bottom = 0; -return 0; -} - -/* calculate the offsets for each plane */ -calc_cropping_offsets(offsets, frame, desc); - -/* adjust the offsets to avoid breaking alignment */ -if (!(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { -int log2_crop_align = frame->crop_left ? av_ctz(frame->crop_left) : INT_MAX; -int min_log2_align = INT_MAX; - -for (i = 0; frame->data[i]; i++) { -int log2_align = offsets[i] ? av_ctz(offsets[i]) : INT_MAX; -min_log2_align = FFMIN(log2_align, min_log2_align); -} - -/* we assume, and it should always be true, that the data alignment is - * related to the cropping alignment by a constant power-of-2 factor */ -if (log2_crop_align < min_log2_align) -return AVERROR_BUG; - -if (min_log2_align < 5) { -frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1); -calc_cropping_offsets(offsets, frame, desc); -} -} - -for (i = 0; frame->data[i]; i++) -frame->data[i] += offsets[i]; - -frame->width -= (frame->crop_left + frame->crop_right); -frame->height -= (frame->crop_top + frame->crop_bottom); -frame->crop_left = 0;
[FFmpeg-cvslog] lavf: allow avformat_close_input() with NULL
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sun Jul 16 12:43:09 2017 +0200| [2b1324bd167553f49736e4eaa94f96da9982925e] | committer: Anton Khirnov lavf: allow avformat_close_input() with NULL This is consistent with how other destructors behave. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2b1324bd167553f49736e4eaa94f96da9982925e --- libavformat/utils.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index eaba473914..bbdc2cdb8a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2733,7 +2733,12 @@ void avformat_free_context(AVFormatContext *s) void avformat_close_input(AVFormatContext **ps) { AVFormatContext *s = *ps; -AVIOContext *pb= s->pb; +AVIOContext *pb; + +if (!*ps) +return; + +pb = s->pb; if ((s->iformat && s->iformat->flags & AVFMT_NOFILE) || (s->flags & AVFMT_FLAG_CUSTOM_IO)) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Jul 10 15:59:38 2017 +0200| [9b9285bbf18e3bca87ec4969f661a4b321756cd5] | committer: Anton Khirnov dxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main This mode apparently does not support decoding of HEVC Main (8 bit). With D3D11 and Intel drivers on Windows 10 I get green corruption, while using DXVA2_ModeHEVC_VLD_Main works. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9b9285bbf18e3bca87ec4969f661a4b321756cd5 --- libavcodec/dxva2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index a60604a84f..9ceb6236d4 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -63,8 +63,7 @@ static const int prof_h264_high[]= {FF_PROFILE_H264_CONSTRAINED_BASELINE, FF_PROFILE_UNKNOWN}; static const int prof_hevc_main[]= {FF_PROFILE_HEVC_MAIN, FF_PROFILE_UNKNOWN}; -static const int prof_hevc_main10[] = {FF_PROFILE_HEVC_MAIN, -FF_PROFILE_HEVC_MAIN_10, +static const int prof_hevc_main10[] = {FF_PROFILE_HEVC_MAIN_10, FF_PROFILE_UNKNOWN}; static const dxva_mode dxva_modes[] = { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: add declarative profile checks
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:52 2017 +0200| [70e5e7c02232d1e51c362d5572c567a9e2a8dcc2] | committer: Luca Barbato dxva: add declarative profile checks Make supported codec profiles part of each dxva_modes entry. Every DXVA2 mode is representative for a codec with a subset of supported profiles, so reflecting that in dxva_modes seems appropriate. In practice, this will more strictly check MPEG2 profiles, will stop relying on the surface format checks for selecting the correct HEVC profile, and remove the verbose messages for mismatching H264/HEVC profiles. Instead of the latter, it will now print the more nebulous "No decoder device for codec found" verbose message. This also respects AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH. Move the Main10 HEVC entry before the normal one to make this work better. Originally inspired by VLC's code. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70e5e7c02232d1e51c362d5572c567a9e2a8dcc2 --- libavcodec/dxva2.c | 64 +- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index e0c54068d6..9f4a5294a4 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -49,18 +49,34 @@ DEFINE_GUID(ff_IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x typedef struct dxva_mode { const GUID *guid; enum AVCodecID codec; +// List of supported profiles, terminated by a FF_PROFILE_UNKNOWN entry. +// If NULL, don't check profile. +const int *profiles; } dxva_mode; +static const int prof_mpeg2_main[] = {FF_PROFILE_MPEG2_SIMPLE, +FF_PROFILE_MPEG2_MAIN, +FF_PROFILE_UNKNOWN}; +static const int prof_h264_high[]= {FF_PROFILE_H264_CONSTRAINED_BASELINE, +FF_PROFILE_H264_MAIN, +FF_PROFILE_H264_HIGH, +FF_PROFILE_UNKNOWN}; +static const int prof_hevc_main[]= {FF_PROFILE_HEVC_MAIN, +FF_PROFILE_UNKNOWN}; +static const int prof_hevc_main10[] = {FF_PROFILE_HEVC_MAIN, +FF_PROFILE_HEVC_MAIN_10, +FF_PROFILE_UNKNOWN}; + static const dxva_mode dxva_modes[] = { /* MPEG-2 */ -{ _DXVA2_ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, -{ _DXVA2_ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO }, +{ _DXVA2_ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main }, +{ _DXVA2_ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main }, /* H.264 */ -{ _DXVA2_ModeH264_F, AV_CODEC_ID_H264 }, -{ _DXVA2_ModeH264_E, AV_CODEC_ID_H264 }, +{ _DXVA2_ModeH264_F, AV_CODEC_ID_H264, prof_h264_high }, +{ _DXVA2_ModeH264_E, AV_CODEC_ID_H264, prof_h264_high }, /* Intel specific H.264 mode */ -{ _DXVADDI_Intel_ModeH264_E, AV_CODEC_ID_H264 }, +{ _DXVADDI_Intel_ModeH264_E, AV_CODEC_ID_H264, prof_h264_high }, /* VC-1 / WMV3 */ { _DXVA2_ModeVC1_D2010, AV_CODEC_ID_VC1 }, @@ -69,8 +85,8 @@ static const dxva_mode dxva_modes[] = { { _DXVA2_ModeVC1_D, AV_CODEC_ID_WMV3 }, /* HEVC/H.265 */ -{ _DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC }, -{ _DXVA2_ModeHEVC_VLD_Main10, AV_CODEC_ID_HEVC }, +{ _DXVA2_ModeHEVC_VLD_Main10, AV_CODEC_ID_HEVC, prof_hevc_main10 }, +{ _DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC, prof_hevc_main }, { NULL, 0 }, }; @@ -160,6 +176,26 @@ static int dxva2_validate_output(void *decoder_service, GUID guid, void *surface } #endif +static int dxva_check_codec_compatibility(AVCodecContext *avctx, const dxva_mode *mode) +{ +if (mode->codec != avctx->codec_id) +return 0; + +if (mode->profiles && !(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) { +int i, found = 0; +for (i = 0; mode->profiles[i] != FF_PROFILE_UNKNOWN; i++) { +if (avctx->profile == mode->profiles[i]) { +found = 1; +break; +} +} +if (!found) +return 0; +} + +return 1; +} + static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format, unsigned guid_count, const GUID *guid_list, GUID *decoder_guid) { @@ -170,7 +206,7 @@ static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *sur for (i = 0; dxva_modes[i].guid; i++) { const dxva_mode *mode = _modes[i]; int validate; -if (mode->codec != avctx->codec_id) +if (!dxva_check_codec_compatibility(avctx, mode))
[FFmpeg-cvslog] hwcontext_d3d11va: add option to enable debug mode
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:57 2017 +0200| [cfc9e7c94eafa33e7f109099664ec4fb57ac5ca3] | committer: Luca Barbato hwcontext_d3d11va: add option to enable debug mode Basically copied from VLC (LGPL): http://git.videolan.org/?p=vlc.git;a=blob;f=modules/video_output/win32/direct3d11.c;h=e9fcb83dcabfe778f26e63d19f218caf06a7c3ae;hb=HEAD#l1482 http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/avcodec/d3d11va.c;h=85e7d25caebc059a9770da2ef4bb8fe90816d76d;hb=HEAD#l599 Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cfc9e7c94eafa33e7f109099664ec4fb57ac5ca3 --- configure | 2 ++ libavutil/hwcontext_d3d11va.c | 32 libavutil/hwcontext_d3d11va.h | 4 3 files changed, 38 insertions(+) diff --git a/configure b/configure index ab183745a7..96bc5ab559 100755 --- a/configure +++ b/configure @@ -1561,6 +1561,7 @@ HEADERS_LIST=" dev_video_meteor_ioctl_meteor_h direct_h dlfcn_h +dxgidebug_h dxva_h gsm_h io_h @@ -4660,6 +4661,7 @@ check_struct windows.h "CONDITION_VARIABLE" Ptr check_header d3d11.h check_header direct.h check_header dlfcn.h +check_header dxgidebug.h check_header dxva.h check_header dxva2api.h check_header io.h diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 376c76e5cf..75f78d8669 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include // Include thread.h before redefining _WIN32_WINNT, to get @@ -32,6 +34,10 @@ #include #include +#if HAVE_DXGIDEBUG_H +#include +#endif + #include "avassert.h" #include "common.h" #include "hwcontext.h" @@ -476,8 +482,18 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, IDXGIAdapter *pAdapter = NULL; ID3D10Multithread *pMultithread; UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; +int is_debug = !!av_dict_get(opts, "debug", NULL, 0); int ret; +// (On UWP we can't check this.) +#if HAVE_LOADLIBRARY +if (!LoadLibrary("d3d11_1sdklayers.dll")) +is_debug = 0; +#endif + +if (is_debug) +creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + if ((ret = ff_thread_once(_loaded, load_functions)) != 0) return AVERROR_UNKNOWN; if (!mD3D11CreateDevice || !mCreateDXGIFactory) { @@ -511,6 +527,22 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, ID3D10Multithread_Release(pMultithread); } +#if HAVE_LOADLIBRARY && HAVE_DXGIDEBUG_H +if (is_debug) { +HANDLE dxgidebug_dll = LoadLibrary("dxgidebug.dll"); +if (dxgidebug_dll) { +HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug) += (void *)GetProcAddress(dxgidebug_dll, "DXGIGetDebugInterface"); +if (pf_DXGIGetDebugInterface) { +IDXGIDebug *dxgi_debug = NULL; +hr = pf_DXGIGetDebugInterface(_IDXGIDebug, (void**)_debug); +if (SUCCEEDED(hr) && dxgi_debug) +IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); +} +} +} +#endif + return 0; } diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h index d41451580e..0ed3033452 100644 --- a/libavutil/hwcontext_d3d11va.h +++ b/libavutil/hwcontext_d3d11va.h @@ -30,6 +30,10 @@ * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for * this format. Refer to MSDN for details. + * + * av_hwdevice_ctx_create() for this device type supports a key named "debug" + * for the AVDictionary entry. If this is set to any value, the device creation + * code will try to load various supported D3D debugging layers. */ #include ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_d3d11va: fix crash on frames_init failure
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:54 2017 +0200| [086321c612185469ebb85a1887527c8915b488b7] | committer: Luca Barbato hwcontext_d3d11va: fix crash on frames_init failure It appears in this case, frames_ininit is called twice (once by av_hwframe_ctx_init(), and again by unreffing the frames ctx ref). Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=086321c612185469ebb85a1887527c8915b488b7 --- libavutil/hwcontext_d3d11va.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 5432dd8b51..0b36a563f1 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -104,9 +104,11 @@ static void d3d11va_frames_uninit(AVHWFramesContext *ctx) if (frames_hwctx->texture) ID3D11Texture2D_Release(frames_hwctx->texture); +frames_hwctx->texture = NULL; if (s->staging_texture) ID3D11Texture2D_Release(s->staging_texture); +s->staging_texture = NULL; } static void free_texture(void *opaque, uint8_t *data) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: support DXGI_FORMAT_420_OPAQUE decoding
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:56 2017 +0200| [5030e3856c2126fb829edb828f5aae011d178eb4] | committer: Luca Barbato dxva: support DXGI_FORMAT_420_OPAQUE decoding Some devices (some phones, apparently) will support only this opaque format. Of course this won't work with CLI, because copying data directly is not supported. Automatic frame allocation (setting AVCodecContext.hw_device_ctx) does not support this mode, even if it's the only supported mode. But since opaque surfaces are generally less useful, that's probably ok. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5030e3856c2126fb829edb828f5aae011d178eb4 --- libavcodec/dxva2.c| 13 +++-- libavutil/hwcontext_d3d11va.c | 12 ++-- libavutil/hwcontext_d3d11va.h | 4 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 23d96687dc..79b77150d0 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -389,19 +389,28 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *avctx, return ret; } +static DXGI_FORMAT d3d11va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt) +{ +switch (pix_fmt) { +case AV_PIX_FMT_NV12: return DXGI_FORMAT_NV12; +case AV_PIX_FMT_P010: return DXGI_FORMAT_P010; +case AV_PIX_FMT_YUV420P:return DXGI_FORMAT_420_OPAQUE; +default:return DXGI_FORMAT_UNKNOWN; +} +} + static int d3d11va_create_decoder(AVCodecContext *avctx) { FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); GUID *guid_list; unsigned guid_count, i; GUID decoder_guid; -DXGI_FORMAT surface_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? - DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; D3D11_VIDEO_DECODER_DESC desc = { 0 }; D3D11_VIDEO_DECODER_CONFIG config; AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; AVD3D11VADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; AVD3D11VAFramesContext *frames_hwctx = frames_ctx->hwctx; +DXGI_FORMAT surface_format = d3d11va_map_sw_to_hw_format(frames_ctx->sw_format); D3D11_TEXTURE2D_DESC texdesc; HRESULT hr; int ret; diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 523a6d2dc6..376c76e5cf 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -83,8 +83,11 @@ static const struct { DXGI_FORMAT d3d_format; enum AVPixelFormat pix_fmt; } supported_formats[] = { -{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 }, -{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 }, +{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 }, +{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 }, +// Special opaque formats. The pix_fmt is merely a place holder, as the +// opaque format cannot be accessed directly. +{ DXGI_FORMAT_420_OPAQUE, AV_PIX_FMT_YUV420P }, }; static void d3d11va_default_lock(void *ctx) @@ -270,6 +273,7 @@ static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats) { +D3D11VAFramesContext *s = ctx->internal->priv; enum AVPixelFormat *fmts; fmts = av_malloc_array(2, sizeof(*fmts)); @@ -279,6 +283,10 @@ static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, fmts[0] = ctx->sw_format; fmts[1] = AV_PIX_FMT_NONE; +// Don't signal support for opaque formats. Actual access would fail. +if (s->format == DXGI_FORMAT_420_OPAQUE) +fmts[0] = AV_PIX_FMT_NONE; + *formats = fmts; return 0; diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h index 676349d7b8..d41451580e 100644 --- a/libavutil/hwcontext_d3d11va.h +++ b/libavutil/hwcontext_d3d11va.h @@ -26,6 +26,10 @@ * The default pool implementation will be fixed-size if initial_pool_size is * set (and allocate elements from an array texture). Otherwise it will allocate * individual textures. Be aware that decoding requires a single array texture. + * + * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to + * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for + * this format. Refer to MSDN for details. */ #include ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: verbose-log decoder GUID list
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:59 2017 +0200| [068eaa534e7ddb2155e2830818d5c3f1069c68d8] | committer: Luca Barbato dxva: verbose-log decoder GUID list Helpful for debugging. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=068eaa534e7ddb2155e2830818d5c3f1069c68d8 --- libavcodec/dxva2.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 79b77150d0..a60604a84f 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -196,12 +196,59 @@ static int dxva_check_codec_compatibility(AVCodecContext *avctx, const dxva_mode return 1; } +static void dxva_list_guids_debug(AVCodecContext *avctx, void *service, + unsigned guid_count, const GUID *guid_list) +{ +FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); +int i; + +av_log(avctx, AV_LOG_VERBOSE, "Decoder GUIDs reported as supported:\n"); + +for (i = 0; i < guid_count; i++) { +const GUID *guid = _list[i]; + +av_log(avctx, AV_LOG_VERBOSE, + "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}", + (unsigned) guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], + guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], + guid->Data4[6], guid->Data4[7]); + +#if CONFIG_D3D11VA +if (sctx->pix_fmt == AV_PIX_FMT_D3D11) { +DXGI_FORMAT format; +// We don't know the maximum valid DXGI_FORMAT, so use 200 as +// arbitrary upper bound (that could become outdated). +for (format = 0; format < 200; format++) { +if (d3d11va_validate_output(service, *guid, )) +av_log(avctx, AV_LOG_VERBOSE, " %d", (int)format); +} +} +#endif +#if CONFIG_DXVA2 +if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { +const D3DFORMAT formats[] = {MKTAG('N', 'V', '1', '2'), + MKTAG('P', '0', '1', '0')}; +int i; +for (i = 0; i < FF_ARRAY_ELEMS(formats); i++) { +if (dxva2_validate_output(service, *guid, [i])) +av_log(avctx, AV_LOG_VERBOSE, " %d", i); +} +} +#endif +av_log(avctx, AV_LOG_VERBOSE, "\n"); +} +} + static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format, unsigned guid_count, const GUID *guid_list, GUID *decoder_guid) { FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); unsigned i, j; +dxva_list_guids_debug(avctx, service, guid_count, guid_list); + *decoder_guid = ff_GUID_NULL; for (i = 0; dxva_modes[i].guid; i++) { const dxva_mode *mode = _modes[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: fix some warnings
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:53 2017 +0200| [752ddb45569ffe278393cd853b70f18ae017219e] | committer: Luca Barbato dxva: fix some warnings Some existed since forever, some are new. The cast in get_surface() is silly, but unless we change the av_log function signature, or all callers of ff_dxva2_get_surface_index(), it's needed to remove the const warning. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=752ddb45569ffe278393cd853b70f18ae017219e --- libavcodec/dxva2.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 9f4a5294a4..23d96687dc 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -359,7 +359,6 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *avctx, const D3D11_VIDEO_DECODER_DESC *desc, D3D11_VIDEO_DECODER_CONFIG *config) { -FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); unsigned cfg_count = 0; D3D11_VIDEO_DECODER_CONFIG *cfg_list = NULL; HRESULT hr; @@ -623,7 +622,6 @@ int ff_dxva2_decode_init(AVCodecContext *avctx) if (sctx->pix_fmt == AV_PIX_FMT_D3D11) { AVD3D11VADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; AVD3D11VAContext *d3d11_ctx = >ctx.d3d11va; -HRESULT hr; ff_dxva2_lock(avctx); ret = d3d11va_create_decoder(avctx); @@ -690,7 +688,7 @@ int ff_dxva2_decode_uninit(AVCodecContext *avctx) return 0; } -static void *get_surface(AVCodecContext *avctx, const AVFrame *frame) +static void *get_surface(const AVCodecContext *avctx, const AVFrame *frame) { #if CONFIG_D3D11VA if (frame->format == AV_PIX_FMT_D3D11) { @@ -698,7 +696,7 @@ static void *get_surface(AVCodecContext *avctx, const AVFrame *frame) intptr_t index = (intptr_t)frame->data[1]; if (index < 0 || index >= sctx->nb_d3d11_views || sctx->d3d11_texture != (ID3D11Texture2D *)frame->data[0]) { -av_log(avctx, AV_LOG_ERROR, "get_buffer frame is invalid!\n"); +av_log((void *)avctx, AV_LOG_ERROR, "get_buffer frame is invalid!\n"); return NULL; } return sctx->d3d11_views[index]; @@ -759,7 +757,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, #endif if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n", - type, hr); + type, (unsigned)hr); return -1; } if (size <= dxva_size) { @@ -801,7 +799,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to release buffer type %u: 0x%x\n", - type, hr); + type, (unsigned)hr); result = -1; } return result; @@ -871,7 +869,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } while(1); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", (unsigned)hr); ff_dxva2_unlock(avctx); return -1; } @@ -966,7 +964,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", (unsigned)hr); result = -1; } @@ -981,7 +979,7 @@ end: #endif ff_dxva2_unlock(avctx); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", (unsigned)hr); result = -1; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_d3d11va: allocate staging texture lazily
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:55 2017 +0200| [98d73e4174333b37d961b79e1182be5a02156c02] | committer: Luca Barbato hwcontext_d3d11va: allocate staging texture lazily Makes dealing with formats that can not be used for staging textures easier (DXGI_FORMAT_420_OPAQUE). It also saves memory if the staging texture is never needed, so this is a good thing. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98d73e4174333b37d961b79e1182be5a02156c02 --- libavutil/hwcontext_d3d11va.c | 46 --- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 0b36a563f1..523a6d2dc6 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -239,17 +239,6 @@ static int d3d11va_frames_init(AVHWFramesContext *ctx) } } -texDesc.ArraySize = 1; -texDesc.Usage = D3D11_USAGE_STAGING; -texDesc.BindFlags = 0; -texDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; -texDesc.MiscFlags = 0; -hr = ID3D11Device_CreateTexture2D(device_hwctx->device, , NULL, >staging_texture); -if (FAILED(hr)) { -av_log(ctx, AV_LOG_ERROR, "Could not create the staging texture (%lx)\n", (long)hr); -return AVERROR_UNKNOWN; -} - ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(AVD3D11FrameDescriptor), ctx, d3d11va_pool_alloc, NULL); if (!ctx->internal->pool_internal) @@ -295,6 +284,31 @@ static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, return 0; } +static int d3d11va_create_staging_texture(AVHWFramesContext *ctx) +{ +AVD3D11VADeviceContext *device_hwctx = ctx->device_ctx->hwctx; +D3D11VAFramesContext *s = ctx->internal->priv; +HRESULT hr; +D3D11_TEXTURE2D_DESC texDesc = { +.Width = ctx->width, +.Height = ctx->height, +.MipLevels = 1, +.Format = s->format, +.SampleDesc = { .Count = 1 }, +.ArraySize = 1, +.Usage = D3D11_USAGE_STAGING, +.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE, +}; + +hr = ID3D11Device_CreateTexture2D(device_hwctx->device, , NULL, >staging_texture); +if (FAILED(hr)) { +av_log(ctx, AV_LOG_ERROR, "Could not create the staging texture (%lx)\n", (long)hr); +return AVERROR_UNKNOWN; +} + +return 0; +} + static void fill_texture_ptrs(uint8_t *data[4], int linesize[4], AVHWFramesContext *ctx, D3D11_TEXTURE2D_DESC *desc, @@ -320,7 +334,7 @@ static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, // (The interface types are compatible.) ID3D11Resource *texture = (ID3D11Resource *)(ID3D11Texture2D *)frame->data[0]; int index = (intptr_t)frame->data[1]; -ID3D11Resource *staging = (ID3D11Resource *)s->staging_texture; +ID3D11Resource *staging; int w = FFMIN(dst->width, src->width); int h = FFMIN(dst->height, src->height); uint8_t *map_data[4]; @@ -334,6 +348,14 @@ static int d3d11va_transfer_data(AVHWFramesContext *ctx, AVFrame *dst, device_hwctx->lock(device_hwctx->lock_ctx); +if (!s->staging_texture) { +int res = d3d11va_create_staging_texture(ctx); +if (res < 0) +return res; +} + +staging = (ID3D11Resource *)s->staging_texture; + ID3D11Texture2D_GetDesc(s->staging_texture, ); if (download) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: move d3d11 locking/unlocking to functions
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:10 2017 +0200| [831cfe10b40414915fe7b6088158421fe02e2b2d] | committer: Diego Biurrun dxva: move d3d11 locking/unlocking to functions I want to make it non-mandatory to set a mutex in the D3D11 device context, and replacing it with user callbacks seems like the best solution. This is preparation for it. Also makes the code slightly more readable. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=831cfe10b40414915fe7b6088158421fe02e2b2d --- libavcodec/dxva2.c | 46 -- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index fe6dbbc030..5bc9b30653 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -29,6 +29,28 @@ #include "avcodec.h" #include "dxva2_internal.h" +static void ff_dxva2_lock(AVCodecContext *avctx) +{ +#if CONFIG_D3D11VA +if (ff_dxva2_is_d3d11(avctx)) { +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); +if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) +WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); +} +#endif +} + +static void ff_dxva2_unlock(AVCodecContext *avctx) +{ +#if CONFIG_D3D11VA +if (ff_dxva2_is_d3d11(avctx)) { +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); +if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) +ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); +} +#endif +} + static void *get_surface(const AVFrame *frame) { return frame->data[3]; @@ -153,14 +175,12 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, unsigned type; do { +ff_dxva2_lock(avctx); #if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) { -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, get_surface(frame), 0, NULL); -} #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) @@ -170,21 +190,13 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, #endif if (hr != E_PENDING || ++runs > 50) break; -#if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -#endif +ff_dxva2_unlock(avctx); av_usleep(2000); } while(1); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); -#if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -#endif +ff_dxva2_unlock(avctx); return -1; } @@ -284,16 +296,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, end: #if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) { +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder); -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -} #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL); #endif +ff_dxva2_unlock(avctx); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); result = -1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: set avctx->hwaccel before init
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:08 2017 +0200| [bd747b9226414007f0207fa201976af7217e3b77] | committer: Diego Biurrun lavc: set avctx->hwaccel before init So a hwaccel can access avctx->hwaccel in init for whatever reason. This is for the new d3d hwaccel API. We could create separate entrypoints for each of the 3 hwaccel types (dxva2, d3d11va, new d3d11va), but this seems nicer. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bd747b9226414007f0207fa201976af7217e3b77 --- libavcodec/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index bb58dfc561..ae2c715677 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -746,16 +746,16 @@ static int setup_hwaccel(AVCodecContext *avctx, return AVERROR(ENOMEM); } +avctx->hwaccel = hwa; if (hwa->init) { ret = hwa->init(avctx); if (ret < 0) { av_freep(>internal->hwaccel_priv_data); +avctx->hwaccel = NULL; return ret; } } -avctx->hwaccel = hwa; - return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: add support for new dxva2 and d3d11 hwaccel APIs
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Jun 7 17:11:17 2017 +0200| [f9e7a2f95a7194a8736cc1416a03a1a0155a3e9f] | committer: Diego Biurrun dxva: add support for new dxva2 and d3d11 hwaccel APIs This also adds support to avconv (which is trivial due to the new hwaccel API being generic enough). The new decoder setup code in dxva2.c is significantly based on work by Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f9e7a2f95a7194a8736cc1416a03a1a0155a3e9f --- Changelog | 1 + avtools/Makefile| 1 - avtools/avconv.h| 1 + avtools/avconv_dxva2.c | 440 - avtools/avconv_opt.c| 10 +- configure | 19 +- doc/APIchanges | 6 + libavcodec/allcodecs.c | 5 + libavcodec/dxva2.c | 663 +++- libavcodec/dxva2_h264.c | 22 ++ libavcodec/dxva2_hevc.c | 22 ++ libavcodec/dxva2_internal.h | 43 ++- libavcodec/dxva2_mpeg2.c| 22 ++ libavcodec/dxva2_vc1.c | 44 +++ libavcodec/h264_slice.c | 3 +- libavcodec/hevcdec.c| 3 +- libavcodec/mpeg12dec.c | 1 + libavcodec/vc1dec.c | 1 + libavcodec/version.h| 4 +- libavutil/hwcontext_dxva2.h | 3 + 20 files changed, 853 insertions(+), 461 deletions(-) diff --git a/Changelog b/Changelog index 6fd30fddb9..e44df54c93 100644 --- a/Changelog +++ b/Changelog @@ -15,6 +15,7 @@ version : - VP9 superframe split/merge bitstream filters - FM Screen Capture Codec decoder - ClearVideo decoder (I-frames only) +- support for decoding through D3D11VA in avconv version 12: diff --git a/avtools/Makefile b/avtools/Makefile index c23a605a55..d95e2d9fc2 100644 --- a/avtools/Makefile +++ b/avtools/Makefile @@ -12,7 +12,6 @@ OBJS-avconv += avtools/avconv_opt.o avtools/avconv_filter.o \ avtools/avconv_hw.o OBJS-avconv-$(CONFIG_LIBMFX) += avtools/avconv_qsv.o OBJS-avconv-$(CONFIG_VDA) += avtools/avconv_vda.o -OBJS-avconv-$(HAVE_DXVA2_LIB) += avtools/avconv_dxva2.o define DOAVTOOL OBJS-$(1) += avtools/cmdutils.o avtools/$(1).o $(OBJS-$(1)-yes) diff --git a/avtools/avconv.h b/avtools/avconv.h index 3354c50444..4c699333a5 100644 --- a/avtools/avconv.h +++ b/avtools/avconv.h @@ -57,6 +57,7 @@ enum HWAccelID { HWACCEL_VDA, HWACCEL_QSV, HWACCEL_VAAPI, +HWACCEL_D3D11VA, }; typedef struct HWAccel { diff --git a/avtools/avconv_dxva2.c b/avtools/avconv_dxva2.c deleted file mode 100644 index 7578c3f632..00 --- a/avtools/avconv_dxva2.c +++ /dev/null @@ -1,440 +0,0 @@ -/* - * This file is part of Libav. - * - * Libav is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * Libav is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#ifdef _WIN32_WINNT -#undef _WIN32_WINNT -#endif -#define _WIN32_WINNT 0x0600 -#define DXVA2API_USE_BITFIELDS -#define COBJMACROS - -#include - -#include -#include - -#include "avconv.h" - -#include "libavcodec/dxva2.h" - -#include "libavutil/avassert.h" -#include "libavutil/buffer.h" -#include "libavutil/frame.h" -#include "libavutil/imgutils.h" -#include "libavutil/pixfmt.h" - -#include "libavutil/hwcontext.h" -#include "libavutil/hwcontext_dxva2.h" - -/* define all the GUIDs used directly here, - to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and different MSVC version */ -#include -DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02); - -DEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28,0x4e65,0xbe,0xea,0x1d,0x26,0xb5,0x08,0xad,0xc9); -DEFINE_GUID(DXVA2_ModeMPEG2and1_VLD, 0x86695f12, 0x340e,0x4f04,0x9f,0xd3,0x92,0x53,0xdd,0x32,0x74,0x60); -DEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); -DEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); -DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951,0x4C54,0x88,0xFE,0xAB,0xD2,0x5C,0x15,0xB3,0xD6); -DEFINE_G
[FFmpeg-cvslog] dxva: preparations for new hwaccel API
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:09 2017 +0200| [4dec101acc393fbfe9a8ce0237b9efbae3f20139] | committer: Diego Biurrun dxva: preparations for new hwaccel API The actual hwaccel code will need to access an internal context instead of avctx->hwaccel_context, so add a new DXVA_CONTEXT() macro, that will dispatch between the "old" external and the new internal context. Also, the new API requires a new D3D11 pixfmt, so all places which check for the pixfmt need to be adjusted. Introduce a ff_dxva2_is_d3d11() function, which does the check. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4dec101acc393fbfe9a8ce0237b9efbae3f20139 --- libavcodec/dxva2.c | 32 libavcodec/dxva2_h264.c | 14 +++--- libavcodec/dxva2_hevc.c | 10 +- libavcodec/dxva2_internal.h | 22 +- libavcodec/dxva2_mpeg2.c| 10 +- libavcodec/dxva2_vc1.c | 10 +- 6 files changed, 55 insertions(+), 43 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index b0452b6a9a..fe6dbbc030 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -71,7 +71,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, HRESULT hr; #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type, @@ -91,7 +91,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, memcpy(dxva_data, data, size); #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc; memset(dsc11, 0, sizeof(*dsc11)); dsc11->BufferType = type; @@ -116,7 +116,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, } #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type); #endif #if CONFIG_DXVA2 @@ -139,7 +139,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice)) { -AVDXVAContext *ctx = avctx->hwaccel_context; +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); unsigned buffer_count = 0; #if CONFIG_D3D11VA D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4]; @@ -154,7 +154,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, do { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, @@ -171,7 +171,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (hr != E_PENDING || ++runs > 50) break; #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); #endif @@ -181,7 +181,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); #endif @@ -189,7 +189,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { buffer = [buffer_count]; type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS; } @@ -212,7 +212,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (qm_size > 0) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { buffer = [buffer_count]; type = D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUA
[FFmpeg-cvslog] lavu: add new D3D11 pixfmt and hwcontext
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:07 2017 +0200| [fff90422d181744cd75dbf011687ee7095f02875] | committer: Diego Biurrun lavu: add new D3D11 pixfmt and hwcontext To be used with the new d3d11 hwaccel decode API. With the new hwaccel API, we don't want surfaces to depend on the decoder (other than the required dimension and format). The old D3D11VA pixfmt uses ID3D11VideoDecoderOutputView pointers, which include the decoder configuration, and thus is incompatible with the new hwaccel API. This patch introduces AV_PIX_FMT_D3D11, which uses ID3D11Texture2D and an index. It's simpler and compatible with the new hwaccel API. The introduced hwcontext supports only the new pixfmt. Frame upload code untested. Significantly based on work by Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fff90422d181744cd75dbf011687ee7095f02875 --- doc/APIchanges | 3 + libavutil/Makefile | 3 + libavutil/hwcontext.c | 4 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 490 + libavutil/hwcontext_d3d11va.h | 160 ++ libavutil/hwcontext_internal.h | 1 + libavutil/pixdesc.c| 4 + libavutil/pixfmt.h | 14 +- libavutil/version.h| 4 +- 10 files changed, 681 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index a251c4ca82..a81e41833d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-xx-xx - xxx - lavu 56.2.0 - hwcontext.h + Add AV_HWDEVICE_TYPE_D3D11VA and AV_PIX_FMT_D3D11. + 2017-04-30 - xxx - lavu 56.1.1 - hwcontext.h av_hwframe_ctx_create_derived() now takes some AV_HWFRAME_MAP_* combination as its flags argument (which was previously unused). diff --git a/libavutil/Makefile b/libavutil/Makefile index 60e180c79d..6fb24db678 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -27,6 +27,7 @@ HEADERS = adler32.h \ hmac.h\ hwcontext.h \ hwcontext_cuda.h \ + hwcontext_d3d11va.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ hwcontext_vaapi.h \ @@ -112,6 +113,7 @@ OBJS = adler32.o \ xtea.o \ OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o +OBJS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.o OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o OBJS-$(CONFIG_LIBMFX) += hwcontext_qsv.o OBJS-$(CONFIG_LZO) += lzo.o @@ -121,6 +123,7 @@ OBJS-$(CONFIG_VDPAU)+= hwcontext_vdpau.o OBJS += $(COMPAT_OBJS:%=../compat/%) SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda.h +SKIPHEADERS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.h SKIPHEADERS-$(CONFIG_DXVA2)+= hwcontext_dxva2.h SKIPHEADERS-$(CONFIG_LIBMFX) += hwcontext_qsv.h SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 360b01205c..d82df56abf 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -32,6 +32,9 @@ static const HWContextType * const hw_table[] = { #if CONFIG_CUDA _hwcontext_type_cuda, #endif +#if CONFIG_D3D11VA +_hwcontext_type_d3d11va, +#endif #if CONFIG_DXVA2 _hwcontext_type_dxva2, #endif @@ -50,6 +53,7 @@ static const HWContextType * const hw_table[] = { const char *hw_type_names[] = { [AV_HWDEVICE_TYPE_CUDA] = "cuda", [AV_HWDEVICE_TYPE_DXVA2] = "dxva2", +[AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va", [AV_HWDEVICE_TYPE_QSV]= "qsv", [AV_HWDEVICE_TYPE_VAAPI] = "vaapi", [AV_HWDEVICE_TYPE_VDPAU] = "vdpau", diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index eaf40c46f1..203ea510ec 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -31,6 +31,7 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_DXVA2, AV_HWDEVICE_TYPE_QSV, +AV_HWDEVICE_TYPE_D3D11VA, }; typedef struct AVHWDeviceInternal AVHWDeviceInternal; diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c new file mode 100644 index 00..3940502868 --- /dev/null +++ b/l
[FFmpeg-cvslog] lavc/avrndec: remove AV_CODEC_CAP_DR1, as it's broken
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Fri Oct 13 18:59:15 2017 +0200| [195dd5c59c89b125b89078c736ae107bcaf23b37] | committer: James Almer lavc/avrndec: remove AV_CODEC_CAP_DR1, as it's broken In the is_mjpeg case, the user's get_buffer2 callback is not called, thus completely breaking the API. Signed-off-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=195dd5c59c89b125b89078c736ae107bcaf23b37 --- libavcodec/avrndec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/avrndec.c b/libavcodec/avrndec.c index c37f99661b..104ff2d904 100644 --- a/libavcodec/avrndec.c +++ b/libavcodec/avrndec.c @@ -168,7 +168,6 @@ AVCodec ff_avrn_decoder = { .init = init, .close = end, .decode = decode_frame, -.capabilities = AV_CODEC_CAP_DR1, .max_lowres = 3, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: Add hwaccel_flags field to AVCodecContext
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Mar 4 23:57:32 2017 +| [16a163b55a6558ed05702b91cc0777987295ef21] | committer: Mark Thompson lavc: Add hwaccel_flags field to AVCodecContext This "reuses" the flags introduced for the av_vdpau_bind_context() API function, and makes them available to all hwaccels. This does not affect the current vdpau API, as av_vdpau_bind_context() should obviously override the AVCodecContext.hwaccel_flags flags for the sake of compatibility. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=16a163b55a6558ed05702b91cc0777987295ef21 --- doc/APIchanges | 4 libavcodec/avcodec.h | 9 + libavcodec/pthread_frame.c | 2 ++ libavcodec/version.h | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 70b3391988..c6a5d82b99 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-03-xx - xxx - lavc 57.37.0 - avcodec.h + Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at + a later point. + 2017-03-xx - xxx - lavu 55.35.0 - hwcontext.h Add AV_HWDEVICE_TYPE_NONE, av_hwdevice_find_type_by_name(), av_hwdevice_get_type_name() and av_hwdevice_iterate_types(). diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 62a4fab8f9..1e2b13e0d7 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3186,6 +3186,15 @@ typedef struct AVCodecContext { * contexts used must be created on the same device. */ AVBufferRef *hw_device_ctx; + +/** + * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated + * decoding (if active). + * - encoding: unused + * - decoding: Set by user (either before avcodec_open2(), or in the + * AVCodecContext.get_format callback) + */ +int hwaccel_flags; } AVCodecContext; /** diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index f3a74c0bd8..65a04d8e90 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -270,6 +270,8 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(ENOMEM); } } + +dst->hwaccel_flags = src->hwaccel_flags; } if (for_user) { diff --git a/libavcodec/version.h b/libavcodec/version.h index 443cc8204a..349b2e9f6a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 36 +#define LIBAVCODEC_VERSION_MINOR 37 #define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: vdpau: add support for new hw_frames_ctx and hw_device_ctx API
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Mar 4 23:57:33 2017 +| [1a7ddba5762b6c31d1338140550cd594b6d7d48b] | committer: Mark Thompson lavc: vdpau: add support for new hw_frames_ctx and hw_device_ctx API This supports retrieving the device from a provided hw_frames_ctx, and automatically creating a hw_frames_ctx if hw_device_ctx is set. The old API is not deprecated yet. The user can still use av_vdpau_bind_context() (with or without setting hw_frames_ctx), or use the API before that by allocating and setting hwaccel_context manually. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1a7ddba5762b6c31d1338140550cd594b6d7d48b --- libavcodec/vdpau.c | 85 +++-- libavcodec/vdpau_internal.h | 2 ++ libavcodec/version.h| 2 +- 3 files changed, 69 insertions(+), 20 deletions(-) diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index d3cb188d74..68d0813f65 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -118,29 +118,76 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, vdctx->width= UINT32_MAX; vdctx->height = UINT32_MAX; -hwctx->reset= 0; -if (hwctx->context.decoder != VDP_INVALID_HANDLE) { -vdctx->decoder = hwctx->context.decoder; -vdctx->render = hwctx->context.render; -vdctx->device = VDP_INVALID_HANDLE; -return 0; /* Decoder created by user */ -} +if (av_vdpau_get_surface_parameters(avctx, , , )) +return AVERROR(ENOSYS); -vdctx->device = hwctx->device; -vdctx->get_proc_address = hwctx->get_proc_address; +if (hwctx) { +hwctx->reset= 0; -if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) -level = 0; -else if (level < 0) -return AVERROR(ENOTSUP); +if (hwctx->context.decoder != VDP_INVALID_HANDLE) { +vdctx->decoder = hwctx->context.decoder; +vdctx->render = hwctx->context.render; +vdctx->device = VDP_INVALID_HANDLE; +return 0; /* Decoder created by user */ +} -if (av_vdpau_get_surface_parameters(avctx, , , )) -return AVERROR(ENOSYS); +vdctx->device = hwctx->device; +vdctx->get_proc_address = hwctx->get_proc_address; + +if (hwctx->flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) +level = 0; + +if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) && +type != VDP_CHROMA_TYPE_420) +return AVERROR(ENOSYS); +} else { +AVHWFramesContext *frames_ctx = NULL; +AVVDPAUDeviceContext *dev_ctx; + +// We assume the hw_frames_ctx always survives until ff_vdpau_common_uninit +// is called. This holds true as the user is not allowed to touch +// hw_device_ctx, or hw_frames_ctx after get_format (and ff_get_format +// itself also uninits before unreffing hw_frames_ctx). +if (avctx->hw_frames_ctx) { +frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; +} else if (avctx->hw_device_ctx) { +int ret; + +avctx->hw_frames_ctx = av_hwframe_ctx_alloc(avctx->hw_device_ctx); +if (!avctx->hw_frames_ctx) +return AVERROR(ENOMEM); + +frames_ctx= (AVHWFramesContext*)avctx->hw_frames_ctx->data; +frames_ctx->format= AV_PIX_FMT_VDPAU; +frames_ctx->sw_format = avctx->sw_pix_fmt; +frames_ctx->width = avctx->coded_width; +frames_ctx->height= avctx->coded_height; + +ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); +if (ret < 0) { +av_buffer_unref(>hw_frames_ctx); +return ret; +} +} -if (!(hwctx->flags & AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH) && -type != VDP_CHROMA_TYPE_420) -return AVERROR(ENOSYS); +if (!frames_ctx) { +av_log(avctx, AV_LOG_ERROR, "A hardware frames context is " + "required for VDPAU decoding.\n"); +return AVERROR(EINVAL); +} + +dev_ctx = frames_ctx->device_ctx->hwctx; + +vdctx->device = dev_ctx->device; +vdctx->get_proc_address = dev_ctx->get_proc_address; + +if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_IGNORE_LEVEL) +level = 0; +} + +if (level < 0) +return AVERROR(ENOTSUP); status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES, @@ -238,7 +285,7 @@ static int ff_vdpau_common_reinit(AVCodecContext *avctx) if (vdc
[FFmpeg-cvslog] avcodec: clarify some decoding/encoding API details
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Mar 6 11:34:20 2017 +0100| [8a60bba0aef77015111570058d5a72f0428dc748] | committer: Diego Biurrun avcodec: clarify some decoding/encoding API details Make it clear that there is no timing-dependent behavior. In particular, there is no state in which both input and output are denied, and where you have to wait for a while yourself to make progress (apparently some hardware decoders like to do this). Avoid wording that makes references to time. It shouldn't be mistaken for some kind of asynchronous API (like POSIX read() can return EAGAIN if there is no new input yet). It's a state machine, so try to use appropriate terms. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a60bba0aef77015111570058d5a72f0428dc748 --- libavcodec/avcodec.h | 44 +++- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 489a618cbb..c03754695f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -114,6 +114,12 @@ * are filled. This situation is handled transparently if you follow the steps * outlined above. * + * In theory, sending input can result in EAGAIN - this should happen only if + * not all output was received. You can use this to structure alternative decode + * or encode loops other than the one suggested above. For example, you could + * try sending new input on each iteration, and try to receive output if that + * returns EAGAIN. + * * End of stream situations. These require "flushing" (aka draining) the codec, * as the codec might buffer multiple frames or packets internally for * performance or out of necessity (consider B-frames). @@ -148,7 +154,8 @@ * Unlike with the old video decoding API, multiple frames might result from * a packet. For audio, splitting the input packet into frames by partially * decoding packets becomes transparent to the API user. You never need to - * feed an AVPacket to the API twice. + * feed an AVPacket to the API twice (unless it is rejected with EAGAIN - then + * no data was read from the packet). * Additionally, sending a flush/draining packet is required only once. * - avcodec_encode_video2()/avcodec_encode_audio2(): * Use avcodec_send_frame() to feed input to the encoder, then use @@ -161,7 +168,22 @@ * and will result in arbitrary behavior. * * Some codecs might require using the new API; using the old API will return - * an error when calling it. + * an error when calling it. All codecs support the new API. + * + * A codec is not allowed to return EAGAIN for both sending and receiving. This + * would be an invalid state, which could put the codec user into an endless + * loop. The API has no concept of time either: it cannot happen that trying to + * do avcodec_send_packet() results in EAGAIN, but a repeated call 1 second + * later accepts the packet (with no other receive/flush API calls involved). + * The API is a strict state machine, and the passage of time is not supposed + * to influence it. Some timing-dependent behavior might still be deemed + * acceptable in certain cases. But it must never result in both send/receive + * returning EAGAIN at the same time at any point. It must also absolutely be + * avoided that the current state is "unstable" and can "flip-flop" between + * the send/receive APIs allowing progress. For example, it's not allowed that + * the codec randomly decides that it actually wants to consume a packet now + * instead of returning a frame, after it just returned EAGAIN on an + * avcodec_send_packet() call. * @} */ @@ -4339,8 +4361,10 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, * a flush packet. * * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted right now - the packet must be - * resent after trying to read output + * AVERROR(EAGAIN): input is not accepted in the current state - user + * must read output with avcodec_receive_frame() (once + * all output is read, the packet should be resent, and + * the call will not fail with EAGAIN). * AVERROR_EOF: the decoder has been flushed, and no new packets can * be sent to it (also returned if more than 1 flush * packet is sent) @@ -4361,7 +4385,7 @@ int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); * * @return * 0: success, a frame was returned - * AVERROR(EAGAIN): output is not available right now - user must try + * AVERROR(EAGAIN): output is not available in this state - user must try * to send new input *
[FFmpeg-cvslog] hwcontext_dxva2: support D3D9Ex
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Fri Feb 10 12:17:24 2017 +0100| [c2f97f050870897575570708ac48c5c15e6a0dd8] | committer: Anton Khirnov hwcontext_dxva2: support D3D9Ex D3D9Ex uses different driver paths. This helps with "headless" configurations when no user logs in. Plain D3D9 device creation will fail if no user is logged in, while it works with D3D9Ex. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c2f97f050870897575570708ac48c5c15e6a0dd8 --- libavutil/hwcontext_dxva2.c | 117 1 file changed, 87 insertions(+), 30 deletions(-) diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c index ccf03c8e9f..3790bed4b7 100644 --- a/libavutil/hwcontext_dxva2.c +++ b/libavutil/hwcontext_dxva2.c @@ -38,8 +38,22 @@ #include "pixfmt.h" typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); +typedef HRESULT WINAPI pDirect3DCreate9Ex(UINT, IDirect3D9Ex **); typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, IDirect3DDeviceManager9 **); +#define FF_D3DCREATE_FLAGS (D3DCREATE_SOFTWARE_VERTEXPROCESSING | \ +D3DCREATE_MULTITHREADED | \ +D3DCREATE_FPU_PRESERVE) + +static const D3DPRESENT_PARAMETERS dxva2_present_params = { +.Windowed = TRUE, +.BackBufferWidth = 640, +.BackBufferHeight = 480, +.BackBufferCount = 0, +.SwapEffect = D3DSWAPEFFECT_DISCARD, +.Flags= D3DPRESENTFLAG_VIDEO, +}; + typedef struct DXVA2Mapping { uint32_t palette_dummy[256]; } DXVA2Mapping; @@ -411,19 +425,83 @@ static void dxva2_device_free(AVHWDeviceContext *ctx) av_freep(>user_opaque); } +static int dxva2_device_create9(AVHWDeviceContext *ctx, UINT adapter) +{ +DXVA2DevicePriv *priv = ctx->user_opaque; +D3DPRESENT_PARAMETERS d3dpp = dxva2_present_params; +D3DDISPLAYMODE d3ddm; +HRESULT hr; +pDirect3DCreate9 *createD3D = (pDirect3DCreate9 *)GetProcAddress(priv->d3dlib, "Direct3DCreate9"); +if (!createD3D) { +av_log(ctx, AV_LOG_ERROR, "Failed to locate Direct3DCreate9\n"); +return AVERROR_UNKNOWN; +} + +priv->d3d9 = createD3D(D3D_SDK_VERSION); +if (!priv->d3d9) { +av_log(ctx, AV_LOG_ERROR, "Failed to create IDirect3D object\n"); +return AVERROR_UNKNOWN; +} + +IDirect3D9_GetAdapterDisplayMode(priv->d3d9, adapter, ); + +d3dpp.BackBufferFormat = d3ddm.Format; + +hr = IDirect3D9_CreateDevice(priv->d3d9, adapter, D3DDEVTYPE_HAL, GetShellWindow(), +FF_D3DCREATE_FLAGS, +, >d3d9device); +if (FAILED(hr)) { +av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device\n"); +return AVERROR_UNKNOWN; +} + +return 0; +} + +static int dxva2_device_create9ex(AVHWDeviceContext *ctx, UINT adapter) +{ +DXVA2DevicePriv *priv = ctx->user_opaque; +D3DPRESENT_PARAMETERS d3dpp = dxva2_present_params; +D3DDISPLAYMODEEX modeex = {0}; +IDirect3D9Ex *d3d9ex = NULL; +IDirect3DDevice9Ex *exdev = NULL; +HRESULT hr; +pDirect3DCreate9Ex *createD3DEx = (pDirect3DCreate9Ex *)GetProcAddress(priv->d3dlib, "Direct3DCreate9Ex"); +if (!createD3DEx) +return AVERROR(ENOSYS); + +hr = createD3DEx(D3D_SDK_VERSION, ); +if (FAILED(hr)) +return AVERROR_UNKNOWN; + +IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, adapter, , NULL); + +d3dpp.BackBufferFormat = modeex.Format; + +hr = IDirect3D9Ex_CreateDeviceEx(d3d9ex, adapter, D3DDEVTYPE_HAL, GetShellWindow(), + FF_D3DCREATE_FLAGS, + , NULL, ); +if (FAILED(hr)) { +IDirect3D9Ex_Release(d3d9ex); +return AVERROR_UNKNOWN; +} + +av_log(ctx, AV_LOG_VERBOSE, "Using D3D9Ex device.\n"); +priv->d3d9 = (IDirect3D9 *)d3d9ex; +priv->d3d9device = (IDirect3DDevice9 *)exdev; +return 0; +} + static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device, AVDictionary *opts, int flags) { AVDXVA2DeviceContext *hwctx = ctx->hwctx; DXVA2DevicePriv *priv; - -pDirect3DCreate9 *createD3D = NULL; pCreateDeviceManager9 *createDeviceManager = NULL; -D3DPRESENT_PARAMETERS d3dpp = {0}; -D3DDISPLAYMODEd3ddm; unsigned resetToken = 0; UINT adapter = D3DADAPTER_DEFAULT; HRESULT hr; +int err; if (device) adapter = atoi(device); @@ -448,11 +526,6 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, const char *device, return AVERROR_UNKNOWN; } -createD3D = (pDirect3DCreate9 *)GetProcAddress(priv->d3dlib, "Direct3DCreate9"); -if (!createD3D) { -av_log(
[FFmpeg-cvslog] AVFrame: add an opaque_ref field
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Feb 2 11:27:54 2017 +0100| [04f3bd349651694f30feeb8c4ed9bc58106fca54] | committer: Anton Khirnov AVFrame: add an opaque_ref field This is an extended version of the AVFrame.opaque field, which can be used to attach arbitrary user information to an AVFrame. The usefulness of the opaque field is rather limited, because it can store only up to 32 bits of information (or 64 bit on 64 bit systems). It's not possible to set this field to a memory allocation, because there is no way to deallocate it correctly. The opaque_ref field circumvents this by letting the user set an AVBuffer, which makes the user data refcounted. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=04f3bd349651694f30feeb8c4ed9bc58106fca54 --- doc/APIchanges | 3 +++ libavutil/frame.c | 9 + libavutil/frame.h | 11 +++ libavutil/version.h | 4 ++-- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 9b9f46ef49..e7a0b14038 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-02-11 - xxx - lavu 55.32.0 - frame.h + Add AVFrame.opaque_ref. + 2017-02-xx - xxx - lavu 55.31.1 - frame.h Allow passing the value of 0 (meaning "automatic") as the required alignment to av_frame_get_buffer(). diff --git a/libavutil/frame.c b/libavutil/frame.c index aa5820c0e9..9cd5f9ab37 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -317,6 +317,8 @@ void av_frame_unref(AVFrame *frame) av_buffer_unref(>hw_frames_ctx); +av_buffer_unref(>opaque_ref); + get_frame_defaults(frame); } @@ -440,6 +442,13 @@ FF_ENABLE_DEPRECATION_WARNINGS av_dict_copy(_dst->metadata, sd_src->metadata, 0); } +av_buffer_unref(>opaque_ref); +if (src->opaque_ref) { +dst->opaque_ref = av_buffer_ref(src->opaque_ref); +if (!dst->opaque_ref) +return AVERROR(ENOMEM); +} + return 0; } diff --git a/libavutil/frame.h b/libavutil/frame.h index 4f63fb0249..f9ffb5bbbf 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -395,6 +395,17 @@ typedef struct AVFrame { /** * @} */ + +/** + * AVBufferRef for free use by the API user. Libav will never check the + * contents of the buffer ref. Libav calls av_buffer_unref() on it when + * the frame is unreferenced. av_frame_copy_props() calls create a new + * reference with av_buffer_ref() for the target frame's opaque_ref field. + * + * This is unrelated to the opaque field, although it serves a similar + * purpose. + */ +AVBufferRef *opaque_ref; } AVFrame; /** diff --git a/libavutil/version.h b/libavutil/version.h index 0768f9fe99..5dbc57cc1b 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,8 +54,8 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 31 -#define LIBAVUTIL_VERSION_MICRO 1 +#define LIBAVUTIL_VERSION_MINOR 32 +#define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc: deprecate refcounted_frames field
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Jan 16 17:32:18 2017 +0100| [577326d430593a25456393a75212b95d1cd94131] | committer: Anton Khirnov lavc: deprecate refcounted_frames field No deprecation guards, because the old decode API (for which this field is needed) doesn't have any either. This field should be removed together with the old decode calls. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=577326d430593a25456393a75212b95d1cd94131 --- doc/APIchanges | 6 ++ libavcodec/avcodec.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index c8c2a219f6..c161618d92 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,12 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-02-01 - xxx - lavc - avcodec.h + Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated + API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs + (avcodec_send_packet/avcodec_receive_frame) always work with reference + counted frames. + 2016-xx-xx - xxx - lavc 57.31.0 - avcodec.h Add AVCodecContext.apply_cropping to control whether cropping is handled by libavcodec or the caller. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 18721561d5..8d8fa594aa 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2327,7 +2327,7 @@ typedef struct AVCodecContext { * - encoding: unused * - decoding: set by the caller before avcodec_open2(). */ -int refcounted_frames; +attribute_deprecated int refcounted_frames; /* - encoding parameters */ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_cuda: implement frames_get_constraints
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Jan 16 16:42:17 2017 +0100| [3ad825793a43253154bed05827f27425fc0757df] | committer: Anton Khirnov hwcontext_cuda: implement frames_get_constraints Copied and modified from hwcontext_qsv.c. Signed-off-by: Anton Khirnov <an...@khirnov.net> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ad825793a43253154bed05827f27425fc0757df --- libavutil/hwcontext_cuda.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c index 260783426a..fc9b8b4298 100644 --- a/libavutil/hwcontext_cuda.c +++ b/libavutil/hwcontext_cuda.c @@ -37,6 +37,31 @@ static const enum AVPixelFormat supported_formats[] = { AV_PIX_FMT_YUV444P16, }; +static int cuda_frames_get_constraints(AVHWDeviceContext *ctx, + const void *hwconfig, + AVHWFramesConstraints *constraints) +{ +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++) +constraints->valid_sw_formats[i] = supported_formats[i]; +constraints->valid_sw_formats[FF_ARRAY_ELEMS(supported_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_CUDA; +constraints->valid_hw_formats[1] = AV_PIX_FMT_NONE; + +return 0; +} + static void cuda_buffer_free(void *opaque, uint8_t *data) { AVHWFramesContext *ctx = opaque; @@ -326,6 +351,7 @@ const HWContextType ff_hwcontext_type_cuda = { .frames_priv_size = sizeof(CUDAFramesContext), .device_create= cuda_device_create, +.frames_get_constraints = cuda_frames_get_constraints, .frames_init = cuda_frames_init, .frames_get_buffer= cuda_get_buffer, .transfer_get_formats = cuda_transfer_get_formats, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf: make avio_read_partial() public
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Aug 17 15:01:44 2017 +0200| [5d76674756806e3b458e484788775fcee34aac2a] | committer: wm4 lavf: make avio_read_partial() public Main use-case is proxying avio through a foreign I/O layer and a custom AVIO context, without losing latency and performance characteristics. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> Merged from Libav commit 173b56218f39c64. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5d76674756806e3b458e484788775fcee34aac2a --- doc/APIchanges | 3 +++ libavformat/avio.h | 9 + libavformat/avio_internal.h | 8 libavformat/aviobuf.c | 2 +- libavformat/rawdec.c| 2 +- libavformat/rtsp.c | 2 +- libavformat/version.h | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 1e9b29fdbb..4effbf9364 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-09-01 - xxx - lavf 57.81.100 - avio.h + Add avio_read_partial(). + 2017-09-01 - xxx - lavf 57.80.100 / 57.11.0 - avio.h Add avio_context_free(). From now on it must be used for freeing AVIOContext. diff --git a/libavformat/avio.h b/libavformat/avio.h index 89ad5c04ea..f9c5972ada 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -599,6 +599,15 @@ void avio_flush(AVIOContext *s); int avio_read(AVIOContext *s, unsigned char *buf, int size); /** + * Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed + * to read fewer bytes than requested. The missing bytes can be read in the next + * call. This always tries to read at least 1 byte. + * Useful to reduce latency in certain cases. + * @return number of bytes read or AVERROR + */ +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size); + +/** * @name Functions for reading from AVIOContext * @{ * diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index fdb323c8f1..c01835df96 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -53,14 +53,6 @@ int ffio_init_context(AVIOContext *s, */ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data); -/** - * Read size bytes from AVIOContext into buf. - * This reads at most 1 packet. If that is not enough fewer bytes will be - * returned. - * @return number of bytes read or AVERROR - */ -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size); - void ffio_fill(AVIOContext *s, int b, int count); static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 716c42eda9..636cb46161 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -703,7 +703,7 @@ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsig } } -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size) +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size) { int len; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 876a6e6a75..e926549a60 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -43,7 +43,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos= avio_tell(s->pb); pkt->stream_index = 0; -ret = ffio_read_partial(s->pb, pkt->data, size); +ret = avio_read_partial(s->pb, pkt->data, size); if (ret < 0) { av_packet_unref(pkt); return ret; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 261e970b75..0bd72dc5ce 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2136,7 +2136,7 @@ redo: wait_end && wait_end < av_gettime_relative()) len = AVERROR(EAGAIN); else -len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); +len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); len = pick_stream(s, _st, rt->recvbuf, len); if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, NULL, s->pb, len); diff --git a/libavformat/version.h b/libavformat/version.h index 0af524c16b..9cca76ee00 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 57 -#define LIBAVFORMAT_VERSION_MINOR 80 +#define LIBAVFORMAT_VERSION_MINOR 81 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] imgutils: add function to clear an image to black
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jul 22 23:05:14 2017 +0200| [463b81de2b252691d75417643597c42684bf830d] | committer: wm4 imgutils: add function to clear an image to black Black isn't always just memset(ptr, 0, size). Limited YUV in particular requires relatively non-obvious values, and filling a frame with repeating 0 bytes is disallowed in some contexts. With component sizes larger than 8 or packed YUV, this can become relatively complicated. So having a generic function for this seems helpful. In order to handle the complex cases in a generic way without destroying performance, this code attempts to compute a black pixel, and then uses that value to clear the image data quickly by using a function like memset. Common cases like yuv410p10 or rgba can't be handled with a simple memset, so there is some code to fill memory with 2/4/8 byte patterns. For the remaining cases, a generic slow fallback is used. Signed-off-by: Anton Khirnov <an...@khirnov.net> Merged from Libav commit 45df7adc1d9b7. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=463b81de2b252691d75417643597c42684bf830d --- doc/APIchanges | 3 + libavutil/imgutils.c | 167 +++ libavutil/imgutils.h | 27 + libavutil/version.h | 2 +- 4 files changed, 198 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index cd69ec7bc6..c82de684ab 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-08-08 - xxx - lavu 55.72.100 - imgutils.h + Add av_image_fill_black(). + 2017-08-08 - xxx - lavu 55.71.100 - frame.h Add av_frame_apply_cropping(). diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index f8f2244b89..4de0fa0c39 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -491,3 +491,170 @@ int av_image_copy_to_buffer(uint8_t *dst, int dst_size, return size; } + +// Fill dst[0..dst_size] with the bytes in clear[0..clear_size]. The clear +// bytes are repeated until dst_size is reached. If dst_size is unaligned (i.e. +// dst_size%clear_size!=0), the remaining data will be filled with the beginning +// of the clear data only. +static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear, + size_t clear_size) +{ +size_t pos = 0; +int same = 1; +int i; + +if (!clear_size) +return; + +// Reduce to memset() if possible. +for (i = 0; i < clear_size; i++) { +if (clear[i] != clear[0]) { +same = 0; +break; +} +} +if (same) +clear_size = 1; + +if (clear_size == 1) { +memset(dst, clear[0], dst_size); +dst_size = 0; +} else if (clear_size == 2) { +uint16_t val = AV_RN16(clear); +for (; dst_size >= 2; dst_size -= 2) { +AV_WN16(dst, val); +dst += 2; +} +} else if (clear_size == 4) { +uint32_t val = AV_RN32(clear); +for (; dst_size >= 4; dst_size -= 4) { +AV_WN32(dst, val); +dst += 4; +} +} else if (clear_size == 8) { +uint32_t val = AV_RN64(clear); +for (; dst_size >= 8; dst_size -= 8) { +AV_WN64(dst, val); +dst += 8; +} +} + +for (; dst_size; dst_size--) +*dst++ = clear[pos++ % clear_size]; +} + +// Maximum size in bytes of a plane element (usually a pixel, or multiple pixels +// if it's a subsampled packed format). +#define MAX_BLOCK_SIZE 32 + +int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4], +enum AVPixelFormat pix_fmt, enum AVColorRange range, +int width, int height) +{ +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); +int nb_planes = av_pix_fmt_count_planes(pix_fmt); +// A pixel or a group of pixels on each plane, with a value that represents black. +// Consider e.g. AV_PIX_FMT_UYVY422 for non-trivial cases. +uint8_t clear_block[4][MAX_BLOCK_SIZE] = {0}; // clear padding with 0 +int clear_block_size[4] = {0}; +ptrdiff_t plane_line_bytes[4] = {0}; +int rgb, limited; +int plane, c; + +if (!desc || nb_planes < 1 || nb_planes > 4 || desc->flags & AV_PIX_FMT_FLAG_HWACCEL) +return AVERROR(EINVAL); + +rgb = !!(desc->flags & AV_PIX_FMT_FLAG_RGB); +limited = !rgb && range != AVCOL_RANGE_JPEG; + +if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM) { +ptrdiff_t bytewidth = av_image_get_linesize(pix_fmt, width, 0); +uint8_t *data; +int mono = pix_fmt == AV_PIX_FMT_MONOWHITE || pix_fmt == AV_PIX_FMT_MONOBLACK; +int fill = pix_fmt == AV_PIX_FMT_MONOWHITE ? 0xFF : 0; +if (nb_planes != 1 || !(rgb || mono) || bytewidth < 1) +return AVERROR(EINVAL);
[FFmpeg-cvslog] lavc, lavu: move frame cropping to a convenience function
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jul 22 23:05:13 2017 +0200| [caa12027baf1180453846c58da08fc87accc0ff6] | committer: wm4 lavc, lavu: move frame cropping to a convenience function Signed-off-by: Anton Khirnov <an...@khirnov.net> Merged from Libav commit 47399ccdfd. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=caa12027baf1180453846c58da08fc87accc0ff6 --- doc/APIchanges | 3 ++ libavcodec/decode.c | 89 ++ libavutil/frame.c | 100 libavutil/frame.h | 34 ++ libavutil/version.h | 2 +- 5 files changed, 140 insertions(+), 88 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 63fac21000..cd69ec7bc6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-08-08 - xxx - lavu 55.71.100 - frame.h + Add av_frame_apply_cropping(). + 2017-07-25 - 24de4fddca - lavu 55.69.100 - frame.h Add AV_FRAME_DATA_ICC_PROFILE side data type. diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 052f93d82f..9b57910842 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -683,44 +683,8 @@ int attribute_align_arg avcodec_send_packet(AVCodecContext *avctx, const AVPacke return 0; } -static int calc_cropping_offsets(size_t offsets[4], const AVFrame *frame, - const AVPixFmtDescriptor *desc) -{ -int i, j; - -for (i = 0; frame->data[i]; i++) { -const AVComponentDescriptor *comp = NULL; -int shift_x = (i == 1 || i == 2) ? desc->log2_chroma_w : 0; -int shift_y = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; - -if (desc->flags & (AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_PSEUDOPAL) && i == 1) { -offsets[i] = 0; -break; -} - -/* find any component descriptor for this plane */ -for (j = 0; j < desc->nb_components; j++) { -if (desc->comp[j].plane == i) { -comp = >comp[j]; -break; -} -} -if (!comp) -return AVERROR_BUG; - -offsets[i] = (frame->crop_top >> shift_y) * frame->linesize[i] + - (frame->crop_left >> shift_x) * comp->step; -} - -return 0; -} - static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) { -const AVPixFmtDescriptor *desc; -size_t offsets[4]; -int i; - /* make sure we are noisy about decoders returning invalid cropping data */ if (frame->crop_left >= INT_MAX - frame->crop_right|| frame->crop_top >= INT_MAX - frame->crop_bottom || @@ -742,57 +706,8 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame *frame) if (!avctx->apply_cropping) return 0; -desc = av_pix_fmt_desc_get(frame->format); -if (!desc) -return AVERROR_BUG; - -/* Apply just the right/bottom cropping for hwaccel formats. Bitstream - * formats cannot be easily handled here either (and corresponding decoders - * should not export any cropping anyway), so do the same for those as well. - * */ -if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL)) { -frame->width -= frame->crop_right; -frame->height -= frame->crop_bottom; -frame->crop_right = 0; -frame->crop_bottom = 0; -return 0; -} - -/* calculate the offsets for each plane */ -calc_cropping_offsets(offsets, frame, desc); - -/* adjust the offsets to avoid breaking alignment */ -if (!(avctx->flags & AV_CODEC_FLAG_UNALIGNED)) { -int log2_crop_align = frame->crop_left ? ff_ctz(frame->crop_left) : INT_MAX; -int min_log2_align = INT_MAX; - -for (i = 0; frame->data[i]; i++) { -int log2_align = offsets[i] ? ff_ctz(offsets[i]) : INT_MAX; -min_log2_align = FFMIN(log2_align, min_log2_align); -} - -/* we assume, and it should always be true, that the data alignment is - * related to the cropping alignment by a constant power-of-2 factor */ -if (log2_crop_align < min_log2_align) -return AVERROR_BUG; - -if (min_log2_align < 5) { -frame->crop_left &= ~((1 << (5 + log2_crop_align - min_log2_align)) - 1); -calc_cropping_offsets(offsets, frame, desc); -} -} - -for (i = 0; frame->data[i]; i++) -frame->data[i] += offsets[i]; - -frame->width -= (frame->crop_left + frame->crop_right); -frame->height -= (frame->crop_top + frame->crop_bottom); -frame->crop_left = 0; -frame->crop_right = 0; -frame->crop_top= 0; -frame->crop_b
[FFmpeg-cvslog] videotoolbox: fix crash when decoding interlaced video with new API
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jul 11 18:24:31 2017 +0200| [02d248d5828dbbfecfb37597c626900f41448bea] | committer: wm4 videotoolbox: fix crash when decoding interlaced video with new API > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02d248d5828dbbfecfb37597c626900f41448bea --- libavcodec/videotoolbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 1b1be41934..dd13e2581b 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -249,7 +249,7 @@ static int videotoolbox_buffer_create(AVCodecContext *avctx, AVFrame *frame) vtctx->cached_hw_frames_ctx = hw_frames_ctx; } -av_assert0(!frame->hw_frames_ctx); +av_buffer_unref(>hw_frames_ctx); frame->hw_frames_ctx = av_buffer_ref(vtctx->cached_hw_frames_ctx); if (!frame->hw_frames_ctx) return AVERROR(ENOMEM); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Jul 10 15:59:38 2017 +0200| [c64da19bbc1d3b405703ef3b705dba39a450504f] | committer: wm4 dxva: DXVA2_ModeHEVC_VLD_Main10 does not support Main This mode apparently does not support decoding of HEVC Main (8 bit). With D3D11 and Intel drivers on Windows 10 I get green corruption, while using DXVA2_ModeHEVC_VLD_Main works. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c64da19bbc1d3b405703ef3b705dba39a450504f --- libavcodec/dxva2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 542607ab3e..afcd361ef6 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -64,8 +64,7 @@ static const int prof_h264_high[]= {FF_PROFILE_H264_CONSTRAINED_BASELINE, FF_PROFILE_UNKNOWN}; static const int prof_hevc_main[]= {FF_PROFILE_HEVC_MAIN, FF_PROFILE_UNKNOWN}; -static const int prof_hevc_main10[] = {FF_PROFILE_HEVC_MAIN, -FF_PROFILE_HEVC_MAIN_10, +static const int prof_hevc_main10[] = {FF_PROFILE_HEVC_MAIN_10, FF_PROFILE_UNKNOWN}; static const dxva_mode dxva_modes[] = { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] htmlsubtitles: support tag
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Mon Jul 3 13:42:44 2017 +0200| [f605b56ad9c5965792359e5474238e318aed1399] | committer: wm4 htmlsubtitles: support tag Some .srt files use this tag. (An alternative implementation would be correctly ignoring unknown tags, and treating them as whitespace. libass can do automatic line wrapping.) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f605b56ad9c5965792359e5474238e318aed1399 --- libavcodec/htmlsubtitles.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c index be5c9316ca..fe991678d5 100644 --- a/libavcodec/htmlsubtitles.c +++ b/libavcodec/htmlsubtitles.c @@ -167,6 +167,8 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const char *in) } } else if (tagname[0] && !tagname[1] && strspn(tagname, "bisu") == 1) { av_bprintf(dst, "{\\%c%d}", tagname[0], !tag_close); +} else if (!strcmp(tagname, "br")) { +av_bprintf(dst, "\\N"); } else { unknown = 1; snprintf(tmp, sizeof(tmp), "", tagname); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] vdpau: do not use buggy HEVC support by default
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Sat Jul 1 11:40:10 2017 +0200| [64ecb78b7179cab2dbdf835463104679dbb7c895] | committer: wm4 vdpau: do not use buggy HEVC support by default NVIDIA broke its own API when using VDPAU decoding. If you retrieve the decoded YUV data, or if you map the surfaces with GL interop, the result are interlacing artifacts. The only way to get non-broken data is by using the vdpau video mixer to convert it to RGB. There is no way to block the non-working operations in a reasonable way (a VdpVideoSurface has to support all operations). NVIDIA refuses to fix this issue (they "fixed" it by making it work with the video mixer, but the rest is still broken). There is no sign of that changing. Do not use HEVC by default with the generic hwaccle API. Detect whether it's the NVIDIA native implementation, and exit with an error. (The same thing work with the MESA implementation.) As an escape hatch and to allow applications to use the decoder if they really want to (perhaps because they make sure to explicitly use the video mixer), reuse AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH to disable this check. Once NVIDIA fixes the bug, working driver versions could be detected, and it could be allowed again. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=64ecb78b7179cab2dbdf835463104679dbb7c895 --- libavcodec/vdpau.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c index 9c7804a287..42ebddbeee 100644 --- a/libavcodec/vdpau.c +++ b/libavcodec/vdpau.c @@ -127,6 +127,8 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, VdpVideoSurfaceQueryCapabilities *surface_query_caps; VdpDecoderQueryCapabilities *decoder_query_caps; VdpDecoderCreate *create; +VdpGetInformationString *info; +const char *info_string; void *func; VdpStatus status; VdpBool supported; @@ -209,6 +211,23 @@ int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile, return AVERROR(ENOTSUP); status = vdctx->get_proc_address(vdctx->device, + VDP_FUNC_ID_GET_INFORMATION_STRING, + ); +if (status != VDP_STATUS_OK) +return vdpau_error(status); +else +info = func; + +status = info(_string); +if (status != VDP_STATUS_OK) +return vdpau_error(status); +if (avctx->codec_id == AV_CODEC_ID_HEVC && strncmp(info_string, "NVIDIA ", 7) == 0 && +!(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) { +av_log(avctx, AV_LOG_VERBOSE, "HEVC with NVIDIA VDPAU drivers is buggy, skipping.\n"); +return AVERROR(ENOTSUP); +} + +status = vdctx->get_proc_address(vdctx->device, VDP_FUNC_ID_VIDEO_SURFACE_QUERY_CAPABILITIES, ); if (status != VDP_STATUS_OK) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hevcdec: properly export some side data with frame threading
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 29 15:36:55 2017 +0200| [ff2d21a58c9c4797ea2d1c4ded09c797abc5a39f] | committer: wm4 hevcdec: properly export some side data with frame threading I noticed this with mastering display data. If frame threading is enabled, this side data is exported only for some frames. It turns out it's not properly propagated to the worker threads. I didn't touch A53 captions, because that involves memory allocation and freeing the data as side data is exported. Micro bump so that API users can detect the bug fix. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff2d21a58c9c4797ea2d1c4ded09c797abc5a39f --- libavcodec/hevcdec.c | 6 ++ libavcodec/version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 3b24fb9bec..cc8ac82164 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -3355,6 +3355,12 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->max_ra = INT_MAX; } +s->sei.frame_packing= s0->sei.frame_packing; +s->sei.display_orientation = s0->sei.display_orientation; +s->sei.mastering_display= s0->sei.mastering_display; +s->sei.content_light= s0->sei.content_light; +s->sei.alternative_transfer = s0->sei.alternative_transfer; + return 0; } diff --git a/libavcodec/version.h b/libavcodec/version.h index 06615268f3..3c5fea9327 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 100 -#define LIBAVCODEC_VERSION_MICRO 102 +#define LIBAVCODEC_VERSION_MICRO 103 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_d3d11va: add option to enable debug mode
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:57 2017 +0200| [289d387330d8a0a07ff98c9e09215627a70ace2d] | committer: wm4 hwcontext_d3d11va: add option to enable debug mode Basically copied from VLC (LGPL): http://git.videolan.org/?p=vlc.git;a=blob;f=modules/video_output/win32/direct3d11.c;h=e9fcb83dcabfe778f26e63d19f218caf06a7c3ae;hb=HEAD#l1482 http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/avcodec/d3d11va.c;h=85e7d25caebc059a9770da2ef4bb8fe90816d76d;hb=HEAD#l599 Merges Libav commit cfc9e7c94eafa33e7f109099664ec4fb57ac5ca3. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=289d387330d8a0a07ff98c9e09215627a70ace2d --- configure | 2 ++ libavutil/hwcontext_d3d11va.c | 32 libavutil/hwcontext_d3d11va.h | 4 3 files changed, 38 insertions(+) diff --git a/configure b/configure index bf48472219..282114d268 100755 --- a/configure +++ b/configure @@ -1859,6 +1859,7 @@ HEADERS_LIST=" direct_h dirent_h dlfcn_h +dxgidebug_h dxva_h ES2_gl_h gsm_h @@ -5683,6 +5684,7 @@ check_header d3d11.h check_header direct.h check_header dirent.h check_header dlfcn.h +check_header dxgidebug.h check_header dxva.h check_header dxva2api.h -D_WIN32_WINNT=0x0600 check_header io.h diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 376c76e5cf..75f78d8669 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include // Include thread.h before redefining _WIN32_WINNT, to get @@ -32,6 +34,10 @@ #include #include +#if HAVE_DXGIDEBUG_H +#include +#endif + #include "avassert.h" #include "common.h" #include "hwcontext.h" @@ -476,8 +482,18 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, IDXGIAdapter *pAdapter = NULL; ID3D10Multithread *pMultithread; UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; +int is_debug = !!av_dict_get(opts, "debug", NULL, 0); int ret; +// (On UWP we can't check this.) +#if HAVE_LOADLIBRARY +if (!LoadLibrary("d3d11_1sdklayers.dll")) +is_debug = 0; +#endif + +if (is_debug) +creationFlags |= D3D11_CREATE_DEVICE_DEBUG; + if ((ret = ff_thread_once(_loaded, load_functions)) != 0) return AVERROR_UNKNOWN; if (!mD3D11CreateDevice || !mCreateDXGIFactory) { @@ -511,6 +527,22 @@ static int d3d11va_device_create(AVHWDeviceContext *ctx, const char *device, ID3D10Multithread_Release(pMultithread); } +#if HAVE_LOADLIBRARY && HAVE_DXGIDEBUG_H +if (is_debug) { +HANDLE dxgidebug_dll = LoadLibrary("dxgidebug.dll"); +if (dxgidebug_dll) { +HRESULT (WINAPI * pf_DXGIGetDebugInterface)(const GUID *riid, void **ppDebug) += (void *)GetProcAddress(dxgidebug_dll, "DXGIGetDebugInterface"); +if (pf_DXGIGetDebugInterface) { +IDXGIDebug *dxgi_debug = NULL; +hr = pf_DXGIGetDebugInterface(_IDXGIDebug, (void**)_debug); +if (SUCCEEDED(hr) && dxgi_debug) +IDXGIDebug_ReportLiveObjects(dxgi_debug, DXGI_DEBUG_ALL, DXGI_DEBUG_RLO_ALL); +} +} +} +#endif + return 0; } diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h index d41451580e..0ed3033452 100644 --- a/libavutil/hwcontext_d3d11va.h +++ b/libavutil/hwcontext_d3d11va.h @@ -30,6 +30,10 @@ * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for * this format. Refer to MSDN for details. + * + * av_hwdevice_ctx_create() for this device type supports a key named "debug" + * for the AVDictionary entry. If this is set to any value, the device creation + * code will try to load various supported D3D debugging layers. */ #include ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: support DXGI_FORMAT_420_OPAQUE decoding
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:56 2017 +0200| [8d7fdba7b8670db9dd5023dde6fe3a06674933c4] | committer: wm4 dxva: support DXGI_FORMAT_420_OPAQUE decoding Some devices (some phones, apparently) will support only this opaque format. Of course this won't work with CLI, because copying data directly is not supported. Automatic frame allocation (setting AVCodecContext.hw_device_ctx) does not support this mode, even if it's the only supported mode. But since opaque surfaces are generally less useful, that's probably ok. Merges Libav commit 5030e3856c2126fb829edb828f5aae011d178eb4. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d7fdba7b8670db9dd5023dde6fe3a06674933c4 --- libavcodec/dxva2.c| 13 +++-- libavutil/hwcontext_d3d11va.c | 12 ++-- libavutil/hwcontext_d3d11va.h | 4 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index e9a6605b5f..76e8249bef 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -393,19 +393,28 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *avctx, return ret; } +static DXGI_FORMAT d3d11va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt) +{ +switch (pix_fmt) { +case AV_PIX_FMT_NV12: return DXGI_FORMAT_NV12; +case AV_PIX_FMT_P010: return DXGI_FORMAT_P010; +case AV_PIX_FMT_YUV420P:return DXGI_FORMAT_420_OPAQUE; +default:return DXGI_FORMAT_UNKNOWN; +} +} + static int d3d11va_create_decoder(AVCodecContext *avctx) { FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); GUID *guid_list; unsigned guid_count, i; GUID decoder_guid; -DXGI_FORMAT surface_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? - DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; D3D11_VIDEO_DECODER_DESC desc = { 0 }; D3D11_VIDEO_DECODER_CONFIG config; AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; AVD3D11VADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; AVD3D11VAFramesContext *frames_hwctx = frames_ctx->hwctx; +DXGI_FORMAT surface_format = d3d11va_map_sw_to_hw_format(frames_ctx->sw_format); D3D11_TEXTURE2D_DESC texdesc; HRESULT hr; int ret; diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 523a6d2dc6..376c76e5cf 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -83,8 +83,11 @@ static const struct { DXGI_FORMAT d3d_format; enum AVPixelFormat pix_fmt; } supported_formats[] = { -{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 }, -{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 }, +{ DXGI_FORMAT_NV12, AV_PIX_FMT_NV12 }, +{ DXGI_FORMAT_P010, AV_PIX_FMT_P010 }, +// Special opaque formats. The pix_fmt is merely a place holder, as the +// opaque format cannot be accessed directly. +{ DXGI_FORMAT_420_OPAQUE, AV_PIX_FMT_YUV420P }, }; static void d3d11va_default_lock(void *ctx) @@ -270,6 +273,7 @@ static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, enum AVHWFrameTransferDirection dir, enum AVPixelFormat **formats) { +D3D11VAFramesContext *s = ctx->internal->priv; enum AVPixelFormat *fmts; fmts = av_malloc_array(2, sizeof(*fmts)); @@ -279,6 +283,10 @@ static int d3d11va_transfer_get_formats(AVHWFramesContext *ctx, fmts[0] = ctx->sw_format; fmts[1] = AV_PIX_FMT_NONE; +// Don't signal support for opaque formats. Actual access would fail. +if (s->format == DXGI_FORMAT_420_OPAQUE) +fmts[0] = AV_PIX_FMT_NONE; + *formats = fmts; return 0; diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h index 676349d7b8..d41451580e 100644 --- a/libavutil/hwcontext_d3d11va.h +++ b/libavutil/hwcontext_d3d11va.h @@ -26,6 +26,10 @@ * The default pool implementation will be fixed-size if initial_pool_size is * set (and allocate elements from an array texture). Otherwise it will allocate * individual textures. Be aware that decoding requires a single array texture. + * + * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to + * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for + * this format. Refer to MSDN for details. */ #include ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: verbose-log decoder GUID list
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:59 2017 +0200| [f0bcedaf37ed4fdb082c88826b8bd3a5dd26382a] | committer: wm4 dxva: verbose-log decoder GUID list Helpful for debugging. Merges Libav commit 068eaa534e7ddb2155e2830818d5c3f1069c68d8. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0bcedaf37ed4fdb082c88826b8bd3a5dd26382a --- libavcodec/dxva2.c | 47 +++ 1 file changed, 47 insertions(+) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 76e8249bef..542607ab3e 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -200,12 +200,59 @@ static int dxva_check_codec_compatibility(AVCodecContext *avctx, const dxva_mode return 1; } +static void dxva_list_guids_debug(AVCodecContext *avctx, void *service, + unsigned guid_count, const GUID *guid_list) +{ +FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); +int i; + +av_log(avctx, AV_LOG_VERBOSE, "Decoder GUIDs reported as supported:\n"); + +for (i = 0; i < guid_count; i++) { +const GUID *guid = _list[i]; + +av_log(avctx, AV_LOG_VERBOSE, + "{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}", + (unsigned) guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], + guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], + guid->Data4[6], guid->Data4[7]); + +#if CONFIG_D3D11VA +if (sctx->pix_fmt == AV_PIX_FMT_D3D11) { +DXGI_FORMAT format; +// We don't know the maximum valid DXGI_FORMAT, so use 200 as +// arbitrary upper bound (that could become outdated). +for (format = 0; format < 200; format++) { +if (d3d11va_validate_output(service, *guid, )) +av_log(avctx, AV_LOG_VERBOSE, " %d", (int)format); +} +} +#endif +#if CONFIG_DXVA2 +if (sctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) { +const D3DFORMAT formats[] = {MKTAG('N', 'V', '1', '2'), + MKTAG('P', '0', '1', '0')}; +int i; +for (i = 0; i < FF_ARRAY_ELEMS(formats); i++) { +if (dxva2_validate_output(service, *guid, [i])) +av_log(avctx, AV_LOG_VERBOSE, " %d", i); +} +} +#endif +av_log(avctx, AV_LOG_VERBOSE, "\n"); +} +} + static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format, unsigned guid_count, const GUID *guid_list, GUID *decoder_guid) { FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); unsigned i, j; +dxva_list_guids_debug(avctx, service, guid_count, guid_list); + *decoder_guid = ff_GUID_NULL; for (i = 0; dxva_modes[i].guid; i++) { const dxva_mode *mode = _modes[i]; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] hwcontext_d3d11va: fix crash on frames_init failure
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:54 2017 +0200| [1509d739a036b9838e12f28dac9f09ac37bc3928] | committer: wm4 hwcontext_d3d11va: fix crash on frames_init failure It appears in this case, frames_ininit is called twice (once by av_hwframe_ctx_init(), and again by unreffing the frames ctx ref). Merges Libav commit 086321c612185469ebb85a1887527c8915b488b7. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1509d739a036b9838e12f28dac9f09ac37bc3928 --- libavutil/hwcontext_d3d11va.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c index 5432dd8b51..0b36a563f1 100644 --- a/libavutil/hwcontext_d3d11va.c +++ b/libavutil/hwcontext_d3d11va.c @@ -104,9 +104,11 @@ static void d3d11va_frames_uninit(AVHWFramesContext *ctx) if (frames_hwctx->texture) ID3D11Texture2D_Release(frames_hwctx->texture); +frames_hwctx->texture = NULL; if (s->staging_texture) ID3D11Texture2D_Release(s->staging_texture); +s->staging_texture = NULL; } static void free_texture(void *opaque, uint8_t *data) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: move d3d11 locking/unlocking to functions
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:10 2017 +0200| [5659f7404731415c7e1cfdf4d8b0afeb6b1132de] | committer: wm4 dxva: move d3d11 locking/unlocking to functions I want to make it non-mandatory to set a mutex in the D3D11 device context, and replacing it with user callbacks seems like the best solution. This is preparation for it. Also makes the code slightly more readable. Merges Libav commit 831cfe10b40414915fe7b6088158421fe02e2b2d. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5659f7404731415c7e1cfdf4d8b0afeb6b1132de --- libavcodec/dxva2.c | 46 -- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 6b214c1877..9138216745 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -29,6 +29,28 @@ #include "avcodec.h" #include "dxva2_internal.h" +static void ff_dxva2_lock(AVCodecContext *avctx) +{ +#if CONFIG_D3D11VA +if (ff_dxva2_is_d3d11(avctx)) { +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); +if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) +WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); +} +#endif +} + +static void ff_dxva2_unlock(AVCodecContext *avctx) +{ +#if CONFIG_D3D11VA +if (ff_dxva2_is_d3d11(avctx)) { +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); +if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) +ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); +} +#endif +} + static void *get_surface(const AVFrame *frame) { return frame->data[3]; @@ -153,14 +175,12 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, unsigned type; do { +ff_dxva2_lock(avctx); #if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) { -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, get_surface(frame), 0, NULL); -} #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) @@ -170,21 +190,13 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, #endif if (hr != E_PENDING || ++runs > 50) break; -#if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -#endif +ff_dxva2_unlock(avctx); av_usleep(2000); } while(1); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); -#if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -#endif +ff_dxva2_unlock(avctx); return -1; } @@ -284,16 +296,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, end: #if CONFIG_D3D11VA -if (ff_dxva2_is_d3d11(avctx)) { +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_DecoderEndFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder); -if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) -ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); -} #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_EndFrame(DXVA2_CONTEXT(ctx)->decoder, NULL); #endif +ff_dxva2_unlock(avctx); if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); result = -1; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: add support for new dxva2 and d3d11 hwaccel APIs
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed Jun 7 17:11:17 2017 +0200| [70143a3954e1c4412efb2bf1a3a818adea2d3abf] | committer: wm4 dxva: add support for new dxva2 and d3d11 hwaccel APIs This also adds support to avconv (which is trivial due to the new hwaccel API being generic enough). The new decoder setup code in dxva2.c is significantly based on work by Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. Merges Libav commit f9e7a2f95a7194a8736cc1416a03a1a0155a3e9f. Also adds untested VP9 support. The check for DXVA2 COBJs is removed. Just update your MinGW to something newer than a 5 year old release. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=70143a3954e1c4412efb2bf1a3a818adea2d3abf --- Changelog | 1 + Makefile| 1 - configure | 30 +- doc/APIchanges | 6 + ffmpeg.h| 2 +- ffmpeg_dxva2.c | 444 - ffmpeg_opt.c| 10 +- libavcodec/allcodecs.c | 6 + libavcodec/dxva2.c | 669 +++- libavcodec/dxva2_h264.c | 22 ++ libavcodec/dxva2_hevc.c | 22 ++ libavcodec/dxva2_internal.h | 43 ++- libavcodec/dxva2_mpeg2.c| 22 ++ libavcodec/dxva2_vc1.c | 44 +++ libavcodec/dxva2_vp9.c | 22 ++ libavcodec/h264_slice.c | 3 +- libavcodec/hevcdec.c| 4 +- libavcodec/mpeg12dec.c | 1 + libavcodec/vc1dec.c | 1 + libavcodec/version.h| 2 +- libavcodec/vp9.c| 3 +- libavutil/hwcontext_dxva2.h | 3 + 22 files changed, 885 insertions(+), 476 deletions(-) diff --git a/Changelog b/Changelog index 24d2255183..a8726c6736 100644 --- a/Changelog +++ b/Changelog @@ -25,6 +25,7 @@ version : - The x86 assembler default switched from yasm to nasm, pass --x86asmexe=yasm to configure to restore the old behavior. - additional frame format support for Interplay MVE movies +- support for decoding through D3D11VA in ffmpeg version 3.3: - CrystalHD decoder moved to new decode API diff --git a/Makefile b/Makefile index aef18185d4..29870d7710 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,6 @@ ifndef CONFIG_VIDEOTOOLBOX OBJS-ffmpeg-$(CONFIG_VDA) += ffmpeg_videotoolbox.o endif OBJS-ffmpeg-$(CONFIG_CUVID) += ffmpeg_cuvid.o -OBJS-ffmpeg-$(HAVE_DXVA2_LIB) += ffmpeg_dxva2.o OBJS-ffserver += ffserver_config.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr tiny_ssim base64 audiomatch diff --git a/configure b/configure index 6ca919be4a..aebd5d5da5 100755 --- a/configure +++ b/configure @@ -2056,8 +2056,6 @@ HAVE_LIST=" alsa atomics_native dos_paths -dxva2_lib -dxva2api_cobj jack libc_msvcrt makeinfo @@ -2594,9 +2592,8 @@ crystalhd_deps="libcrystalhd_libcrystalhd_if_h" cuda_deps_any="dlopen LoadLibrary" cuvid_deps="cuda" d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder ID3D11VideoContext" -dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode" +dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32" dxva2_extralibs="-luser32" -dxva2_lib_deps="dxva2" vda_framework_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension" vda_framework_extralibs="-framework VideoDecodeAcceleration" vda_deps="vda_framework pthreads" @@ -2613,6 +2610,8 @@ h264_cuvid_hwaccel_deps="cuda cuvid" h264_cuvid_hwaccel_select="h264_cuvid_decoder" h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" +h264_d3d11va2_hwaccel_deps="d3d11va" +h264_d3d11va2_hwaccel_select="h264_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_mediacodec_hwaccel_deps="mediacodec" @@ -2633,6 +2632,8 @@ hevc_cuvid_hwaccel_select="hevc_cuvid_decoder" hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_mediacodec_hwaccel_deps="mediacodec" +hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" +hevc_d3d11va2_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_qsv_hwaccel_deps="libmfx" @@ -2656,6 +2657,8 @@ mpeg2_cuvid_hwaccel_deps="cuda cuvid" mpeg2_cuvid_hwaccel_select="mpeg2_cuvid_decoder" mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" +mpeg2_d3d11va2_hwaccel_deps="d3d11va" +mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2
[FFmpeg-cvslog] dxva: fix some warnings
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 22 14:52:53 2017 +0200| [39f201a0ec7913f7509a01fb0fa6634a24e52203] | committer: wm4 dxva: fix some warnings Some existed since forever, some are new. The cast in get_surface() is silly, but unless we change the av_log function signature, or all callers of ff_dxva2_get_surface_index(), it's needed to remove the const warning. Merges Libav commit 752ddb45569ffe278393cd853b70f18ae017219e. Signed-off-by: Luca Barbato <lu_z...@gentoo.org> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39f201a0ec7913f7509a01fb0fa6634a24e52203 --- libavcodec/dxva2.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index f90a7729a3..e9a6605b5f 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -363,7 +363,6 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *avctx, const D3D11_VIDEO_DECODER_DESC *desc, D3D11_VIDEO_DECODER_CONFIG *config) { -FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx); unsigned cfg_count = 0; D3D11_VIDEO_DECODER_CONFIG *cfg_list = NULL; HRESULT hr; @@ -629,7 +628,6 @@ int ff_dxva2_decode_init(AVCodecContext *avctx) if (sctx->pix_fmt == AV_PIX_FMT_D3D11) { AVD3D11VADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx; AVD3D11VAContext *d3d11_ctx = >ctx.d3d11va; -HRESULT hr; ff_dxva2_lock(avctx); ret = d3d11va_create_decoder(avctx); @@ -696,7 +694,7 @@ int ff_dxva2_decode_uninit(AVCodecContext *avctx) return 0; } -static void *get_surface(AVCodecContext *avctx, const AVFrame *frame) +static void *get_surface(const AVCodecContext *avctx, const AVFrame *frame) { #if CONFIG_D3D11VA if (frame->format == AV_PIX_FMT_D3D11) { @@ -704,7 +702,7 @@ static void *get_surface(AVCodecContext *avctx, const AVFrame *frame) intptr_t index = (intptr_t)frame->data[1]; if (index < 0 || index >= sctx->nb_d3d11_views || sctx->d3d11_texture != (ID3D11Texture2D *)frame->data[0]) { -av_log(avctx, AV_LOG_ERROR, "get_buffer frame is invalid!\n"); +av_log((void *)avctx, AV_LOG_ERROR, "get_buffer frame is invalid!\n"); return NULL; } return sctx->d3d11_views[index]; @@ -765,7 +763,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, #endif if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n", - type, hr); + type, (unsigned)hr); return -1; } if (size <= dxva_size) { @@ -807,7 +805,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to release buffer type %u: 0x%x\n", - type, hr); + type, (unsigned)hr); result = -1; } return result; @@ -877,7 +875,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } while(1); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", (unsigned)hr); ff_dxva2_unlock(avctx); return -1; } @@ -972,7 +970,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #endif if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", (unsigned)hr); result = -1; } @@ -987,7 +985,7 @@ end: #endif ff_dxva2_unlock(avctx); if (FAILED(hr)) { -av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", hr); +av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", (unsigned)hr); result = -1; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] dxva: preparations for new hwaccel API
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:09 2017 +0200| [ab28108a361196134704071b7b34c42fc7d747c7] | committer: wm4 dxva: preparations for new hwaccel API The actual hwaccel code will need to access an internal context instead of avctx->hwaccel_context, so add a new DXVA_CONTEXT() macro, that will dispatch between the "old" external and the new internal context. Also, the new API requires a new D3D11 pixfmt, so all places which check for the pixfmt need to be adjusted. Introduce a ff_dxva2_is_d3d11() function, which does the check. Merges Libav commit 4dec101acc393fbfe9a8ce0237b9efbae3f20139. Adds changes to vp9 over the Libav patch. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab28108a361196134704071b7b34c42fc7d747c7 --- libavcodec/dxva2.c | 32 libavcodec/dxva2_h264.c | 14 +++--- libavcodec/dxva2_hevc.c | 10 +- libavcodec/dxva2_internal.h | 22 +- libavcodec/dxva2_mpeg2.c| 10 +- libavcodec/dxva2_vc1.c | 10 +- libavcodec/dxva2_vp9.c | 10 +- 7 files changed, 60 insertions(+), 48 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 0036b5bec1..6b214c1877 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -71,7 +71,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, HRESULT hr = 0; #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type, @@ -91,7 +91,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, memcpy(dxva_data, data, size); #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = dsc; memset(dsc11, 0, sizeof(*dsc11)); dsc11->BufferType = type; @@ -116,7 +116,7 @@ int ff_dxva2_commit_buffer(AVCodecContext *avctx, } #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) hr = ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type); #endif #if CONFIG_DXVA2 @@ -139,7 +139,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice)) { -AVDXVAContext *ctx = avctx->hwaccel_context; +AVDXVAContext *ctx = DXVA_CONTEXT(avctx); unsigned buffer_count = 0; #if CONFIG_D3D11VA D3D11_VIDEO_DECODER_BUFFER_DESC buffer11[4]; @@ -154,7 +154,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, do { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) WaitForSingleObjectEx(D3D11VA_CONTEXT(ctx)->context_mutex, INFINITE, FALSE); hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, @@ -171,7 +171,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (hr != E_PENDING || ++runs > 50) break; #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); #endif @@ -181,7 +181,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (FAILED(hr)) { av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", hr); #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +if (ff_dxva2_is_d3d11(avctx)) if (D3D11VA_CONTEXT(ctx)->context_mutex != INVALID_HANDLE_VALUE) ReleaseMutex(D3D11VA_CONTEXT(ctx)->context_mutex); #endif @@ -189,7 +189,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, } #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +if (ff_dxva2_is_d3d11(avctx)) { buffer = [buffer_count]; type = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS; } @@ -212,7 +212,7 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, if (qm_size > 0) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D
[FFmpeg-cvslog] lavu: add new D3D11 pixfmt and hwcontext
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:07 2017 +0200| [3303511f33dcc1b708fc18072cd93bca62196676] | committer: wm4 lavu: add new D3D11 pixfmt and hwcontext To be used with the new d3d11 hwaccel decode API. With the new hwaccel API, we don't want surfaces to depend on the decoder (other than the required dimension and format). The old D3D11VA pixfmt uses ID3D11VideoDecoderOutputView pointers, which include the decoder configuration, and thus is incompatible with the new hwaccel API. This patch introduces AV_PIX_FMT_D3D11, which uses ID3D11Texture2D and an index. It's simpler and compatible with the new hwaccel API. The introduced hwcontext supports only the new pixfmt. Frame upload code untested. Significantly based on work by Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. Merges Libav commit fff90422d181744cd75dbf011687ee7095f02875. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3303511f33dcc1b708fc18072cd93bca62196676 --- doc/APIchanges | 3 + libavutil/Makefile | 3 + libavutil/hwcontext.c | 4 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 490 + libavutil/hwcontext_d3d11va.h | 160 ++ libavutil/hwcontext_internal.h | 1 + libavutil/pixdesc.c| 4 + libavutil/pixfmt.h | 14 +- libavutil/version.h| 2 +- 10 files changed, 680 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index fc013fd513..857d44402d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-xx-xx - xxx - lavu 56.67.100 - hwcontext.h + Add AV_HWDEVICE_TYPE_D3D11VA and AV_PIX_FMT_D3D11. + 2017-06-24 - xxx - lavf 57.75.100 - avio.h Add AVIO_DATA_MARKER_FLUSH_POINT to signal preferred flush points to aviobuf. diff --git a/libavutil/Makefile b/libavutil/Makefile index 4fe81fdd07..b4464b0d76 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -33,6 +33,7 @@ HEADERS = adler32.h \ hmac.h\ hwcontext.h \ hwcontext_cuda.h \ + hwcontext_d3d11va.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ hwcontext_vaapi.h \ @@ -156,6 +157,7 @@ OBJS = adler32.o \ OBJS-$(!HAVE_ATOMICS_NATIVE)+= atomic.o \ OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o +OBJS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.o OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o OBJS-$(CONFIG_QSV) += hwcontext_qsv.o OBJS-$(CONFIG_LZO) += lzo.o @@ -171,6 +173,7 @@ SLIBOBJS-$(HAVE_GNU_WINDRES)+= avutilres.o SKIPHEADERS-$(HAVE_CUDA_H) += hwcontext_cuda.h SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda_internal.h +SKIPHEADERS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.h SKIPHEADERS-$(CONFIG_DXVA2)+= hwcontext_dxva2.h SKIPHEADERS-$(CONFIG_QSV) += hwcontext_qsv.h SKIPHEADERS-$(CONFIG_VAAPI)+= hwcontext_vaapi.h diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index 5a22194716..2a755a6878 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -32,6 +32,9 @@ static const HWContextType *const hw_table[] = { #if CONFIG_CUDA _hwcontext_type_cuda, #endif +#if CONFIG_D3D11VA +_hwcontext_type_d3d11va, +#endif #if CONFIG_DXVA2 _hwcontext_type_dxva2, #endif @@ -53,6 +56,7 @@ static const HWContextType *const hw_table[] = { static const char *const hw_type_names[] = { [AV_HWDEVICE_TYPE_CUDA] = "cuda", [AV_HWDEVICE_TYPE_DXVA2] = "dxva2", +[AV_HWDEVICE_TYPE_D3D11VA] = "d3d11va", [AV_HWDEVICE_TYPE_QSV]= "qsv", [AV_HWDEVICE_TYPE_VAAPI] = "vaapi", [AV_HWDEVICE_TYPE_VDPAU] = "vdpau", diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index edf12cc631..afb0d80d59 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -32,6 +32,7 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_QSV, AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_NONE, +AV_HWDEVICE_TYPE_D3D11VA, }; typedef struct AVHWDeviceInternal AVHWDeviceInternal; diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c new file mode 100644 index 00
[FFmpeg-cvslog] lavc: set avctx->hwaccel before init
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue Jun 6 18:51:08 2017 +0200| [865360ba633b09f1292d52ba6d07f16b6bcef6df] | committer: wm4 lavc: set avctx->hwaccel before init So a hwaccel can access avctx->hwaccel in init for whatever reason. This is for the new d3d hwaccel API. We could create separate entrypoints for each of the 3 hwaccel types (dxva2, d3d11va, new d3d11va), but this seems nicer. Merges Libav commit bd747b9226414007f0207fa201976af7217e3b77. Signed-off-by: Diego Biurrun <di...@biurrun.de> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=865360ba633b09f1292d52ba6d07f16b6bcef6df --- libavcodec/decode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index f7dea930ed..dccce01402 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1248,16 +1248,16 @@ static int setup_hwaccel(AVCodecContext *avctx, return AVERROR(ENOMEM); } +avctx->hwaccel = hwa; if (hwa->init) { ret = hwa->init(avctx); if (ret < 0) { av_freep(>internal->hwaccel_priv_data); +avctx->hwaccel = NULL; return ret; } } -avctx->hwaccel = hwa; - return 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg: remove misleading and incorrect warning messages
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Thu Jun 15 18:52:14 2017 +0200| [f1df7cc10c62b3d7a8979be36d14b9fb6fc30ff7] | committer: wm4 ffmpeg: remove misleading and incorrect warning messages It is wrong/incorrect in two aspects: 1. The pixel format is not enough to guarantee that the resulting file will be any more compatible with media players. 2. Media players not supporting higher profiles are not necessarily outdated (in fact this is simply an arrogant statement that libavcodec can handle these particular features). You could add that there are plenty of other ways to produce widely incompatible files with ffmpeg, and these don't show any warnings. What we really want to do here is defaulting to codec profiles that have wide compatibility, such as main/high for h264. Also, if an encoder does not accept certain pixfmts, we should automatically convert them to a pixfmt the encoder can accept. But the existing message certainly is not appropriate. It also works for 2 specific encoders only. Extending it for other cases would result in a lot of special cases, so this is not the right place. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f1df7cc10c62b3d7a8979be36d14b9fb6fc30ff7 --- ffmpeg.c | 15 +-- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 6170bd453c..a783e6e04b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -3343,20 +3343,7 @@ static int init_output_stream_encode(OutputStream *ost) ost->frame_aspect_ratio.num ? // overridden by the -aspect cli option av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) : av_buffersink_get_sample_aspect_ratio(ost->filter->filter); -if (!strncmp(ost->enc->name, "libx264", 7) && -enc_ctx->pix_fmt == AV_PIX_FMT_NONE && -av_buffersink_get_format(ost->filter->filter) != AV_PIX_FMT_YUV420P) -av_log(NULL, AV_LOG_WARNING, - "No pixel format specified, %s for H.264 encoding chosen.\n" - "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", - av_get_pix_fmt_name(av_buffersink_get_format(ost->filter->filter))); -if (!strncmp(ost->enc->name, "mpeg2video", 10) && -enc_ctx->pix_fmt == AV_PIX_FMT_NONE && -av_buffersink_get_format(ost->filter->filter) != AV_PIX_FMT_YUV420P) -av_log(NULL, AV_LOG_WARNING, - "No pixel format specified, %s for MPEG-2 encoding chosen.\n" - "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", - av_get_pix_fmt_name(av_buffersink_get_format(ost->filter->filter))); + enc_ctx->pix_fmt = av_buffersink_get_format(ost->filter->filter); if (dec_ctx) enc_ctx->bits_per_raw_sample = FFMIN(dec_ctx->bits_per_raw_sample, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf: consider codec framerate for framerate detection
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Tue May 23 13:36:38 2017 +0200| [66cf78e932956eaa7d5a9dab8766efbfc1431e55] | committer: wm4 lavf: consider codec framerate for framerate detection Fixes detection of some TV sample as 24.5 FPS. With the patch applied, it's detected as 25 FPS. This is enabled for mpegts only. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=66cf78e932956eaa7d5a9dab8766efbfc1431e55 --- libavformat/internal.h | 5 + libavformat/mpegts.c | 2 ++ libavformat/utils.c| 10 ++ 3 files changed, 17 insertions(+) diff --git a/libavformat/internal.h b/libavformat/internal.h index c856945ce9..d136c79bdd 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -145,6 +145,11 @@ struct AVFormatInternal { * ID3v2 tag useful for MP3 demuxing */ AVDictionary *id3v2_meta; + +/* + * Prefer the codec framerate for avg_frame_rate computation. + */ +int prefer_codec_framerate; }; struct AVStreamInternal { diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 3eff1522bd..4d2f5c6802 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -2616,6 +2616,8 @@ static int mpegts_read_header(AVFormatContext *s) int len; int64_t pos, probesize = s->probesize; +s->internal->prefer_codec_framerate = 1; + if (ffio_ensure_seekback(pb, probesize) < 0) av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); diff --git a/libavformat/utils.c b/libavformat/utils.c index c641377385..38d247c6cd 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3904,6 +3904,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->info->codec_info_duration) { int best_fps = 0; double best_error = 0.01; +AVRational codec_frame_rate = avctx->framerate; if (st->info->codec_info_duration>= INT64_MAX / st->time_base.num / 2|| st->info->codec_info_duration_fields >= INT64_MAX / st->time_base.den || @@ -3924,6 +3925,15 @@ FF_ENABLE_DEPRECATION_WARNINGS best_error = error; best_fps = std_fps.num; } + +if (ic->internal->prefer_codec_framerate && codec_frame_rate.num > 0 && codec_frame_rate.den > 0) { +error = fabs(av_q2d(codec_frame_rate) / + av_q2d(std_fps) - 1); +if (error < best_error) { +best_error = error; +best_fps = std_fps.num; +} +} } if (best_fps) av_reduce(>avg_frame_rate.num, >avg_frame_rate.den, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/tls_schannel: log unknown error codes
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed May 31 12:07:43 2017 +0200| [3da13fd6acea0c975625f719640f1c14b48da434] | committer: wm4 avformat/tls_schannel: log unknown error codes > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3da13fd6acea0c975625f719640f1c14b48da434 --- libavformat/tls_schannel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/tls_schannel.c b/libavformat/tls_schannel.c index 065dccb020..9f1c08806f 100644 --- a/libavformat/tls_schannel.c +++ b/libavformat/tls_schannel.c @@ -494,7 +494,7 @@ static int tls_read(URLContext *h, uint8_t *buf, int len) ret = AVERROR(EAGAIN); goto cleanup; } else { -av_log(h, AV_LOG_ERROR, "Unable to decrypt message\n"); +av_log(h, AV_LOG_ERROR, "Unable to decrypt message (error 0x%x)\n", (unsigned)sspi_ret); ret = AVERROR(EIO); goto cleanup; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] videotoolbox: log errors
ffmpeg | branch: master | wm4 <nfx...@googlemail.com> | Wed May 24 15:46:39 2017 +0200| [01602303821768013253749959f1367fa710f27d] | committer: wm4 videotoolbox: log errors With the new decode API, you can't handle errors directly in the API user - you only know that the hwaccel did not initialize at all. Add some approximate logging. > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=01602303821768013253749959f1367fa710f27d --- libavcodec/videotoolbox.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index d36a33efcd..1b1be41934 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -648,15 +648,21 @@ static int videotoolbox_default_init(AVCodecContext *avctx) switch (status) { case kVTVideoDecoderNotAvailableNowErr: +av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox session not available.\n"); +return AVERROR(ENOSYS); case kVTVideoDecoderUnsupportedDataFormatErr: +av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this format.\n"); return AVERROR(ENOSYS); case kVTVideoDecoderMalfunctionErr: +av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n"); return AVERROR(EINVAL); case kVTVideoDecoderBadDataErr : +av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox reported invalid data.\n"); return AVERROR_INVALIDDATA; case 0: return 0; default: +av_log(avctx, AV_LOG_VERBOSE, "Unknown VideoToolbox session creation error %u\n", (unsigned)status); return AVERROR_UNKNOWN; } } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog