Re: [FFmpeg-devel] [PATCH] Replace br return with ret
Hi, Just wondering what current thoughts on the patch was. It looks as though the change is fine, but if there is still an issue I can submit a new patch using BTI landing pads instead. Best regards, Casey. On 7/27/23 18:22, Reimar Döffinger wrote: On 27 Jul 2023, at 15:55, Rémi Denis-Courmont wrote: Hi, The use of RET vs BR also has microarchitectural side effects. AFAIU, RET should always be paired with an earlier BL/BLR to avoid interfering with branch prediction. So depending on the circumstances, either one of these should be addressed: * Clarify that this is actually a function return , and RET should be used anyway, regardless of BTI. * Keep BR and add BTI J landing pads where appropriate, if this wasn't really a function return. Yes BL and RET is best to match up. For this function: % git grep func_tr_32x4 libavcodec/aarch64/hevcdsp_idct_neon.S:function func_tr_32x4_\name libavcodec/aarch64/hevcdsp_idct_neon.S:bl func_tr_32x4_firstpass libavcodec/aarch64/hevcdsp_idct_neon.S:bl func_tr_32x4_secondpass_\bitdepth libavcodec/arm/hevcdsp_idct_neon.S:function func_tr_32x4_\name libavcodec/arm/hevcdsp_idct_neon.S:bl func_tr_32x4_firstpass libavcodec/arm/hevcdsp_idct_neon.S:bl func_tr_32x4_secondpass_\bitdepth It is always used with "bl", thus ret is also more correct from that aspect. Was your comment only on checking that, or did you mean that this should be mentioned in the commit message? (if you are wondering why the code did not use ret before, I guess it's because it was ported from the 32-bit arm assembler and it slipped by code review) Best regards, Reimar ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v6 1/3] tests/fate/flvenc: add hevc in enhanced flv test case
Steven Liu 于2023年7月24日周一 17:20写道: > > Signed-off-by: Steven Liu > --- > tests/fate/flvenc.mak| 7 +- > tests/ref/fate/enhanced-flv-hevc | 258 +++ > 2 files changed, 264 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/enhanced-flv-hevc > > diff --git a/tests/fate/flvenc.mak b/tests/fate/flvenc.mak > index 5032fface3..406d04db1d 100644 > --- a/tests/fate/flvenc.mak > +++ b/tests/fate/flvenc.mak > @@ -1,5 +1,10 @@ > FATE_FLVENC_FFMPEG_FFPROBE-$(call TRANSCODE, FLV, FLV, RAWVIDEO_DECODER > SCALE_FILTER TESTSRC_FILTER LAVFI_INDEV) += fate-flv-add_keyframe_index > fate-flv-add_keyframe_index: CMD = transcode "lavfi -graph > testsrc=r=7:n=2:d=20" "foo" flv "-vf scale -c:v flv1 -dct int -g 7 -flvflags > add_keyframe_index" "-c copy -t 0.1" "-show_entries format_tags" > > +FATE_ENHANCED_FLVENC_FFMPEG-$(call REMUX, FLV MOV, FLV_DEMUXER HEVC_PARSER) > += fate-enhanced-flv-hevc > +fate-enhanced-flv-hevc: CMD = transcode mov $(TARGET_SAMPLES)/hevc/dv84.mov\ > + flv "-c copy" "-c copy" > + > FATE_FFMPEG_FFPROBE += $(FATE_FLVENC_FFMPEG_FFPROBE-yes) > -fate-flvenc: $(FATE_FLVENC_FFMPEG_FFPROBE-yes) > +FATE_SAMPLES_FFMPEG += $(FATE_ENHANCED_FLVENC_FFMPEG-yes) > +fate-flvenc: $(FATE_FLVENC_FFMPEG_FFPROBE-yes) > $(FATE_ENHANCED_FLVENC_FFMPEG-yes) > diff --git a/tests/ref/fate/enhanced-flv-hevc > b/tests/ref/fate/enhanced-flv-hevc > new file mode 100644 > index 00..3799f1f50b > --- /dev/null > +++ b/tests/ref/fate/enhanced-flv-hevc > @@ -0,0 +1,258 @@ > +e7030c9d4301afbbe0ec6f6899a80bdc *tests/data/fate/enhanced-flv-hevc.flv > +3602600 tests/data/fate/enhanced-flv-hevc.flv > +#extradata 0: 551, 0xa18acf66 > +#extradata 1:2, 0x00340022 > +#tb 0: 1/1000 > +#media_type 0: video > +#codec_id 0: hevc > +#dimensions 0: 1920x1080 > +#sar 0: 0/1 > +#tb 1: 1/1000 > +#media_type 1: audio > +#codec_id 1: aac > +#sample_rate 1: 44100 > +#channel_layout_name 1: stereo > +0, 0, 0, 33,63375, 0xc76606ab > +0, 33, 33, 33,46706, 0x0e08a7e5, F=0x0 > +0, 66, 66, 33,29766, 0x753c031a, F=0x0 > +1, 68, 68, 23,6, 0x031e0108 > +1, 91, 91, 23, 251, 0x6b4a7cbd > +0,100,100, 33,19409, 0x4b948b6c, F=0x0 > +1,114,114, 23, 389, 0x6673c205 > +0,133,133, 33,21086, 0x1b9412ce, F=0x0 > +1,138,138, 23, 356, 0x8c71a316 > +1,161,161, 23, 339, 0x3018a45a > +0,166,166, 33,62043, 0xc2356b56, F=0x0 > +1,184,184, 23, 405, 0xc89ebe05 > +0,200,200, 33,36175, 0x0a7df38c, F=0x0 > +1,207,207, 23, 449, 0x42eadf96 > +1,231,231, 23, 416, 0x28a7c9b9 > +0,233,233, 33,16028, 0xa57fcbe9, F=0x0 > +1,254,254, 23, 426, 0x9a74d4ec > +0,266,266, 33,15428, 0x9a91f357, F=0x0 > +1,277,277, 23, 419, 0xbe3dc54b > +0,300,300, 33,66072, 0xa542b6d7, F=0x0 > +1,300,300, 23, 424, 0x5102d50e > +1,323,323, 23, 402, 0xb11cc14c > +0,333,333, 33,34985, 0xbfd8ff45, F=0x0 > +1,347,347, 23, 401, 0x3820b8f9 > +0,366,366, 33,16036, 0xfc39c6ea, F=0x0 > +1,370,370, 23, 400, 0xe5c4c168 > +1,393,393, 23, 435, 0x6dbecc33 > +0,400,400, 33,19893, 0x7e746f4e, F=0x0 > +1,416,416, 23, 441, 0x0ad3d199 > +0,433,433, 33,77576, 0xeba2e5c8, F=0x0 > +1,440,440, 23, 479, 0x44dce967 > +1,463,463, 23, 439, 0x7d85e4c9 > +0,466,466, 33,35400, 0xbe179462, F=0x0 > +1,486,486, 23, 461, 0xca18e36b > +0,500,500, 33,15962, 0x7703dcd8, F=0x0 > +1,509,509, 23, 498, 0xf73befd7 > +1,532,532, 23, 469, 0x0119e958 > +0,533,533, 33,16136, 0x78a74880, F=0x0 > +1,556,556, 23, 472, 0x4980e108 > +0,566,566, 33,74990, 0xb6fc1da7, F=0x0 > +1,579,579, 23, 488, 0x42baeb77 > +0,600,600, 33,36594, 0xc3c61c3e, F=0x0 > +1,602,602, 23, 458, 0x2198dde8 > +1,625,625, 23, 430, 0x0858cc8f > +0,633,633, 33,16524, 0xb297a886, F=0x0 > +1,648,648, 23, 464, 0x9590e068 > +0,666,666, 33,17033, 0x31b3dd63, F=0x0 > +1,672
Re: [FFmpeg-devel] [PATCH 06/15] avcodec/avcodec: Remove unnecessary forward declaration
Andreas Rheinhardt: > This would only be necessary if this header declared a function > that takes a (pointer to) struct AVCodecContext as parameter. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/avcodec.h | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index a2680256d7..649411ac79 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -421,8 +421,6 @@ typedef struct RcOverride{ > */ > #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0) > > -struct AVCodecInternal; > - > /** > * main external API structure. > * New fields can be added to the end with minor version bumps. Will apply the part of this patchset that does not deal with the addition of hwaccel_internal.h tomorrow unless there are objections. Also: Ping for the hwaccel_internal.h patches. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Replace br return with ret
On Thu, 27 Jul 2023, Rémi Denis-Courmont wrote: Hi, The use of RET vs BR also has microarchitectural side effects. AFAIU, RET should always be paired with an earlier BL/BLR to avoid interfering with branch prediction. So depending on the circumstances, either one of these should be addressed: * Clarify that this is actually a function return , and RET should be used anyway, regardless of BTI. This is the case, and the patch looks good to me. I guess the commit message could be clarified that this is an issue even without BTI (even if the effect is much harder to notice there). Would this amended commit message be ok with you? (If no input I guess I'll push it in a few days.) ---8<--- Subject: aarch64/hevc: Replace br return with ret This patch changes the return instruction in the tr_32x4 macro from br to ret. Function returns should always use the RET instruction instead of BR, to avoid interfering with branch prediction. On devices that support BTI, this is observeable as a landing pad is required when branching with BR. The change fixes fate-hevc-hdr-vivid-metadata when on hardware with BTI support. ---8<--- // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 0/4] Add passthrough support for SCTE-35
On Mon, Jul 31, 2023 at 9:38 AM Devin Heitmueller wrote: > > Properly set up the MPEG-TS mux and recalculate the pts_adjust field > in SCTE_35 packets, such that a user can transparently pass through > SCTE-35 streams when both the input and output are MPEG-TS. > > This patch series updated to reflect feedback from James Almer. > > Devin Heitmueller (4): > avcodec: Add new side data type to contain original PTS value > mpegts: Stash original PTS for SCTE-35 sections for processing later > mpegtsenc: Add support for output of SCTE-35 streams over TS > bsf: Add new bitstream filter to set SCTE-35 pts_adjustment when > reclocking > > doc/bitstream_filters.texi | 9 > libavcodec/Makefile | 1 + > libavcodec/bitstream_filters.c | 1 + > libavcodec/defs.h| 12 + > libavcodec/packet.h | 11 + > libavcodec/scte35ptsadjust_bsf.c | 100 > +++ > libavformat/mpegts.c | 11 - > libavformat/mpegts.h | 1 + > libavformat/mpegtsenc.c | 76 +++-- > libavformat/mux.c| 6 ++- > 10 files changed, 221 insertions(+), 7 deletions(-) > create mode 100644 libavcodec/scte35ptsadjust_bsf.c > > -- > 1.8.3.1 > ping. -- Devin Heitmueller, Senior Software Engineer LTN Global Communications o: +1 (301) 363-1001 w: https://ltnglobal.com e: devin.heitmuel...@ltnglobal.com ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] intreadwrite: Indicate potential aliasing in AV_RN/AV_WN for Clang/MSVC mode
Use the GCC specific codepath for Clang in MSVC mode too. This matches the condition used in a number of other places. MSVC doesn't have a way to signal potential aliasing, while GCC (and Clang) can use __attribute__((may_alias)) for this purpose. When building with Clang in MSVC mode, __GNUC__ isn't defined but _MSC_VER is as Clang primarily impersonates MSVC - but even then it does support the GCC style attributes. The GCC specific codepath uses av_alias, which expands to the may_alias attribute if supported. The MSVC specific codepath doesn't use av_alias so far (as MSVC doesn't support any corresponding attribute). This fixes a couple HEVC decoder tests when built with Clang 14 or newer in MSVC mode (with issues observed on all of x86_64, armv7 and aarch64). --- v2: Changed to just use the GCC specific codepath here, as suggested by Andreas on irc. Will push if there's no objections. --- libavutil/intreadwrite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h index c4679fdba4..21df7887f3 100644 --- a/libavutil/intreadwrite.h +++ b/libavutil/intreadwrite.h @@ -213,7 +213,7 @@ typedef union { * by per-arch headers. */ -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] tests: Correctly distinguish between SAMPLES and TARGET_SAMPLES for hls_fmp4_ac3.m3u8
On Wed, 2 Aug 2023, Martin Storsjö wrote: This fixes the test when running in a cross test setup where the samples are located at a different path between build host and temote test target. --- tests/fate/hlsenc.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fate/hlsenc.mak b/tests/fate/hlsenc.mak index 7df74f1f63..8118d5b925 100644 --- a/tests/fate/hlsenc.mak +++ b/tests/fate/hlsenc.mak @@ -100,7 +100,7 @@ fate-hls-fmp4: CMD = framecrc -auto_conversion_filters -flags +bitexact -i $(TAR tests/data/hls_fmp4_ac3.m3u8: TAG = GEN tests/data/hls_fmp4_ac3.m3u8: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin \ - -stream_loop 4 -i $(SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 -c copy -map 0 \ + -stream_loop 4 -i $(TARGET_SAMPLES)/ac3/monsters_inc_5.1_448_small.ac3 -c copy -map 0 \ -hls_segment_type fmp4 -hls_fmp4_init_filename now_ac3.mp4 -hls_list_size 0 \ -hls_time 2 -hls_segment_filename "$(TARGET_PATH)/tests/data/hls_fmp4_ac3_%d.m4s" \ $(TARGET_PATH)/tests/data/hls_fmp4_ac3.m3u8 2>/dev/null -- 2.34.1 Will push later as this is rather trivial fix. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] w32pthreads: Fix function signature mismatches for CreateThread
On Wed, 2 Aug 2023, Martin Storsjö wrote: In WinRT mode, we use CreateThread instead of _beginthreadex. CreateThread takes a LPTHREAD_START_ROUTINE function pointer, which has got the signature DWORD WINAPI ThreadProc(LPVOID). _beginthreadex takes a function with the signature unsigned __stdcall func(void *). DWORD is defined as an unsigned long, which is different type from unsigned int, even if they have the same size on Windows. This fixes build failures with Clang 16 and newer, where function pointer type mismatches are a fatal error by default. --- compat/w32pthreads.h | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index 6405e72b64..dae8d9420d 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -66,7 +66,14 @@ typedef CONDITION_VARIABLE pthread_cond_t; #define PTHREAD_CANCEL_ENABLE 1 #define PTHREAD_CANCEL_DISABLE 0 -static av_unused unsigned __stdcall attribute_align_arg win32thread_worker(void *arg) +#if HAVE_WINRT +#define THREADFUNC_RETTYPE DWORD +#else +#define THREADFUNC_RETTYPE unsigned +#endif + +static av_unused THREADFUNC_RETTYPE +__stdcall attribute_align_arg win32thread_worker(void *arg) { pthread_t *h = (pthread_t*)arg; h->ret = h->func(h->arg); -- 2.34.1 Will push soon if there's no objections, as this is rather trivial. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] os_support, network: Fix build failure on Windows with BZIP2
On Thu, 27 Jul 2023, L. E. Segovia wrote: Including winsock2.h without WIN32_LEAN_AND_MEAN causes bzlib.h to parse as nonsense, due to an instance of #define char small in rpcndr.h (included transitively from windows.h). See: https://stackoverflow.com/a/27794577 Signed-off-by: L. E. Segovia --- libavformat/network.h| 1 + libavformat/os_support.c | 6 ++ libavformat/os_support.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) The change looks mostly reasonable to me I think, and WIN32_LEAN_AND_MEAN is generally beneficial. I've got a couple comments below though. diff --git a/libavformat/network.h b/libavformat/network.h index ca214087fc..06b6117fc7 100644 --- a/libavformat/network.h +++ b/libavformat/network.h @@ -35,6 +35,7 @@ #endif #if HAVE_WINSOCK2_H +#define WIN32_LEAN_AND_MEAN #include #include The diff seems very hard to apply. The diff stat above says that this shows a snippet of 6 lines originally, 7 lines after the modification - but in fact the diff only shows 4 lines originally and 5 lines after the modification. I don't know what has happened to the patch, but it makes it hard to apply automatically. diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 15cea7fa5b..2de6a7c3d9 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -34,11 +34,9 @@ #if HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ -#if HAVE_WINSOCK2_H -#include -#elif HAVE_SYS_SELECT_H +#if HAVE_SYS_SELECT_H #include -#endif /* HAVE_WINSOCK2_H */ +#endif /* HAVE_SYS_SELECT_H */ #endif /* !HAVE_POLL_H */ #include "network.h" I presume this is done to avoid touching winsock2.h here, as the headers that we've included already define this? // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] os_support, network: Fix build failure on Windows with BZIP2
On Fri, 4 Aug 2023, Martin Storsjö wrote: On Thu, 27 Jul 2023, L. E. Segovia wrote: Including winsock2.h without WIN32_LEAN_AND_MEAN causes bzlib.h to parse as nonsense, due to an instance of #define char small in rpcndr.h (included transitively from windows.h). See: https://stackoverflow.com/a/27794577 Signed-off-by: L. E. Segovia --- libavformat/network.h| 1 + libavformat/os_support.c | 6 ++ libavformat/os_support.h | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) The change looks mostly reasonable to me I think, and WIN32_LEAN_AND_MEAN is generally beneficial. I've got a couple comments below though. Alternatively, I guess we could consider adding WIN32_LEAN_AND_MEAN in configure somewhere instead? That way we don't need to hunt down any potential stray includes of windows.h/winsock2.h if they are added elsewhere. // Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 1/9] libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12
From: Wu Jianhua Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 5 + doc/APIchanges | 7 + libavutil/Makefile | 3 + libavutil/hwcontext.c | 4 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d12va.c | 703 + libavutil/hwcontext_d3d12va.h | 169 ++ libavutil/hwcontext_d3d12va_internal.h | 59 +++ libavutil/hwcontext_internal.h | 1 + libavutil/pixdesc.c| 4 + libavutil/pixfmt.h | 9 + libavutil/tests/hwdevice.c | 2 + libavutil/version.h| 2 +- 13 files changed, 968 insertions(+), 1 deletion(-) create mode 100644 libavutil/hwcontext_d3d12va.c create mode 100644 libavutil/hwcontext_d3d12va.h create mode 100644 libavutil/hwcontext_d3d12va_internal.h diff --git a/configure b/configure index 99388e7664..9919551ad0 100755 --- a/configure +++ b/configure @@ -338,6 +338,7 @@ External library support: --disable-cuda-llvm disable CUDA compilation using clang [autodetect] --disable-cuvid disable Nvidia CUVID support [autodetect] --disable-d3d11vadisable Microsoft Direct3D 11 video acceleration code [autodetect] + --disable-d3d12vadisable Microsoft Direct3D 12 video acceleration code [autodetect] --disable-dxva2 disable Microsoft DirectX 9 video acceleration code [autodetect] --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] --enable-libdrm enable DRM code (Linux) [no] @@ -1926,6 +1927,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST=" cuda_llvm cuvid d3d11va +d3d12va dxva2 ffnvcodec nvdec @@ -3053,6 +3055,7 @@ crystalhd_deps="libcrystalhd_libcrystalhd_if_h" cuda_deps="ffnvcodec" cuvid_deps="ffnvcodec" d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" +d3d12va_deps="dxva_h ID3D12Device ID3D12VideoDecoder" dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" ffnvcodec_deps_any="libdl LoadLibrary" mediacodec_deps="android" @@ -6543,6 +6546,8 @@ check_type "windows.h dxgi1_2.h" "IDXGIOutput1" check_type "windows.h dxgi1_5.h" "IDXGIOutput5" check_type "windows.h d3d11.h" "ID3D11VideoDecoder" check_type "windows.h d3d11.h" "ID3D11VideoContext" +check_type "windows.h d3d12.h" "ID3D12Device" +check_type "windows.h d3d12video.h" "ID3D12VideoDecoder" check_type "windows.h" "DPI_AWARENESS_CONTEXT" -D_WIN32_WINNT=0x0A00 check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 check_func_headers mfapi.h MFCreateAlignedMemoryBuffer -lmfplat diff --git a/doc/APIchanges b/doc/APIchanges index 5afe8bcb75..c14ab0b394 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,13 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-07-xx - xx - lavu 58.15.100 - pixfmt.h hwcontext.h hwcontext_d3d12va.h + Add AV_HWDEVICE_TYPE_D3D12VA and AV_PIX_FMT_D3D12. + Add AVD3D12VADeviceContext, AVD3D12VASyncContext, AVD3D12FrameDescriptor, + and AVD3D12VAFramesContext. + Add av_d3d12va_map_sw_to_hw_format, av_d3d12va_create_sync_context, + av_d3d12va_release_sync_context, av_d3d12va_wait_idle, and av_d3d12va_wait_queue_idle. + 2023-07-xx - xx - lavc 60 - avcodec.h Deprecate AV_CODEC_FLAG_DROPCHANGED without replacement. diff --git a/libavutil/Makefile b/libavutil/Makefile index bd9c6f9e32..40d49d76dd 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -41,6 +41,7 @@ HEADERS = adler32.h \ hwcontext.h \ hwcontext_cuda.h \ hwcontext_d3d11va.h \ + hwcontext_d3d12va.h \ hwcontext_drm.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ @@ -186,6 +187,7 @@ OBJS = adler32.o \ OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o OBJS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.o +OBJS-$(CONFIG_D3D12VA) += hwcontext_d3d12va.o OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o @@ -209,6 +211,7 @@ SKIPHEADERS-$(HAVE_CUDA_H) += hwcontext_cuda.h SKIPHEADERS-$(CONFIG_CUDA) += hwcontext_cuda_internal.h \ cuda_check.h SKIPHEADERS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.h +SKIPHEADERS-$(CONFIG_D3D1
[FFmpeg-devel] [PATCH v5 2/9] avcodec: add D3D12VA hardware accelerated H264 decoding
From: Wu Jianhua The implementation is based on: https://learn.microsoft.com/en-us/windows/win32/medfound/direct3d-12-video-overview With the Direct3D 12 video decoding support, we can render or process the decoded images by the pixel shaders or compute shaders directly without the extra copy overhead, which is beneficial especially if you are trying to render or post-process a 4K or 8K video. The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 3 + libavcodec/d3d11va.h| 3 - libavcodec/d3d12va_decode.c | 533 libavcodec/d3d12va_decode.h | 182 libavcodec/d3d12va_h264.c | 210 ++ libavcodec/dxva2.c | 24 ++ libavcodec/dxva2.h | 3 - libavcodec/dxva2_h264.c | 12 +- libavcodec/dxva2_internal.h | 67 ++--- libavcodec/h264_slice.c | 4 + libavcodec/h264dec.c| 3 + libavcodec/hwaccels.h | 1 + libavcodec/hwconfig.h | 2 + 14 files changed, 1007 insertions(+), 42 deletions(-) create mode 100644 libavcodec/d3d12va_decode.c create mode 100644 libavcodec/d3d12va_decode.h create mode 100644 libavcodec/d3d12va_h264.c diff --git a/configure b/configure index 9919551ad0..8c5790b046 100755 --- a/configure +++ b/configure @@ -3087,6 +3087,8 @@ h264_d3d11va_hwaccel_deps="d3d11va" h264_d3d11va_hwaccel_select="h264_decoder" h264_d3d11va2_hwaccel_deps="d3d11va" h264_d3d11va2_hwaccel_select="h264_decoder" +h264_d3d12va_hwaccel_deps="d3d12va" +h264_d3d12va_hwaccel_select="h264_decoder" h264_dxva2_hwaccel_deps="dxva2" h264_dxva2_hwaccel_select="h264_decoder" h264_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3c16b51462..8d45b02334 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -982,6 +982,7 @@ OBJS-$(CONFIG_ADPCM_ZORK_DECODER) += adpcm.o adpcm_data.o # hardware accelerators OBJS-$(CONFIG_D3D11VA)+= dxva2.o +OBJS-$(CONFIG_D3D12VA)+= dxva2.o d3d12va_decode.o OBJS-$(CONFIG_DXVA2) += dxva2.o OBJS-$(CONFIG_NVDEC) += nvdec.o OBJS-$(CONFIG_VAAPI) += vaapi_decode.o @@ -999,6 +1000,7 @@ OBJS-$(CONFIG_H263_VAAPI_HWACCEL) += vaapi_mpeg4.o OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_H264_D3D11VA_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o +OBJS-$(CONFIG_H264_D3D12VA_HWACCEL) += dxva2_h264.o d3d12va_h264.o OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o OBJS-$(CONFIG_H264_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o @@ -1288,6 +1290,7 @@ SKIPHEADERS+= %_tablegen.h \ SKIPHEADERS-$(CONFIG_AMF) += amfenc.h SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h +SKIPHEADERS-$(CONFIG_D3D12VA) += d3d12va_decode.h SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_JNI) += ffjni.h SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h diff --git a/libavcodec/d3d11va.h b/libavcodec/d3d11va.h index 6816b6c1e6..27f40e5519 100644 --- a/libavcodec/d3d11va.h +++ b/libavcodec/d3d11va.h @@ -45,9 +45,6 @@ * @{ */ -#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for Direct3D11 and old UVD/UVD+ ATI video cards -#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO2 ///< Work around for Direct3D11 and old Intel GPUs with ClearVideo interface - /** * This structure is used to provides the necessary configurations and data * to the Direct3D11 FFmpeg HWAccel implementation. diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c new file mode 100644 index 00..7e516eb7dc --- /dev/null +++ b/libavcodec/d3d12va_decode.c @@ -0,0 +1,533 @@ +/* + * Direct3D 12 HW acceleration video decoder + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include +#include +#include + +#include "libavutil/c
[FFmpeg-devel] [PATCH v5 3/9] avcodec: add D3D12VA hardware accelerated HEVC decoding
From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 1 + libavcodec/d3d12va_hevc.c | 211 libavcodec/dxva2_hevc.c | 10 +- libavcodec/dxva2_internal.h | 4 + libavcodec/hevcdec.c| 10 ++ libavcodec/hwaccels.h | 1 + 7 files changed, 235 insertions(+), 4 deletions(-) create mode 100644 libavcodec/d3d12va_hevc.c diff --git a/configure b/configure index 8c5790b046..fc82bbc3a7 100755 --- a/configure +++ b/configure @@ -3105,6 +3105,8 @@ hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va_hwaccel_select="hevc_decoder" hevc_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_HEVC" hevc_d3d11va2_hwaccel_select="hevc_decoder" +hevc_d3d12va_hwaccel_deps="d3d12va DXVA_PicParams_HEVC" +hevc_d3d12va_hwaccel_select="hevc_decoder" hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" hevc_dxva2_hwaccel_select="hevc_decoder" hevc_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 8d45b02334..033bb5d505 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1009,6 +1009,7 @@ OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_H264_VULKAN_HWACCEL)+= vulkan_decode.o vulkan_h264.o OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL) += dxva2_hevc.o OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o +OBJS-$(CONFIG_HEVC_D3D12VA_HWACCEL) += dxva2_hevc.o d3d12va_hevc.o OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c new file mode 100644 index 00..894fa73d60 --- /dev/null +++ b/libavcodec/d3d12va_hevc.c @@ -0,0 +1,211 @@ +/* + * Direct3D 12 HEVC HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include "config_components.h" + +#include "libavutil/avassert.h" +#include "libavutil/hwcontext_d3d12va_internal.h" +#include "hevc_data.h" +#include "hevcdec.h" +#include "dxva2_internal.h" +#include "d3d12va_decode.h" +#include + +#define MAX_SLICES 256 + +typedef struct HEVCDecodePictureContext { +DXVA_PicParams_HEVCpp; +DXVA_Qmatrix_HEVC qm; +unsigned slice_count; +DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]; +const uint8_t *bitstream; +unsigned bitstream_size; +} HEVCDecodePictureContext; + +static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size) +{ +memset(slice, 0, sizeof(*slice)); +slice->BSNALunitDataLocation = position; +slice->SliceBytesInBuffer= size; +slice->wBadSliceChopping = 0; +} + +static int d3d12va_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ +const HEVCContext*h = avctx->priv_data; +D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); +HEVCDecodePictureContext *ctx_pic = h->ref->hwaccel_picture_private; + +if (!ctx) +return -1; + +av_assert0(ctx_pic); + +ff_dxva2_hevc_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp); + +ff_dxva2_hevc_fill_scaling_lists(avctx, (AVDXVAContext *)ctx, &ctx_pic->qm); + +ctx_pic->slice_count= 0; +ctx_pic->bitstream_size = 0; +ctx_pic->bitstream = NULL; + +return 0; +} + +static int d3d12va_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ +const HEVCContext*h = avctx->priv_data; +const HEVCFrame *current_picture = h->ref; +HEVCDecodePictureContext *ctx_pic = current_picture->hwaccel_picture_private; +unsigned position; + +if (ctx_pic->slice_count >= MAX_SLICES) +return AVERROR(ERANGE); + +if (!ctx_pic->bitstream) +ctx_pic->bitstream = buffer; +ctx_pic->bitstream_size += size; + +position = buffer - ctx_pic->bitstream; +fill_slice_short(&ct
[FFmpeg-devel] [PATCH v5 4/9] avcodec: add D3D12VA hardware accelerated VP9 decoding
From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 1 + libavcodec/d3d12va_vp9.c| 176 libavcodec/dxva2_internal.h | 2 + libavcodec/dxva2_vp9.c | 7 +- libavcodec/hwaccels.h | 1 + libavcodec/vp9.c| 7 ++ 7 files changed, 193 insertions(+), 3 deletions(-) create mode 100644 libavcodec/d3d12va_vp9.c diff --git a/configure b/configure index fc82bbc3a7..0339630e7e 100755 --- a/configure +++ b/configure @@ -3173,6 +3173,8 @@ vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" vp9_d3d11va_hwaccel_select="vp9_decoder" vp9_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_VP9" vp9_d3d11va2_hwaccel_select="vp9_decoder" +vp9_d3d12va_hwaccel_deps="d3d12va DXVA_PicParams_VP9" +vp9_d3d12va_hwaccel_select="vp9_decoder" vp9_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_VP9" vp9_dxva2_hwaccel_select="vp9_decoder" vp9_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 033bb5d505..9ef49a8da5 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1041,6 +1041,7 @@ OBJS-$(CONFIG_VP8_NVDEC_HWACCEL) += nvdec_vp8.o OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL)+= dxva2_vp9.o OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o +OBJS-$(CONFIG_VP9_D3D12VA_HWACCEL)+= dxva2_vp9.o d3d12va_vp9.o OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o diff --git a/libavcodec/d3d12va_vp9.c b/libavcodec/d3d12va_vp9.c new file mode 100644 index 00..5535c8bad0 --- /dev/null +++ b/libavcodec/d3d12va_vp9.c @@ -0,0 +1,176 @@ +/* + * Direct3D 12 VP9 HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include "config_components.h" + +#include "libavutil/avassert.h" +#include "libavutil/pixdesc.h" +#include "libavutil/hwcontext_d3d12va_internal.h" + +#include "vp9shared.h" +#include "dxva2_internal.h" +#include "d3d12va_decode.h" + +typedef struct VP9DecodePictureContext { +DXVA_PicParams_VP9pp; +DXVA_Slice_VPx_Short slice; +const uint8_t*bitstream; +unsigned bitstream_size; +} VP9DecodePictureContext; + +static void fill_slice_short(DXVA_Slice_VPx_Short *slice, unsigned position, unsigned size) +{ +memset(slice, 0, sizeof(*slice)); +slice->BSNALunitDataLocation = position; +slice->SliceBytesInBuffer= size; +slice->wBadSliceChopping = 0; +} + +static int d3d12va_vp9_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ +const VP9SharedContext *h = avctx->priv_data; +D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); +VP9DecodePictureContext *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; + +if (!ctx) +return -1; + +av_assert0(ctx_pic); + +if (ff_dxva2_vp9_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp) < 0) +return -1; + +ctx_pic->bitstream_size = 0; +ctx_pic->bitstream = NULL; + +return 0; +} + +static int d3d12va_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ +const VP9SharedContext *h = avctx->priv_data; +VP9DecodePictureContext *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private; +unsigned position; + +if (!ctx_pic->bitstream) +ctx_pic->bitstream = buffer; +ctx_pic->bitstream_size += size; + +position = buffer - ctx_pic->bitstream; +fill_slice_short(&ctx_pic->slice, position, size); + +return 0; +} + +static int update_input_arguments(AVCodecContext *avctx, D3D12_VIDEO_DECODE_INPUT_STREAM_ARGUMENTS *input_args, ID3D12Resource *buffer) +{ +D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); +AVHWFramesContext *frames_ctx = D3D12VA_FRAMES_CONTEXT(avctx); +AVD3D12VAFramesContext *frames_hwctx = frames_ctx->hwctx; + +const VP9Shared
[FFmpeg-devel] [PATCH v5 5/9] avcodec: add D3D12VA hardware accelerated AV1 decoding
From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 1 + libavcodec/av1dec.c | 10 ++ libavcodec/d3d12va_av1.c| 220 libavcodec/dxva2_av1.c | 5 +- libavcodec/dxva2_internal.h | 4 + libavcodec/hwaccels.h | 1 + 7 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 libavcodec/d3d12va_av1.c diff --git a/configure b/configure index 0339630e7e..c97d7a4874 100755 --- a/configure +++ b/configure @@ -3069,6 +3069,8 @@ av1_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_AV1" av1_d3d11va_hwaccel_select="av1_decoder" av1_d3d11va2_hwaccel_deps="d3d11va DXVA_PicParams_AV1" av1_d3d11va2_hwaccel_select="av1_decoder" +av1_d3d12va_hwaccel_deps="d3d12va DXVA_PicParams_AV1" +av1_d3d12va_hwaccel_select="av1_decoder" av1_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_AV1" av1_dxva2_hwaccel_select="av1_decoder" av1_nvdec_hwaccel_deps="nvdec CUVIDAV1PICPARAMS" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9ef49a8da5..fb5ec2ee2d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -992,6 +992,7 @@ OBJS-$(CONFIG_VULKAN) += vulkan.o vulkan_video.o OBJS-$(CONFIG_AV1_D3D11VA_HWACCEL)+= dxva2_av1.o OBJS-$(CONFIG_AV1_DXVA2_HWACCEL) += dxva2_av1.o +OBJS-$(CONFIG_AV1_D3D12VA_HWACCEL)+= dxva2_av1.o d3d12va_av1.o OBJS-$(CONFIG_AV1_NVDEC_HWACCEL) += nvdec_av1.o OBJS-$(CONFIG_AV1_VAAPI_HWACCEL) += vaapi_av1.o OBJS-$(CONFIG_AV1_VDPAU_HWACCEL) += vdpau_av1.o diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index cc178464b9..2067d67c68 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -448,6 +448,7 @@ static int get_pixel_format(AVCodecContext *avctx) enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; #define HWACCEL_MAX (CONFIG_AV1_DXVA2_HWACCEL + \ CONFIG_AV1_D3D11VA_HWACCEL * 2 + \ + CONFIG_AV1_D3D12VA_HWACCEL + \ CONFIG_AV1_NVDEC_HWACCEL + \ CONFIG_AV1_VAAPI_HWACCEL + \ CONFIG_AV1_VDPAU_HWACCEL + \ @@ -523,6 +524,9 @@ static int get_pixel_format(AVCodecContext *avctx) *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; *fmtp++ = AV_PIX_FMT_D3D11; #endif +#if CONFIG_AV1_D3D12VA_HWACCEL +*fmtp++ = AV_PIX_FMT_D3D12; +#endif #if CONFIG_AV1_NVDEC_HWACCEL *fmtp++ = AV_PIX_FMT_CUDA; #endif @@ -544,6 +548,9 @@ static int get_pixel_format(AVCodecContext *avctx) *fmtp++ = AV_PIX_FMT_D3D11VA_VLD; *fmtp++ = AV_PIX_FMT_D3D11; #endif +#if CONFIG_AV1_D3D12VA_HWACCEL +*fmtp++ = AV_PIX_FMT_D3D12; +#endif #if CONFIG_AV1_NVDEC_HWACCEL *fmtp++ = AV_PIX_FMT_CUDA; #endif @@ -1541,6 +1548,9 @@ const FFCodec ff_av1_decoder = { #if CONFIG_AV1_D3D11VA2_HWACCEL HWACCEL_D3D11VA2(av1), #endif +#if CONFIG_AV1_D3D12VA_HWACCEL +HWACCEL_D3D12VA(av1), +#endif #if CONFIG_AV1_NVDEC_HWACCEL HWACCEL_NVDEC(av1), #endif diff --git a/libavcodec/d3d12va_av1.c b/libavcodec/d3d12va_av1.c new file mode 100644 index 00..7544e97eae --- /dev/null +++ b/libavcodec/d3d12va_av1.c @@ -0,0 +1,220 @@ +/* + * Direct3D 12 AV1 HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include "config_components.h" +#include "libavutil/avassert.h" +#include "libavutil/hwcontext_d3d12va_internal.h" +#include "av1dec.h" +#include "dxva2_internal.h" +#include "d3d12va_decode.h" + +#define MAX_TILES 256 + +typedef struct D3D12AV1DecodeContext { +D3D12VADecodeContext ctx; +uint8_t *bitstream_buffer; +} D3D12AV1DecodeContext; + +#define D3D12_AV1_DECODE_CONTEXT(avctx) ((D3D12AV1DecodeContext *)D3D12VA_DECODE_CONTEXT(avctx)) + +typedef struct AV1DecodePictureContext { +DXVA_PicParams_AV1 pp; +unsignedtile_count; +DXVA_Tile_AV1 tiles[MAX_TILES]; +uint8_t*bitstream; +unsignedbitstream_size; +} AV1DecodePictureContext; + +static int d3d12va_av1_start_frame(AVCodecContext *avctx, av_
[FFmpeg-devel] [PATCH v5 6/9] avcodec: add D3D12VA hardware accelerated MPEG-2 decoding
From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 2 + libavcodec/Makefile | 1 + libavcodec/d3d12va_mpeg2.c | 191 libavcodec/dxva2_internal.h | 6 ++ libavcodec/dxva2_mpeg2.c| 18 ++-- libavcodec/hwaccels.h | 1 + libavcodec/mpeg12dec.c | 6 ++ 7 files changed, 216 insertions(+), 9 deletions(-) create mode 100644 libavcodec/d3d12va_mpeg2.c diff --git a/configure b/configure index c97d7a4874..67b5b36eea 100755 --- a/configure +++ b/configure @@ -3135,6 +3135,8 @@ mpeg2_d3d11va_hwaccel_deps="d3d11va" mpeg2_d3d11va_hwaccel_select="mpeg2video_decoder" mpeg2_d3d11va2_hwaccel_deps="d3d11va" mpeg2_d3d11va2_hwaccel_select="mpeg2video_decoder" +mpeg2_d3d12va_hwaccel_deps="d3d12va" +mpeg2_d3d12va_hwaccel_select="mpeg2video_decoder" mpeg2_dxva2_hwaccel_deps="dxva2" mpeg2_dxva2_hwaccel_select="mpeg2video_decoder" mpeg2_nvdec_hwaccel_deps="nvdec" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fb5ec2ee2d..30928a4c1d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1023,6 +1023,7 @@ OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL)+= vdpau_mpeg12.o OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL) += dxva2_mpeg2.o OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)+= dxva2_mpeg2.o +OBJS-$(CONFIG_MPEG2_D3D12VA_HWACCEL) += dxva2_mpeg2.o d3d12va_mpeg2.o OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)+= nvdec_mpeg12.o OBJS-$(CONFIG_MPEG2_QSV_HWACCEL) += qsvdec.o OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)+= vaapi_mpeg2.o diff --git a/libavcodec/d3d12va_mpeg2.c b/libavcodec/d3d12va_mpeg2.c new file mode 100644 index 00..83aca620b3 --- /dev/null +++ b/libavcodec/d3d12va_mpeg2.c @@ -0,0 +1,191 @@ +/* + * Direct3D12 MPEG-2 HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include "config_components.h" +#include "libavutil/avassert.h" +#include "libavutil/hwcontext_d3d12va_internal.h" +#include "mpegutils.h" +#include "mpegvideodec.h" +#include "d3d12va_decode.h" +#include "dxva2_internal.h" + +#define MAX_SLICES 1024 +#define INVALID_REF 0x + +#define REF_RESOURCE(index) if (index != INVALID_REF) { \ +ctx->ref_resources[index] = frames_hwctx->texture_infos[index].texture; \ +} + +typedef struct D3D12DecodePictureContext { +DXVA_PictureParameters pp; +DXVA_QmatrixDataqm; +unsignedslice_count; +DXVA_SliceInfo slices[MAX_SLICES]; +const uint8_t *bitstream; +unsignedbitstream_size; +} D3D12DecodePictureContext; + +static int d3d12va_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ +const MpegEncContext *s = avctx->priv_data; +D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); +D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; +DXVA_QmatrixData *qm = &ctx_pic->qm; + +if (!ctx) +return -1; + +av_assert0(ctx_pic); + +ff_dxva2_mpeg2_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp); +ff_dxva2_mpeg2_fill_quantization_matrices(avctx, (AVDXVAContext *)ctx, &ctx_pic->qm); + +// Post processing operations are not supported in D3D12 Video +ctx_pic->pp.wDeblockedPictureIndex = INVALID_REF; + +ctx_pic->bitstream = NULL; +ctx_pic->bitstream_size = 0; +ctx_pic->slice_count= 0; + +return 0; +} + +static int d3d12va_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ +const MpegEncContext *s = avctx->priv_data; +D3D12DecodePictureContext *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; + +int is_field = s->picture_structure != PICT_FRAME; + +if (ctx_pic->slice_count >= MAX_SLICES) { +return AVERROR(ERANGE); +} + +if (!ctx_pic->bitstream) +ctx_pic->bitstream = buffer; +ctx_pic->bitstream_size += size; + +ff_dxva2_mpeg2_fill_slice(avctx, &ctx_pic->
[FFmpeg-devel] [PATCH v5 9/9] avcodec/d3d12va_hevc: enable allow_profile_mismatch flag for d3d12va msp profile
Same as d3d11va, this flag enables main still picture profile for d3d12va. User should add this flag when decoding main still picture profile. Signed-off-by: Tong Wu --- libavcodec/d3d12va_hevc.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/d3d12va_hevc.c b/libavcodec/d3d12va_hevc.c index 894fa73d60..a56d038a40 100644 --- a/libavcodec/d3d12va_hevc.c +++ b/libavcodec/d3d12va_hevc.c @@ -181,8 +181,13 @@ static int d3d12va_hevc_decode_init(AVCodecContext *avctx) break; case FF_PROFILE_HEVC_MAIN_STILL_PICTURE: -av_log(avctx, AV_LOG_ERROR, "D3D12 doesn't support PROFILE_HEVC_MAIN_STILL_PICTURE!\n"); -return AVERROR(EINVAL); +if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) { +ctx->cfg.DecodeProfile = D3D12_VIDEO_DECODE_PROFILE_HEVC_MAIN; +break; +} else { +av_log(avctx, AV_LOG_ERROR, "D3D12 doesn't support PROFILE_HEVC_MAIN_STILL_PICTURE!\n"); +return AVERROR(EINVAL); +} case FF_PROFILE_HEVC_MAIN: default: -- 2.41.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v5 7/9] avcodec: add D3D12VA hardware accelerated VC1 decoding
From: Wu Jianhua The command below is how to enable d3d12va: ffmpeg -hwaccel d3d12va -i input.mp4 output.mp4 Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- configure | 3 + libavcodec/Makefile | 1 + libavcodec/d3d12va_vc1.c| 214 libavcodec/dxva2_internal.h | 4 + libavcodec/dxva2_vc1.c | 11 +- libavcodec/hwaccels.h | 2 + libavcodec/vc1dec.c | 9 ++ 7 files changed, 239 insertions(+), 5 deletions(-) create mode 100644 libavcodec/d3d12va_vc1.c diff --git a/configure b/configure index 67b5b36eea..ecdd1e2afc 100755 --- a/configure +++ b/configure @@ -3161,6 +3161,8 @@ vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_d3d11va2_hwaccel_deps="d3d11va" vc1_d3d11va2_hwaccel_select="vc1_decoder" +vc1_d3d12va_hwaccel_deps="d3d12va" +vc1_d3d12va_hwaccel_select="vc1_decoder" vc1_dxva2_hwaccel_deps="dxva2" vc1_dxva2_hwaccel_select="vc1_decoder" vc1_nvdec_hwaccel_deps="nvdec" @@ -3191,6 +3193,7 @@ vp9_videotoolbox_hwaccel_deps="videotoolbox" vp9_videotoolbox_hwaccel_select="vp9_decoder" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel" +wmv3_d3d12va_hwaccel_select="vc1_d3d12va_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" wmv3_nvdec_hwaccel_select="vc1_nvdec_hwaccel" wmv3_vaapi_hwaccel_select="vc1_vaapi_hwaccel" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 30928a4c1d..b1f7dde3da 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1035,6 +1035,7 @@ OBJS-$(CONFIG_MPEG4_VDPAU_HWACCEL)+= vdpau_mpeg4.o OBJS-$(CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL)+= dxva2_vc1.o OBJS-$(CONFIG_VC1_DXVA2_HWACCEL) += dxva2_vc1.o +OBJS-$(CONFIG_VC1_D3D12VA_HWACCEL)+= dxva2_vc1.o d3d12va_vc1.o OBJS-$(CONFIG_VC1_NVDEC_HWACCEL) += nvdec_vc1.o OBJS-$(CONFIG_VC1_QSV_HWACCEL)+= qsvdec.o OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o diff --git a/libavcodec/d3d12va_vc1.c b/libavcodec/d3d12va_vc1.c new file mode 100644 index 00..b89cc6527d --- /dev/null +++ b/libavcodec/d3d12va_vc1.c @@ -0,0 +1,214 @@ +/* + * Direct3D12 WMV3/VC-1 HW acceleration + * + * copyright (c) 2022-2023 Wu Jianhua + * + * 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 + */ + +#include "config_components.h" +#include "libavutil/avassert.h" +#include "libavutil/hwcontext_d3d12va_internal.h" +#include "mpegutils.h" +#include "mpegvideodec.h" +#include "vc1.h" +#include "vc1data.h" +#include "d3d12va_decode.h" +#include "dxva2_internal.h" + +#define MAX_SLICES 1024 +#define INVALID_REF 0x + +#define REF_RESOURCE(index) if (index != INVALID_REF) { \ +ctx->ref_resources[index] = frames_hwctx->texture_infos[index].texture; \ +} + +typedef struct D3D12DecodePictureContext { +DXVA_PictureParameters pp; +unsigned slice_count; +DXVA_SliceInfo slices[MAX_SLICES]; +const uint8_t *bitstream; +unsigned bitstream_size; +} D3D12DecodePictureContext; + +static int d3d12va_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) +{ +const VC1Context *v = avctx->priv_data; +D3D12VADecodeContext *ctx = D3D12VA_DECODE_CONTEXT(avctx); +D3D12DecodePictureContext *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + +if (!ctx) +return -1; + +av_assert0(ctx_pic); + +ff_dxva2_vc1_fill_picture_parameters(avctx, (AVDXVAContext *)ctx, &ctx_pic->pp); +ctx_pic->pp.wDeblockedPictureIndex = INVALID_REF; + +ctx_pic->bitstream = NULL; +ctx_pic->bitstream_size = 0; +ctx_pic->slice_count= 0; + +return 0; +} + +static int d3d12va_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) +{ +const VC1Context *v = avctx->priv_data; +D3D12DecodePictureContext *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; + +if (ctx_pic->slice_count >= MAX_SLICES) { +return AVERROR(ERANGE); +} + +if (avctx->codec_id == AV_CODEC_ID_VC1 && +size >= 4 && IS_MARKER(AV_RB32(buff
[FFmpeg-devel] [PATCH v5 8/9] Changelog: D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and VC1 decoding
From: Wu Jianhua Signed-off-by: Wu Jianhua Signed-off-by: Tong Wu --- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index bbda4f4fd4..5b21103b29 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ version : - Bitstream filter for converting VVC from MP4 to Annex B - scale_vt filter for videotoolbox - transpose_vt filter for videotoolbox +- D3D12VA hardware accelerated H264, HEVC, VP9, AV1, MPEG-2 and VC1 decoding version 6.0: - Radiance HDR image support -- 2.41.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] What is FFmpeg and what should it be
On Thu, Aug 03, 2023 at 04:04:23PM -0400, Kieran Kunhya wrote: > On Thu, 3 Aug 2023, 15:25 Michael Niedermayer, > wrote: > > > On Thu, Aug 03, 2023 at 02:24:04PM -0400, Kieran Kunhya wrote: > > > > > > > > > > > > There are 2 things DAB and DVB both use mpeg ts > > > > > > > > > > DAB does not use mpegts. It has several layers of it's own framing. > > > > Well, i stand corrected then. I saw it on the ML and in some spec but that > > was about IP data in DAB or something it seems. > > > > but thats a good thing, because if the framing used is not MPEG-TS > > there will probably be noone objecting to it being removed and not > > output. > > > > What does this sentence even mean? > The framing is there for a reason (to > delimit programs amongst other things). You can't just remove it. It has > layers that some users will want. Everything is there for a reason. Every part of mp4 has a use, still we extract the data and setup various structs like AVStream, AVPacket, AVProgram and so on. We do not return raw mp4/mov atoms the seperation between programs in a stream of bits/bytes looses meaning once the frames are in AVPackets with AVStream/AVProgram. If there is more data in any framing that people want, theres a wide range of ways to preserve and export that data. OTOH outputting AAC in TS or AAC is other framing is painfull to handle especially when it is muxed into something again. because it then needs the right framing and even if it comes in as DAB framing and the output wants DAB framing, it is unlikely everything in the framing will be correct for the output. The same is true for TS. I surely can take raw TS from 3 programs but if i just take these and concatenate them into something that suppports TS thats quite likely going to blow up somehow. All this framing stuff should IMHO be "removed" on the demuxer side usefull data be extracted and properly exported. And if anything on the muxing side needs something similar it needed to rebuild it all. I may be missing something but i dont think the raw framing is too usefull to the user. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1
asivery: > Signed-off-by: asivery > --- > libavformat/matroska.c | 1 + > libavformat/matroskadec.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/libavformat/matroska.c b/libavformat/matroska.c > index 90d94b65bf..37305a523c 100644 > --- a/libavformat/matroska.c > +++ b/libavformat/matroska.c > @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={ > {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3}, > {"A_REAL/COOK" , AV_CODEC_ID_COOK}, > {"A_REAL/SIPR" , AV_CODEC_ID_SIPR}, > + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1}, > {"A_TRUEHD" , AV_CODEC_ID_TRUEHD}, > {"A_TTA1" , AV_CODEC_ID_TTA}, > {"A_VORBIS" , AV_CODEC_ID_VORBIS}, > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index d582f566a2..0aa8e6f3b3 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext *s) > track->audio.frame_size); > if (!track->audio.buf) > return AVERROR(ENOMEM); > + } else if (codec_id == AV_CODEC_ID_ATRAC1) { > + st->codecpar->block_align = track->audio.channels * 212; /* Constant ATRAC > frame size */ > } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) { > ret = matroska_parse_flac(s, track, &extradata_offset); > if (ret < 0) > -- > 2.34.1 This patch is broken. The indentation is off. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v5 1/9] libavutil: add hwcontext_d3d12va and AV_PIX_FMT_D3D12
Aug 4, 2023, 15:50 by tong1.wu-at-intel@ffmpeg.org: > From: Wu Jianhua > > Signed-off-by: Wu Jianhua > Signed-off-by: Tong Wu > --- > configure | 5 + > doc/APIchanges | 7 + > libavutil/Makefile | 3 + > libavutil/hwcontext.c | 4 + > libavutil/hwcontext.h | 1 + > libavutil/hwcontext_d3d12va.c | 703 + > libavutil/hwcontext_d3d12va.h | 169 ++ > libavutil/hwcontext_d3d12va_internal.h | 59 +++ > libavutil/hwcontext_internal.h | 1 + > libavutil/pixdesc.c| 4 + > libavutil/pixfmt.h | 9 + > libavutil/tests/hwdevice.c | 2 + > libavutil/version.h| 2 +- > 13 files changed, 968 insertions(+), 1 deletion(-) > create mode 100644 libavutil/hwcontext_d3d12va.c > create mode 100644 libavutil/hwcontext_d3d12va.h > create mode 100644 libavutil/hwcontext_d3d12va_internal.h > > diff --git a/configure b/configure > index 99388e7664..9919551ad0 100755 > --- a/configure > +++ b/configure > @@ -338,6 +338,7 @@ External library support: > --disable-cuda-llvm disable CUDA compilation using clang [autodetect] > --disable-cuvid disable Nvidia CUVID support [autodetect] > --disable-d3d11vadisable Microsoft Direct3D 11 video acceleration > code [autodetect] > + --disable-d3d12vadisable Microsoft Direct3D 12 video acceleration > code [autodetect] > --disable-dxva2 disable Microsoft DirectX 9 video acceleration code > [autodetect] > --disable-ffnvcodec disable dynamically linked Nvidia code [autodetect] > --enable-libdrm enable DRM code (Linux) [no] > @@ -1926,6 +1927,7 @@ HWACCEL_AUTODETECT_LIBRARY_LIST=" > cuda_llvm > cuvid > d3d11va > +d3d12va > dxva2 > ffnvcodec > nvdec > @@ -3053,6 +3055,7 @@ crystalhd_deps="libcrystalhd_libcrystalhd_if_h" > cuda_deps="ffnvcodec" > cuvid_deps="ffnvcodec" > d3d11va_deps="dxva_h ID3D11VideoDecoder ID3D11VideoContext" > +d3d12va_deps="dxva_h ID3D12Device ID3D12VideoDecoder" > dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32 user32" > ffnvcodec_deps_any="libdl LoadLibrary" > mediacodec_deps="android" > @@ -6543,6 +6546,8 @@ check_type "windows.h dxgi1_2.h" "IDXGIOutput1" > check_type "windows.h dxgi1_5.h" "IDXGIOutput5" > check_type "windows.h d3d11.h" "ID3D11VideoDecoder" > check_type "windows.h d3d11.h" "ID3D11VideoContext" > +check_type "windows.h d3d12.h" "ID3D12Device" > +check_type "windows.h d3d12video.h" "ID3D12VideoDecoder" > check_type "windows.h" "DPI_AWARENESS_CONTEXT" -D_WIN32_WINNT=0x0A00 > check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode > -D_WIN32_WINNT=0x0602 > check_func_headers mfapi.h MFCreateAlignedMemoryBuffer -lmfplat > diff --git a/doc/APIchanges b/doc/APIchanges > index 5afe8bcb75..c14ab0b394 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -2,6 +2,13 @@ The last version increases of all libraries were on > 2023-02-09 > > API changes, most recent first: > > +2023-07-xx - xx - lavu 58.15.100 - pixfmt.h hwcontext.h > hwcontext_d3d12va.h > + Add AV_HWDEVICE_TYPE_D3D12VA and AV_PIX_FMT_D3D12. > + Add AVD3D12VADeviceContext, AVD3D12VASyncContext, AVD3D12FrameDescriptor, > + and AVD3D12VAFramesContext. > + Add av_d3d12va_map_sw_to_hw_format, av_d3d12va_create_sync_context, > + av_d3d12va_release_sync_context, av_d3d12va_wait_idle, and > av_d3d12va_wait_queue_idle. > + > 2023-07-xx - xx - lavc 60 - avcodec.h > Deprecate AV_CODEC_FLAG_DROPCHANGED without replacement. > > diff --git a/libavutil/Makefile b/libavutil/Makefile > index bd9c6f9e32..40d49d76dd 100644 > --- a/libavutil/Makefile > +++ b/libavutil/Makefile > @@ -41,6 +41,7 @@ HEADERS = adler32.h > \ > hwcontext.h \ > hwcontext_cuda.h \ > hwcontext_d3d11va.h \ > + hwcontext_d3d12va.h \ > hwcontext_drm.h \ > hwcontext_dxva2.h \ > hwcontext_qsv.h \ > @@ -186,6 +187,7 @@ OBJS = adler32.o > \ > > OBJS-$(CONFIG_CUDA) += hwcontext_cuda.o > OBJS-$(CONFIG_D3D11VA) += hwcontext_d3d11va.o > +OBJS-$(CONFIG_D3D12VA) += hwcontext_d3d12va.o > OBJS-$(CONFIG_DXVA2)+= hwcontext_dxva2.o > OBJS-$(CONFIG_LIBDRM) += hwcontext_drm.o > OBJS-$(CONFIG_MACOS_KPERF) += macos_kperf.o > @@ -209,6 +211,7 @@ SKIPHEADERS-$(HAVE_CUDA_H) += hwcontext_cuda.h > SKIPHEADERS-$(CONFIG_CUDA) +=
Re: [FFmpeg-devel] [PATCH] avformat/matroska: Add support for A_ATRAC/AT1
Andreas Rheinhardt: > asivery: >> Signed-off-by: asivery >> --- >> libavformat/matroska.c | 1 + >> libavformat/matroskadec.c | 2 ++ >> 2 files changed, 3 insertions(+) >> >> diff --git a/libavformat/matroska.c b/libavformat/matroska.c >> index 90d94b65bf..37305a523c 100644 >> --- a/libavformat/matroska.c >> +++ b/libavformat/matroska.c >> @@ -55,6 +55,7 @@ const CodecTags ff_mkv_codec_tags[]={ >> {"A_REAL/ATRC" , AV_CODEC_ID_ATRAC3}, >> {"A_REAL/COOK" , AV_CODEC_ID_COOK}, >> {"A_REAL/SIPR" , AV_CODEC_ID_SIPR}, >> + {"A_ATRAC/AT1" , AV_CODEC_ID_ATRAC1}, >> {"A_TRUEHD" , AV_CODEC_ID_TRUEHD}, >> {"A_TTA1" , AV_CODEC_ID_TTA}, >> {"A_VORBIS" , AV_CODEC_ID_VORBIS}, >> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c >> index d582f566a2..0aa8e6f3b3 100644 >> --- a/libavformat/matroskadec.c >> +++ b/libavformat/matroskadec.c >> @@ -2795,6 +2795,8 @@ static int matroska_parse_tracks(AVFormatContext *s) >> track->audio.frame_size); >> if (!track->audio.buf) >> return AVERROR(ENOMEM); >> + } else if (codec_id == AV_CODEC_ID_ATRAC1) { >> + st->codecpar->block_align = track->audio.channels * 212; /* Constant ATRAC >> frame size */ >> } else if (codec_id == AV_CODEC_ID_FLAC && track->codec_priv.size) { >> ret = matroska_parse_flac(s, track, &extradata_offset); >> if (ret < 0) >> -- >> 2.34.1 > > This patch is broken. The indentation is off. > > - Andreas > Apart from this: The result of the multiplication may not fit into an int; looking at the other atrac1 code it seems that we only support mono and stereo files. Is this a limitation of FFmpeg or of the format? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] What is FFmpeg and what should it be
Michael Niedermayer (12023-08-04): > Everything is there for a reason. > Every part of mp4 has a use, still we extract the data and setup various > structs like AVStream, AVPacket, AVProgram and so on. > We do not return raw mp4/mov atoms > the seperation between programs in a stream of bits/bytes looses meaning > once the frames are in AVPackets with AVStream/AVProgram. > If there is more data in any framing that people want, theres a wide range > of ways to preserve and export that data. > OTOH outputting AAC in TS or AAC is other framing is painfull to handle > especially when it is muxed into something again. because it then needs > the right framing and even if it comes in as DAB framing and the output > wants DAB framing, it is unlikely everything in the framing will be correct > for the output. > The same is true for TS. I surely can take raw TS from 3 programs but if > i just take these and concatenate them into something that suppports TS > thats quite likely going to blow up somehow. > All this framing stuff should IMHO be "removed" on the demuxer side > usefull data be extracted and properly exported. And if anything > on the muxing side needs something similar it needed to rebuild it all. > > I may be missing something but i dont think the raw framing is too usefull > to the user. I recommend you do what feels most simple, or most elegant, or most logical, whichever feels right. If somebody else, or you later, find a use for the framing, the code that removes it can be turned into code that extract information from it or reshape it. If and when that happens is the good time to figure out how to bring that information to the user, because that will be when what is necessary will be known. This is why the demands that you design a clean API first are absurd: at this point, you do not know exactly where this code is going, what kind of information or control you will need to expose. All this depends on which direction the codes takes, which in turns depends on you inspiration. And as the code progresses, the necessary API will emerge, and at one point it will be just a matter of thinking on it carefully to cut it cleanly. I suppose this is what the buzzword-living industry calls “agile programming”. But the industry cannot do it right because it needs return on investment quick. Only a real Libre Software project like FFmpeg can do that. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [RFC][PATCH] libwebp: combine libwebp_anim and libwebp encoders into one
On May 24, 2015 at 04:49PM, Michael Niedermayer wrote: > On Sun, May 24, 2015 at 06:39:05PM -0300, James Almer wrote: > > On 24/05/15 5:59 PM, Michael Niedermayer wrote: > > > On Sun, May 24, 2015 at 04:22:42PM -0300, James Almer wrote: > > >> Use either the WebPEncoder or WebPAnimEncoder APIs depending on > > >> availability > > >> of the latter. > > >> > > >> Signed-off-by: James Almer > > >> --- > > >> This is an RFC because the resulting encoder will use one of the two > > >> APIs, which > > >> is a change from the current behavior of having one encoder for each API. > > >> The new encoder was added only two days ago so removing it shouldn't be > > >> an issue. > > >> Basically, is there any benefit from using the native lavf muxer over > > >> letting > > >> WebPAnimEncoder do the entire process to justify having two encoders? > > >> > > >> The resulting ifdeffery is minimal now that the webp muxer can act as a > > >> raw muxer > > >> cleanly, so the only concern is the above. We can deal with cosmetics > > >> later, but > > >> the functional change needs to be done asap least we want to deal with > > >> deprecation > > >> nonsense if the new encoder makes it into a release. > > > > > > They are 2 different encoders, the old is partly implemented in > > > FFmpeg, the new does all steps in an external lib > > > The 2 variants work differently > > > command lines for the old encoder do NOT work with WebPAnimEncoder, > > > at least not with the current implementation we have > > > > My intention was to keep it all as a single encoder, using one of the two > > APIs depending > > on availability. If the AVOptions have different results on them then i > > guess it's not > > really feasible after all. So patch dropped. > > I dont know if its (im)possible with the new API to support the > stuff, just that it is not supported with the current > wraper/implementation we have There are still two encoders for animated webp, libwebp and libwebp_anim. Do we still need both? There was an attempt to combine these back in 2015 or so that was dropped at the time. At this point though WebPAnimEncoder has been around for years. Using libwebp_anim seems to be about 3x faster in my testing and produces smaller file sizes, and is selected by ffmpeg by default. New users may not realize that specifying `-c:v libwebp` is the inferior choice. Can we revisit merging these two? I propose dropping the current libwebp and renaming (or aliasing) libwebp_anim to libwebp and dropping support for libwebpmux < 0.4.0. I can submit a patch if there is agreement. - Cosmin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] wmavoice: convert RDFT to lavu/tx
Patch attached. >From a5b6b7d954447d4cc07377f00370a0781e5056b3 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 4 Aug 2023 20:20:10 +0200 Subject: [PATCH 1/2] wmavoice: convert RDFT to lavu/tx --- libavcodec/wmavoice.c | 75 ++- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 44fda0e2d6..5ae92e2dbc 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -31,6 +31,7 @@ #include "libavutil/float_dsp.h" #include "libavutil/mem_internal.h" #include "libavutil/thread.h" +#include "libavutil/tx.h" #include "avcodec.h" #include "codec_internal.h" #include "decode.h" @@ -263,8 +264,8 @@ typedef struct WMAVoiceContext { * smoothing and so on, and context variables for FFT/iFFT. * @{ */ -RDFTContext rdft, irdft; ///< contexts for FFT-calculation in the - ///< postfilter (for denoise filter) +AVTXContext *rdft, *irdft;///< contexts for FFT-calculation in the +av_tx_fn rdft_fn, irdft_fn; ///< postfilter (for denoise filter) DCTContext dct, dst; ///< contexts for phase shift (in Hilbert ///< transform, part of postfilter) float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi] @@ -277,9 +278,9 @@ typedef struct WMAVoiceContext { ///< by postfilter float denoise_filter_cache[MAX_FRAMESIZE]; int denoise_filter_cache_size; ///< samples in #denoise_filter_cache -DECLARE_ALIGNED(32, float, tilted_lpcs_pf)[0x80]; +DECLARE_ALIGNED(32, float, tilted_lpcs_pf)[0x82]; ///< aligned buffer for LPC tilting -DECLARE_ALIGNED(32, float, denoise_coeffs_pf)[0x80]; +DECLARE_ALIGNED(32, float, denoise_coeffs_pf)[0x82]; ///< aligned buffer for denoise coefficients DECLARE_ALIGNED(32, float, synth_filter_out_buf)[0x80 + MAX_LSPS_ALIGN16]; ///< aligned buffer for postfilter speech @@ -388,12 +389,20 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) s->spillover_bitsize = 3 + av_ceil_log2(ctx->block_align); s->do_apf=flags & 0x1; if (s->do_apf) { -if ((ret = ff_rdft_init(&s->rdft, 7, DFT_R2C)) < 0 || -(ret = ff_rdft_init(&s->irdft, 7, IDFT_C2R)) < 0 || -(ret = ff_dct_init (&s->dct, 6,DCT_I)) < 0 || +float scale = 1.0f; + +if ((ret = ff_dct_init (&s->dct, 6,DCT_I)) < 0 || (ret = ff_dct_init (&s->dst, 6,DST_I)) < 0) return ret; +ret = av_tx_init(&s->rdft, &s->rdft_fn, AV_TX_FLOAT_RDFT, 0, 1 << 7, &scale, 0); +if (ret < 0) +return ret; + +ret = av_tx_init(&s->irdft, &s->irdft_fn, AV_TX_FLOAT_RDFT, 1, 1 << 7, &scale, 0); +if (ret < 0) +return ret; + ff_sine_window_init(s->cos, 256); memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); for (n = 0; n < 255; n++) { @@ -596,20 +605,24 @@ static float tilt_factor(const float *lpcs, int n_lpcs) /** * Derive denoise filter coefficients (in real domain) from the LPCs. */ -static void calc_input_response(WMAVoiceContext *s, float *lpcs, -int fcb_type, float *coeffs, int remainder) +static void calc_input_response(WMAVoiceContext *s, float *lpcs_src, +int fcb_type, float *coeffs_dst, int remainder) { float last_coeff, min = 15.0, max = -15.0; float irange, angle_mul, gain_mul, range, sq; +LOCAL_ALIGNED_32(float, coeffs, [0x82]); +LOCAL_ALIGNED_32(float, lpcs, [0x82]); int n, idx; +memcpy(coeffs, coeffs_dst, 0x82*sizeof(float)); + /* Create frequency power spectrum of speech input (i.e. RDFT of LPCs) */ -s->rdft.rdft_calc(&s->rdft, lpcs); +s->rdft_fn(s->rdft, lpcs, lpcs_src, sizeof(float)); #define log_range(var, assign) do { \ float tmp = log10f(assign); var = tmp; \ max = FFMAX(max, tmp); min = FFMIN(min, tmp); \ } while (0) -log_range(last_coeff, lpcs[1] * lpcs[1]); +log_range(last_coeff, lpcs[64] * lpcs[64]); for (n = 1; n < 64; n++) log_range(lpcs[n], lpcs[n * 2] * lpcs[n * 2] + lpcs[n * 2 + 1] * lpcs[n * 2 + 1]); @@ -668,25 +681,25 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs, coeffs[n * 2 + 1] = coeffs[n] * s->sin[idx]; coeffs[n * 2] = coeffs[n] * s->cos[idx]; } -coeffs[1] = last_coeff; +coeffs[64] = last_coeff; /* move into real domain */ -s->irdft.rdft_calc(&s->irdft, coeffs); +s->irdft_fn(s->irdft, coeffs_dst, coeffs, sizeof(AVComplexFloat)); /* tilt correction and normalize scale */ -memset(&coeffs[remainder], 0, sizeof(coeffs[0]) * (128 - remai
[FFmpeg-devel] [PATCH 2/2] wmavoice: convert DCT-I/DST-I to lavu/tx
This is the very last user of any lavc transform code. This also *corrects* wmavoice decoding, as the previous DCT/DST transforms were incorrect, bringing it closer to Microsoft's own wmavoice decoder. Note: this requires new FATE files, or for the tests to be modified to use a target error. >From c892079d2b816d2742aa3c192c090e2cb83952e7 Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 4 Aug 2023 21:16:30 +0200 Subject: [PATCH 2/2] wmavoice: convert DCT-I/DST-I to lavu/tx This is the very last user of any lavc transform code. This also *corrects* wmavoice decoding, as the previous DCT/DST transforms were incorrect, bringing it closer to Microsoft's own wmavoice decoder. --- libavcodec/wmavoice.c | 29 + tests/fate/wma.mak| 6 +++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c index 5ae92e2dbc..915315cb8a 100644 --- a/libavcodec/wmavoice.c +++ b/libavcodec/wmavoice.c @@ -42,8 +42,6 @@ #include "acelp_vectors.h" #include "acelp_filters.h" #include "lsp.h" -#include "dct.h" -#include "rdft.h" #include "sinewin.h" #define MAX_BLOCKS 8 ///< maximum number of blocks per frame @@ -266,8 +264,8 @@ typedef struct WMAVoiceContext { */ AVTXContext *rdft, *irdft;///< contexts for FFT-calculation in the av_tx_fn rdft_fn, irdft_fn; ///< postfilter (for denoise filter) -DCTContext dct, dst; ///< contexts for phase shift (in Hilbert - ///< transform, part of postfilter) +AVTXContext *dct, *dst; ///< contexts for phase shift (in Hilbert +av_tx_fn dct_fn, dst_fn; ///< transform, part of postfilter) float sin[511], cos[511]; ///< 8-bit cosine/sine windows over [-pi,pi] ///< range float postfilter_agc; ///< gain control memory, used in @@ -391,10 +389,6 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) if (s->do_apf) { float scale = 1.0f; -if ((ret = ff_dct_init (&s->dct, 6,DCT_I)) < 0 || -(ret = ff_dct_init (&s->dst, 6,DST_I)) < 0) -return ret; - ret = av_tx_init(&s->rdft, &s->rdft_fn, AV_TX_FLOAT_RDFT, 0, 1 << 7, &scale, 0); if (ret < 0) return ret; @@ -403,6 +397,16 @@ static av_cold int wmavoice_decode_init(AVCodecContext *ctx) if (ret < 0) return ret; +scale = 1.0 / (1 << 6); +ret = av_tx_init(&s->dct, &s->dct_fn, AV_TX_FLOAT_DCT_I, 0, 1 << 6, &scale, 0); +if (ret < 0) +return ret; + +scale = 1.0 / (1 << 6); +ret = av_tx_init(&s->dst, &s->dst_fn, AV_TX_FLOAT_DST_I, 0, 1 << 6, &scale, 0); +if (ret < 0) +return ret; + ff_sine_window_init(s->cos, 256); memcpy(&s->sin[255], s->cos, 256 * sizeof(s->cos[0])); for (n = 0; n < 255; n++) { @@ -612,6 +616,7 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src, float irange, angle_mul, gain_mul, range, sq; LOCAL_ALIGNED_32(float, coeffs, [0x82]); LOCAL_ALIGNED_32(float, lpcs, [0x82]); +LOCAL_ALIGNED_32(float, lpcs_dct, [0x82]); int n, idx; memcpy(coeffs, coeffs_dst, 0x82*sizeof(float)); @@ -662,8 +667,8 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs_src, * is a sine input) by doing a phase shift (in theory, H(sin())=cos()). * Hilbert_Transform(RDFT(x)) = Laplace_Transform(x), which calculates the * "moment" of the LPCs in this filter. */ -s->dct.dct_calc(&s->dct, lpcs); -s->dst.dct_calc(&s->dst, lpcs); +s->dct_fn(s->dct, lpcs_dct, lpcs, sizeof(float)); +s->dst_fn(s->dst, lpcs, lpcs_dct, sizeof(float)); /* Split out the coefficient indexes into phase/magnitude pairs */ idx = 255 + av_clip(lpcs[64], -255, 255); @@ -2003,8 +2008,8 @@ static av_cold int wmavoice_decode_end(AVCodecContext *ctx) if (s->do_apf) { av_tx_uninit(&s->rdft); av_tx_uninit(&s->irdft); -ff_dct_end(&s->dct); -ff_dct_end(&s->dst); +av_tx_uninit(&s->dct); +av_tx_uninit(&s->dst); } return 0; diff --git a/tests/fate/wma.mak b/tests/fate/wma.mak index c13874ebfc..d23ea29c92 100644 --- a/tests/fate/wma.mak +++ b/tests/fate/wma.mak @@ -20,17 +20,17 @@ fate-wmapro: $(FATE_WMAPRO-yes) FATE_WMAVOICE-$(call DEMDEC, ASF, WMAVOICE) += fate-wmavoice-7k fate-wmavoice-7k: CMD = pcm -i $(TARGET_SAMPLES)/wmavoice/streaming_CBR-7K.wma -fate-wmavoice-7k: REF = $(SAMPLES)/wmavoice/streaming_CBR-7K.pcm +fate-wmavoice-7k: REF = $(SAMPLES)/wmavoice/streaming_CBR-7K_new.pcm fate-wmavoice-7k: FUZZ = 3 FATE_WMAVOICE-$(call DEMDEC, ASF, WMAVOICE) += fate-wmavoice-11k fate-wmavoice-11k: CMD = pcm -i $(TARGET_SAMPLES)/wmavoice/streaming_CBR-11K.wma -fate-wmavoice-11k: REF = $(SAMPLES)/wmavoice/streaming_CBR-11K.pcm +fate-wmavoice-11k: REF = $(SAMPLES)/wma
Re: [FFmpeg-devel] What is FFmpeg and what should it be
On Fri, 4 Aug 2023, 13:35 Nicolas George, wrote: > Michael Niedermayer (12023-08-04): > > Everything is there for a reason. > > Every part of mp4 has a use, still we extract the data and setup various > > structs like AVStream, AVPacket, AVProgram and so on. > > We do not return raw mp4/mov atoms > > the seperation between programs in a stream of bits/bytes looses meaning > > once the frames are in AVPackets with AVStream/AVProgram. > > If there is more data in any framing that people want, theres a wide > range > > of ways to preserve and export that data. > > OTOH outputting AAC in TS or AAC is other framing is painfull to handle > > especially when it is muxed into something again. because it then needs > > the right framing and even if it comes in as DAB framing and the output > > wants DAB framing, it is unlikely everything in the framing will be > correct > > for the output. > > The same is true for TS. I surely can take raw TS from 3 programs but if > > i just take these and concatenate them into something that suppports TS > > thats quite likely going to blow up somehow. > > All this framing stuff should IMHO be "removed" on the demuxer side > > usefull data be extracted and properly exported. And if anything > > on the muxing side needs something similar it needed to rebuild it all. > > > > I may be missing something but i dont think the raw framing is too > usefull > > to the user. > > I recommend you do what feels most simple, or most elegant, or most > logical, whichever feels right. > > If somebody else, or you later, find a use for the framing, the code > that removes it can be turned into code that extract information from it > or reshape it. If and when that happens is the good time to figure out > how to bring that information to the user, because that will be when > what is necessary will be known. > Literally in this thread someone has countered all your points by wanting TCP replay (a form of framing). If you design a bad API for a simple case, the edge use cases (that have a tendency to make it into FFmpeg) will immediately need hacks to support. Plenty of examples of this such as wrapped_avframe. Kieran > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/3] avcodec/jpeg2000htdec: Check m
On Tue, Aug 1, 2023 at 5:02 PM Michael Niedermayer wrote: > > This also fixes assertion failures > > Fixes: shift exponent 95 is too large for 64-bit type 'unsigned long long' > Fixes: > 58299/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5828618092937216 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/jpeg2000htdec.c | 22 -- > 1 file changed, 20 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c > index 3985783f3a..ae2ee6d6ee 100644 > --- a/libavcodec/jpeg2000htdec.c > +++ b/libavcodec/jpeg2000htdec.c > @@ -689,6 +689,10 @@ static int jpeg2000_decode_ht_cleanup_segment(const > Jpeg2000DecoderContext *s, > for (int i = 0; i < 4; i++) { > m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - > ((emb_pat_k[J2K_Q1] >> i) & 1); > m[J2K_Q2][i] = sigma_n[4 * q2 + i] * U[J2K_Q2] - > ((emb_pat_k[J2K_Q2] >> i) & 1); > +if (m[J2K_Q1][i] > 63 || m[J2K_Q2][i] > 63) { AFAIK, m[i], which is m_n in the standard, can never be larger than the sample bit depth (including the sign bit, if any). Is it worth comparing it to a value more precise than 63? > +ret = AVERROR_INVALIDDATA; > +goto free; > +} > } > > recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, > v, m, > @@ -723,8 +727,13 @@ static int jpeg2000_decode_ht_cleanup_segment(const > Jpeg2000DecoderContext *s, > > U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1]; > > -for (int i = 0; i < 4; i++) > +for (int i = 0; i < 4; i++) { > m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - > ((emb_pat_k[J2K_Q1] >> i) & 1); > +if (m[J2K_Q1][i] > 63) { > +ret = AVERROR_INVALIDDATA; > +goto free; > +} > +} > > recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, > v, m, > E, mu_n, Dcup, Pcup, pLSB); > @@ -855,6 +864,10 @@ static int jpeg2000_decode_ht_cleanup_segment(const > Jpeg2000DecoderContext *s, > for (int i = 0; i < 4; i++) { > m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - > ((emb_pat_k[J2K_Q1] >> i) & 1); > m[J2K_Q2][i] = sigma_n[4 * q2 + i] * U[J2K_Q2] - > ((emb_pat_k[J2K_Q2] >> i) & 1); > +if (m[J2K_Q1][i] > 63 || m[J2K_Q2][i] > 63) { > +ret = AVERROR_INVALIDDATA; > +goto free; > +} > } > recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, > emb_pat_1, v, m, > E, mu_n, Dcup, Pcup, pLSB); > @@ -920,8 +933,13 @@ static int jpeg2000_decode_ht_cleanup_segment(const > Jpeg2000DecoderContext *s, > > U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1]; > > -for (int i = 0; i < 4; i++) > +for (int i = 0; i < 4; i++) { > m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - > ((emb_pat_k[J2K_Q1] >> i) & 1); > +if (m[J2K_Q1][i] > 63) { > +ret = AVERROR_INVALIDDATA; > +goto free; > +} > +} > > recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, > emb_pat_1, v, m, > E, mu_n, Dcup, Pcup, pLSB); > -- > 2.17.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/jpeg2000htdec: Consolidate jpeg2000 spec bits in jpeg2000_bitbuf_refill_backwards()
On Tue, Aug 1, 2023 at 5:02 PM Michael Niedermayer wrote: > > Code should make more sense now > > Fixes: out of array access > Fixes: > 58299/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6627570448465920 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/jpeg2000htdec.c | 13 +++-- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c > index 2b082b3b2f..3985783f3a 100644 > --- a/libavcodec/jpeg2000htdec.c > +++ b/libavcodec/jpeg2000htdec.c > @@ -159,21 +159,14 @@ static int jpeg2000_bitbuf_refill_backwards(StateVars > *buffer, const uint8_t *ar > */ > position -= 4; Can't we get rid of this line and the comment above, and instead replace `int32_t position = buffer->pos;` with `int32_t position = buffer->pos - 4;`? LGTM otherwise. > > -tmp = AV_RB32(&array[position + 1]); > - > -if (buffer->pos < 4){ > -/* mask un-needed bits if we are close to input end */ > -uint64_t mask = (1ull << (buffer->pos + 1) * 8) - 1; > -tmp &= mask; > -} > - > /** > * Unstuff bits. Load a temporary byte, which precedes the position we > * currently at, to ensure that we can also un-stuff if the stuffed bit > is > * the bottom most bits. > */ > -tmp <<= 8; > -tmp |= array[buffer->pos + 1]; > + > +for(int i = FFMAX(0, position + 1); i <= buffer->pos + 1; i++) > +tmp = 256*tmp + array[i]; > > if ((tmp & 0x7FFF00) > 0x7F8F00) { > tmp &= 0x7F; > -- > 2.17.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".