[libav-devel] [PATCH] [v2] use bcrypt instead of the old wincrypt API
When targeting Windows Vista and above The wincrypt API is deprecated and not allowed for Windows Store apps. Wincrypt can be removed after XP support is dropped. --- configure | 4 +++- libavutil/random_seed.c | 17 +++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 77754d0f51..0ab975bb1c 100755 --- a/configure +++ b/configure @@ -1703,6 +1703,7 @@ SYSTEM_FUNCS=" " SYSTEM_LIBRARIES=" +bcrypt sdl vaapi_1 vaapi_drm @@ -2611,7 +2612,7 @@ avdevice_extralibs="libm_extralibs" avformat_extralibs="libm_extralibs" avfilter_extralibs="pthreads_extralibs libm_extralibs" avresample_extralibs="libm_extralibs" -avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" +avutil_extralibs="bcrypt_extralibs clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" swscale_extralibs="libm_extralibs" # programs @@ -4581,6 +4582,7 @@ check_lib ole32"windows.h"CoTaskMemFree -lole32 check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi +test_cpp_condition windows.h "_WIN32_WINNT >= 0x0600" && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 089d883916..d11bff2ef6 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -23,7 +23,10 @@ #if HAVE_UNISTD_H #include #endif -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +#include +#include +#elif HAVE_WINCRYPT #include #include #endif @@ -96,7 +99,17 @@ uint32_t av_get_random_seed(void) { uint32_t seed; -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +BCRYPT_ALG_HANDLE algo_handle; +NTSTATUS ret = BCryptOpenAlgorithmProvider(_handle, BCRYPT_RNG_ALGORITHM, + MS_PRIMITIVE_PROVIDER, 0); +if (BCRYPT_SUCCESS(ret)) { +NTSTATUS ret = BCryptGenRandom(algo_handle, (UCHAR*), sizeof(seed), 0); +BCryptCloseAlgorithmProvider(algo_handle, 0); +if (BCRYPT_SUCCESS(ret)) +return seed; +} +#elif HAVE_WINCRYPT HCRYPTPROV provider; if (CryptAcquireContext(, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { -- 2.16.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] use bcrypt instead of the old wincrypt API
Le 30/03/2018 à 21:07, Martin Storsjö a écrit : On Fri, 30 Mar 2018, James Almer wrote: On 3/30/2018 3:13 PM, Martin Storsjö wrote: On Fri, 30 Mar 2018, James Almer wrote: On 3/30/2018 10:57 AM, Martin Storsjö wrote: On Fri, 30 Mar 2018, Diego Biurrun wrote: On Fri, Mar 30, 2018 at 10:43:27AM -0300, James Almer wrote: On 3/30/2018 10:38 AM, Diego Biurrun wrote: > On Fri, Mar 30, 2018 at 12:38:05PM +0200, Steve Lhomme wrote: >> Le 30/03/2018 à 10:46, Diego Biurrun a écrit : >>> On Fri, Mar 30, 2018 at 09:36:05AM +0200, Steve Lhomme wrote: >>>> --- a/configure >>>> +++ b/configure >>>> @@ -4581,6 +4582,7 @@ check_lib ole32 "windows.h" CoTaskMemFree -lole32 >>>> check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 >>>> check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 >>>> check_lib psapi "windows.h psapi.h" GetProcessMemoryInfo -lpsapi >>>> +check_cpp_condition Vista+ windows.h "_WIN32_WINNT >= 0x0600" && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt If you don't need to set any variable then just use test_cpp_condition() Yes, good point. >>> Do you really need to check the Vista condition? What about using bcrypt >>> unconditionally if available? >> >> Yes, you need to use it only on builds that won't run on XP. Otherwise it >> will fail to load the bcrypt.dll and the whole libavutil DLL (or whatever >> its form) will fail to load. It would be possible to do it dynamically but >> IMO it's overkill. It's not really a critical component. > > Is bcrypt available on XP? If no then the CPP condition check would seem > unnecessary. You could just check for bcrypt and bcrypt being available > would imply Vista. I think I'm missing something. check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt Seems to succeed even if targeting XP, at least on mingw-w64. Isn't that wrong then? I guess it just means that mingw-w64 doesn't have _WIN32_WINNT ifdefs guarding the availability of this function in the headers. (The official windows SDK might, although that SDK also have dropped XP support long ago iirc.) bcrypt.h on mingw-w64 is completely wrapped in checks like #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) || _WIN32_WINNT = 0x0A00 The former is the reason it succeeds in XP, seeing the latter is checking for Windows 10 or newer. Hmm, ok. I guess the correct form would be something like "(WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP) && _WIN32_WINNT >= 0x0600) || _WIN32_WINNT >= 0x0A00" then. // Martin The WINAPI_PARTITION_DESKTOP check is already done in configure to enable or disable the uwp variable. Not sure I see how that relates... that part of the header guard makes it visible on and makes the check succeed when targeting XP, even though it really isn't available there according to Steve. In any case, does this mean that on uwp neither BCryptGenRandom or CryptGenRandom are available/allowed? The way I read that, for UWP on Win10, the bcrypt.h stuff should be fine, no? (Based on the mingw-w64 header guards, it might not be for win8/8.1 RT/store/UWP/whatever apps, although MSDN doesn't seem to say anything about it.) It's available for 8.1 and even before for Winstore apps. That's why I only added the Vista check. Everything above, on all possible targets, is supported. // Martin ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] use bcrypt instead of the old wincrypt API
Le 30/03/2018 à 10:46, Diego Biurrun a écrit : On Fri, Mar 30, 2018 at 09:36:05AM +0200, Steve Lhomme wrote: --- a/configure +++ b/configure @@ -1708,6 +1708,7 @@ SYSTEM_LIBRARIES=" vaapi_x11 vdpau_x11 +bcrypt wincrypt " This should be ordered. @@ -2611,7 +2612,7 @@ avdevice_extralibs="libm_extralibs" avfilter_extralibs="pthreads_extralibs libm_extralibs" avresample_extralibs="libm_extralibs" -avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" +avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs bcrypt_extralibs wincrypt_extralibs" same @@ -4581,6 +4582,7 @@ check_lib ole32"windows.h"CoTaskMemFree -lole32 check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi +check_cpp_condition Vista+ windows.h "_WIN32_WINNT >= 0x0600" && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt Do you really need to check the Vista condition? What about using bcrypt Yes, you need to use it only on builds that won't run on XP. Otherwise it will fail to load the bcrypt.dll and the whole libavutil DLL (or whatever its form) will fail to load. It would be possible to do it dynamically but IMO it's overkill. It's not really a critical component. But with time if XP support is dropped this check can go and wincrypt dropped entirely. unconditionally if available? The variable name with an uppercase letter and a '+' is slightly odd. I'm not sure if it can cause problems but I cannot rule it out offhand either. It seems the same is only used in config.log. And the + didn't cause any problem for me. Diego ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] use bcrypt instead of the old wincrypt API
When targeting Windows Vista and above The wincrypt API is deprecated and not allowed for Windows Store apps. --- configure | 4 +++- libavutil/random_seed.c | 16 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7612a6052c..20064f44d8 100755 --- a/configure +++ b/configure @@ -1708,6 +1708,7 @@ SYSTEM_LIBRARIES=" vaapi_drm vaapi_x11 vdpau_x11 +bcrypt wincrypt " @@ -2611,7 +2612,7 @@ avdevice_extralibs="libm_extralibs" avformat_extralibs="libm_extralibs" avfilter_extralibs="pthreads_extralibs libm_extralibs" avresample_extralibs="libm_extralibs" -avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" +avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs bcrypt_extralibs wincrypt_extralibs" swscale_extralibs="libm_extralibs" # programs @@ -4581,6 +4582,7 @@ check_lib ole32"windows.h"CoTaskMemFree -lole32 check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi +check_cpp_condition windows.h "_WIN32_WINNT >= 0x0600" && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 089d883916..f9686dfae2 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -23,7 +23,9 @@ #if HAVE_UNISTD_H #include #endif -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +#include +#elif HAVE_WINCRYPT #include #include #endif @@ -96,7 +98,17 @@ uint32_t av_get_random_seed(void) { uint32_t seed; -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +BCRYPT_ALG_HANDLE algo_handle; +NTSTATUS ret = BCryptOpenAlgorithmProvider(_handle, BCRYPT_RNG_ALGORITHM, + MS_PRIMITIVE_PROVIDER, 0); +if (BCRYPT_SUCCESS(ret)) { +NTSTATUS ret = BCryptGenRandom(algo_handle, , sizeof(seed), 0); +BCryptCloseAlgorithmProvider(algo_handle, 0); +if (BCRYPT_SUCCESS(ret)) +return seed; +} +#elif HAVE_WINCRYPT HCRYPTPROV provider; if (CryptAcquireContext(, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { -- 2.16.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] use bcrypt instead of the old wincrypt API
When targeting Windows Vista and above The wincrypt API is deprecated and not allowed for Windows Store apps. --- configure | 4 +++- libavutil/random_seed.c | 16 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 7612a6052c..60bca6ff25 100755 --- a/configure +++ b/configure @@ -1708,6 +1708,7 @@ SYSTEM_LIBRARIES=" vaapi_drm vaapi_x11 vdpau_x11 +bcrypt wincrypt " @@ -2611,7 +2612,7 @@ avdevice_extralibs="libm_extralibs" avformat_extralibs="libm_extralibs" avfilter_extralibs="pthreads_extralibs libm_extralibs" avresample_extralibs="libm_extralibs" -avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs wincrypt_extralibs" +avutil_extralibs="clock_gettime_extralibs cuda_extralibs cuvid_extralibs d3d11va_extralibs libm_extralibs libmfx_extralibs nanosleep_extralibs pthreads_extralibs user32_extralibs vaapi_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs bcrypt_extralibs wincrypt_extralibs" swscale_extralibs="libm_extralibs" # programs @@ -4581,6 +4582,7 @@ check_lib ole32"windows.h"CoTaskMemFree -lole32 check_lib shell32 "windows.h shellapi.h" CommandLineToArgvW -lshell32 check_lib wincrypt "windows.h wincrypt.h" CryptGenRandom -ladvapi32 check_lib psapi"windows.h psapi.h"GetProcessMemoryInfo -lpsapi +check_cpp_condition Vista+ windows.h "_WIN32_WINNT >= 0x0600" && check_lib bcrypt "windows.h bcrypt.h" BCryptGenRandom -lbcrypt check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c index 089d883916..f9686dfae2 100644 --- a/libavutil/random_seed.c +++ b/libavutil/random_seed.c @@ -23,7 +23,9 @@ #if HAVE_UNISTD_H #include #endif -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +#include +#elif HAVE_WINCRYPT #include #include #endif @@ -96,7 +98,17 @@ uint32_t av_get_random_seed(void) { uint32_t seed; -#if HAVE_WINCRYPT +#if HAVE_BCRYPT +BCRYPT_ALG_HANDLE algo_handle; +NTSTATUS ret = BCryptOpenAlgorithmProvider(_handle, BCRYPT_RNG_ALGORITHM, + MS_PRIMITIVE_PROVIDER, 0); +if (BCRYPT_SUCCESS(ret)) { +NTSTATUS ret = BCryptGenRandom(algo_handle, , sizeof(seed), 0); +BCryptCloseAlgorithmProvider(algo_handle, 0); +if (BCRYPT_SUCCESS(ret)) +return seed; +} +#elif HAVE_WINCRYPT HCRYPTPROV provider; if (CryptAcquireContext(, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { -- 2.16.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags
On Thu, Sep 21, 2017 at 7:15 PM, Vittorio Giovara <vittorio.giov...@gmail.com> wrote: > On Thu, Sep 21, 2017 at 5:40 PM, Steve Lhomme <rob...@gmail.com> wrote: > >> On Thu, Sep 21, 2017 at 4:58 PM, Vittorio Giovara >> <vittorio.giov...@gmail.com> wrote: >> > On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme <rob...@gmail.com> wrote: >> > >> >> From: "Mohammed (Shaan) Huzaifa Danish" <sha...@gmail.com> >> >> >> >> --- >> >> fix previous patch skipping the wrong amount of bits >> >> --- >> >> libavcodec/h264_sei.c | 6 -- >> >> libavcodec/h264_sei.h | 1 + >> >> libavcodec/h264_slice.c | 2 ++ >> >> libavutil/stereo3d.h| 4 >> >> 4 files changed, 11 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c >> >> index 03fca9017f..96ac427931 100644 >> >> --- a/libavcodec/h264_sei.c >> >> +++ b/libavcodec/h264_sei.c >> >> @@ -315,9 +315,11 @@ static int decode_frame_packing_arrangeme >> nt(H264SEIFramePacking >> >> *h, >> >> h->content_interpretation_type= get_bits(gb, 6); >> >> >> >> // the following skips: spatial_flipping_flag, >> >> frame0_flipped_flag, >> >> -// field_views_flag, current_frame_is_frame0_flag, >> >> +// field_views_flag >> >> +skip_bits(gb, 3); >> >> +h->current_frame_is_frame0_flag = get_bits1(gb); >> >> // frame0_self_contained_flag, frame1_self_contained_flag >> >> -skip_bits(gb, 6); >> >> +skip_bits(gb, 2); >> >> >> >> if (!h->quincunx_subsampling && h->arrangement_type != 5) >> >> skip_bits(gb, 16); // frame[01]_grid_position_[xy] >> >> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h >> >> index f6ac6034da..c3a19dd831 100644 >> >> --- a/libavcodec/h264_sei.h >> >> +++ b/libavcodec/h264_sei.h >> >> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { >> >> int arrangement_type; >> >> int content_interpretation_type; >> >> int quincunx_subsampling; >> >> +int current_frame_is_frame0_flag; >> >> } H264SEIFramePacking; >> >> >> >> typedef struct H264SEIDisplayOrientation { >> >> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c >> >> index 5dd01d836e..f5b78bfe29 100644 >> >> --- a/libavcodec/h264_slice.c >> >> +++ b/libavcodec/h264_slice.c >> >> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context >> *h) >> >> >> >> if (fp->content_interpretation_type == 2) >> >> stereo->flags = AV_STEREO3D_FLAG_INVERT; >> >> +if (fp->current_frame_is_frame0_flag) >> >> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0; >> >> } >> >> >> >> if (h->sei.display_orientation.present && >> >> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h >> >> index 0fa9f63a2c..4c8ab5c40a 100644 >> >> --- a/libavutil/stereo3d.h >> >> +++ b/libavutil/stereo3d.h >> >> @@ -146,6 +146,10 @@ enum AVStereo3DType { >> >> * Inverted views, Right/Bottom represents the left view. >> >> */ >> >> #define AV_STEREO3D_FLAG_INVERT (1 << 0) >> >> +/** >> >> + * This frame is frame0 (left view), otherwise it's the right view. >> >> + */ >> >> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1) >> >> >> > >> > Hey Steve, >> > I would rather not expose a flag for something this specific (as it >> applies >> > to a single type only). >> > The name is also peculiar, and confusing, the left view has always >> priority >> > so that should be the default variant (ie no flag). >> >> If left is the default, how do you signal that it's the right eye ? >> > > You can keep track of the decoded frames, if frame_num%2 == 1 it means > you're on a right view. > > >> Given in all other cases where this SEI is not present you don't know >> if you can assume it's there or not ? > > > if you want, given that the left view has priority, you could do something > like > if packing_type == 5 > if flag0 == 0 > flags |= invert > else > flags = 0 > > >> The flag signals that this frame is the left eye and the one coming >> next is the right eye. >> > > I'm not sure that's the best approach because this flag would be for a very > specific packing type only, and not generic (like the inverted one). What's the status on this ? Weren't you going to submit a patch to set a flag for that mode only ? Should I submit it ? > Do you have a sample available? > -- > Vittorio > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags
On Thu, Sep 21, 2017 at 7:15 PM, Vittorio Giovara <vittorio.giov...@gmail.com> wrote: > On Thu, Sep 21, 2017 at 5:40 PM, Steve Lhomme <rob...@gmail.com> wrote: > >> On Thu, Sep 21, 2017 at 4:58 PM, Vittorio Giovara >> <vittorio.giov...@gmail.com> wrote: >> > On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme <rob...@gmail.com> wrote: >> > >> >> From: "Mohammed (Shaan) Huzaifa Danish" <sha...@gmail.com> >> >> >> >> --- >> >> fix previous patch skipping the wrong amount of bits >> >> --- >> >> libavcodec/h264_sei.c | 6 -- >> >> libavcodec/h264_sei.h | 1 + >> >> libavcodec/h264_slice.c | 2 ++ >> >> libavutil/stereo3d.h| 4 >> >> 4 files changed, 11 insertions(+), 2 deletions(-) >> >> >> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c >> >> index 03fca9017f..96ac427931 100644 >> >> --- a/libavcodec/h264_sei.c >> >> +++ b/libavcodec/h264_sei.c >> >> @@ -315,9 +315,11 @@ static int decode_frame_packing_arrangeme >> nt(H264SEIFramePacking >> >> *h, >> >> h->content_interpretation_type= get_bits(gb, 6); >> >> >> >> // the following skips: spatial_flipping_flag, >> >> frame0_flipped_flag, >> >> -// field_views_flag, current_frame_is_frame0_flag, >> >> +// field_views_flag >> >> +skip_bits(gb, 3); >> >> +h->current_frame_is_frame0_flag = get_bits1(gb); >> >> // frame0_self_contained_flag, frame1_self_contained_flag >> >> -skip_bits(gb, 6); >> >> +skip_bits(gb, 2); >> >> >> >> if (!h->quincunx_subsampling && h->arrangement_type != 5) >> >> skip_bits(gb, 16); // frame[01]_grid_position_[xy] >> >> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h >> >> index f6ac6034da..c3a19dd831 100644 >> >> --- a/libavcodec/h264_sei.h >> >> +++ b/libavcodec/h264_sei.h >> >> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { >> >> int arrangement_type; >> >> int content_interpretation_type; >> >> int quincunx_subsampling; >> >> +int current_frame_is_frame0_flag; >> >> } H264SEIFramePacking; >> >> >> >> typedef struct H264SEIDisplayOrientation { >> >> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c >> >> index 5dd01d836e..f5b78bfe29 100644 >> >> --- a/libavcodec/h264_slice.c >> >> +++ b/libavcodec/h264_slice.c >> >> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context >> *h) >> >> >> >> if (fp->content_interpretation_type == 2) >> >> stereo->flags = AV_STEREO3D_FLAG_INVERT; >> >> +if (fp->current_frame_is_frame0_flag) >> >> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0; >> >> } >> >> >> >> if (h->sei.display_orientation.present && >> >> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h >> >> index 0fa9f63a2c..4c8ab5c40a 100644 >> >> --- a/libavutil/stereo3d.h >> >> +++ b/libavutil/stereo3d.h >> >> @@ -146,6 +146,10 @@ enum AVStereo3DType { >> >> * Inverted views, Right/Bottom represents the left view. >> >> */ >> >> #define AV_STEREO3D_FLAG_INVERT (1 << 0) >> >> +/** >> >> + * This frame is frame0 (left view), otherwise it's the right view. >> >> + */ >> >> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1) >> >> >> > >> > Hey Steve, >> > I would rather not expose a flag for something this specific (as it >> applies >> > to a single type only). >> > The name is also peculiar, and confusing, the left view has always >> priority >> > so that should be the default variant (ie no flag). >> >> If left is the default, how do you signal that it's the right eye ? >> > > You can keep track of the decoded frames, if frame_num%2 == 1 it means > you're on a right view. > > >> Given in all other cases where this SEI is not present you don't know >> if you can assume it's there or not ? > > > if you want, given that the left view has priority, you could do something > like > if packing_type == 5 > if flag0 == 0 > flags |= invert > else > flags = 0 > > >> The flag signals that this frame is the left eye and the one coming >> next is the right eye. >> > > I'm not sure that's the best approach because this flag would be for a very > specific packing type only, and not generic (like the inverted one). > > Do you have a sample available? Yes, I don't think that's what is used in MVC but it seemed to be a popular feature in the Playstation world at some point. Some links to samples can be found here: http://forum.doom9.org/archive/index.php/t-170863.html > -- > Vittorio > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags
On Thu, Sep 21, 2017 at 4:58 PM, Vittorio Giovara <vittorio.giov...@gmail.com> wrote: > On Thu, Sep 21, 2017 at 4:03 PM, Steve Lhomme <rob...@gmail.com> wrote: > >> From: "Mohammed (Shaan) Huzaifa Danish" <sha...@gmail.com> >> >> --- >> fix previous patch skipping the wrong amount of bits >> --- >> libavcodec/h264_sei.c | 6 -- >> libavcodec/h264_sei.h | 1 + >> libavcodec/h264_slice.c | 2 ++ >> libavutil/stereo3d.h| 4 >> 4 files changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c >> index 03fca9017f..96ac427931 100644 >> --- a/libavcodec/h264_sei.c >> +++ b/libavcodec/h264_sei.c >> @@ -315,9 +315,11 @@ static int >> decode_frame_packing_arrangement(H264SEIFramePacking >> *h, >> h->content_interpretation_type= get_bits(gb, 6); >> >> // the following skips: spatial_flipping_flag, >> frame0_flipped_flag, >> -// field_views_flag, current_frame_is_frame0_flag, >> +// field_views_flag >> +skip_bits(gb, 3); >> +h->current_frame_is_frame0_flag = get_bits1(gb); >> // frame0_self_contained_flag, frame1_self_contained_flag >> -skip_bits(gb, 6); >> +skip_bits(gb, 2); >> >> if (!h->quincunx_subsampling && h->arrangement_type != 5) >> skip_bits(gb, 16); // frame[01]_grid_position_[xy] >> diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h >> index f6ac6034da..c3a19dd831 100644 >> --- a/libavcodec/h264_sei.h >> +++ b/libavcodec/h264_sei.h >> @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { >> int arrangement_type; >> int content_interpretation_type; >> int quincunx_subsampling; >> +int current_frame_is_frame0_flag; >> } H264SEIFramePacking; >> >> typedef struct H264SEIDisplayOrientation { >> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c >> index 5dd01d836e..f5b78bfe29 100644 >> --- a/libavcodec/h264_slice.c >> +++ b/libavcodec/h264_slice.c >> @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context *h) >> >> if (fp->content_interpretation_type == 2) >> stereo->flags = AV_STEREO3D_FLAG_INVERT; >> +if (fp->current_frame_is_frame0_flag) >> +stereo->flags |= AV_STEREO3D_FLAG_FRAME0; >> } >> >> if (h->sei.display_orientation.present && >> diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h >> index 0fa9f63a2c..4c8ab5c40a 100644 >> --- a/libavutil/stereo3d.h >> +++ b/libavutil/stereo3d.h >> @@ -146,6 +146,10 @@ enum AVStereo3DType { >> * Inverted views, Right/Bottom represents the left view. >> */ >> #define AV_STEREO3D_FLAG_INVERT (1 << 0) >> +/** >> + * This frame is frame0 (left view), otherwise it's the right view. >> + */ >> +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1) >> > > Hey Steve, > I would rather not expose a flag for something this specific (as it applies > to a single type only). > The name is also peculiar, and confusing, the left view has always priority > so that should be the default variant (ie no flag). If left is the default, how do you signal that it's the right eye ? Given in all other cases where this SEI is not present you don't know if you can assume it's there or not ? The flag signals that this frame is the left eye and the one coming next is the right eye. > All in all, what problem is this trying to solve? Differentiate the left and right view for frame sequential 3D files. > -- > Vittorio > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags
From: "Mohammed (Shaan) Huzaifa Danish"--- fix previous patch skipping the wrong amount of bits --- libavcodec/h264_sei.c | 6 -- libavcodec/h264_sei.h | 1 + libavcodec/h264_slice.c | 2 ++ libavutil/stereo3d.h| 4 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 03fca9017f..96ac427931 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -315,9 +315,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h, h->content_interpretation_type= get_bits(gb, 6); // the following skips: spatial_flipping_flag, frame0_flipped_flag, -// field_views_flag, current_frame_is_frame0_flag, +// field_views_flag +skip_bits(gb, 3); +h->current_frame_is_frame0_flag = get_bits1(gb); // frame0_self_contained_flag, frame1_self_contained_flag -skip_bits(gb, 6); +skip_bits(gb, 2); if (!h->quincunx_subsampling && h->arrangement_type != 5) skip_bits(gb, 16); // frame[01]_grid_position_[xy] diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index f6ac6034da..c3a19dd831 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { int arrangement_type; int content_interpretation_type; int quincunx_subsampling; +int current_frame_is_frame0_flag; } H264SEIFramePacking; typedef struct H264SEIDisplayOrientation { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 5dd01d836e..f5b78bfe29 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context *h) if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; +if (fp->current_frame_is_frame0_flag) +stereo->flags |= AV_STEREO3D_FLAG_FRAME0; } if (h->sei.display_orientation.present && diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h index 0fa9f63a2c..4c8ab5c40a 100644 --- a/libavutil/stereo3d.h +++ b/libavutil/stereo3d.h @@ -146,6 +146,10 @@ enum AVStereo3DType { * Inverted views, Right/Bottom represents the left view. */ #define AV_STEREO3D_FLAG_INVERT (1 << 0) +/** + * This frame is frame0 (left view), otherwise it's the right view. + */ +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1) /** * Stereo 3D type: this structure describes how two videos are packed -- 2.12.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] h264_sei: handle stereoscopy frame sequential flags
From: "Mohammed (Shaan) Huzaifa Danish"--- libavcodec/h264_sei.c | 4 +++- libavcodec/h264_sei.h | 1 + libavcodec/h264_slice.c | 2 ++ libavutil/stereo3d.h| 4 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c index 03fca9017f..337270cb6e 100644 --- a/libavcodec/h264_sei.c +++ b/libavcodec/h264_sei.c @@ -315,7 +315,9 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h, h->content_interpretation_type= get_bits(gb, 6); // the following skips: spatial_flipping_flag, frame0_flipped_flag, -// field_views_flag, current_frame_is_frame0_flag, +// field_views_flag +skip_bits(gb, 3); +h->current_frame_is_frame0_flag = get_bits1(gb); // frame0_self_contained_flag, frame1_self_contained_flag skip_bits(gb, 6); diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h index f6ac6034da..c3a19dd831 100644 --- a/libavcodec/h264_sei.h +++ b/libavcodec/h264_sei.h @@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking { int arrangement_type; int content_interpretation_type; int quincunx_subsampling; +int current_frame_is_frame0_flag; } H264SEIFramePacking; typedef struct H264SEIDisplayOrientation { diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 5dd01d836e..f5b78bfe29 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1112,6 +1112,8 @@ static int h264_export_frame_props(H264Context *h) if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; +if (fp->current_frame_is_frame0_flag) +stereo->flags |= AV_STEREO3D_FLAG_FRAME0; } if (h->sei.display_orientation.present && diff --git a/libavutil/stereo3d.h b/libavutil/stereo3d.h index 0fa9f63a2c..4c8ab5c40a 100644 --- a/libavutil/stereo3d.h +++ b/libavutil/stereo3d.h @@ -146,6 +146,10 @@ enum AVStereo3DType { * Inverted views, Right/Bottom represents the left view. */ #define AV_STEREO3D_FLAG_INVERT (1 << 0) +/** + * This frame is frame0 (left view), otherwise it's the right view. + */ +#define AV_STEREO3D_FLAG_FRAME0 (1 << 1) /** * Stereo 3D type: this structure describes how two videos are packed -- 2.12.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/3] qsvenc: merge the output fifo elements into a structure
This is cleaner to read and less error prone. --- libavcodec/qsvenc.c | 117 +--- 1 file changed, 56 insertions(+), 61 deletions(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 0c10fd45c9..0dd4b5288d 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -68,6 +68,13 @@ static const struct { #endif }; +struct QSVpacket +{ +AVPacket new_pkt; +mfxBitstream *bs; +mfxSyncPoint *syncp; +}; + static const char *print_profile(mfxU16 profile) { int i; @@ -813,8 +820,7 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext *q) q->param.AsyncDepth = q->async_depth; -q->async_fifo = av_fifo_alloc((1 + q->async_depth) * - (sizeof(AVPacket) + sizeof(mfxSyncPoint*) + sizeof(mfxBitstream*))); +q->async_fifo = av_fifo_alloc((1 + q->async_depth) * sizeof(struct QSVpacket)); if (!q->async_fifo) return AVERROR(ENOMEM); @@ -1063,14 +1069,19 @@ static void print_interlace_msg(AVCodecContext *avctx, QSVEncContext *q) } } +static void qsv_packet_release(struct QSVpacket *qsv_pkt) +{ +av_packet_unref(_pkt->new_pkt); +av_freep(qsv_pkt->bs); +av_freep(qsv_pkt->syncp); +} + static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, const AVFrame *frame) { -AVPacket new_pkt = { 0 }; -mfxBitstream *bs; +struct QSVpacket qsv_pkt = { 0 }; mfxFrameSurface1 *surf = NULL; -mfxSyncPoint *sync = NULL; mfxStatus ret; if (frame) { @@ -1081,29 +1092,29 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, } } -ret = av_new_packet(_pkt, q->packet_size); +ret = av_new_packet(_pkt.new_pkt, q->packet_size); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error allocating the output packet\n"); return ret; } -bs = av_mallocz(sizeof(*bs)); -if (!bs) { -av_packet_unref(_pkt); +qsv_pkt.bs = av_mallocz(sizeof(*qsv_pkt.bs)); +if (!qsv_pkt.bs) { +av_packet_unref(_pkt.new_pkt); return AVERROR(ENOMEM); } -bs->Data = new_pkt.data; -bs->MaxLength = new_pkt.size; +qsv_pkt.bs->Data = qsv_pkt.new_pkt.data; +qsv_pkt.bs->MaxLength = qsv_pkt.new_pkt.size; -sync = av_mallocz(sizeof(*sync)); -if (!sync) { -av_freep(); -av_packet_unref(_pkt); +qsv_pkt.syncp = av_mallocz(sizeof(*qsv_pkt.syncp)); +if (!qsv_pkt.syncp) { +av_freep(_pkt.bs); +av_packet_unref(_pkt.new_pkt); return AVERROR(ENOMEM); } do { -ret = MFXVideoENCODE_EncodeFrameAsync(q->session, NULL, surf, bs, sync); +ret = MFXVideoENCODE_EncodeFrameAsync(q->session, enc_ctrl, surf, qsv_pkt.bs, qsv_pkt.syncp); if (ret == MFX_WRN_DEVICE_BUSY) av_usleep(1); } while (ret == MFX_WRN_DEVICE_BUSY || ret == MFX_WRN_IN_EXECUTION); @@ -1112,9 +1123,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, ff_qsv_print_warning(avctx, ret, "Warning during encoding"); if (ret < 0) { -av_packet_unref(_pkt); -av_freep(); -av_freep(); +qsv_packet_release(_pkt); return (ret == MFX_ERR_MORE_DATA) ? 0 : ff_qsv_print_error(avctx, ret, "Error during encoding"); } @@ -1122,14 +1131,10 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, if (ret == MFX_WRN_INCOMPATIBLE_VIDEO_PARAM && frame->interlaced_frame) print_interlace_msg(avctx, q); -if (*sync) { -av_fifo_generic_write(q->async_fifo, _pkt, sizeof(new_pkt), NULL); -av_fifo_generic_write(q->async_fifo, ,sizeof(sync),NULL); -av_fifo_generic_write(q->async_fifo, , sizeof(bs),NULL); +if (*qsv_pkt.syncp) { +av_fifo_generic_write(q->async_fifo, _pkt, sizeof(qsv_pkt), NULL); } else { -av_freep(); -av_packet_unref(_pkt); -av_freep(); +qsv_packet_release(_pkt); } return 0; @@ -1146,57 +1151,53 @@ int ff_qsv_encode(AVCodecContext *avctx, QSVEncContext *q, if (!av_fifo_space(q->async_fifo) || (!frame && av_fifo_size(q->async_fifo))) { -AVPacket new_pkt; -mfxBitstream *bs; -mfxSyncPoint *sync; +struct QSVpacket qsv_pkt; -av_fifo_generic_read(q->async_fifo, _pkt, sizeof(new_pkt), NULL); -av_fifo_generic_read(q->async_fifo, ,sizeof(sync),NULL); -av_fifo_generic_read(q->async_fifo, , sizeof(bs), NULL); +av_fifo_generic_read(q->async_fifo, _pkt, sizeof(qsv_pkt), NULL); do { -ret = MFXVideoCORE_SyncOperation(q->session, *sync, 1000); +ret = MFXVideoCORE_SyncOperation(q->session, *qsv_pkt.syncp, 1000); } while (ret == MFX_WRN_IN_EXECUTION); -new_pkt.dts = av_rescale_q(bs->DecodeTimeStamp, (AVRational){1, 9},
[libav-devel] [PATCH 1/3] qsvenc: the return value is not any kind of int, it's a mfxStatus
--- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index c7e5947361..0c10fd45c9 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1071,7 +1071,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, mfxFrameSurface1 *surf = NULL; mfxSyncPoint *sync = NULL; -int ret; +mfxStatus ret; if (frame) { ret = submit_frame(q, frame, ); -- 2.12.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/3] qsvenc: use 'else' on exclusive code
--- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 0dd4b5288d..eee975c4cd 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1122,7 +1122,7 @@ static int encode_frame(AVCodecContext *avctx, QSVEncContext *q, if (ret > 0) ff_qsv_print_warning(avctx, ret, "Warning during encoding"); -if (ret < 0) { +else if (ret < 0) { qsv_packet_release(_pkt); return (ret == MFX_ERR_MORE_DATA) ? 0 : ff_qsv_print_error(avctx, ret, "Error during encoding"); -- 2.12.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 1/6] lavu: add new D3D11 pixfmt and hwcontext
On Wed, Jun 7, 2017 at 4:53 PM, wm4 <nfx...@googlemail.com> wrote: > On Wed, 7 Jun 2017 16:42:32 +0200 > Steve Lhomme <rob...@gmail.com> wrote: > >> On Wed, Jun 7, 2017 at 12:06 PM, wm4 <nfx...@googlemail.com> wrote: >> > On Wed, 7 Jun 2017 08:59:24 +0200 >> > Steve Lhomme <rob...@gmail.com> wrote: >> > >> >> On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: >> > >> >> > +static int d3d11va_device_create(AVHWDeviceContext *ctx, const char >> >> > *device, >> >> > + AVDictionary *opts, int flags) >> >> > +{ >> >> > +AVD3D11VADeviceContext *device_hwctx = ctx->hwctx; >> >> > +HANDLE d3dlib; >> >> > + >> >> > +HRESULT hr; >> >> > +PFN_D3D11_CREATE_DEVICE createD3D; >> >> > +IDXGIAdapter *pAdapter = NULL; >> >> > +ID3D10Multithread *pMultithread; >> >> > +UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; >> >> >> >> It may be nice to be able to load d3d11_1sdklayers.dll optionally to >> >> debug leaks and have more debug messages when error occurs. Probably >> >> using a value in flags. >> > >> > Yes, that could be added later, if that's fine. I'm also not sure how >> > to load the DLL, or rather what to do with it once it's loaded. >> >> You don't do anything with it. But it provides fancy debug messages >> when you're doing something you shouldn't be doing. >> >> This is how we enable it in VLC >> http://git.videolan.org/?p=vlc.git;a=blob;f=modules/video_output/win32/direct3d11.c;h=e9fcb83dcabfe778f26e63d19f218caf06a7c3ae;hb=HEAD#l1482 > > Why does it immediately unload it? Is it just for checking whether it > exists? Yes, otherwise if you set the flag and the DLL doesn't exist, it will fail to create the device. > But yes, this could definitely be added to the Libav code. > >> And since you use the DXGI API you may also enable debugging of DXGI: >> >> http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/avcodec/d3d11va.c;h=85e7d25caebc059a9770da2ef4bb8fe90816d76d;hb=HEAD#l599 > > Seems like a good idea too. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 1/6] lavu: add new D3D11 pixfmt and hwcontext
On Wed, Jun 7, 2017 at 12:06 PM, wm4 <nfx...@googlemail.com> wrote: > On Wed, 7 Jun 2017 08:59:24 +0200 > Steve Lhomme <rob...@gmail.com> wrote: > >> On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: > >> > +static int d3d11va_device_create(AVHWDeviceContext *ctx, const char >> > *device, >> > + AVDictionary *opts, int flags) >> > +{ >> > +AVD3D11VADeviceContext *device_hwctx = ctx->hwctx; >> > +HANDLE d3dlib; >> > + >> > +HRESULT hr; >> > +PFN_D3D11_CREATE_DEVICE createD3D; >> > +IDXGIAdapter *pAdapter = NULL; >> > +ID3D10Multithread *pMultithread; >> > +UINT creationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT; >> >> It may be nice to be able to load d3d11_1sdklayers.dll optionally to >> debug leaks and have more debug messages when error occurs. Probably >> using a value in flags. > > Yes, that could be added later, if that's fine. I'm also not sure how > to load the DLL, or rather what to do with it once it's loaded. You don't do anything with it. But it provides fancy debug messages when you're doing something you shouldn't be doing. This is how we enable it in VLC http://git.videolan.org/?p=vlc.git;a=blob;f=modules/video_output/win32/direct3d11.c;h=e9fcb83dcabfe778f26e63d19f218caf06a7c3ae;hb=HEAD#l1482 And since you use the DXGI API you may also enable debugging of DXGI: http://git.videolan.org/?p=vlc.git;a=blob;f=modules/codec/avcodec/d3d11va.c;h=85e7d25caebc059a9770da2ef4bb8fe90816d76d;hb=HEAD#l599 > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 5/6] dxva: add support for new dxva2 and d3d11 hwaccel APIs
On Wed, Jun 7, 2017 at 12:13 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Wed, Jun 7, 2017 at 9:10 AM, Steve Lhomme <rob...@gmail.com> wrote: >> On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: >>> This also adds support to avconv (which is trivial due to the new >>> hwaccel API being generic enough). For now, this keeps avconv_dxva2.c as >>> "dxva2-old", although it doesn't work as avconv.c can't handle multiple >>> hwaccels with the same pixfmt. It will be removed in a later commit. >>> >>> The new decoder setup code in dxva2.c is significantly based on work by >>> Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. >>> --- >>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c >>> index 69d5908551..7a9182af9b 100644 >>> --- a/libavcodec/hevcdec.c >>> +++ b/libavcodec/hevcdec.c >>> @@ -383,7 +383,7 @@ static void export_stream_params(AVCodecContext *avctx, >>> const HEVCParamSets *ps, >>> >>> static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) >>> { >>> -#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + >>> CONFIG_HEVC_D3D11VA_HWACCEL + \ >>> +#define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + >>> CONFIG_HEVC_D3D11VA_HWACCEL * 2 + \ >>> CONFIG_HEVC_VAAPI_HWACCEL + >>> CONFIG_HEVC_VDPAU_HWACCEL) >>> enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; >>> >>> @@ -391,6 +391,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, >>> const HEVCSPS *sps) >>> sps->pix_fmt == AV_PIX_FMT_YUV420P10) { >>> #if CONFIG_HEVC_D3D11VA_HWACCEL >>> *fmt++ = AV_PIX_FMT_D3D11VA_VLD; >>> +*fmt++ = AV_PIX_FMT_D3D11; >> >> Can this be configured when building ? Since I will not support the >> new format anytime soon I'd rather not try this for every file we >> decode for nothing. >> > > The old version is first in the format list, so your app gets called > with that first. Additional ifdefs everywhere and a configure option > would get seriously messy, just to avoid one if check in the app that > you should be having anyway (and possibly even do already?). Please > don't :) Yes but in VLC if you select no HW acceleration we still try all output formats until we find a matching configuration. Also if the new format is better, shouldn't it come before the old one ? (I wouldn't mind having D3D11 above DXVA2 as well) > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 4/6] dxva: move d3d11 locking/unlocking to functions
On Wed, Jun 7, 2017 at 12:11 PM, wm4 <nfx...@googlemail.com> wrote: > On Wed, 7 Jun 2017 09:01:07 +0200 > Steve Lhomme <rob...@gmail.com> wrote: > >> On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: > >> > 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)) >> >> Did you mean ff_dxva2_lock() ? > > But that call is there? It's still D3D11-only, and does nothing with > DXVA2. I thought it'd be cleaner to have it outside of the ifdefs. Ooops, I missed it. It's above. My bad. >> > 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)) >> >> Same here > > Should be fine here too. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 5/6] dxva: add support for new dxva2 and d3d11 hwaccel APIs
On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: > This also adds support to avconv (which is trivial due to the new > hwaccel API being generic enough). For now, this keeps avconv_dxva2.c as > "dxva2-old", although it doesn't work as avconv.c can't handle multiple > hwaccels with the same pixfmt. It will be removed in a later commit. > > The new decoder setup code in dxva2.c is significantly based on work by > Steve Lhomme <rob...@gmail.com>, but with heavy changes/rewrites. > --- > Changelog | 1 + > avtools/avconv.h| 2 + > avtools/avconv_opt.c| 8 +- > configure | 10 + > 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 + > 18 files changed, 852 insertions(+), 11 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/avconv.h b/avtools/avconv.h > index 3354c50444..fe2bb313b7 100644 > --- a/avtools/avconv.h > +++ b/avtools/avconv.h > @@ -54,9 +54,11 @@ enum HWAccelID { > HWACCEL_AUTO, > HWACCEL_VDPAU, > HWACCEL_DXVA2, > +HWACCEL_DXVA2_OLD, > HWACCEL_VDA, > HWACCEL_QSV, > HWACCEL_VAAPI, > +HWACCEL_D3D11VA, > }; > > typedef struct HWAccel { > diff --git a/avtools/avconv_opt.c b/avtools/avconv_opt.c > index 9839a2269e..7e4f124610 100644 > --- a/avtools/avconv_opt.c > +++ b/avtools/avconv_opt.c > @@ -60,8 +60,14 @@ const HWAccel hwaccels[] = { > { "vdpau", hwaccel_decode_init, HWACCEL_VDPAU, AV_PIX_FMT_VDPAU, >AV_HWDEVICE_TYPE_VDPAU }, > #endif > +#if CONFIG_D3D11VA > +{ "d3d11va", hwaccel_decode_init, HWACCEL_D3D11VA, AV_PIX_FMT_D3D11, > + AV_HWDEVICE_TYPE_D3D11VA }, > +#endif > #if HAVE_DXVA2_LIB > -{ "dxva2", dxva2_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD, > +{ "dxva2", hwaccel_decode_init, HWACCEL_DXVA2, AV_PIX_FMT_DXVA2_VLD, > + AV_HWDEVICE_TYPE_DXVA2 }, > +{ "dxva2-old", dxva2_init, HWACCEL_DXVA2_OLD, AV_PIX_FMT_DXVA2_VLD, >AV_HWDEVICE_TYPE_NONE }, > #endif > #if CONFIG_VDA > diff --git a/configure b/configure > index 481ce2674a..5fd535b80d 100755 > --- a/configure > +++ b/configure > @@ -2175,6 +2175,8 @@ h263_vaapi_hwaccel_deps="vaapi" > h263_vaapi_hwaccel_select="h263_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_mmal_hwaccel_deps="mmal" > @@ -2189,6 +2191,8 @@ h264_vdpau_hwaccel_deps="vdpau" > h264_vdpau_hwaccel_select="h264_decoder" > 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_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC" > hevc_dxva2_hwaccel_select="hevc_decoder" > hevc_qsv_hwaccel_deps="libmfx" > @@ -2200,6 +2204,8 @@ mpeg1_vdpau_hwaccel_deps="vdpau" > mpeg1_vdpau_hwaccel_select="mpeg1video_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="mpeg2video_decoder" > mpeg2_mmal_hwaccel_deps="mmal" > @@ -2214,6 +2220,8 @@ mpeg4_vdpau_hwaccel_deps="vdpau" > mpeg4_vdpau_hwaccel_select=
Re: [libav-devel] [PATCH v3 4/6] dxva: move d3d11 locking/unlocking to functions
On Tue, Jun 6, 2017 at 6:51 PM, wm4wrote: > 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. > --- > libavcodec/dxva2.c | 46 -- > 1 file changed, 28 insertions(+), 18 deletions(-) > > diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c > index 1cb79fe294..0d4effd228 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)) Did you mean ff_dxva2_lock() ? > 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)) Same here > 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; > -- > 2.11.0 > > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH v3 1/6] lavu: add new D3D11 pixfmt and hwcontext
On Tue, Jun 6, 2017 at 6:51 PM, wm4 <nfx...@googlemail.com> wrote: > 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. > --- > configure | 6 +- > 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 +- > 11 files changed, 686 insertions(+), 4 deletions(-) > create mode 100644 libavutil/hwcontext_d3d11va.c > create mode 100644 libavutil/hwcontext_d3d11va.h > > diff --git a/configure b/configure > index 0281f54505..481ce2674a 100755 > --- a/configure > +++ b/configure > @@ -2166,7 +2166,7 @@ zmbv_encoder_deps="zlib" > > # hardware accelerators > d3d11va_deps="d3d11_h dxva_h ID3D11VideoDecoder" > -dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode" > +dxva2_deps="dxva2api_h DXVA2_ConfigPictureDecode ole32" > dxva2_lib_deps="dxva2" > vda_deps="VideoDecodeAcceleration_VDADecoder_h blocks_extension pthreads" > vda_extralibs="-framework CoreFoundation -framework VideoDecodeAcceleration > -framework QuartzCore" > @@ -4877,6 +4877,10 @@ if enabled libxcb; then > check_pkg_config libxcb_xfixes xcb-xfixes xcb/xfixes.h > xcb_xfixes_get_cursor_image > fi > > +enabled d3d11va && > +check_type "windows.h d3d11.h" ID3D11VideoDevice || > +disable d3d11va > + > enabled dxva2 && > check_lib dxva2_lib windows.h CoTaskMemFree -lole32 > > 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
Re: [libav-devel] [PATCH v2 0/6] New D3D hwaccel API stuff
LGTM. I haven't tested the patches so I'm not sure it works as expected. But just looking at the code it seems to do the job. There doesn't seem to be support for decoding to DXGI_FORMAT_420_OPAQUE which is often available. But since it can't be displayed or mapped to CPU I guess it's useless here. In some cases that's the only available decoder though (some cellphones). On Mon, May 22, 2017 at 4:02 PM, wm4wrote: > Hopefully addresses most of the review comments. > > wm4 (6): > lavu: add new D3D11 pixfmt and hwcontext > lavc: set avctx->hwaccel before init > dxva: preparations for new hwaccel API > dxva: move d3d11 locking/unlocking to functions > dxva: add support for new dxva2 and d3d11 hwaccel APIs > avconv: remove old avconv_dxva2 > > Changelog | 1 + > avtools/Makefile | 1 - > avtools/avconv.h | 1 + > avtools/avconv_dxva2.c | 440 - > avtools/avconv_opt.c | 10 +- > configure | 21 +- > doc/APIchanges | 9 + > libavcodec/allcodecs.c | 5 + > libavcodec/decode.c| 4 +- > libavcodec/dxva2.c | 732 > +++-- > libavcodec/dxva2_h264.c| 36 +- > libavcodec/dxva2_hevc.c| 32 +- > libavcodec/dxva2_internal.h| 63 +++- > libavcodec/dxva2_mpeg2.c | 32 +- > libavcodec/dxva2_vc1.c | 54 ++- > libavcodec/h264_slice.c| 3 +- > libavcodec/hevcdec.c | 3 +- > libavcodec/mpeg12dec.c | 1 + > libavcodec/vc1dec.c| 1 + > libavcodec/version.h | 4 +- > libavutil/Makefile | 3 + > libavutil/hwcontext.c | 4 + > libavutil/hwcontext.h | 1 + > libavutil/hwcontext_d3d11va.c | 490 +++ > libavutil/hwcontext_d3d11va.h | 160 + > libavutil/hwcontext_dxva2.h| 3 + > libavutil/hwcontext_internal.h | 1 + > libavutil/pixdesc.c| 4 + > libavutil/pixfmt.h | 14 +- > libavutil/version.h| 4 +- > 30 files changed, 1617 insertions(+), 520 deletions(-) > delete mode 100644 avtools/avconv_dxva2.c > create mode 100644 libavutil/hwcontext_d3d11va.c > create mode 100644 libavutil/hwcontext_d3d11va.h > > -- > 2.11.0 > > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/8] hevc: properly handle no_rasl_output_flag when removing pictures from the DPB
Yes, I probably messed up. Merging code from very different 2 year old code is not exactly easy. I don't know how you people do this... On Tue, Apr 11, 2017 at 3:33 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Tue, Apr 11, 2017 at 3:29 PM, Anton Khirnov <an...@khirnov.net> wrote: >> Quoting Steve Lhomme (2017-04-07 14:27:39) >>> From: Hendrik Leppkes <h.lepp...@gmail.com> >>> >>> Fixes ticket #4185. >>> >>> Reviewed-By: Mickael Raulet <mickael.rau...@insa-rennes.fr> >>> Signed-off-by: Hendrik Leppkes <h.lepp...@gmail.com> >>> --- >>> libavcodec/hevcdec.c | 3 +++ >>> libavcodec/hevcdec.h | 1 + >>> 2 files changed, 4 insertions(+) >>> >>> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c >>> index 6a04858587..6fe05d1b01 100644 >>> --- a/libavcodec/hevcdec.c >>> +++ b/libavcodec/hevcdec.c >>> @@ -2421,6 +2421,8 @@ static int hevc_frame_start(HEVCContext *s) >>> s->is_decoded= 0; >>> s->first_nal_type= s->nal_unit_type; >>> >>> +s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s); >>> + >>> if (s->ps.pps->tiles_enabled_flag) >>> lc->end_of_tiles_x = s->ps.pps->column_width[0] << >>> s->ps.sps->log2_ctb_size; >>> >>> @@ -3007,6 +3009,7 @@ static int hevc_update_thread_context(AVCodecContext >>> *dst, >>> s->seq_output = s0->seq_output; >>> s->pocTid0= s0->pocTid0; >>> s->max_ra = s0->max_ra; >>> +s->no_rasl_output_flag = s0->no_rasl_output_flag; >>> >>> s->is_nalff= s0->is_nalff; >>> s->nal_length_size = s0->nal_length_size; >>> diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h >>> index ff192f67ae..64089bde75 100644 >>> --- a/libavcodec/hevcdec.h >>> +++ b/libavcodec/hevcdec.h >>> @@ -484,6 +484,7 @@ typedef struct HEVCContext { >>> int bs_height; >>> >>> int is_decoded; >>> +int no_rasl_output_flag; >>> >>> HEVCPredContext hpc; >>> HEVCDSPContext hevcdsp; >>> -- >>> 2.11.1 >> >> Eh? This seems to be write-only. >> > > For some reason he skipped one of the hunks (and also modified the > actual setting of the flag?) > http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=0118158efa8e45761f9f65a3bb74f33907bd2aec > > Also, a follow up for tsan happyness: > http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=bddabfaab65808e40605181d579ffcd85bfe4c26 > > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 7/8] lavc: Add Content Light Level side metadata found in HEVC
These data are necessary when transmitting HDR over HDMI. Signed-off-by: James Almer--- doc/APIchanges| 3 +++ libavcodec/avcodec.h | 7 +++ libavcodec/decode.c | 1 + libavcodec/hevc_sei.c | 15 +++ libavcodec/hevcdec.c | 18 ++ libavcodec/hevcdec.h | 5 + libavcodec/version.h | 4 ++-- 7 files changed, 51 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4c35f727e6..ace50b2a3d 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2016-04-06 - xxx - lavc 58.2.0 - avcodec.h + Add AV_PKT_DATA_CONTENT_LIGHT_LEVEL packet side data. + 2016-04-xx - xxx - lavu 56.2.0 - mastering_display_metadata.h Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc() and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index fc1f2a4dfc..1d41badea6 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1075,6 +1075,13 @@ enum AVPacketSideDataType { * of the AVMasteringDisplayMetadata struct. */ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + +/** + * Content light level (based on CTA-861.3). This metadata should be + * associated with a video stream and containts data in the form of the + * AVContentLightMetadata struct. + */ +AV_PKT_DATA_CONTENT_LIGHT_LEVEL, }; typedef struct AVPacketSideData { diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 4a05b8d089..3ed5cc4fd6 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1030,6 +1030,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, +{ AV_PKT_DATA_CONTENT_LIGHT_LEVEL, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL }, }; frame->color_primaries = avctx->color_primaries; diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 1105b51493..e41b8262bc 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -99,6 +99,19 @@ static int decode_nal_sei_mastering_display_info(HEVCContext *s) return 0; } +static int decode_nal_sei_content_light_info(HEVCContext *s) +{ +GetBitContext *gb = >HEVClc.gb; +// Max and average light levels +s->max_content_light_level = get_bits_long(gb, 16); +s->max_pic_average_light_level = get_bits_long(gb, 16); +// As this SEI message comes before the first frame that references it, +// initialize the flag to 2 and decrement on IRAP access unit so it +// persists for the coded video sequence (e.g., between two IRAPs) +s-> sei_content_light_present = 2; +return 0; +} + static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s) { GetBitContext *gb = >HEVClc.gb; @@ -155,6 +168,8 @@ static int decode_nal_sei_prefix(HEVCContext *s, int type, int size) return decode_nal_sei_display_orientation(s); case SEI_TYPE_MASTERING_DISPLAY_INFO: return decode_nal_sei_mastering_display_info(s); +case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO: +return decode_nal_sei_content_light_info(s); default: av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); skip_bits_long(gb, 8 * size); diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 30d9194c60..22ca33a9f7 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2455,6 +2455,24 @@ static int set_side_data(HEVCContext *s) "min_luminance=%f, max_luminance=%f\n", av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); } +// Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1 +// so the side data persists for the entire coded video sequence. +if (s->sei_content_light_present > 0 && +IS_IRAP(s) && s->no_rasl_output_flag) { +s->sei_content_light_present--; +} +if (s->sei_content_light_present) { +AVContentLightMetadata *metadata = +av_content_light_metadata_create_side_data(out); +if (!metadata) +return AVERROR(ENOMEM); +metadata->MaxCLL = s->max_content_light_level; +metadata->MaxFALL = s->max_pic_average_light_level; + +av_log(s->avctx, AV_LOG_DEBUG, "Content Light Level Metadata:\n"); +av_log(s->avctx, AV_LOG_DEBUG, "MaxCLL=%d, MaxFALL=%d\n", + metadata->MaxCLL, metadata->MaxFALL); +} return 0; } diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index cb8bd2e7e5..ffc3fdcac2 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -553,6 +553,11 @@ typedef struct HEVCContext { uint32_t max_mastering_luminance;
[libav-devel] [PATCH 8/8] avformat/dump : Display Content Light Level metadata
Signed-off-by: James Almer--- libavformat/dump.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/libavformat/dump.c b/libavformat/dump.c index 3645e82d7b..090d5c1a9b 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -325,6 +325,14 @@ static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) { av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); } +static void dump_content_light_metadata(void *ctx, AVPacketSideData* sd) +{ +AVContentLightMetadata* metadata = (AVContentLightMetadata*)sd->data; +av_log(ctx, AV_LOG_INFO, "Content Light Level Metadata, " + "MaxCLL=%d, MaxFALL=%d", + metadata->MaxCLL, metadata->MaxFALL); +} + static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData *sd) { AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data; @@ -416,6 +424,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: dump_mastering_display_metadata(ctx, ); break; +case AV_PKT_DATA_CONTENT_LIGHT_LEVEL: +dump_content_light_metadata(ctx, ); +break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd.type, sd.size); -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 6/8] lavu: add support for Content Light Level side metadata
As found in HEVC. Signed-off-by: James Almer--- doc/APIchanges | 5 + libavutil/frame.h | 6 ++ libavutil/mastering_display_metadata.c | 23 libavutil/mastering_display_metadata.h | 39 ++ libavutil/version.h| 2 +- 5 files changed, 74 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index e8bb5a4012..4c35f727e6 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,11 @@ libavutil: 2017-03-23 API changes, most recent first: +2016-04-xx - xxx - lavu 56.2.0 - mastering_display_metadata.h + Add AV_FRAME_DATA_CONTENT_LIGHT_LEVEL value, av_content_light_metadata_alloc() + and av_content_light_metadata_create_side_data() API, and AVContentLightMetadata + type to export content light level video properties. + 2017-04-xx - xxx - lavc 58.1.1 - avcodec.h Add AV_PKT_DATA_MASTERING_DISPLAY_METADATA. diff --git a/libavutil/frame.h b/libavutil/frame.h index 881d8f0051..a6b50feb49 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -105,6 +105,12 @@ enum AVFrameSideDataType { * mastering display color volume. */ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA, + +/** + * Content light level (based on CTA-861.3). This payload contains data in + * the form of the AVContentLightMetadata struct. + */ +AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, }; enum AVActiveFormatDescription { diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c index e1683e55c7..6069347617 100644 --- a/libavutil/mastering_display_metadata.c +++ b/libavutil/mastering_display_metadata.c @@ -41,3 +41,26 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFra return (AVMasteringDisplayMetadata *)side_data->data; } + +AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size) +{ +AVContentLightMetadata *metadata = av_mallocz(sizeof(AVContentLightMetadata)); + +if (size) +*size = sizeof(*metadata); + +return metadata; +} + +AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame) +{ +AVFrameSideData *side_data = av_frame_new_side_data(frame, + AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, + sizeof(AVContentLightMetadata)); +if (!side_data) +return NULL; + +memset(side_data->data, 0, sizeof(AVContentLightMetadata)); + +return (AVContentLightMetadata *)side_data->data; +} diff --git a/libavutil/mastering_display_metadata.h b/libavutil/mastering_display_metadata.h index 936533fec4..847b0b62c6 100644 --- a/libavutil/mastering_display_metadata.h +++ b/libavutil/mastering_display_metadata.h @@ -86,4 +86,43 @@ AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void); */ AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame); +/** + * Content light level needed by to transmit HDR over HDMI (CTA-861.3). + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with av_content_light_metadata_alloc() + * and its size is not a part of the public ABI. + */ +typedef struct AVContentLightMetadata { +/** + * Max content light level (cd/m^2). + */ +unsigned MaxCLL; + +/** + * Max average light level per frame (cd/m^2). + */ +unsigned MaxFALL; +} AVContentLightMetadata; + +/** + * Allocate an AVContentLightMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVContentLightMetadata filled with default values or NULL + * on failure. + */ +AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size); + +/** + * Allocate a complete AVContentLightMetadata and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVContentLightMetadata structure to be filled by caller. + */ +AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame); + #endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */ diff --git a/libavutil/version.h b/libavutil/version.h index fd72ff431d..2c85120b64 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -54,7 +54,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 1 +#define LIBAVUTIL_VERSION_MINOR 2 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 5/8] lavf/dump.c: Print mastering display metadata
From: Neil BirkbeckSigned-off-by: Neil Birkbeck Signed-off-by: Michael Niedermayer --- libavformat/dump.c | 21 + 1 file changed, 21 insertions(+) diff --git a/libavformat/dump.c b/libavformat/dump.c index c56895628d..3645e82d7b 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -25,6 +25,7 @@ #include "libavutil/display.h" #include "libavutil/intreadwrite.h" #include "libavutil/log.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/mathematics.h" #include "libavutil/replaygain.h" #include "libavutil/spherical.h" @@ -307,6 +308,23 @@ static void dump_cpb(void *ctx, AVPacketSideData *sd) cpb->vbv_delay); } +static void dump_mastering_display_metadata(void *ctx, AVPacketSideData* sd) { +AVMasteringDisplayMetadata* metadata = (AVMasteringDisplayMetadata*)sd->data; +av_log(ctx, AV_LOG_INFO, "Mastering Display Metadata, " + "has_primaries:%d has_luminance:%d " + "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f) " + "min_luminance=%f, max_luminance=%f\n", + metadata->has_primaries, metadata->has_luminance, + av_q2d(metadata->display_primaries[0][0]), + av_q2d(metadata->display_primaries[0][1]), + av_q2d(metadata->display_primaries[1][0]), + av_q2d(metadata->display_primaries[1][1]), + av_q2d(metadata->display_primaries[2][0]), + av_q2d(metadata->display_primaries[2][1]), + av_q2d(metadata->white_point[0]), av_q2d(metadata->white_point[1]), + av_q2d(metadata->min_luminance), av_q2d(metadata->max_luminance)); +} + static void dump_spherical(void *ctx, AVCodecParameters *par, AVPacketSideData *sd) { AVSphericalMapping *spherical = (AVSphericalMapping *)sd->data; @@ -395,6 +413,9 @@ static void dump_sidedata(void *ctx, AVStream *st, const char *indent) av_log(ctx, AV_LOG_INFO, "spherical: "); dump_spherical(ctx, st->codecpar, ); break; +case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: +dump_mastering_display_metadata(ctx, ); +break; default: av_log(ctx, AV_LOG_WARNING, "unknown side data type %d (%d bytes)", sd.type, sd.size); -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/8] libavcodec:add packet level support for mastering metadata
From: Neil BirkbeckSome containers, like webm/mkv, will contain this mastering metadata. This is analogous to the way 3D fpa data is handled (in frame and packet side data). Signed-off-by: Neil Birkbeck Signed-off-by: Michael Niedermayer --- doc/APIchanges | 3 +++ libavcodec/avcodec.h | 7 +++ libavcodec/decode.c | 1 + libavcodec/version.h | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 5ce112262a..e8bb5a4012 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-04-xx - xxx - lavc 58.1.1 - avcodec.h + Add AV_PKT_DATA_MASTERING_DISPLAY_METADATA. + 2017-04-xx - xxx - lavu 56.1.0 - mastering_display_metadata.h Add mastering_display_metadata.h/c, av_mastering_display_metadata_alloc() and av_mastering_display_metadata_create_side_data() API, and AVMasteringDisplayMetadata diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 1c58fe2d68..fc1f2a4dfc 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1068,6 +1068,13 @@ enum AVPacketSideDataType { * to the AVSphericalMapping structure. */ AV_PKT_DATA_SPHERICAL, + +/** + * Mastering display metadata (based on SMPTE-2086:2014). This metadata + * should be associated with a video stream and containts data in the form + * of the AVMasteringDisplayMetadata struct. + */ +AV_PKT_DATA_MASTERING_DISPLAY_METADATA, }; typedef struct AVPacketSideData { diff --git a/libavcodec/decode.c b/libavcodec/decode.c index e4f6a0d727..4a05b8d089 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1029,6 +1029,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_SPHERICAL, AV_FRAME_DATA_SPHERICAL }, { AV_PKT_DATA_STEREO3D, AV_FRAME_DATA_STEREO3D }, { AV_PKT_DATA_AUDIO_SERVICE_TYPE, AV_FRAME_DATA_AUDIO_SERVICE_TYPE }, +{ AV_PKT_DATA_MASTERING_DISPLAY_METADATA, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA }, }; frame->color_primaries = avctx->color_primaries; diff --git a/libavcodec/version.h b/libavcodec/version.h index 8943ef3d0f..774230b1ef 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 1 -#define LIBAVCODEC_VERSION_MICRO 0 +#define LIBAVCODEC_VERSION_MICRO 1 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/8] lavc/hevc Parse SEI_TYPE_MASTERING_DISPLAY_INFO and propagate content into the AVMasteringDisplayMetadata side data.
From: Neil BirkbeckAdd support for parsing SEI_TYPE_MASTERING_DISPLAY_INFO and propagate contents into the AVMasteringDisplayMetadata side data. Primaries are ordered in RGB order and the values are converted to rationals ([0,1] for CEI 1931 Chroma coords, and cd/m^2 for luma). Signed-off-by: Neil Birkbeck Signed-off-by: Michael Niedermayer --- libavcodec/hevc_sei.c | 26 ++ libavcodec/hevcdec.c | 52 +++ libavcodec/hevcdec.h | 7 +++ 3 files changed, 85 insertions(+) diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c index 1f8554ad5f..1105b51493 100644 --- a/libavcodec/hevc_sei.c +++ b/libavcodec/hevc_sei.c @@ -75,6 +75,30 @@ static int decode_nal_sei_decoded_picture_hash(HEVCContext *s) return 0; } +static int decode_nal_sei_mastering_display_info(HEVCContext *s) +{ +GetBitContext *gb = >HEVClc.gb; +int i; +// Mastering primaries +for (i = 0; i < 3; i++) { +s->display_primaries[i][0] = get_bits(gb, 16); +s->display_primaries[i][1] = get_bits(gb, 16); +} +// White point (x, y) +s->white_point[0] = get_bits(gb, 16); +s->white_point[1] = get_bits(gb, 16); + +// Max and min luminance of mastering display +s->max_mastering_luminance = get_bits_long(gb, 32); +s->min_mastering_luminance = get_bits_long(gb, 32); + +// As this SEI message comes before the first frame that references it, +// initialize the flag to 2 and decrement on IRAP access unit so it +// persists for the coded video sequence (e.g., between two IRAPs) +s->sei_mastering_display_info_present = 2; +return 0; +} + static int decode_nal_sei_frame_packing_arrangement(HEVCContext *s) { GetBitContext *gb = >HEVClc.gb; @@ -129,6 +153,8 @@ static int decode_nal_sei_prefix(HEVCContext *s, int type, int size) return decode_nal_sei_frame_packing_arrangement(s); case SEI_TYPE_DISPLAY_ORIENTATION: return decode_nal_sei_display_orientation(s); +case SEI_TYPE_MASTERING_DISPLAY_INFO: +return decode_nal_sei_mastering_display_info(s); default: av_log(s->avctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type); skip_bits_long(gb, 8 * size); diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 6fe05d1b01..30d9194c60 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -27,6 +27,7 @@ #include "libavutil/common.h" #include "libavutil/display.h" #include "libavutil/internal.h" +#include "libavutil/mastering_display_metadata.h" #include "libavutil/md5.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -2404,6 +2405,57 @@ static int set_side_data(HEVCContext *s) s->sei_hflip, s->sei_vflip); } +// Decrement the mastering display flag when IRAP frame has no_rasl_output_flag=1 +// so the side data persists for the entire coded video sequence. +if (s->sei_mastering_display_info_present > 0 && +IS_IRAP(s) && s->no_rasl_output_flag) { +s->sei_mastering_display_info_present--; +} +if (s->sei_mastering_display_info_present) { +// HEVC uses a g,b,r ordering, which we convert to a more natural r,g,b +const int mapping[3] = {2, 0, 1}; +const int chroma_den = 5; +const int luma_den = 1; +int i; +AVMasteringDisplayMetadata *metadata = +av_mastering_display_metadata_create_side_data(out); +if (!metadata) +return AVERROR(ENOMEM); + +for (i = 0; i < 3; i++) { +const int j = mapping[i]; +metadata->display_primaries[i][0].num = s->display_primaries[j][0]; +metadata->display_primaries[i][0].den = chroma_den; +metadata->display_primaries[i][1].num = s->display_primaries[j][1]; +metadata->display_primaries[i][1].den = chroma_den; +} +metadata->white_point[0].num = s->white_point[0]; +metadata->white_point[0].den = chroma_den; +metadata->white_point[1].num = s->white_point[1]; +metadata->white_point[1].den = chroma_den; + +metadata->max_luminance.num = s->max_mastering_luminance; +metadata->max_luminance.den = luma_den; +metadata->min_luminance.num = s->min_mastering_luminance; +metadata->min_luminance.den = luma_den; +metadata->has_luminance = 1; +metadata->has_primaries = 1; + +av_log(s->avctx, AV_LOG_DEBUG, "Mastering Display Metadata:\n"); +av_log(s->avctx, AV_LOG_DEBUG, + "r(%5.4f,%5.4f) g(%5.4f,%5.4f) b(%5.4f %5.4f) wp(%5.4f, %5.4f)\n", + av_q2d(metadata->display_primaries[0][0]), + av_q2d(metadata->display_primaries[0][1]), + av_q2d(metadata->display_primaries[1][0]), + av_q2d(metadata->display_primaries[1][1]), +
[libav-devel] [PATCH 1/8] hevc: properly handle no_rasl_output_flag when removing pictures from the DPB
From: Hendrik LeppkesFixes ticket #4185. Reviewed-By: Mickael Raulet Signed-off-by: Hendrik Leppkes --- libavcodec/hevcdec.c | 3 +++ libavcodec/hevcdec.h | 1 + 2 files changed, 4 insertions(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 6a04858587..6fe05d1b01 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2421,6 +2421,8 @@ static int hevc_frame_start(HEVCContext *s) s->is_decoded= 0; s->first_nal_type= s->nal_unit_type; +s->no_rasl_output_flag = IS_IDR(s) || IS_BLA(s); + if (s->ps.pps->tiles_enabled_flag) lc->end_of_tiles_x = s->ps.pps->column_width[0] << s->ps.sps->log2_ctb_size; @@ -3007,6 +3009,7 @@ static int hevc_update_thread_context(AVCodecContext *dst, s->seq_output = s0->seq_output; s->pocTid0= s0->pocTid0; s->max_ra = s0->max_ra; +s->no_rasl_output_flag = s0->no_rasl_output_flag; s->is_nalff= s0->is_nalff; s->nal_length_size = s0->nal_length_size; diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index ff192f67ae..64089bde75 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -484,6 +484,7 @@ typedef struct HEVCContext { int bs_height; int is_decoded; +int no_rasl_output_flag; HEVCPredContext hpc; HEVCDSPContext hevcdsp; -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/8] libavutil: add mastering display metadata sidedata
From: Neil BirkbeckAdding mastering display metadata struct to avutil. The mastering display metadata contains information about the mastering display color volume (SMPTE 2086:2014). This info comes from HEVC in the SEI_TYPE_MASTERING_DISPLAY_INFO and is soon to be included in MKV: https://mailarchive.ietf.org/arch/search/?email_list=cellar=1=sZyfPTM-QY69P-0omfOIiTN622o so it is similar to SEI FPA / stereo_mode in MKV and as such this patch follows how AVStereo3D is implemented. I'll add support to HEVC in a follow-up (and MKV when spec is approved). Signed-off-by: Neil Birkbeck Signed-off-by: Michael Niedermayer --- doc/APIchanges | 5 ++ libavutil/Makefile | 2 + libavutil/frame.h | 6 +++ libavutil/mastering_display_metadata.c | 43 libavutil/mastering_display_metadata.h | 89 ++ libavutil/version.h| 2 +- 6 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 libavutil/mastering_display_metadata.c create mode 100644 libavutil/mastering_display_metadata.h diff --git a/doc/APIchanges b/doc/APIchanges index a0ca3b7ac0..5ce112262a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,11 @@ libavutil: 2017-03-23 API changes, most recent first: +2017-04-xx - xxx - lavu 56.1.0 - mastering_display_metadata.h + Add mastering_display_metadata.h/c, av_mastering_display_metadata_alloc() + and av_mastering_display_metadata_create_side_data() API, and AVMasteringDisplayMetadata + type to export mastering metadata video properties. + 2017-03-xx - xxx - lavc 57.37.0 - avcodec.h Add AVCodecContext.hwaccel_flags field. This will control some hwaccels at a later point. diff --git a/libavutil/Makefile b/libavutil/Makefile index 60e180c79d..3c5aca49e4 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -38,6 +38,7 @@ HEADERS = adler32.h \ log.h \ macros.h \ mathematics.h \ + mastering_display_metadata.h \ md5.h \ mem.h \ opt.h \ @@ -94,6 +95,7 @@ OBJS = adler32.o \ log.o\ log2_tab.o \ mathematics.o\ + mastering_display_metadata.o \ md5.o\ mem.o\ opt.o\ diff --git a/libavutil/frame.h b/libavutil/frame.h index f9ffb5bbbf..881d8f0051 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -99,6 +99,12 @@ enum AVFrameSideDataType { * libavutil/spherical.h. */ AV_FRAME_DATA_SPHERICAL, +/** + * Mastering display metadata associated with a video frame. The payload is + * an AVMasteringDisplayMetadata type and contains information about the + * mastering display color volume. + */ +AV_FRAME_DATA_MASTERING_DISPLAY_METADATA, }; enum AVActiveFormatDescription { diff --git a/libavutil/mastering_display_metadata.c b/libavutil/mastering_display_metadata.c new file mode 100644 index 00..e1683e55c7 --- /dev/null +++ b/libavutil/mastering_display_metadata.c @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016 Neil Birkbeck + * + * 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 "mastering_display_metadata.h" +#include "mem.h" + +AVMasteringDisplayMetadata
Re: [libav-devel] ff_thread_get_format and metadata
On Thu, Apr 6, 2017 at 1:08 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Thu, Apr 6, 2017 at 11:35 AM, Steve Lhomme <rob...@gmail.com> wrote: >> On Thu, Apr 6, 2017 at 11:08 AM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: >>> On Thu, Apr 6, 2017 at 11:01 AM, Steve Lhomme <rob...@gmail.com> wrote: >>>> Hi, >>>> >>>> As I am progressing in proper HDR10 support in VLC, I am facing an >>>> issue. The mastering (and lighting pending patch) metadata are set on >>>> the AVFrame but not available to the ff_get_format() receiver. >>>> >>>> That means when we configure our vout and decoder we don't know if >>>> it's going to have HDR metadata or not. >>>> >>>> Could we move the mastering (and lighting) metadata on the >>>> AVCodecContext ? Or provide the metadata on the ff_get_format() call ? >>>> >>>> I CC'ed libav as they have opinions on possible API changes, even >>>> though there is no mastering metadata support in there yet. >>> >>> >>> I'm against polluting AVCodecContext with more random fields, and >>> get_format is fixed API/ABI, we can't change that very easily. >> >> I understand, that's why I prefer asking before trying things out. >> >>> In general, this is per-frame metadata, which can appear or change >>> with any given frame, without get_format being invoked again. You >>> should probably just be able to have your output react to that once it >>> receives it. >> >> This is already the case. I copy the relevant metadata of the AVFrame >> in the picture we are going to display. But the underlying stream >> format has no idea that it has HDR metadata. We can't tell the user >> what kind of metadata the stream has (think of ffprobe-like info). >> > > So you just want this for probing, not even for actual playback? > The users will get over it then, I'm sure. Otherwise you could just > decode one frame and retrieve the metadata - thats the best way to > retrieve full accurate information anyway. In this particular case, for now, yes. But I am asking a more general question on how metadata, that are necessary for playback may be known when configuring the playback pipeline, can be provided early. I guess for now I can find a solution for my special use case. > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] ff_thread_get_format and metadata
On Thu, Apr 6, 2017 at 11:38 AM, wm4 <nfx...@googlemail.com> wrote: > On Thu, 6 Apr 2017 11:08:24 +0200 > Hendrik Leppkes <h.lepp...@gmail.com> wrote: > >> On Thu, Apr 6, 2017 at 11:01 AM, Steve Lhomme <rob...@gmail.com> wrote: >> > Hi, >> > >> > As I am progressing in proper HDR10 support in VLC, I am facing an >> > issue. The mastering (and lighting pending patch) metadata are set on >> > the AVFrame but not available to the ff_get_format() receiver. >> > >> > That means when we configure our vout and decoder we don't know if >> > it's going to have HDR metadata or not. >> > >> > Could we move the mastering (and lighting) metadata on the >> > AVCodecContext ? Or provide the metadata on the ff_get_format() call ? >> > >> > I CC'ed libav as they have opinions on possible API changes, even >> > though there is no mastering metadata support in there yet. >> >> >> I'm against polluting AVCodecContext with more random fields, and >> get_format is fixed API/ABI, we can't change that very easily. >> >> In general, this is per-frame metadata, which can appear or change >> with any given frame, without get_format being invoked again. You >> should probably just be able to have your output react to that once it >> receives it. > > +1 > > Also, get_format is not for such things - it's to allocate frames > _only_, and thus needs only size and pixfmt. Yes, but for example if you're going to have stereo pictures you may need to setup your allocated textures a certain way. Also AVColorPrimaries are found in the mastering metadata are found in AVCodecContext, should the metadata write there instead ? > You should configure your vout based on the _decoded_ frame, not > get_format. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] ff_thread_get_format and metadata
On Thu, Apr 6, 2017 at 11:38 AM, Luca Barbato <lu_z...@gentoo.org> wrote: > On 06/04/2017 11:01, Steve Lhomme wrote: >> I CC'ed libav as they have opinions on possible API changes, even >> though there is no mastering metadata support in there yet. > > You should send over those changes otherwise here isn't much we can say :) I am planning on doing that once the content level lighting metadata are merged. No point in doing the same work twice. > It should be a side-data like many other from what I can guess anyway. > > lu > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] ff_thread_get_format and metadata
On Thu, Apr 6, 2017 at 11:08 AM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Thu, Apr 6, 2017 at 11:01 AM, Steve Lhomme <rob...@gmail.com> wrote: >> Hi, >> >> As I am progressing in proper HDR10 support in VLC, I am facing an >> issue. The mastering (and lighting pending patch) metadata are set on >> the AVFrame but not available to the ff_get_format() receiver. >> >> That means when we configure our vout and decoder we don't know if >> it's going to have HDR metadata or not. >> >> Could we move the mastering (and lighting) metadata on the >> AVCodecContext ? Or provide the metadata on the ff_get_format() call ? >> >> I CC'ed libav as they have opinions on possible API changes, even >> though there is no mastering metadata support in there yet. > > > I'm against polluting AVCodecContext with more random fields, and > get_format is fixed API/ABI, we can't change that very easily. I understand, that's why I prefer asking before trying things out. > In general, this is per-frame metadata, which can appear or change > with any given frame, without get_format being invoked again. You > should probably just be able to have your output react to that once it > receives it. This is already the case. I copy the relevant metadata of the AVFrame in the picture we are going to display. But the underlying stream format has no idea that it has HDR metadata. We can't tell the user what kind of metadata the stream has (think of ffprobe-like info). Also as a more general case there can even be an issue with selecting/configuring the display when ff_get_format() is called. For example you don't know the frame packing format (3D, side by side, etc). It's available in SEI_TYPE_FRAME_PACKING for H264 and HEVC. Couldn't there be a way to query AVCodecContext for certain metadata ? In the case of HEVC/H264 it would look in the calling associated HEVCContext/H264Context. Which is the (upper) context that is calling the ff_get_format(). > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] ff_thread_get_format and metadata
Hi, As I am progressing in proper HDR10 support in VLC, I am facing an issue. The mastering (and lighting pending patch) metadata are set on the AVFrame but not available to the ff_get_format() receiver. That means when we configure our vout and decoder we don't know if it's going to have HDR metadata or not. Could we move the mastering (and lighting) metadata on the AVCodecContext ? Or provide the metadata on the ff_get_format() call ? I CC'ed libav as they have opinions on possible API changes, even though there is no mastering metadata support in there yet. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] avcodec/hevc: add the dimension constraints when attempting to use DXVA
On Wed, Mar 22, 2017 at 11:02 AM, wm4 <nfx...@googlemail.com> wrote: > On Wed, 22 Mar 2017 10:41:13 +0100 > Steve Lhomme <rob...@gmail.com> wrote: > >> --- >> libavcodec/hevcdec.c | 10 ++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c >> index e24ce1e3c..3b8fadff3 100644 >> --- a/libavcodec/hevcdec.c >> +++ b/libavcodec/hevcdec.c >> @@ -381,6 +381,14 @@ static void export_stream_params(AVCodecContext *avctx, >> const HEVCParamSets *ps, >>num, den, 1 << 30); >> } >> >> +#if CONFIG_HEVC_DXVA2_HWACCEL || CONFIG_HEVC_D3D11VA_HWACCEL >> ++static void add_dxva_constraints(AVCodecContext *avctx) >> +{ >> +avctx->coded_width = FFALIGN(avctx->coded_width, 128); >> +avctx->coded_height = FFALIGN(avctx->coded_height, 128); >> +} >> +#endif >> + >> static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) >> { >> #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + >> CONFIG_HEVC_D3D11VA_HWACCEL + \ >> @@ -391,9 +399,11 @@ static enum AVPixelFormat get_format(HEVCContext *s, >> const HEVCSPS *sps) >> sps->pix_fmt == AV_PIX_FMT_YUV420P10) { >> #if CONFIG_HEVC_D3D11VA_HWACCEL >> *fmt++ = AV_PIX_FMT_D3D11VA_VLD; >> +add_dxva_constraints(s->avctx); >> #endif >> #if CONFIG_HEVC_DXVA2_HWACCEL >> *fmt++ = AV_PIX_FMT_DXVA2_VLD; >> +add_dxva_constraints(s->avctx); >> #endif >> #if CONFIG_HEVC_VAAPI_HWACCEL >> *fmt++ = AV_PIX_FMT_VAAPI; > > Seems a bit fragile to do it this way. Might be better to wait for > glorious future hwaccel improvements. > > We'll probably have an API that returns required surface format, > minimum surface number, and surface dimensions in a specific case. Then > decoder and hwaccel code would be cleanly separated. If that replaces reading coded_width/coded_height directly that might help. Otherwise in my case the information of which source codec is used with the hardware acceleration is lost by the time I get to allocate the surfaces and it should not depend on any libavcodec/util stuff. IMO coded_width/height should always have the proper value to allocate the surfaces. But if it makes more sense via an external API, fine with me. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] avcodec/hevc: add the dimension constraints when attempting to use DXVA
On Wed, Mar 22, 2017 at 10:43 AM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Wed, Mar 22, 2017 at 10:41 AM, Steve Lhomme <rob...@gmail.com> wrote: >> --- >> libavcodec/hevcdec.c | 10 ++ >> 1 file changed, 10 insertions(+) >> >> diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c >> index e24ce1e3c..3b8fadff3 100644 >> --- a/libavcodec/hevcdec.c >> +++ b/libavcodec/hevcdec.c >> @@ -381,6 +381,14 @@ static void export_stream_params(AVCodecContext *avctx, >> const HEVCParamSets *ps, >>num, den, 1 << 30); >> } >> >> +#if CONFIG_HEVC_DXVA2_HWACCEL || CONFIG_HEVC_D3D11VA_HWACCEL >> ++static void add_dxva_constraints(AVCodecContext *avctx) >> +{ >> +avctx->coded_width = FFALIGN(avctx->coded_width, 128); >> +avctx->coded_height = FFALIGN(avctx->coded_height, 128); >> +} >> +#endif >> + >> static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) >> { >> #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + >> CONFIG_HEVC_D3D11VA_HWACCEL + \ >> @@ -391,9 +399,11 @@ static enum AVPixelFormat get_format(HEVCContext *s, >> const HEVCSPS *sps) >> sps->pix_fmt == AV_PIX_FMT_YUV420P10) { >> #if CONFIG_HEVC_D3D11VA_HWACCEL >> *fmt++ = AV_PIX_FMT_D3D11VA_VLD; >> +add_dxva_constraints(s->avctx); >> #endif >> #if CONFIG_HEVC_DXVA2_HWACCEL >> *fmt++ = AV_PIX_FMT_DXVA2_VLD; >> +add_dxva_constraints(s->avctx); >> #endif >> #if CONFIG_HEVC_VAAPI_HWACCEL >> *fmt++ = AV_PIX_FMT_VAAPI; > > I don't think shoving more hwaccel specific logic into the codec > themself is the best approach to follow here. Where else should it be ? Are we supposed to not trust coded_width/coded_height when we have to allocate buffers ? > Also, this isn't actually a "constraint" as such, but a > recommendation/suggestion in the spec to avoid the need to re-allocate > surfaces should the coded size increase due to coding tool changes in > future segments. > > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/2] avcodec/hevc: add the dimension constraints when attempting to use DXVA
--- libavcodec/hevcdec.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index e24ce1e3c..3b8fadff3 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -381,6 +381,14 @@ static void export_stream_params(AVCodecContext *avctx, const HEVCParamSets *ps, num, den, 1 << 30); } +#if CONFIG_HEVC_DXVA2_HWACCEL || CONFIG_HEVC_D3D11VA_HWACCEL ++static void add_dxva_constraints(AVCodecContext *avctx) +{ +avctx->coded_width = FFALIGN(avctx->coded_width, 128); +avctx->coded_height = FFALIGN(avctx->coded_height, 128); +} +#endif + static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) { #define HWACCEL_MAX (CONFIG_HEVC_DXVA2_HWACCEL + CONFIG_HEVC_D3D11VA_HWACCEL + \ @@ -391,9 +399,11 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) sps->pix_fmt == AV_PIX_FMT_YUV420P10) { #if CONFIG_HEVC_D3D11VA_HWACCEL *fmt++ = AV_PIX_FMT_D3D11VA_VLD; +add_dxva_constraints(s->avctx); #endif #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; +add_dxva_constraints(s->avctx); #endif #if CONFIG_HEVC_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/2] avcodec/mpeg12dec: set the coded dimensions with proper alignement
--- libavcodec/mpeg12dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index afdd652b6..e37ae0f1d 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -1207,6 +1207,9 @@ static int mpeg_decode_postinit(AVCodecContext *avctx) if (ret < 0) return ret; +avctx->coded_width = FFALIGN(avctx->coded_width, 16); +avctx->coded_height = FFALIGN(avctx->coded_height, s->progressive_sequence ? 16: 32); + avctx->bit_rate = s->bit_rate; s1->save_aspect_info = s->aspect_ratio_info; s1->save_width = s->width; -- 2.11.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] Hardware decoding buffer size
On Tue, Mar 21, 2017 at 3:06 PM, wm4 <nfx...@googlemail.com> wrote: > On Tue, 21 Mar 2017 14:50:59 +0100 > Steve Lhomme <rob...@gmail.com> wrote: > >> Hi, >> >> We have this bug in VLC with an MPEG2 file that decodes with green >> bars at the top. After investigation it's because we allocate a >> 1920x1080 texture when it should actually need 1920x1088. >> https://trac.videolan.org/vlc/ticket/17856 >> >> In software decoding it works because we adjust the >> `ctx->coded_height` with avcodec_align_dimensions2(). But we do not >> call it for hardware decoding. And looking at the code it seems it's >> not meant to happen anyway (the DXVA pixel formats have no size >> constraint). >> >> So my question is: is it the job of libavcodec hardware decoders to >> set the proper coded_width/coded_height, in which case there's a bug, >> or it should be done outside of libavcodec ? And if so, how ? > > avconv_dxva2.c does this: > > /* decoding MPEG-2 requires additional alignment on some Intel GPUs, >but it causes issues for H.264 on certain AMD GPUs. */ > if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO) > surface_alignment = 32; Actually we have the same code. But it's called after we have our surfaces (doh!) I think I need to refactor this. > It aligns width and height accordingly, which gives you your 1088. No > idea how this should be handled, especially with the new hwaccel API. Yes, it would probably be nice to factorize this code so anyone can benefit from it without reinventing the wheel each time. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] Hardware decoding buffer size
Hi, We have this bug in VLC with an MPEG2 file that decodes with green bars at the top. After investigation it's because we allocate a 1920x1080 texture when it should actually need 1920x1088. https://trac.videolan.org/vlc/ticket/17856 In software decoding it works because we adjust the `ctx->coded_height` with avcodec_align_dimensions2(). But we do not call it for hardware decoding. And looking at the code it seems it's not meant to happen anyway (the DXVA pixel formats have no size constraint). So my question is: is it the job of libavcodec hardware decoders to set the proper coded_width/coded_height, in which case there's a bug, or it should be done outside of libavcodec ? And if so, how ? Thanks ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] hwcontext_dxva2: support D3D9Ex
On Fri, Feb 3, 2017 at 3:47 PM, wm4 <nfx...@googlemail.com> wrote: > On Fri, 3 Feb 2017 13:01:05 +0100 > Steve Lhomme <rob...@gmail.com> wrote: > >> On Fri, Feb 3, 2017 at 11:22 AM, wm4 <nfx...@googlemail.com> wrote: >> > 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. >> > --- >> > libavutil/hwcontext_dxva2.c | 120 >> > +--- >> > 1 file changed, 90 insertions(+), 30 deletions(-) >> > >> > diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c >> > index ccf03c8e9f..eac98c3df0 100644 >> > --- a/libavutil/hwcontext_dxva2.c >> > +++ b/libavutil/hwcontext_dxva2.c >> > @@ -38,8 +38,13 @@ >> > #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) >> > + >> > typedef struct DXVA2Mapping { >> > uint32_t palette_dummy[256]; >> > } DXVA2Mapping; >> > @@ -411,19 +416,95 @@ 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 = {0}; >> > +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.Windowed = TRUE; >> > +d3dpp.BackBufferWidth = 640; >> > +d3dpp.BackBufferHeight = 480; >> > +d3dpp.BackBufferCount = 0; >> > +d3dpp.BackBufferFormat = d3ddm.Format; >> > +d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; >> > +d3dpp.Flags= D3DPRESENTFLAG_VIDEO; >> > + >> > +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 = {0}; >> > +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.Windowed = TRUE; >> > +d3dpp.BackBufferWidth = 640; >> > +d3dpp.BackBufferHeight = 480; >> > +d3dpp.BackBufferCount = 0; >> > +d3dpp.BackBufferFormat = modeex.Format; >> > +d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; >> > +d3dpp.Flags= D3DPRESENTFLAG_VIDEO; >> >> The whole D3DPRESENT_PARAMETERS init is the same so the code should be >> common as well. > > I did it this way because lu_zero wanted the creation moved to a > function or something. > > What's a non-awkward way to share the definition? I would say an inline function. > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] hwcontext_dxva2: support D3D9Ex
On Fri, Feb 3, 2017 at 11:22 AM, wm4wrote: > 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. > --- > libavutil/hwcontext_dxva2.c | 120 > +--- > 1 file changed, 90 insertions(+), 30 deletions(-) > > diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c > index ccf03c8e9f..eac98c3df0 100644 > --- a/libavutil/hwcontext_dxva2.c > +++ b/libavutil/hwcontext_dxva2.c > @@ -38,8 +38,13 @@ > #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) > + > typedef struct DXVA2Mapping { > uint32_t palette_dummy[256]; > } DXVA2Mapping; > @@ -411,19 +416,95 @@ 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 = {0}; > +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.Windowed = TRUE; > +d3dpp.BackBufferWidth = 640; > +d3dpp.BackBufferHeight = 480; > +d3dpp.BackBufferCount = 0; > +d3dpp.BackBufferFormat = d3ddm.Format; > +d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; > +d3dpp.Flags= D3DPRESENTFLAG_VIDEO; > + > +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 = {0}; > +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.Windowed = TRUE; > +d3dpp.BackBufferWidth = 640; > +d3dpp.BackBufferHeight = 480; > +d3dpp.BackBufferCount = 0; > +d3dpp.BackBufferFormat = modeex.Format; > +d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; > +d3dpp.Flags= D3DPRESENTFLAG_VIDEO; The whole D3DPRESENT_PARAMETERS init is the same so the code should be common as well. > + > +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 +529,6 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, > const char *device, > return AVERROR_UNKNOWN; > } > > -createD3D = (pDirect3DCreate9
Re: [libav-devel] [PATCH 2/2] hwcontext_dxva2: support D3D9Ex
On Thu, Feb 2, 2017 at 4:43 PM, Hendrik Leppkeswrote: > On Thu, Feb 2, 2017 at 11:27 AM, wm4 wrote: >> 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. >> --- >> libavutil/hwcontext_dxva2.c | 61 >> ++--- >> 1 file changed, 47 insertions(+), 14 deletions(-) >> >> diff --git a/libavutil/hwcontext_dxva2.c b/libavutil/hwcontext_dxva2.c >> index ccf03c8e9f..b9c26a84f4 100644 >> --- a/libavutil/hwcontext_dxva2.c >> +++ b/libavutil/hwcontext_dxva2.c >> @@ -38,6 +38,7 @@ >> #include "pixfmt.h" >> >> typedef IDirect3D9* WINAPI pDirect3DCreate9(UINT); >> +typedef HRESULT WINAPI pDirect3DCreate9Ex(UINT, IDirect3D9Ex **); >> typedef HRESULT WINAPI pCreateDeviceManager9(UINT *, >> IDirect3DDeviceManager9 **); >> >> typedef struct DXVA2Mapping { >> @@ -418,6 +419,7 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, >> const char *device, >> DXVA2DevicePriv *priv; >> >> pDirect3DCreate9 *createD3D = NULL; >> +pDirect3DCreate9Ex *createD3DEx = NULL; >> pCreateDeviceManager9 *createDeviceManager = NULL; >> D3DPRESENT_PARAMETERS d3dpp = {0}; >> D3DDISPLAYMODEd3ddm; >> @@ -453,6 +455,7 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, >> const char *device, >> av_log(ctx, AV_LOG_ERROR, "Failed to locate Direct3DCreate9\n"); >> return AVERROR_UNKNOWN; >> } >> +createD3DEx = (pDirect3DCreate9Ex *)GetProcAddress(priv->d3dlib, >> "Direct3DCreate9Ex"); >> createDeviceManager = (pCreateDeviceManager9 >> *)GetProcAddress(priv->dxva2lib, >> >> "DXVA2CreateDirect3DDeviceManager9"); >> if (!createDeviceManager) { >> @@ -460,27 +463,57 @@ static int dxva2_device_create(AVHWDeviceContext *ctx, >> const char *device, >> 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.Windowed = TRUE; >> d3dpp.BackBufferWidth = 640; >> d3dpp.BackBufferHeight = 480; >> d3dpp.BackBufferCount = 0; >> -d3dpp.BackBufferFormat = d3ddm.Format; >> d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; >> d3dpp.Flags= D3DPRESENTFLAG_VIDEO; >> >> -hr = IDirect3D9_CreateDevice(priv->d3d9, adapter, D3DDEVTYPE_HAL, >> GetShellWindow(), >> - D3DCREATE_SOFTWARE_VERTEXPROCESSING | >> D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, >> - , >d3d9device); >> -if (FAILED(hr)) { >> -av_log(ctx, AV_LOG_ERROR, "Failed to create Direct3D device\n"); >> -return AVERROR_UNKNOWN; >> +if (createD3DEx) { >> +IDirect3D9Ex *d3d9ex = NULL; >> + >> +hr = createD3DEx(D3D_SDK_VERSION, ); >> +if (!FAILED(hr)) { >> +D3DDISPLAYMODEEX modeex = {0}; >> +IDirect3DDevice9Ex *exdev = NULL; >> + >> +IDirect3D9Ex_GetAdapterDisplayModeEx(d3d9ex, adapter, , >> NULL); >> +d3dpp.BackBufferFormat = modeex.Format; >> + >> +hr = IDirect3D9Ex_CreateDeviceEx(d3d9ex, adapter, >> D3DDEVTYPE_HAL, GetShellWindow(), >> + >> D3DCREATE_SOFTWARE_VERTEXPROCESSING | >> + D3DCREATE_MULTITHREADED | >> + D3DCREATE_FPU_PRESERVE, >> + , NULL, ); >> +if (FAILED(hr)) { >> +// Retry with "classic" d3d9 below >> +IDirect3D9_Release(d3d9ex); > > I'm not sure its safe to mismatch the release function to the actual > object in the C API, even if its an "inherited" type, so this would > need to use the Ex release. Yes it is safe. In C it calls the callback in a structure with all the callbacks. The order of the callbacks matter. It is in the same place for each inherited interface. If you dislike mismatches you can always call IUnknown_Release() which is really what it calls and where the method comes from. > In consequence, this would also mean you would need a separate member > in the priv context to be able to distinguish them later when doing > the release again. > >> +} else { >> +av_log(ctx, AV_LOG_VERBOSE, "Using D3D9Ex device.\n"); >> +priv->d3d9 = d3d9ex; >> +priv->d3d9device = exdev; >> +} >> +} >> +} >> + >> +if (!priv->d3d9device) { >> +priv->d3d9 = createD3D(D3D_SDK_VERSION); >> +if (!priv->d3d9) { >>
Re: [libav-devel] [PATCH 1/6] libavutil: add support for AV_HWDEVICE_TYPE_D3D11VA
On Mon, Jan 9, 2017 at 11:51 AM, wm4 <nfx...@googlemail.com> wrote: > On Tue, 3 Jan 2017 17:34:59 +0100 > Steve Lhomme <rob...@videolabs.io> wrote: > >> From: Steve Lhomme <rob...@gmail.com> >> >> --- >> doc/APIchanges | 3 + >> libavutil/Makefile | 3 + >> libavutil/hwcontext.c | 3 + >> libavutil/hwcontext.h | 1 + >> libavutil/hwcontext_d3d11va.c | 460 >> + >> libavutil/hwcontext_d3d11va.h | 70 +++ >> libavutil/hwcontext_internal.h | 1 + >> libavutil/version.h| 2 +- >> 8 files changed, 542 insertions(+), 1 deletion(-) >> create mode 100644 libavutil/hwcontext_d3d11va.c >> create mode 100644 libavutil/hwcontext_d3d11va.h >> >> diff --git a/doc/APIchanges b/doc/APIchanges >> index 7633c99..29d5113 100644 >> --- a/doc/APIchanges >> +++ b/doc/APIchanges >> @@ -13,6 +13,9 @@ libavutil: 2015-08-28 >> >> API changes, most recent first: >> >> +2017-xx-xx - xxx - lavu 55.30.0 - hwcontext.h >> + Add AV_HWDEVICE_TYPE_D3D11VA to decode using Direct3D11. >> + >> 2016-xx-xx - xxx - lavc 57.29.0 - avcodec.h >>Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping >>information from containers. >> diff --git a/libavutil/Makefile b/libavutil/Makefile >> index 60e180c..6fb24db 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 83f733e..ae27c51 100644 >> --- a/libavutil/hwcontext.c >> +++ b/libavutil/hwcontext.c >> @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = { >> #if CONFIG_CUDA >> _hwcontext_type_cuda, >> #endif >> +#if CONFIG_D3D11VA >> +_hwcontext_type_d3d11va, >> +#endif >> #if CONFIG_DXVA2 >> _hwcontext_type_dxva2, >> #endif >> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h >> index 037ca64..d64b2da 100644 >> --- a/libavutil/hwcontext.h >> +++ b/libavutil/hwcontext.h >> @@ -30,6 +30,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 000..a23a475 >> --- /dev/null >> +++ b/libavutil/hwcontext_d3d11va.c >> @@ -0,0 +1,460 @@ >> +/* >> + * 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
Re: [libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
Up ? This patch and 4/4 have not been rejected. I would rather not have to update them again and wait even longer if something else is changes in libavcodec that changes the version number. On Wed, Jan 4, 2017 at 1:44 PM, Steve Lhomme <rob...@gmail.com> wrote: > No need to loop through the known surfaces, we'll use the requested surface > anyway. > > The loop is only done for DXVA2. > --- > libavcodec/dxva2.c | 14 +++--- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c > index 6fc4f97..b0452b6 100644 > --- a/libavcodec/dxva2.c > +++ b/libavcodec/dxva2.c > @@ -41,19 +41,19 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext > *avctx, > void *surface = get_surface(frame); > unsigned i; > > -for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { > #if CONFIG_D3D11VA > -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && > ctx->d3d11va.surface[i] == surface) { > -D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; > -ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], > ); > -return viewDesc.Texture2D.ArraySlice; > -} > +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { > +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; > +ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) > surface, ); > +return viewDesc.Texture2D.ArraySlice; > +} > #endif > #if CONFIG_DXVA2 > +for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { > if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] > == surface) > return i; > -#endif > } > +#endif > > assert(0); > return 0; > -- > 2.10.1.windows.1 > ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
No need to loop through the known surfaces, we'll use the requested surface anyway. The loop is only done for DXVA2. --- libavcodec/dxva2.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 6fc4f97..b0452b6 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -41,19 +41,19 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, void *surface = get_surface(frame); unsigned i; -for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) { -D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; -ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], ); -return viewDesc.Texture2D.ArraySlice; -} +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; +ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, ); +return viewDesc.Texture2D.ArraySlice; +} #endif #if CONFIG_DXVA2 +for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) return i; -#endif } +#endif assert(0); return 0; -- 2.10.1.windows.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
On Wed, Jan 4, 2017 at 12:31 PM, Diego Biurrun <di...@biurrun.de> wrote: > On Tue, Jan 03, 2017 at 05:31:50PM +0100, Steve Lhomme wrote: >> From: Steve Lhomme <rob...@gmail.com> >> >> No need to loop through the known surfaces, we'll use it anyway. >> >> The loop is only done for DXVA2 > > Good example of why one should avoid "it" in documentation. What will > you use anyway, the loop or the surfaces? I'll fix "that". No need to loop through the known surfaces, we'll use the requested surface anyway. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 5/6] avconv: add avconv_d3d11va
On Tue, Jan 3, 2017 at 5:35 PM, Steve Lhomme <rob...@videolabs.io> wrote: > From: Steve Lhomme <rob...@gmail.com> > > The code is similar to avconv_dxva2. The decoded output needs to be copied > into > a staging texture that can be accessed by the CPU as the decoder texture can't > be accessed by the CPU. > > edit: move the actual GUID definitions in a shared C file > --- > Changelog| 1 + > Makefile | 1 + > avconv.h | 2 + > avconv_d3d11va.c | 213 > +++ > avconv_dxva.c| 28 Oops, this stray file should not be there. > avconv_opt.c | 3 + > configure| 6 ++ > 7 files changed, 254 insertions(+) > create mode 100644 avconv_d3d11va.c > create mode 100644 avconv_dxva.c > > diff --git a/Changelog b/Changelog > index e17ef20..6aa3f03 100644 > --- a/Changelog > +++ b/Changelog > @@ -6,6 +6,7 @@ version : > - Intel QSV-accelerated VP8 and VC-1 decoding > - VAAPI-accelerated VP8 and HEVC decoding > - VAAPI-accelerated deinterlacing > +- support for decoding through D3D11VA in avconv > > > version 12: > diff --git a/Makefile b/Makefile > index 26c296f..6040131 100644 > --- a/Makefile > +++ b/Makefile > @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o > avconv_filter.o > OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o > OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o > OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o > +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o avconv_guid.o > OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o avconv_guid.o > OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o > > diff --git a/avconv.h b/avconv.h > index 6360f76..1919c66 100644 > --- a/avconv.h > +++ b/avconv.h > @@ -56,6 +56,7 @@ enum HWAccelID { > HWACCEL_VDA, > HWACCEL_QSV, > HWACCEL_VAAPI, > +HWACCEL_D3D11VA, > }; > > typedef struct HWAccel { > @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, > const AVFrame *frame); > int avconv_parse_options(int argc, char **argv); > > int vdpau_init(AVCodecContext *s); > +int d3d11va_init(AVCodecContext *s); > int dxva2_init(AVCodecContext *s); > int vda_init(AVCodecContext *s); > int qsv_init(AVCodecContext *s); > diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c > new file mode 100644 > index 000..d7ec558 > --- /dev/null > +++ b/avconv_d3d11va.c > @@ -0,0 +1,213 @@ > +/* > + * 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 > + > +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 > +#undef _WIN32_WINNT > +#define _WIN32_WINNT 0x0600 > +#endif > +#define COBJMACROS > + > +#include > + > +#include > + > +#include "avconv.h" > + > +#include "libavcodec/d3d11va.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_d3d11va.h" > + > +typedef struct D3D11VAContext { > +D3D11_VIDEO_DECODER_CONFIG decoder_config; > + > +AVFrame *tmp_frame; > + > +AVBufferRef *hw_device_ctx; > +AVBufferRef *hw_frames_ctx; > +} D3D11VAContext; > + > +typedef D3D11_VIDEO_DECODER_CONFIG DXVA_DECODER_CONFIG; > +typedef DXGI_FORMATDXVA_SURFACE_FORMAT; > +typedef D3D11VAContext DXVA_CONTEXT; > +typedef AVD3D11VAContext DXVA_AV_CONTEXT; > +typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; > +#include "avconv_dxva_template.c" > + > +static int d3d11va_get_decoder_configuration(AVCodecContext *s, > + const D3
[libav-devel] [PATCH] hevcdec: add P010 support for D3D11VA
Given it's the same API than DVXA2 I don't know why the same output was not enabled for both. --- libavcodec/hevcdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 8326690..700b5f0 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -388,6 +388,9 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P || sps->pix_fmt == AV_PIX_FMT_YUV420P10) { +#if CONFIG_HEVC_D3D11VA_HWACCEL +*fmt++ = AV_PIX_FMT_D3D11VA_VLD; +#endif #if CONFIG_HEVC_DXVA2_HWACCEL *fmt++ = AV_PIX_FMT_DXVA2_VLD; #endif @@ -396,9 +399,6 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif } if (sps->pix_fmt == AV_PIX_FMT_YUV420P || sps->pix_fmt == AV_PIX_FMT_YUVJ420P) { -#if CONFIG_HEVC_D3D11VA_HWACCEL -*fmt++ = AV_PIX_FMT_D3D11VA_VLD; -#endif #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 0/6] D3D11VA in avconv
Update on this patchset with a lot of fixes that was discussed during the last weeks. The patches have been split more. The public structures in libavutil are more documented and require less things set by the caller. The GUIDs declared in the template are defined in a separate avconv_guid.c file so that they are not twice in the same binary. Steve Lhomme (6): libavutil: add support for AV_HWDEVICE_TYPE_D3D11VA avconv: dxva2: factorize some code that can be common with d3d11va avconv: dxva2: move the DXVA GUID definitions outside of the template avconv_dxva2: remove unused initial values avconv: add avconv_d3d11va avconv: use the typedefs more to make comparison between dxva2 and d3d11va Changelog | 1 + Makefile | 3 +- avconv.h | 2 + avconv_d3d11va.c | 213 +++ avconv_dxva.c | 28 +++ avconv_dxva2.c | 302 ++- avconv_dxva_template.c | 294 ++ avconv_guid.c | 20 ++ avconv_opt.c | 3 + configure | 6 + doc/APIchanges | 3 + libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 460 + libavutil/hwcontext_d3d11va.h | 70 +++ libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 18 files changed, 1170 insertions(+), 245 deletions(-) create mode 100644 avconv_d3d11va.c create mode 100644 avconv_dxva.c create mode 100644 avconv_dxva_template.c create mode 100644 avconv_guid.c create mode 100644 libavutil/hwcontext_d3d11va.c create mode 100644 libavutil/hwcontext_d3d11va.h -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 5/6] avconv: add avconv_d3d11va
From: Steve Lhomme <rob...@gmail.com> The code is similar to avconv_dxva2. The decoded output needs to be copied into a staging texture that can be accessed by the CPU as the decoder texture can't be accessed by the CPU. edit: move the actual GUID definitions in a shared C file --- Changelog| 1 + Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 213 +++ avconv_dxva.c| 28 avconv_opt.c | 3 + configure| 6 ++ 7 files changed, 254 insertions(+) create mode 100644 avconv_d3d11va.c create mode 100644 avconv_dxva.c diff --git a/Changelog b/Changelog index e17ef20..6aa3f03 100644 --- a/Changelog +++ b/Changelog @@ -6,6 +6,7 @@ version : - Intel QSV-accelerated VP8 and VC-1 decoding - VAAPI-accelerated VP8 and HEVC decoding - VAAPI-accelerated deinterlacing +- support for decoding through D3D11VA in avconv version 12: diff --git a/Makefile b/Makefile index 26c296f..6040131 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o avconv_guid.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o avconv_guid.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o diff --git a/avconv.h b/avconv.h index 6360f76..1919c66 100644 --- a/avconv.h +++ b/avconv.h @@ -56,6 +56,7 @@ enum HWAccelID { HWACCEL_VDA, HWACCEL_QSV, HWACCEL_VAAPI, +HWACCEL_D3D11VA, }; typedef struct HWAccel { @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int avconv_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); +int d3d11va_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c new file mode 100644 index 000..d7ec558 --- /dev/null +++ b/avconv_d3d11va.c @@ -0,0 +1,213 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include + +#include + +#include "avconv.h" + +#include "libavcodec/d3d11va.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_d3d11va.h" + +typedef struct D3D11VAContext { +D3D11_VIDEO_DECODER_CONFIG decoder_config; + +AVFrame *tmp_frame; + +AVBufferRef *hw_device_ctx; +AVBufferRef *hw_frames_ctx; +} D3D11VAContext; + +typedef D3D11_VIDEO_DECODER_CONFIG DXVA_DECODER_CONFIG; +typedef DXGI_FORMATDXVA_SURFACE_FORMAT; +typedef D3D11VAContext DXVA_CONTEXT; +typedef AVD3D11VAContext DXVA_AV_CONTEXT; +typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; +#include "avconv_dxva_template.c" + +static int d3d11va_get_decoder_configuration(AVCodecContext *s, + const D3D11_VIDEO_DECODER_DESC *desc, + DXVA_DECODER_CONFIG *config) +{ +InputStream *ist = s->opaque; +int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; +unsigned cfg_count = 0; +DXVA_DECODER_CONFIG *cfg_list = NULL; +HRESULT hr; +int i, ret; + +DXVA_CONTEXT *ctx= ist->hwaccel_ctx; +AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; +AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx; + +hr = ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, desc, _count); +if (FAILED(hr)) { +av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n&quo
[libav-devel] [PATCH 3/6] avconv: dxva2: move the DXVA GUID definitions outside of the template
From: Steve Lhomme <rob...@gmail.com> --- Makefile | 2 +- avconv_dxva2.c | 1 + avconv_dxva_template.c | 7 ++- avconv_guid.c | 20 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 avconv_guid.c diff --git a/Makefile b/Makefile index a9f5f9a..26c296f 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o -OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o +OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o avconv_guid.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o TESTTOOLS = audiogen videogen rotozoom tiny_psnr base64 diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 442a0bd..4c6ef8d 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -63,6 +63,7 @@ typedef struct dxva_context DXVA_AV_CONTEXT; typedef IDirectXVideoDecoderService *DXVA_DECODER_SERVICE; #include "avconv_dxva_template.c" +#include DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02); static void dxva2_uninit(AVCodecContext *s) diff --git a/avconv_dxva_template.c b/avconv_dxva_template.c index c6bd0c5..572a140 100644 --- a/avconv_dxva_template.c +++ b/avconv_dxva_template.c @@ -16,9 +16,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef INITGUID +#include +#endif + /* 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(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); @@ -31,6 +34,7 @@ DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0 DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); DEFINE_GUID(GUID_NULL,0x, 0x,0x,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); +#ifndef INITGUID typedef struct dxva_mode { const GUID *guid; enum AVCodecID codec; @@ -287,3 +291,4 @@ fail: dxva_uninit(s); return AVERROR(EINVAL); } +#endif /* INITGUID */ diff --git a/avconv_guid.c b/avconv_guid.c new file mode 100644 index 000..0093e33 --- /dev/null +++ b/avconv_guid.c @@ -0,0 +1,20 @@ +/* + * 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 +#include "avconv_dxva_template.c" -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/6] avconv_dxva2: remove unused initial values
From: Steve Lhomme <rob...@gmail.com> --- avconv_dxva2.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 4c6ef8d..0edfe55 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -125,8 +125,8 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; -unsigned cfg_count = 0; -DXVA2_ConfigPictureDecode *cfg_list = NULL; +unsigned cfg_count; +DXVA2_ConfigPictureDecode *cfg_list; HRESULT hr; int ret; @@ -145,7 +145,7 @@ static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, G { HRESULT hr; int ret = 0; -unsigned j, target_count = 0; +unsigned j, target_count; D3DFORMAT *target_list; hr = IDirectXVideoDecoderService_GetDecoderRenderTargets(decoder_service, , _count, _list); if (SUCCEEDED(hr)) { @@ -167,9 +167,9 @@ static int dxva2_create_decoder(AVCodecContext *s) int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; struct dxva_context *dxva_ctx = s->hwaccel_context; -GUID *guid_list = NULL; -unsigned guid_count = 0; -GUID device_guid = GUID_NULL; +GUID *guid_list; +unsigned guid_count; +GUID device_guid; const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', '1', '2'); DXVA2_VideoDesc desc = { 0 }; -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/6] libavutil: add support for AV_HWDEVICE_TYPE_D3D11VA
From: Steve Lhomme <rob...@gmail.com> --- doc/APIchanges | 3 + libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 460 + libavutil/hwcontext_d3d11va.h | 70 +++ libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 8 files changed, 542 insertions(+), 1 deletion(-) create mode 100644 libavutil/hwcontext_d3d11va.c create mode 100644 libavutil/hwcontext_d3d11va.h diff --git a/doc/APIchanges b/doc/APIchanges index 7633c99..29d5113 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,9 @@ libavutil: 2015-08-28 API changes, most recent first: +2017-xx-xx - xxx - lavu 55.30.0 - hwcontext.h + Add AV_HWDEVICE_TYPE_D3D11VA to decode using Direct3D11. + 2016-xx-xx - xxx - lavc 57.29.0 - avcodec.h Add AV_PKT_DATA_SPHERICAL packet side data to export AVSphericalMapping information from containers. diff --git a/libavutil/Makefile b/libavutil/Makefile index 60e180c..6fb24db 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 83f733e..ae27c51 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = { #if CONFIG_CUDA _hwcontext_type_cuda, #endif +#if CONFIG_D3D11VA +_hwcontext_type_d3d11va, +#endif #if CONFIG_DXVA2 _hwcontext_type_dxva2, #endif diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 037ca64..d64b2da 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -30,6 +30,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 000..a23a475 --- /dev/null +++ b/libavutil/hwcontext_d3d11va.c @@ -0,0 +1,460 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include +#include +#include + +#include "avassert.h" +#include "common.h" +#include "hwcontext.h" +#include "hwcontext_d3d11va.h" +#include "hwcontext_internal.h" +#include "imgutils.h" +#include "pixdesc.h" +#include "pixfmt.h" + +typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + +typedef struct D3D11VAFramesContext { +ID3D11VideoDecoderOutputVie
[libav-devel] [PATCH 6/6] avconv: use the typedefs more to make comparison between dxva2 and d3d11va
From: Steve Lhomme <rob...@gmail.com> --- avconv_dxva2.c | 22 +++--- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 0edfe55..99f608f 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -69,7 +69,7 @@ DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55, static void dxva2_uninit(AVCodecContext *s) { InputStream *ist = s->opaque; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; if (ctx->decoder_service) IDirectXVideoDecoderService_Release(ctx->decoder_service); @@ -81,7 +81,7 @@ static int dxva2_alloc(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx; +DXVA_CONTEXT *ctx; HANDLE device_handle; HRESULT hr; @@ -120,13 +120,13 @@ fail: static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device_guid, const DXVA2_VideoDesc *desc, - DXVA2_ConfigPictureDecode *config) + DXVA_DECODER_CONFIG *config) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; unsigned cfg_count; -DXVA2_ConfigPictureDecode *cfg_list; +DXVA_DECODER_CONFIG *cfg_list; HRESULT hr; int ret; @@ -141,7 +141,7 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device return ret; } -static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, GUID guid, D3DFORMAT surface_format) +static int dxva2_validate_output(DXVA_DECODER_SERVICE decoder_service, GUID guid, DXVA_SURFACE_FORMAT surface_format) { HRESULT hr; int ret = 0; @@ -165,15 +165,15 @@ static int dxva2_create_decoder(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx = ist->hwaccel_ctx; -struct dxva_context *dxva_ctx = s->hwaccel_context; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; +DXVA_AV_CONTEXT *dxva_ctx = s->hwaccel_context; GUID *guid_list; unsigned guid_count; GUID device_guid; -const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? - MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', '1', '2'); +const DXVA_SURFACE_FORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? + MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', '1', '2'); DXVA2_VideoDesc desc = { 0 }; -DXVA2_ConfigPictureDecode config; +DXVA_DECODER_CONFIG config; HRESULT hr; int ret; -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/4] dxva2: allow an empty array of ID3D11VideoDecoderOutputView
From: Steve Lhomme <rob...@gmail.com> We can pick the correct slice index directly from the ID3D11VideoDecoderOutputView casted from data[3]. --- libavcodec/dxva2_internal.h | 4 ++-- libavcodec/version.h| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 2e425f6..7667deb 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -73,7 +73,7 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ DXVA_CONTEXT_CFG(avctx, ctx) && \ - DXVA_CONTEXT_COUNT(avctx, ctx)) + (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -93,7 +93,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) -#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/version.h b/libavcodec/version.h index 5b6fb6c..7348a0c 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 30 -#define LIBAVCODEC_VERSION_MICRO 2 +#define LIBAVCODEC_VERSION_MICRO 3 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
From: Steve Lhomme <rob...@gmail.com> No need to loop through the known surfaces, we'll use it anyway. The loop is only done for DXVA2 --- libavcodec/dxva2.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 6fc4f97..b0452b6 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -41,19 +41,19 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, void *surface = get_surface(frame); unsigned i; -for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) { -D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; -ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], ); -return viewDesc.Texture2D.ArraySlice; -} +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; +ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, ); +return viewDesc.Texture2D.ArraySlice; +} #endif #if CONFIG_DXVA2 +for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) return i; -#endif } +#endif assert(0); return 0; -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static and rename it
From: Steve Lhomme <rob...@gmail.com> --- libavcodec/dxva2.c | 8 libavcodec/dxva2_internal.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 6063993..6fc4f97 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "dxva2_internal.h" -void *ff_dxva2_get_surface(const AVFrame *frame) +static void *get_surface(const AVFrame *frame) { return frame->data[3]; } @@ -38,7 +38,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame) { -void *surface = ff_dxva2_get_surface(frame); +void *surface = get_surface(frame); unsigned i; for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { @@ -158,14 +158,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, 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, - ff_dxva2_get_surface(frame), + get_surface(frame), 0, NULL); } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder, - ff_dxva2_get_surface(frame), + get_surface(frame), NULL); #endif if (hr != E_PENDING || ++runs > 50) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 499b37c..a2ebc2a 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -91,8 +91,6 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) #endif -void *ff_dxva2_get_surface(const AVFrame *frame); - unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *, const AVFrame *frame); -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 0/4] DXVA2 cleaning
This patchset was already sent but various cleaning has been done and it has been rebased to the latest master. The main goal is to have patch 3/4 that allows more flexibility on the decoder pool, which we need in VLC for better efficiency. Patch 4/4 is the one that enables this flexibility. Steve Lhomme (4): dxva2: make ff_dxva2_get_surface() static and rename it dxva2: use a single macro to test if the DXVA context is valid dxva2: get the slice number directly from the surface in D3D11VA dxva2: allow an empty array of ID3D11VideoDecoderOutputView libavcodec/dxva2.c | 22 +++--- libavcodec/dxva2_h264.c | 4 +--- libavcodec/dxva2_hevc.c | 4 +--- libavcodec/dxva2_internal.h | 7 +-- libavcodec/dxva2_mpeg2.c| 4 +--- libavcodec/dxva2_vc1.c | 4 +--- libavcodec/version.h| 2 +- 7 files changed, 21 insertions(+), 26 deletions(-) -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/4] dxva2: use a single macro to test if the DXVA context is valid
From: Steve Lhomme <rob...@gmail.com> --- libavcodec/dxva2_h264.c | 4 +--- libavcodec/dxva2_hevc.c | 4 +--- libavcodec/dxva2_internal.h | 5 + libavcodec/dxva2_mpeg2.c| 4 +--- libavcodec/dxva2_vc1.c | 4 +--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 5622c22..84959c5 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -445,9 +445,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 673fada..17548d2 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -365,9 +365,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; av_assert0(ctx_pic); diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index a2ebc2a..2e425f6 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -71,6 +71,9 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ + DXVA_CONTEXT_CFG(avctx, ctx) && \ + DXVA_CONTEXT_COUNT(avctx, ctx)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -80,6 +83,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count) #elif CONFIG_D3D11VA #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) @@ -89,6 +93,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index 2d88f9b..a459049 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -263,9 +263,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index d170e18..0672c97 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -264,9 +264,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx,
Re: [libav-devel] [PATCH 2/5] libautil: add support for AV_HWDEVICE_TYPE_D3D11VA
Hi, On Mon, Dec 19, 2016 at 1:04 PM, Anton Khirnov <an...@khirnov.net> wrote: > Quoting Steve Lhomme (2016-12-16 11:05:40) >> From: Steve Lhomme <rob...@gmail.com> >> >> --- >> libavutil/Makefile | 3 + >> libavutil/hwcontext.c | 3 + >> libavutil/hwcontext.h | 1 + >> libavutil/hwcontext_d3d11va.c | 456 >> + >> libavutil/hwcontext_d3d11va.h | 81 >> libavutil/hwcontext_internal.h | 1 + >> libavutil/version.h| 2 +- >> 7 files changed, 546 insertions(+), 1 deletion(-) >> create mode 100644 libavutil/hwcontext_d3d11va.c >> create mode 100644 libavutil/hwcontext_d3d11va.h >> >> diff --git a/libavutil/Makefile b/libavutil/Makefile >> index f34c799..962dcf2 100644 >> --- a/libavutil/Makefile >> +++ b/libavutil/Makefile >> @@ -26,6 +26,7 @@ HEADERS = adler32.h >> \ >>hmac.h\ >>hwcontext.h \ >>hwcontext_cuda.h \ >> + hwcontext_d3d11va.h \ >>hwcontext_dxva2.h \ >>hwcontext_qsv.h \ >>hwcontext_vaapi.h \ >> @@ -111,6 +112,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 >> @@ -120,6 +122,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 83f733e..ae27c51 100644 >> --- a/libavutil/hwcontext.c >> +++ b/libavutil/hwcontext.c >> @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = { >> #if CONFIG_CUDA >> _hwcontext_type_cuda, >> #endif >> +#if CONFIG_D3D11VA >> +_hwcontext_type_d3d11va, >> +#endif >> #if CONFIG_DXVA2 >> _hwcontext_type_dxva2, >> #endif >> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h >> index 037ca64..d64b2da 100644 >> --- a/libavutil/hwcontext.h >> +++ b/libavutil/hwcontext.h >> @@ -30,6 +30,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 000..db5ec03 >> --- /dev/null >> +++ b/libavutil/hwcontext_d3d11va.c >> @@ -0,0 +1,456 @@ >> +/* >> + * 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 >> + >> +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 >> +#undef _WIN
[libav-devel] [PATCH 4/5] avconv_dxva2: remove unused initial values
From: Steve Lhomme <rob...@gmail.com> --- avconv_dxva2.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 082eac1..797b540 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -124,8 +124,8 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; -unsigned cfg_count = 0; -DXVA2_ConfigPictureDecode *cfg_list = NULL; +unsigned cfg_count; +DXVA2_ConfigPictureDecode *cfg_list; HRESULT hr; int ret; @@ -144,7 +144,7 @@ static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, G { HRESULT hr; int ret = 0; -unsigned j, target_count = 0; +unsigned j, target_count; D3DFORMAT *target_list; hr = IDirectXVideoDecoderService_GetDecoderRenderTargets(decoder_service, , _count, _list); if (SUCCEEDED(hr)) { @@ -166,9 +166,9 @@ static int dxva2_create_decoder(AVCodecContext *s) int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; struct dxva_context *dxva_ctx = s->hwaccel_context; -GUID *guid_list = NULL; -unsigned guid_count = 0; -GUID device_guid = GUID_NULL; +GUID *guid_list; +unsigned guid_count; +GUID device_guid; const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', '1', '2'); DXVA2_VideoDesc desc = { 0 }; -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/5] avconv: add avconv_d3d11va
From: Steve Lhomme <rob...@gmail.com> The code is similar to avconv_dxva2. The decoded output needs to be copied into a staging texture that can be accessed by the CPU as the decoder texture can't be accessed by the CPU. --- Changelog| 1 + Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 210 +++ avconv_opt.c | 3 + configure| 4 +- 6 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 avconv_d3d11va.c diff --git a/Changelog b/Changelog index feb151c..35ee6f7 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest. version : - Support for spherical videos +- support for decoding through D3D11VA in avconv version 12: diff --git a/Makefile b/Makefile index d4c2b8e..d7f8743 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o +OBJS-avconv-$(CONFIG_D3D11VA) += avconv_d3d11va.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o diff --git a/avconv.h b/avconv.h index 6360f76..1919c66 100644 --- a/avconv.h +++ b/avconv.h @@ -56,6 +56,7 @@ enum HWAccelID { HWACCEL_VDA, HWACCEL_QSV, HWACCEL_VAAPI, +HWACCEL_D3D11VA, }; typedef struct HWAccel { @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int avconv_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); +int d3d11va_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c new file mode 100644 index 000..989d927 --- /dev/null +++ b/avconv_d3d11va.c @@ -0,0 +1,210 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include + +#include + +#include "avconv.h" + +#include "libavcodec/d3d11va.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_d3d11va.h" + +typedef struct D3D11VAContext { +D3D11_VIDEO_DECODER_CONFIG decoder_config; + +AVFrame *tmp_frame; + +AVBufferRef *hw_device_ctx; +AVBufferRef *hw_frames_ctx; +} D3D11VAContext; + +typedef D3D11_VIDEO_DECODER_CONFIG DXVA_DECODER_CONFIG; +typedef DXGI_FORMATDXVA_SURFACE_FORMAT; +typedef D3D11VAContext DXVA_CONTEXT; +typedef AVD3D11VAContext DXVA_AV_CONTEXT; +typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; +#include "avconv_directx_va_template.c" + +static int d3d11va_get_decoder_configuration(AVCodecContext *s, + const D3D11_VIDEO_DECODER_DESC *desc, + D3D11_VIDEO_DECODER_CONFIG *config) +{ +InputStream *ist= s->opaque; +int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; +D3D11VAContext *ctx= ist->hwaccel_ctx; +AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; +AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx; +unsigned cfg_count; +D3D11_VIDEO_DECODER_CONFIG *cfg_list; +HRESULT hr; +int i, ret; + +hr = ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, desc, _count); +if (FAILED(hr)) { +av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n"); +return AVERROR(EINVAL); +} + +cfg_list = av_malloc(cfg_count * sizeof(D3D11_VIDEO_DECODER_CONFIG)); +if (cfg_
[libav-devel] [PATCH 5/5] avconv: use the typedefs more to make comparison between dxva2 and d3d11va
From: Steve Lhomme <rob...@gmail.com> --- avconv_d3d11va.c | 20 ++-- avconv_dxva2.c | 22 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c index 989d927..e86b410 100644 --- a/avconv_d3d11va.c +++ b/avconv_d3d11va.c @@ -59,15 +59,15 @@ typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; static int d3d11va_get_decoder_configuration(AVCodecContext *s, const D3D11_VIDEO_DECODER_DESC *desc, - D3D11_VIDEO_DECODER_CONFIG *config) + DXVA_DECODER_CONFIG *config) { InputStream *ist= s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -D3D11VAContext *ctx= ist->hwaccel_ctx; +DXVA_CONTEXT *ctx= ist->hwaccel_ctx; AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx; unsigned cfg_count; -D3D11_VIDEO_DECODER_CONFIG *cfg_list; +DXVA_DECODER_CONFIG *cfg_list; HRESULT hr; int i, ret; @@ -77,7 +77,7 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *s, return AVERROR(EINVAL); } -cfg_list = av_malloc(cfg_count * sizeof(D3D11_VIDEO_DECODER_CONFIG)); +cfg_list = av_malloc(cfg_count * sizeof(DXVA_DECODER_CONFIG)); if (cfg_list == NULL) return AVERROR(ENOMEM); for (i = 0; i < cfg_count; i++) { @@ -94,7 +94,7 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *s, return ret; } -static int d3d11va_validate_output(ID3D11VideoDevice *service, GUID guid, DXGI_FORMAT surface_format) +static int d3d11va_validate_output(DXVA_DECODER_SERVICE service, GUID guid, DXVA_SURFACE_FORMAT surface_format) { HRESULT hr; BOOL is_supported = FALSE; @@ -106,15 +106,15 @@ static int d3d11va_create_decoder(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -D3D11VAContext *ctx = ist->hwaccel_ctx; -AVD3D11VAContext *dxva_ctx = s->hwaccel_context; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; +DXVA_AV_CONTEXT *dxva_ctx = s->hwaccel_context; GUID *guid_list; unsigned guid_count, i; GUID device_guid; -const DXGI_FORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? - DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; +const DXVA_SURFACE_FORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? + DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; D3D11_VIDEO_DECODER_DESC desc = { 0 }; -D3D11_VIDEO_DECODER_CONFIG config; +DXVA_DECODER_CONFIG config; HRESULT hr; int ret; diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 797b540..3681c7f 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -68,7 +68,7 @@ DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55, static void dxva2_uninit(AVCodecContext *s) { InputStream *ist = s->opaque; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; if (ctx->decoder_service) IDirectXVideoDecoderService_Release(ctx->decoder_service); @@ -80,7 +80,7 @@ static int dxva2_alloc(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx; +DXVA_CONTEXT *ctx; HANDLE device_handle; HRESULT hr; @@ -119,13 +119,13 @@ fail: static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device_guid, const DXVA2_VideoDesc *desc, - DXVA2_ConfigPictureDecode *config) + DXVA_DECODER_CONFIG *config) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; unsigned cfg_count; -DXVA2_ConfigPictureDecode *cfg_list; +DXVA_DECODER_CONFIG *cfg_list; HRESULT hr; int ret; @@ -140,7 +140,7 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device return ret; } -static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, GUID guid, D3DFORMAT surface_format) +static int dxva2_validate_output(DXVA_DECODER_SERVICE decoder_service, GUID guid, DXVA_SURFACE_FORMAT surface_format) { HRESULT hr; int ret = 0; @@ -164,15 +164,15 @@ static int dxva2_create_decoder(AVCodec
[libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va
From: Steve Lhomme <rob...@gmail.com> avconv_dxva.h has to be included and misc. typedefs have to be set to use the proper DXVA2 structures. initguid.h is included in avconv_dxva.h so any includes after that will also define GUIDs locally. --- avconv_directx_va_template.c | 294 +++ avconv_dxva2.c | 277 +++- 2 files changed, 340 insertions(+), 231 deletions(-) create mode 100644 avconv_directx_va_template.c diff --git a/avconv_directx_va_template.c b/avconv_directx_va_template.c new file mode 100644 index 000..b51ecd8 --- /dev/null +++ b/avconv_directx_va_template.c @@ -0,0 +1,294 @@ +/* + * 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 + */ + +#ifndef AVCONV_DXVA_H +#define AVCONV_DXVA_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(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_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13); +DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(GUID_NULL,0x, 0x,0x,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); + +typedef struct dxva_mode { + const GUID *guid; + enum AVCodecID codec; +} dxva_mode; + +static const dxva_mode dxva_modes[] = { +/* MPEG-2 */ +{ _ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, +{ _ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO }, + +/* H.264 */ +{ _ModeH264_F, AV_CODEC_ID_H264 }, +{ _ModeH264_E, AV_CODEC_ID_H264 }, +/* Intel specific H.264 mode */ +{ _Intel_ModeH264_E, AV_CODEC_ID_H264 }, + +/* VC-1 / WMV3 */ +{ _ModeVC1_D2010, AV_CODEC_ID_VC1 }, +{ _ModeVC1_D2010, AV_CODEC_ID_WMV3 }, +{ _ModeVC1_D, AV_CODEC_ID_VC1 }, +{ _ModeVC1_D, AV_CODEC_ID_WMV3 }, + +/* HEVC/H.265 */ +{ _ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC }, +{ _ModeHEVC_VLD_Main10,AV_CODEC_ID_HEVC }, + +{ NULL, 0 }, +}; + +static int dxva_get_decoder_configuration(AVCodecContext *s, + const DXVA_DECODER_CONFIG *cfg_list, + unsigned cfg_count, + DXVA_DECODER_CONFIG *config) +{ +InputStream *ist = s->opaque; +int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; +unsigned i, best_score = 0; +DXVA_DECODER_CONFIG best_cfg = { { 0 } }; + +for (i = 0; i < cfg_count; i++) { +const DXVA_DECODER_CONFIG *cfg = _list[i]; + +unsigned score; +if (cfg->ConfigBitstreamRaw == 1) +score = 1; +else if (s->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2) +score = 2; +else +continue; +if (IsEqualGUID(>guidConfigBitstreamEncryption, _NoEncrypt)) +score += 16; +if (score > best_score) { +best_score = score; +best_cfg = *cfg; +} +} + +if (!best_score) { +av_log(NULL, loglevel, "No valid decoder configuration available\n"); +return AVERROR(EINVAL); +} + +*config = best_cfg; +return 0; +} + + +st
[libav-devel] [PATCH 0/5] add d3d11va hwaccel
Compared the previous patchset: - use a template for the common code - fix C90 compilation - check for ID3D11VideoContext availability to enable d3d11va - simplify the d3d11va configuration - improve formating Steve Lhomme (5): avconv: dxva2: factorize some code that can be common with d3d11va libautil: add support for AV_HWDEVICE_TYPE_D3D11VA avconv: add avconv_d3d11va avconv_dxva2: remove unused initial values avconv: use the typedefs more to make comparison between dxva2 and d3d11va Changelog | 1 + Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 210 +++ avconv_directx_va_template.c | 294 ++ avconv_dxva2.c | 301 ++- avconv_opt.c | 3 + configure | 4 +- libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 456 + libavutil/hwcontext_d3d11va.h | 81 libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 15 files changed, 1118 insertions(+), 245 deletions(-) create mode 100644 avconv_d3d11va.c create mode 100644 avconv_directx_va_template.c create mode 100644 libavutil/hwcontext_d3d11va.c create mode 100644 libavutil/hwcontext_d3d11va.h -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/5] libautil: add support for AV_HWDEVICE_TYPE_D3D11VA
From: Steve Lhomme <rob...@gmail.com> --- libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 456 + libavutil/hwcontext_d3d11va.h | 81 libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 7 files changed, 546 insertions(+), 1 deletion(-) create mode 100644 libavutil/hwcontext_d3d11va.c create mode 100644 libavutil/hwcontext_d3d11va.h diff --git a/libavutil/Makefile b/libavutil/Makefile index f34c799..962dcf2 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -26,6 +26,7 @@ HEADERS = adler32.h \ hmac.h\ hwcontext.h \ hwcontext_cuda.h \ + hwcontext_d3d11va.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ hwcontext_vaapi.h \ @@ -111,6 +112,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 @@ -120,6 +122,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 83f733e..ae27c51 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = { #if CONFIG_CUDA _hwcontext_type_cuda, #endif +#if CONFIG_D3D11VA +_hwcontext_type_d3d11va, +#endif #if CONFIG_DXVA2 _hwcontext_type_dxva2, #endif diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 037ca64..d64b2da 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -30,6 +30,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 000..db5ec03 --- /dev/null +++ b/libavutil/hwcontext_d3d11va.c @@ -0,0 +1,456 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include +#include +#include + +#include "avassert.h" +#include "common.h" +#include "hwcontext.h" +#include "hwcontext_d3d11va.h" +#include "hwcontext_internal.h" +#include "imgutils.h" +#include "pixdesc.h" +#include "pixfmt.h" + +typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + +typedef struct D3D11VAFramesContext { +ID3D11VideoDecoderOutputView **surfaces_internal; +int nb_surfaces_used; + +ID3D11DeviceContext *d3d11_context; + +DXGI_FORMAT format; +} D3D11VAFramesContext; + +typedef struct D3D11VADevicePriv { +HMODULE d3dlib; +} D3D11VADevicePriv; + +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 }, +}; + +static void d3d11va_frames_uninit(AVHWFramesContext *ctx
Re: [libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va
On Fri, Dec 16, 2016 at 10:02 AM, Diego Biurrun <di...@biurrun.de> wrote: > On Fri, Dec 16, 2016 at 09:27:35AM +0100, Steve Lhomme wrote: >> On Thu, Dec 15, 2016 at 6:52 PM, Diego Biurrun <di...@biurrun.de> wrote: >> > On Thu, Dec 15, 2016 at 06:01:42PM +0100, Steve Lhomme wrote: >> >> From: Steve Lhomme <rob...@gmail.com> >> >> >> >> avconv_dxva.h has to be included and misc. typedefs have to be set to use >> >> the >> >> proper DXVA2 structures. >> >> >> >> initguid.h is included in avconv_dxva.h so any includes after that will >> >> also >> >> define GUIDs locally. >> >> --- >> >> avconv_dxva.h | 294 >> >> + >> >> avconv_dxva2.c | 277 >> >> + >> >> 2 files changed, 340 insertions(+), 231 deletions(-) >> >> create mode 100644 avconv_dxva.h >> > >> > Does this pass "make check"? >> >> I'll "check". >> >> >> --- /dev/null >> >> +++ b/avconv_dxva.h >> >> @@ -0,0 +1,294 @@ >> >> + >> >> +#ifndef AVCONV_DXVA_H >> >> +#define AVCONV_DXVA_H >> > >> > Probably dxva2.h would be a better file name. >> >> As replied already, it's a header that will be shared between dxva2 and >> d3d11va. > > I meant avconv_dxva2.h. Is that stuff specific to dxva 2.0 or 1.0? If > the former, I'd add the '2' to the file name like everywhere else. In VLC I called that code directx_va to avoid confusion. Using dxva2 for d3d11va will give even more confusion. >> >> +static int dxva_get_decoder_configuration(AVCodecContext *s, >> >> + const DXVA_DECODER_CONFIG >> >> *cfg_list, >> >> + unsigned cfg_count, >> >> + DXVA_DECODER_CONFIG *config) >> > >> > You are putting static functions in a header file. They will be duplicated >> > in the object code if you #include this from the d3d11va code as well. >> >> That's the goal. The code is the same but applies on different >> structures. It must be duplicated for each variant. > > We don't want code duplication. > > Maybe you are trying to say that this file is meant to be a template that > should be instantiated twice? Then it should have _template.c in the name > like we do for other template files. Yes, I'll do that. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va
On Fri, Dec 16, 2016 at 9:27 AM, Steve Lhomme <rob...@gmail.com> wrote: > On Thu, Dec 15, 2016 at 6:52 PM, Diego Biurrun <di...@biurrun.de> wrote: >> On Thu, Dec 15, 2016 at 06:01:42PM +0100, Steve Lhomme wrote: >>> From: Steve Lhomme <rob...@gmail.com> >>> >>> avconv_dxva.h has to be included and misc. typedefs have to be set to use >>> the >>> proper DXVA2 structures. >>> >>> initguid.h is included in avconv_dxva.h so any includes after that will also >>> define GUIDs locally. >>> --- >>> avconv_dxva.h | 294 >>> + >>> avconv_dxva2.c | 277 + >>> 2 files changed, 340 insertions(+), 231 deletions(-) >>> create mode 100644 avconv_dxva.h >> >> Does this pass "make check"? > > I'll "check". yvyu422 b0364ee13bd574d01b23a0809e6ddca9 make: *** [tests/Makefile:150: fate-filter-pixfmts-copy] Error 1 I'm not sure it's related to this patch. With a gcc build I get this: --- ./tests/ref/fate/eval 2015-10-14 08:52:07.548534300 +0200 +++ tests/data/fate/eval2016-12-16 10:20:34.042753500 +0100 @@ -173,7 +173,7 @@ 'sqrt(1764)' -> 42.00 Evaluating 'isnan(sqrt(-1))' -'isnan(sqrt(-1))' -> 1.00 +'isnan(sqrt(-1))' -> 0.00 Evaluating 'not(1)' 'not(1)' -> 0.00 make: *** [tests/Makefile:150: fate-eval] Error 1 I don't think that's related to my patches either. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va
On Thu, Dec 15, 2016 at 6:52 PM, Diego Biurrun <di...@biurrun.de> wrote: > On Thu, Dec 15, 2016 at 06:01:42PM +0100, Steve Lhomme wrote: >> From: Steve Lhomme <rob...@gmail.com> >> >> avconv_dxva.h has to be included and misc. typedefs have to be set to use the >> proper DXVA2 structures. >> >> initguid.h is included in avconv_dxva.h so any includes after that will also >> define GUIDs locally. >> --- >> avconv_dxva.h | 294 >> + >> avconv_dxva2.c | 277 + >> 2 files changed, 340 insertions(+), 231 deletions(-) >> create mode 100644 avconv_dxva.h > > Does this pass "make check"? I'll "check". >> --- /dev/null >> +++ b/avconv_dxva.h >> @@ -0,0 +1,294 @@ >> + >> +#ifndef AVCONV_DXVA_H >> +#define AVCONV_DXVA_H > > Probably dxva2.h would be a better file name. As replied already, it's a header that will be shared between dxva2 and d3d11va. >> +static int dxva_get_decoder_configuration(AVCodecContext *s, >> + const DXVA_DECODER_CONFIG >> *cfg_list, >> + unsigned cfg_count, >> + DXVA_DECODER_CONFIG *config) > > You are putting static functions in a header file. They will be duplicated > in the object code if you #include this from the d3d11va code as well. That's the goal. The code is the same but applies on different structures. It must be duplicated for each variant. >> --- a/avconv_dxva2.c >> +++ b/avconv_dxva2.c >> @@ -43,52 +43,6 @@ >> #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); >> - >> @@ -102,55 +56,24 @@ typedef struct DXVA2Context { >> AVBufferRef *hw_frames_ctx; >> } DXVA2Context; >> >> +typedef DXVA2_ConfigPictureDecode DXVA_DECODER_CONFIG; >> +typedef D3DFORMAT DXVA_SURFACE_FORMAT; >> +typedef DXVA2ContextDXVA_CONTEXT; >> +typedef struct dxva_context DXVA_AV_CONTEXT; >> +typedef IDirectXVideoDecoderService *DXVA_DECODER_SERVICE; >> +#include "avconv_dxva.h" > > Why is the #include down here? And please at least leave an empty line above > it. As said in the include, it include initguid.h which defines DEFINE_GUID a certain way. We don't want that applied in the above headers. Some similar GUIDs might be defined twice. >> +DEFINE_GUID(IID_IDirectXVideoDecoderService, >> 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55,0x00,0x05,0x4e,0x43,0xff,0x02); > > Why do you move this DEFINE down? For the reason above, we want initguid.h to apply to this one too but not above. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/5] libautil: add support for AV_HWDEVICE_TYPE_D3D11VA
From: Steve Lhomme <rob...@gmail.com> --- libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_d3d11va.c | 456 + libavutil/hwcontext_d3d11va.h | 81 libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 7 files changed, 546 insertions(+), 1 deletion(-) create mode 100644 libavutil/hwcontext_d3d11va.c create mode 100644 libavutil/hwcontext_d3d11va.h diff --git a/libavutil/Makefile b/libavutil/Makefile index f34c799..962dcf2 100644 --- a/libavutil/Makefile +++ b/libavutil/Makefile @@ -26,6 +26,7 @@ HEADERS = adler32.h \ hmac.h\ hwcontext.h \ hwcontext_cuda.h \ + hwcontext_d3d11va.h \ hwcontext_dxva2.h \ hwcontext_qsv.h \ hwcontext_vaapi.h \ @@ -111,6 +112,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 @@ -120,6 +122,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 83f733e..ae27c51 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -32,6 +32,9 @@ static const HWContextType *hw_table[] = { #if CONFIG_CUDA _hwcontext_type_cuda, #endif +#if CONFIG_D3D11VA +_hwcontext_type_d3d11va, +#endif #if CONFIG_DXVA2 _hwcontext_type_dxva2, #endif diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 037ca64..d64b2da 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -30,6 +30,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 000..e6e3b53 --- /dev/null +++ b/libavutil/hwcontext_d3d11va.c @@ -0,0 +1,456 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include +#include +#include + +#include "avassert.h" +#include "common.h" +#include "hwcontext.h" +#include "hwcontext_d3d11va.h" +#include "hwcontext_internal.h" +#include "imgutils.h" +#include "pixdesc.h" +#include "pixfmt.h" + +typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + +typedef struct D3D11VAFramesContext { +ID3D11VideoDecoderOutputView **surfaces_internal; +int nb_surfaces_used; + +ID3D11DeviceContext *d3d11_context; + +DXGI_FORMAT format; +} D3D11VAFramesContext; + +typedef struct D3D11VADevicePriv { +HMODULE d3dlib; +} D3D11VADevicePriv; + +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 }, +}; + +static void d3d11va_frames_uninit(AVHWFramesContext *ctx
[libav-devel] [PATCH 4/5] avconv_dxva2: remove unused initial values
From: Steve Lhomme <rob...@gmail.com> --- avconv_dxva2.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 6a56f3a..027285a 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -124,8 +124,8 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; -unsigned cfg_count = 0; -DXVA2_ConfigPictureDecode *cfg_list = NULL; +unsigned cfg_count; +DXVA2_ConfigPictureDecode *cfg_list; HRESULT hr; int ret; @@ -144,7 +144,7 @@ static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, G { HRESULT hr; int ret = 0; -unsigned j, target_count = 0; +unsigned j, target_count; D3DFORMAT *target_list; hr = IDirectXVideoDecoderService_GetDecoderRenderTargets(decoder_service, , _count, _list); if (SUCCEEDED(hr)) { @@ -166,9 +166,9 @@ static int dxva2_create_decoder(AVCodecContext *s) int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; DXVA2Context *ctx = ist->hwaccel_ctx; struct dxva_context *dxva_ctx = s->hwaccel_context; -GUID *guid_list = NULL; -unsigned guid_count = 0; -GUID device_guid = GUID_NULL; +GUID *guid_list; +unsigned guid_count; +GUID device_guid; const D3DFORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? MKTAG('P', '0', '1', '0') : MKTAG('N', 'V', '1', '2'); DXVA2_VideoDesc desc = { 0 }; -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 5/5] avconv: use the typedefs more to make comparison between dxva2 and d3d11va
From: Steve Lhomme <rob...@gmail.com> --- avconv_d3d11va.c | 24 +--- avconv_dxva2.c | 22 +++--- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c index 4799017..ca7f2e8 100644 --- a/avconv_d3d11va.c +++ b/avconv_d3d11va.c @@ -59,16 +59,18 @@ typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; static int d3d11va_get_decoder_configuration(AVCodecContext *s, const D3D11_VIDEO_DECODER_DESC *desc, - D3D11_VIDEO_DECODER_CONFIG *config) + DXVA_DECODER_CONFIG *config) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -D3D11VAContext *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx; unsigned cfg_count = 0; -D3D11_VIDEO_DECODER_CONFIG *cfg_list = NULL; +DXVA_DECODER_CONFIG *cfg_list = NULL; HRESULT hr; int i, ret; -AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; + +ctx = ist->hwaccel_ctx; +AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx; hr = ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, desc, _count); @@ -77,7 +79,7 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *s, return AVERROR(EINVAL); } -cfg_list = av_malloc(cfg_count * sizeof(D3D11_VIDEO_DECODER_CONFIG)); +cfg_list = av_malloc(cfg_count * sizeof(DXVA_DECODER_CONFIG)); if (cfg_list == NULL) return AVERROR(ENOMEM); for (i = 0; i < cfg_count; i++) { @@ -94,7 +96,7 @@ static int d3d11va_get_decoder_configuration(AVCodecContext *s, return ret; } -static int d3d11va_validate_output(ID3D11VideoDevice *service, GUID guid, DXGI_FORMAT surface_format) +static int d3d11va_validate_output(DXVA_DECODER_SERVICE service, GUID guid, DXVA_SURFACE_FORMAT surface_format) { HRESULT hr; BOOL is_supported = FALSE; @@ -106,15 +108,15 @@ static int d3d11va_create_decoder(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -D3D11VAContext *ctx = ist->hwaccel_ctx; -AVD3D11VAContext *dxva_ctx = s->hwaccel_context; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; +DXVA_AV_CONTEXT *dxva_ctx = s->hwaccel_context; GUID *guid_list; unsigned guid_count, i; GUID device_guid; -const DXGI_FORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? - DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; +const DXVA_SURFACE_FORMAT surface_format = s->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ? + DXGI_FORMAT_P010 : DXGI_FORMAT_NV12; D3D11_VIDEO_DECODER_DESC desc = { 0 }; -D3D11_VIDEO_DECODER_CONFIG config; +DXVA_DECODER_CONFIG config; HRESULT hr; int ret; diff --git a/avconv_dxva2.c b/avconv_dxva2.c index 027285a..71d589d 100644 --- a/avconv_dxva2.c +++ b/avconv_dxva2.c @@ -68,7 +68,7 @@ DEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551,0xd5e7,0x11d9,0xaf,0x55, static void dxva2_uninit(AVCodecContext *s) { InputStream *ist = s->opaque; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; if (ctx->decoder_service) IDirectXVideoDecoderService_Release(ctx->decoder_service); @@ -80,7 +80,7 @@ static int dxva2_alloc(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx; +DXVA_CONTEXT *ctx; HANDLE device_handle; HRESULT hr; @@ -119,13 +119,13 @@ fail: static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device_guid, const DXVA2_VideoDesc *desc, - DXVA2_ConfigPictureDecode *config) + DXVA_DECODER_CONFIG *config) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; -DXVA2Context *ctx = ist->hwaccel_ctx; +DXVA_CONTEXT *ctx = ist->hwaccel_ctx; unsigned cfg_count; -DXVA2_ConfigPictureDecode *cfg_list; +DXVA_DECODER_CONFIG *cfg_list; HRESULT hr; int ret; @@ -140,7 +140,7 @@ static int dxva2_get_decoder_configuration(AVCodecContext *s, const GUID *device return ret; } -static int dxva2_validate_output(IDirectXVideoDecoderService *decoder_service, GUID guid, D3DFORMAT surface_format) +static int dxva2_validate_output(DXVA_
[libav-devel] [PATCH 3/5] avconv: add avconv_d3d11va
From: Steve Lhomme <rob...@gmail.com> The code is similar to avconv_dxva2. The decoded output needs to be copied into a staging texture that can be accessed by the CPU as the decoder texture can't be accessed by the CPU. --- Changelog| 1 + Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 210 +++ avconv_opt.c | 3 + configure| 6 ++ 6 files changed, 223 insertions(+) create mode 100644 avconv_d3d11va.c diff --git a/Changelog b/Changelog index feb151c..35ee6f7 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest. version : - Support for spherical videos +- support for decoding through D3D11VA in avconv version 12: diff --git a/Makefile b/Makefile index d4c2b8e..d604827 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o diff --git a/avconv.h b/avconv.h index 6360f76..1919c66 100644 --- a/avconv.h +++ b/avconv.h @@ -56,6 +56,7 @@ enum HWAccelID { HWACCEL_VDA, HWACCEL_QSV, HWACCEL_VAAPI, +HWACCEL_D3D11VA, }; typedef struct HWAccel { @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int avconv_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); +int d3d11va_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c new file mode 100644 index 000..4799017 --- /dev/null +++ b/avconv_d3d11va.c @@ -0,0 +1,210 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include + +#include + +#include "avconv.h" + +#include "libavcodec/d3d11va.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_d3d11va.h" + +typedef struct D3D11VAContext { +D3D11_VIDEO_DECODER_CONFIG decoder_config; + +AVFrame *tmp_frame; + +AVBufferRef *hw_device_ctx; +AVBufferRef *hw_frames_ctx; +} D3D11VAContext; + +typedef D3D11_VIDEO_DECODER_CONFIG DXVA_DECODER_CONFIG; +typedef DXGI_FORMATDXVA_SURFACE_FORMAT; +typedef D3D11VAContext DXVA_CONTEXT; +typedef AVD3D11VAContext DXVA_AV_CONTEXT; +typedef ID3D11VideoDevice *DXVA_DECODER_SERVICE; +#include "avconv_dxva.h" + +static int d3d11va_get_decoder_configuration(AVCodecContext *s, + const D3D11_VIDEO_DECODER_DESC *desc, + D3D11_VIDEO_DECODER_CONFIG *config) +{ +InputStream *ist = s->opaque; +int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; +D3D11VAContext *ctx = ist->hwaccel_ctx; +unsigned cfg_count = 0; +D3D11_VIDEO_DECODER_CONFIG *cfg_list = NULL; +HRESULT hr; +int i, ret; +AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)ctx->hw_device_ctx->data; +AVD3D11VADeviceContext *device_hwctx = device_ctx->hwctx; + +hr = ID3D11VideoDevice_GetVideoDecoderConfigCount(device_hwctx->video_device, desc, _count); +if (FAILED(hr)) { +av_log(NULL, loglevel, "Unable to retrieve decoder configurations\n"); +return AVERROR(EINVAL); +} + +cfg_list = av_malloc(cfg_count * sizeof(D3D11_VIDEO_DECODER_CONFIG)); +if (cfg_list == NULL) +return AVERROR(ENOMEM); +for (i = 0; i < c
[libav-devel] [PATCH 1/5] avconv: dxva2: factorize some code that can be common with d3d11va
From: Steve Lhomme <rob...@gmail.com> avconv_dxva.h has to be included and misc. typedefs have to be set to use the proper DXVA2 structures. initguid.h is included in avconv_dxva.h so any includes after that will also define GUIDs locally. --- avconv_dxva.h | 294 + avconv_dxva2.c | 277 + 2 files changed, 340 insertions(+), 231 deletions(-) create mode 100644 avconv_dxva.h diff --git a/avconv_dxva.h b/avconv_dxva.h new file mode 100644 index 000..58b016e --- /dev/null +++ b/avconv_dxva.h @@ -0,0 +1,294 @@ +/* + * 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 + */ + +#ifndef AVCONV_DXVA_H +#define AVCONV_DXVA_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(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_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13); +DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(GUID_NULL,0x, 0x,0x,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00); + +typedef struct dxva_mode { +const GUID *guid; +enum AVCodecID codec; +} dxva_mode; + +static const dxva_mode dxva_modes[] = { +/* MPEG-2 */ +{ _ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, +{ _ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO }, + +/* H.264 */ +{ _ModeH264_F, AV_CODEC_ID_H264 }, +{ _ModeH264_E, AV_CODEC_ID_H264 }, +/* Intel specific H.264 mode */ +{ _Intel_ModeH264_E, AV_CODEC_ID_H264 }, + +/* VC-1 / WMV3 */ +{ _ModeVC1_D2010, AV_CODEC_ID_VC1 }, +{ _ModeVC1_D2010, AV_CODEC_ID_WMV3 }, +{ _ModeVC1_D, AV_CODEC_ID_VC1 }, +{ _ModeVC1_D, AV_CODEC_ID_WMV3 }, + +/* HEVC/H.265 */ +{ _ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC }, +{ _ModeHEVC_VLD_Main10, AV_CODEC_ID_HEVC }, + +{ NULL, 0 }, +}; + +static int dxva_get_decoder_configuration(AVCodecContext *s, + const DXVA_DECODER_CONFIG *cfg_list, + unsigned cfg_count, + DXVA_DECODER_CONFIG *config) +{ +InputStream *ist = s->opaque; +int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; +unsigned i, best_score = 0; +DXVA_DECODER_CONFIG best_cfg = { { 0 } }; + +for (i = 0; i < cfg_count; i++) { +const DXVA_DECODER_CONFIG *cfg = _list[i]; + +unsigned score; +if (cfg->ConfigBitstreamRaw == 1) +score = 1; +else if (s->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2) +score = 2; +else +continue; +if (IsEqualGUID(>guidConfigBitstreamEncryption, _NoEncrypt)) +score += 16; +if (score > best_score) { +best_score = score; +best_cfg = *cfg; +} +} + +if (!best_score) { +av_log(NULL, loglevel, "No valid decoder configuration available\n"); +return AVERROR(EINVAL); +} + +*config = best_cfg; +return 0; +} + + +static int dxva_get_decoder_guid(AVCodecContext *s, DX
[libav-devel] [PATCH 1/2] configure: put d3d11 check in alphabetical order
From: Steve Lhomme <rob...@gmail.com> --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index fb82fc4..25640eb 100755 --- a/configure +++ b/configure @@ -1514,6 +1514,7 @@ HEADERS_LIST=" arpa_inet_h cdio_paranoia_h cdio_paranoia_paranoia_h +d3d11_h dispatch_dispatch_h dev_bktr_ioctl_bt848_h dev_bktr_ioctl_meteor_h @@ -1522,7 +1523,6 @@ HEADERS_LIST=" dev_video_meteor_ioctl_meteor_h direct_h dlfcn_h -d3d11_h dxva_h gsm_h io_h @@ -4530,9 +4530,9 @@ check_func_headers windows.h Sleep check_func_headers windows.h VirtualAlloc check_struct windows.h "CONDITION_VARIABLE" Ptr +check_header d3d11.h check_header direct.h check_header dlfcn.h -check_header d3d11.h check_header dxva.h check_header dxva2api.h check_header io.h -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/2] configure: fix linking with MSVC when using --disable-optimizations
From: Steve Lhomme <rob...@gmail.com> Without any optimization flags, MSVC does no dead code elimination (DCE) at all, even for the most trivial cases. DCE is a prerequisite for building libav correctly, otherwise there are undefined references to functions for other architectures and disabled components. -O1 is the minimal optimization flags for MSVC that does include DCE. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 25640eb..2ecd0ed 100755 --- a/configure +++ b/configure @@ -3279,6 +3279,7 @@ probe_cc(){ _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" +_cflags_noopt="-O1" if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: fix linking with MSVC when using --disable-optimizations
On Wed, Dec 14, 2016 at 5:12 PM, Diego Biurrun <di...@biurrun.de> wrote: > On Wed, Dec 14, 2016 at 04:46:54PM +0100, Steve Lhomme wrote: >> From: Steve Lhomme <rob...@gmail.com> >> >> Without any optimization flags, MSVC does no dead code elimination (DCE) at >> all, even for the most trivial cases. DCE is a prerequisite for building >> libav >> correctly, otherwise there are undefined references to functions for other >> architectures and disabled components. >> >> -Os -Og is the minimal optimization flags for MSVC that does include DCE. It > > -Os -Og are .. that do .. I would say "the setting '-Os -Og' is". One could say "the flags '-Os -Og' are". >> warns that -Og will be removed but it doesn't work without. -O1 includes >> these >> flags and some other ones not necessary to link properly. > > What does "warn" mean? And is this combination really preferable to plain -O1? Every C file compiled warns that Og is deprecated and may be removed soon. I prefer it to -O1 because it involves less optimizations, which is the goal of --disable-optimizations. O1 sets "-Og -Os -Oy -Ob2 -Gs -GF -Gy". > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] configure: fix linking with MSVC when using --disable-optimizations
From: Steve Lhomme <rob...@gmail.com> Without any optimization flags, MSVC does no dead code elimination (DCE) at all, even for the most trivial cases. DCE is a prerequisite for building libav correctly, otherwise there are undefined references to functions for other architectures and disabled components. -Os -Og is the minimal optimization flags for MSVC that does include DCE. It warns that -Og will be removed but it doesn't work without. -O1 includes these flags and some other ones not necessary to link properly. --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 6d809f7..881d226 100755 --- a/configure +++ b/configure @@ -3278,6 +3278,7 @@ probe_cc(){ _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" +_cflags_noopt="-Os -Og" if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: use -O1 with MSVC by default
LGTM On Wed, Dec 14, 2016 at 9:22 AM, Martin Storsjö <mar...@martin.st> wrote: > On Tue, 13 Dec 2016, Steve Lhomme wrote: > >> From: Steve Lhomme <rob...@gmail.com> >> >> Otherwise some ARM and other unsupported CPU/OS is linked with -O0 >> --- >> configure | 1 + >> 1 file changed, 1 insertion(+) > > > I find the commit message quite hard to understand and easily misleading. > Would this make more sense? > > ---8<--- > configure: Use -O1 with MSVC for --disable-optimizations > > Without any optimization flags, MSVC does no dead code elimination (DCE) at > all, even for the most trivial cases. DCE is a prerequisite for building > libav correctly, otherwise there are undefined references to functions for > other architectures and disabled components. > > -O1 is the minimal optimization flags for MSVC that does include DCE. > ---8<--- > > // Martin > > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] avconv: add avconv_d3d11va
On Tue, Dec 13, 2016 at 5:36 PM, Diego Biurrun <di...@biurrun.de> wrote: > Just a few cursory remarks as I only have a short moment right now. > > On Tue, Dec 13, 2016 at 02:19:03PM +0100, Steve Lhomme wrote: >> --- /dev/null >> +++ b/avconv_d3d11va.c >> @@ -0,0 +1,410 @@ >> + >> +/* define all the GUIDs used directly here, >> + to avoid problems with inconsistent dxva2api.h versions in mingw-w64 and >> different MSVC version */ > > That sounds scary. What is the problem. I just copy pasted from the dxva2 version. It's always hard to rely on mingw headers because you never know which version you have and what may be missing. There's a similar issue with MSVC ones although they are more up to date. >> --- a/configure >> +++ b/configure >> @@ -1677,6 +1677,8 @@ HAVE_LIST=" >> $TOOLCHAIN_FEATURES >> $TYPES_LIST >> dos_paths >> +d3d11va_lib >> +d3d11vaapi_cobj > > d3 < do in lexical order OK >> @@ -4777,6 +4779,15 @@ if enabled libxcb; then >> >> +enabled d3d11_h && >> +check_cc <> +#define _WIN32_WINNT 0x0600 >> +#define COBJMACROS >> +#include >> +#include >> +int main(void) { ID3D11VideoDevice *o = NULL; ID3D11VideoDevice_Release(o); >> return 0; } >> +EOF > > What is d3d11vaapi_cobj for? It seems like a pointless level of indirection > over d3d11va_lib. Ys, one level of testing should probably be enough. > There should be a helper function that you can reuse for this instead > of rolling your own test. > >> @@ -5059,6 +5070,9 @@ check_deps $CONFIG_LIST \ >> $HAVE_LIST \ >> $ALL_COMPONENTS\ >> >> +enabled_all d3d11va d3d11vaapi_cobj && >> +enable d3d11va_lib > > Declare a dependency instead, see how it's done for dxva2_lib. OK >> --- a/libavutil/hwcontext.h >> +++ b/libavutil/hwcontext.h >> @@ -28,6 +28,7 @@ enum AVHWDeviceType { >> AV_HWDEVICE_TYPE_VDPAU, >> AV_HWDEVICE_TYPE_CUDA, >> AV_HWDEVICE_TYPE_VAAPI, >> +AV_HWDEVICE_TYPE_D3D11VA, >> AV_HWDEVICE_TYPE_DXVA2, >> AV_HWDEVICE_TYPE_QSV, >> }; > > You have to add new members at the end to avoid ABI issues. OK Thanks for your constructive input :) > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] avconv: add avconv_d3d11va
On Tue, Dec 13, 2016 at 5:16 PM, Luca Barbato <lu_z...@gentoo.org> wrote: > On 13/12/2016 14:19, Steve Lhomme wrote: >> +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_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, >> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); >> +DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, >> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); >> +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, >> 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0); >> +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, >> 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13); >> +DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, >> 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); > > Shouldn't they live in a common header? I agree. > In general, shouldn't this code and the dxva2 be refactored so all the > common parts are shared? Yes but should refactoring happen after similar code is added ? Doing a refactor before the code is added sound counter intuitive. Also the code may look very similar but I'm not sure there's a lot to share. All the allocation and interfaces are different and in different order. > lu > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: use -O1 with MSVC by default
On Tue, Dec 13, 2016 at 5:17 PM, Diego Biurrun <di...@biurrun.de> wrote: > On Tue, Dec 13, 2016 at 04:23:02PM +0100, Steve Lhomme wrote: >> On Tue, Dec 13, 2016 at 3:33 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: >> > On Tue, Dec 13, 2016 at 2:24 PM, Steve Lhomme <rob...@gmail.com> wrote: >> >> From: Steve Lhomme <rob...@gmail.com> >> >> >> >> Otherwise some ARM and other unsupported CPU/OS is linked with -O0 >> >> --- a/configure >> >> +++ b/configure >> >> @@ -3278,6 +3278,7 @@ probe_cc(){ >> >> _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' >> >> _cflags_speed="-O2" >> >> _cflags_size="-O1" >> >> +_cflags_noopt="-O1" >> > >> > noopt should only be used with --disable-optimizations, why are you >> > building with that if thats not what you actually want? >> >> That's what I used indeed. But it didn't link because it would try to >> use all kinds of stuff that are compiled but to be dropped by the >> linker. If you have another suggestion for this not to happen... > > You mean DCE (dead code elimination) does not work? We do indeed > require DCE to build.. That's the thing, yes. It doesn't work with -O0. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] configure: use -O1 with MSVC by default
On Tue, Dec 13, 2016 at 3:33 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: > On Tue, Dec 13, 2016 at 2:24 PM, Steve Lhomme <rob...@gmail.com> wrote: >> From: Steve Lhomme <rob...@gmail.com> >> >> Otherwise some ARM and other unsupported CPU/OS is linked with -O0 >> --- >> configure | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/configure b/configure >> index 6d809f7..251b7c4 100755 >> --- a/configure >> +++ b/configure >> @@ -3278,6 +3278,7 @@ probe_cc(){ >> _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' >> _cflags_speed="-O2" >> _cflags_size="-O1" >> +_cflags_noopt="-O1" > > noopt should only be used with --disable-optimizations, why are you > building with that if thats not what you actually want? That's what I used indeed. But it didn't link because it would try to use all kinds of stuff that are compiled but to be dropped by the linker. If you have another suggestion for this not to happen... > - Hendrik > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] configure: use -O1 with MSVC by default
From: Steve Lhomme <rob...@gmail.com> Otherwise some ARM and other unsupported CPU/OS is linked with -O0 --- configure | 1 + 1 file changed, 1 insertion(+) diff --git a/configure b/configure index 6d809f7..251b7c4 100755 --- a/configure +++ b/configure @@ -3278,6 +3278,7 @@ probe_cc(){ _DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs' _cflags_speed="-O2" _cflags_size="-O1" +_cflags_noopt="-O1" if $_cc -nologo- 2>&1 | grep -q Linker; then _ld_o='-out:$@' else -- 2.10.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] avconv: add avconv_d3d11va
From: Steve Lhomme <rob...@videolabs.io> The code is similar to avconv_dxva2. The decoded output needs to be copied into a staging texture that can be accessed by the CPU as the decoder texture can't be accessed by the CPU. --- Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 410 + avconv_opt.c | 3 + configure | 14 ++ libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 10 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 avconv_d3d11va.c diff --git a/Makefile b/Makefile index d4c2b8e..d604827 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o diff --git a/avconv.h b/avconv.h index 6360f76..fcaf84e 100644 --- a/avconv.h +++ b/avconv.h @@ -52,6 +52,7 @@ enum HWAccelID { HWACCEL_NONE = 0, HWACCEL_AUTO, HWACCEL_VDPAU, +HWACCEL_D3D11VA, HWACCEL_DXVA2, HWACCEL_VDA, HWACCEL_QSV, @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int avconv_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); +int d3d11va_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c new file mode 100644 index 000..41c7354 --- /dev/null +++ b/avconv_d3d11va.c @@ -0,0 +1,410 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include + +#include + +#include "avconv.h" + +#include "libavcodec/d3d11va.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_d3d11va.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(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_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13); +DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); + +typedef struct d3d11va_mode { + const GUID *guid; + enum AVCodecID codec; +} d3d11va_mode; + +static const d3d11va_mode d3d11va_modes[] = { +/* MPEG-2 */ +{ _ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, +{ _ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO }, + +/* H.264 */ +{ _ModeH264_F, AV_CODEC_ID_H264 }, +{ _ModeH264_E, AV_CODEC_ID_H264 }, +/* Intel specific H.264 m
[libav-devel] [PATCH] avconv: add avconv_d3d11va
From: Steve Lhomme <slho...@videolabs.io> The code is similar to avconv_dxva2. The decoded output needs to be copied into a staging texture that can be accessed by the CPU as the decoder texture can't be accessed by the CPU. --- Makefile | 1 + avconv.h | 2 + avconv_d3d11va.c | 410 + avconv_opt.c | 3 + configure | 14 ++ libavutil/Makefile | 3 + libavutil/hwcontext.c | 3 + libavutil/hwcontext.h | 1 + libavutil/hwcontext_internal.h | 1 + libavutil/version.h| 2 +- 10 files changed, 439 insertions(+), 1 deletion(-) create mode 100644 avconv_d3d11va.c diff --git a/Makefile b/Makefile index d4c2b8e..d604827 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,7 @@ OBJS-avconv += avconv_opt.o avconv_filter.o OBJS-avconv-$(CONFIG_LIBMFX) += avconv_qsv.o OBJS-avconv-$(CONFIG_VAAPI) += avconv_vaapi.o OBJS-avconv-$(CONFIG_VDA) += avconv_vda.o +OBJS-avconv-$(HAVE_D3D11VA_LIB) += avconv_d3d11va.o OBJS-avconv-$(HAVE_DXVA2_LIB) += avconv_dxva2.o OBJS-avconv-$(HAVE_VDPAU_X11) += avconv_vdpau.o diff --git a/avconv.h b/avconv.h index 6360f76..fcaf84e 100644 --- a/avconv.h +++ b/avconv.h @@ -52,6 +52,7 @@ enum HWAccelID { HWACCEL_NONE = 0, HWACCEL_AUTO, HWACCEL_VDPAU, +HWACCEL_D3D11VA, HWACCEL_DXVA2, HWACCEL_VDA, HWACCEL_QSV, @@ -498,6 +499,7 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame); int avconv_parse_options(int argc, char **argv); int vdpau_init(AVCodecContext *s); +int d3d11va_init(AVCodecContext *s); int dxva2_init(AVCodecContext *s); int vda_init(AVCodecContext *s); int qsv_init(AVCodecContext *s); diff --git a/avconv_d3d11va.c b/avconv_d3d11va.c new file mode 100644 index 000..41c7354 --- /dev/null +++ b/avconv_d3d11va.c @@ -0,0 +1,410 @@ +/* + * 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 + +#if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600 +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0600 +#endif +#define COBJMACROS + +#include + +#include + +#include "avconv.h" + +#include "libavcodec/d3d11va.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_d3d11va.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(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_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0); +DEFINE_GUID(DXVA2_ModeHEVC_VLD_Main10,0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13); +DEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7,0x11d3,0xb9,0x84,0x00,0xc0,0x4f,0x2e,0x73,0xc5); + +typedef struct d3d11va_mode { + const GUID *guid; + enum AVCodecID codec; +} d3d11va_mode; + +static const d3d11va_mode d3d11va_modes[] = { +/* MPEG-2 */ +{ _ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO }, +{ _ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO }, + +/* H.264 */ +{ _ModeH264_F, AV_CODEC_ID_H264 }, +{ _ModeH264_E, AV_CODEC_ID_H264 }, +/* Intel specific H.264 m
Re: [libav-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static
Oops, it's based on a patch I never submitted. I'll redo them in the proper order. On Sat, Dec 3, 2016 at 1:26 PM, Steve Lhomme <rob...@gmail.com> wrote: > From: Steve Lhomme <rob...@gmail.com> > > --- > libavcodec/dxva2.c | 8 > libavcodec/dxva2_internal.h | 2 -- > 2 files changed, 4 insertions(+), 6 deletions(-) > > diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c > index 12acfd2..960a957 100644 > --- a/libavcodec/dxva2.c > +++ b/libavcodec/dxva2.c > @@ -31,7 +31,7 @@ > > #define DEBUG_CONTEXT_LOCK 0 > > -void *ff_dxva2_get_surface(const AVFrame *frame) > +static inline void *get_surface(const AVFrame *frame) > { > return frame->data[3]; > } > @@ -40,7 +40,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext > *avctx, > const AVDXVAContext *ctx, > const AVFrame *frame) > { > -void *surface = ff_dxva2_get_surface(frame); > +void *surface = get_surface(frame); > unsigned i; > > for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { > @@ -179,14 +179,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, > AVFrame *frame, > #endif /* DEBUG_CONTEXT_LOCK */ > } > hr = > ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, > D3D11VA_CONTEXT(ctx)->decoder, > - > ff_dxva2_get_surface(frame), > + get_surface(frame), >0, NULL); > } > #endif > #if CONFIG_DXVA2 > if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) > hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder, > - ff_dxva2_get_surface(frame), > + get_surface(frame), > NULL); > #endif > if (hr != E_PENDING || ++runs > 50) > diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h > index f0fe3d6..766af0b 100644 > --- a/libavcodec/dxva2_internal.h > +++ b/libavcodec/dxva2_internal.h > @@ -95,8 +95,6 @@ typedef union { > #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) > (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) > #endif > > -void *ff_dxva2_get_surface(const AVFrame *frame); > - > unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, > const AVDXVAContext *, > const AVFrame *frame); > -- > 2.9.1 > ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/4] dxva2: allow an empty array of ID3D11VideoDecoderOutputView
From: Steve Lhomme <rob...@gmail.com> We can pick the correct slice index directly from the ID3D11VideoDecoderOutputView casted from data[3]. --- libavcodec/dxva2_internal.h | 4 ++-- libavcodec/version.h| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 43c7912..25c1496 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -77,7 +77,7 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ DXVA_CONTEXT_CFG(avctx, ctx) && \ - DXVA_CONTEXT_COUNT(avctx, ctx)) + (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -97,7 +97,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) -#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/version.h b/libavcodec/version.h index 6f58bc8..36adc45 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 28 -#define LIBAVCODEC_VERSION_MICRO 4 +#define LIBAVCODEC_VERSION_MICRO 5 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.9.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 0/4] Updated dxva patches
This patches take in account the remarks from Diego Biurrun. The main goal of those patches is to remove the requirement on d3d11 to preallocate decoding buffers. In VLC we can save a copy by not using a preallocated buffer. Steve Lhomme (4): dxva2: make ff_dxva2_get_surface() static dxva2: use a single macro to test if the DXVA context is valid dxva2: get the slice number directly from the surface in D3D11VA dxva2: allow an empty array of ID3D11VideoDecoderOutputView libavcodec/dxva2.c | 22 +++--- libavcodec/dxva2_h264.c | 4 +--- libavcodec/dxva2_hevc.c | 4 +--- libavcodec/dxva2_internal.h | 7 +-- libavcodec/dxva2_mpeg2.c| 4 +--- libavcodec/dxva2_vc1.c | 4 +--- libavcodec/version.h| 2 +- 7 files changed, 21 insertions(+), 26 deletions(-) -- 2.9.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
From: Steve Lhomme <rob...@gmail.com> No need to loop through the known surfaces, we'll use it anyway. The loop is only done for DXVA2 --- libavcodec/dxva2.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 960a957..b74faac 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -43,19 +43,19 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, void *surface = get_surface(frame); unsigned i; -for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) { -D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; -ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], ); -return viewDesc.Texture2D.ArraySlice; -} +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) { +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; +ID3D11VideoDecoderOutputView_GetDesc(surface, ); +return viewDesc.Texture2D.ArraySlice; +} #endif #if CONFIG_DXVA2 +for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) return i; -#endif } +#endif assert(0); return 0; -- 2.9.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/4] dxva2: use a single macro to test if the DXVA context is valid
From: Steve Lhomme <rob...@gmail.com> --- libavcodec/dxva2_h264.c | 4 +--- libavcodec/dxva2_hevc.c | 4 +--- libavcodec/dxva2_internal.h | 5 + libavcodec/dxva2_mpeg2.c| 4 +--- libavcodec/dxva2_vc1.c | 4 +--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 5622c22..84959c5 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -445,9 +445,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 673fada..17548d2 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -365,9 +365,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; av_assert0(ctx_pic); diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 766af0b..43c7912 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -75,6 +75,9 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ + DXVA_CONTEXT_CFG(avctx, ctx) && \ + DXVA_CONTEXT_COUNT(avctx, ctx)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -84,6 +87,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count) #elif CONFIG_D3D11VA #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) @@ -93,6 +97,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index 2d88f9b..a459049 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -263,9 +263,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index d170e18..0672c97 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -264,9 +264,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx,
[libav-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static
From: Steve Lhomme <rob...@gmail.com> --- libavcodec/dxva2.c | 8 libavcodec/dxva2_internal.h | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 12acfd2..960a957 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -31,7 +31,7 @@ #define DEBUG_CONTEXT_LOCK 0 -void *ff_dxva2_get_surface(const AVFrame *frame) +static inline void *get_surface(const AVFrame *frame) { return frame->data[3]; } @@ -40,7 +40,7 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame) { -void *surface = ff_dxva2_get_surface(frame); +void *surface = get_surface(frame); unsigned i; for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { @@ -179,14 +179,14 @@ int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, #endif /* DEBUG_CONTEXT_LOCK */ } hr = ID3D11VideoContext_DecoderBeginFrame(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, - ff_dxva2_get_surface(frame), + get_surface(frame), 0, NULL); } #endif #if CONFIG_DXVA2 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) hr = IDirectXVideoDecoder_BeginFrame(DXVA2_CONTEXT(ctx)->decoder, - ff_dxva2_get_surface(frame), + get_surface(frame), NULL); #endif if (hr != E_PENDING || ++runs > 50) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index f0fe3d6..766af0b 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -95,8 +95,6 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) #endif -void *ff_dxva2_get_surface(const AVFrame *frame); - unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *, const AVFrame *frame); -- 2.9.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/4] dxva2: use a single macro to test if the DXVA context is valid
From: Steve Lhomme <slho...@matroska.org> --- libavcodec/dxva2_h264.c | 4 +--- libavcodec/dxva2_hevc.c | 4 +--- libavcodec/dxva2_internal.h | 5 + libavcodec/dxva2_mpeg2.c| 4 +--- libavcodec/dxva2_vc1.c | 4 +--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c index 5622c22..84959c5 100644 --- a/libavcodec/dxva2_h264.c +++ b/libavcodec/dxva2_h264.c @@ -445,9 +445,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 673fada..17548d2 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -365,9 +365,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; av_assert0(ctx_pic); diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 766af0b..43c7912 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -75,6 +75,9 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ + DXVA_CONTEXT_CFG(avctx, ctx) && \ + DXVA_CONTEXT_COUNT(avctx, ctx)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -84,6 +87,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->dxva2.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count) #elif CONFIG_D3D11VA #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) @@ -93,6 +97,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c index 2d88f9b..a459049 100644 --- a/libavcodec/dxva2_mpeg2.c +++ b/libavcodec/dxva2_mpeg2.c @@ -263,9 +263,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx, struct dxva2_picture_context *ctx_pic = s->current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || -DXVA_CONTEXT_CFG(avctx, ctx) == NULL || -DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) +if (!DXVA_CONTEXT_VALID(avctx, ctx)) return -1; assert(ctx_pic); diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c index d170e18..0672c97 100644 --- a/libavcodec/dxva2_vc1.c +++ b/libavcodec/dxva2_vc1.c @@ -264,9 +264,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx, AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private; -if (DXVA_CONTEXT_DECODER(avctx,
[libav-devel] [PATCH 4/4] dxva2: allow an empty array of ID3D11VideoDecoderOutputView
From: Steve Lhomme <slho...@matroska.org> We can pick the correct slice index directly from the ID3D11VideoDecoderOutputView casted from data[3]. --- libavcodec/dxva2_internal.h | 4 ++-- libavcodec/version.h| 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 43c7912..25c1496 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -77,7 +77,7 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator) #define DXVA_CONTEXT_VALID(avctx, ctx) (DXVA_CONTEXT_DECODER(avctx, ctx) && \ DXVA_CONTEXT_CFG(avctx, ctx) && \ - DXVA_CONTEXT_COUNT(avctx, ctx)) + (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD || ctx->dxva2.surface_count)) #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) @@ -97,7 +97,7 @@ typedef union { #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx) (ctx->d3d11va.cfg->ConfigBitstreamRaw) #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned) #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) -#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count) +#define DXVA_CONTEXT_VALID(avctx, ctx) (ctx->d3d11va.decoder && ctx->d3d11va.cfg) #endif unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, diff --git a/libavcodec/version.h b/libavcodec/version.h index 6f58bc8..36adc45 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 28 -#define LIBAVCODEC_VERSION_MICRO 4 +#define LIBAVCODEC_VERSION_MICRO 5 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.10.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/4] dxva2: get the slice number directly from the surface in D3D11VA
From: Steve Lhomme <slho...@matroska.org> No need to loop through the known surfaces, we'll use it anyway. The loop is only done for DXVA2 --- libavcodec/dxva2.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 4d50793..e32f026 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -41,19 +41,20 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, void *surface = ff_dxva2_get_surface(frame); unsigned i; -for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { #if CONFIG_D3D11VA -if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) { -D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; -ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], ); -return viewDesc.Texture2D.ArraySlice; -} +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) +{ +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; +ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, ); +return viewDesc.Texture2D.ArraySlice; +} #endif #if CONFIG_DXVA2 +for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) { if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) return i; -#endif } +#endif assert(0); return 0; -- 2.10.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/4] dxva2: make ff_dxva2_get_surface() static
From: Steve Lhomme <slho...@matroska.org> --- libavcodec/dxva2.c | 2 +- libavcodec/dxva2_internal.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 6063993..4d50793 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -29,7 +29,7 @@ #include "avcodec.h" #include "dxva2_internal.h" -void *ff_dxva2_get_surface(const AVFrame *frame) +static void *ff_dxva2_get_surface(const AVFrame *frame) { return frame->data[3]; } diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index f0fe3d6..766af0b 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -95,8 +95,6 @@ typedef union { #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator) #endif -void *ff_dxva2_get_surface(const AVFrame *frame); - unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *, const AVFrame *frame); -- 2.10.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] d3d11va: use the proper slice index
The slice index expected by D3D11VA is the one from the texture not from the array or texture/slices. In VLC the slices we provide the decoder don't start from 0 and thus pictures appear in bogus order. With possible crashes and corruptions when using an invalid index. -- * forgot to bump the minor version * get rid of DXVA_CONTEXT_SURFACE * bump the minor version, not the macro --- libavcodec/dxva2.c | 12 +++- libavcodec/dxva2_internal.h | 3 --- libavcodec/version.h| 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c index 9157094..2fc5f47 100644 --- a/libavcodec/dxva2.c +++ b/libavcodec/dxva2.c @@ -42,8 +42,18 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, unsigned i; for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) -if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface) +#if CONFIG_D3D11VA +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface) +{ +D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc; +ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], ); +return viewDesc.Texture2D.ArraySlice; +} +#endif +#if CONFIG_DXVA2 +if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface) return i; +#endif assert(0); return 0; diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h index 30aec8b..f0fe3d6 100644 --- a/libavcodec/dxva2_internal.h +++ b/libavcodec/dxva2_internal.h @@ -69,7 +69,6 @@ typedef union { #if CONFIG_D3D11VA && CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.workaround : ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface_count : ctx->dxva2.surface_count) -#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.surface[i] : ctx->dxva2.surface[i]) #define DXVA_CONTEXT_DECODER(avctx, ctx)(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.decoder : ctx->dxva2.decoder) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? >d3d11va.report_id : >dxva2.report_id)) #define DXVA_CONTEXT_CFG(avctx, ctx)(avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg : ctx->dxva2.cfg) @@ -79,7 +78,6 @@ typedef union { #elif CONFIG_DXVA2 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->dxva2.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->dxva2.surface_count) -#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->dxva2.surface[i]) #define DXVA_CONTEXT_DECODER(avctx, ctx)(ctx->dxva2.decoder) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(>dxva2.report_id)) #define DXVA_CONTEXT_CFG(avctx, ctx)(ctx->dxva2.cfg) @@ -89,7 +87,6 @@ typedef union { #elif CONFIG_D3D11VA #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ctx->d3d11va.workaround) #define DXVA_CONTEXT_COUNT(avctx, ctx) (ctx->d3d11va.surface_count) -#define DXVA_CONTEXT_SURFACE(avctx, ctx, i) (ctx->d3d11va.surface[i]) #define DXVA_CONTEXT_DECODER(avctx, ctx)(ctx->d3d11va.decoder) #define DXVA_CONTEXT_REPORT_ID(avctx, ctx) (*(>d3d11va.report_id)) #define DXVA_CONTEXT_CFG(avctx, ctx)(ctx->d3d11va.cfg) diff --git a/libavcodec/version.h b/libavcodec/version.h index 71ec9ce..3f21711 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 57 #define LIBAVCODEC_VERSION_MINOR 27 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MICRO 2 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ -- 2.8.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] d3d11va: use the proper slice index
On Wed, Oct 5, 2016 at 10:20 AM, Diego Biurrun <di...@biurrun.de> wrote: > On Wed, Oct 05, 2016 at 09:55:08AM +0200, Steve Lhomme wrote: >> The slice index expected by D3D11VA is the one from the texture not from the >> array or texture/slices. >> >> In VLC the slices we provide the decoder don't start from 0 and thus pictures >> appear in bogus order. With possible crashes and corruptions when using an >> invalid index. >> >> -- >> * forgot to bump the micro version > > You bumped minor, not micro, what was your intention? Be able to detect grammatically the old/new behavior. >> --- a/libavcodec/dxva2.c >> +++ b/libavcodec/dxva2.c >> @@ -42,8 +42,18 @@ unsigned ff_dxva2_get_surface_index(const AVCodecContext >> *avctx, >> unsigned i; >> >> for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) >> -if (DXVA_CONTEXT_SURFACE(avctx, ctx, i) == surface) >> +#if CONFIG_D3D11VA >> +if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && >> ctx->d3d11va.surface[i] == surface) >> +{ > > if (..) { > >> --- 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 27 >> +#define LIBAVCODEC_VERSION_MINOR 28 >> #define LIBAVCODEC_VERSION_MICRO 1 > > If you bump minor, you should reset micro. OK, I thought micro was either 0 or 100, if you see what I mean :) I'll do a patch with MINOR incremented. > Diego > ___ > libav-devel mailing list > libav-devel@libav.org > https://lists.libav.org/mailman/listinfo/libav-devel ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel