Commit Graph

26 Commits

Author SHA1 Message Date
James Almer 18516d3e69 avutil/hwcontext_dxva2: return an error when buffer allocation fails
This also prevents the use of an uninitialized variable.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
2017-09-19 19:30:08 -03:00
Aaron Levinson 0c1c514643 avutil/hwcontext_dxva2: Don't improperly free IDirect3DSurface9 objects
Add dxva2_pool_release_dummy() and use it in call to
av_buffer_create() in dxva2_pool_alloc().

Prior to this change, av_buffer_create() was called with NULL for the
third argument, which indicates that av_buffer_default_free() should
be used to free the buffer's data.  Eventually, it gets to
buffer_pool_free() and calls buf->free() on a surface object (which is
av_buffer_default_free()).

This can result in a crash when the debug version of the C-runtime is
used on Windows.  While it doesn't appear to result in a crash when
the release version of the C-runtime is used on Windows, it likely
results in memory corruption, since av_free() is being called on
memory that was allocated using
IDirectXVideoAccelerationService::CreateSurface().

Signed-off-by: Aaron Levinson <alevinsn@aracnet.com>
Reviewed-by: wm4 <nfxjfg@googlemail.com>
Reviewed-by: Steven Liu <lingjiujianke@gmail.com>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
2017-05-16 21:45:52 +01:00
Hendrik Leppkes 5c612c5ff8 Merge commit 'e18ba2dfd2d19aedc8afccf011d5fd0833352423'
* commit 'e18ba2dfd2d19aedc8afccf011d5fd0833352423':
  hwcontext_dxva2: make sure the sw frame format is the right one during transfer

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-04-01 18:53:40 +02:00
Hendrik Leppkes 0f9ce9c5fc Merge commit '5a1d605ceae448b476a525f7368ec452000d1f26'
* commit '5a1d605ceae448b476a525f7368ec452000d1f26':
  hwcontext_dxva2: split transfer_data() into upload/download functions

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-04-01 18:53:36 +02:00
Hendrik Leppkes fbfa72916c Merge commit '9d7026574bbbe67d004a1c32911da75375692967'
* commit '9d7026574bbbe67d004a1c32911da75375692967':
  hwcontext_dxva2: fix handling of the mapping flags

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-04-01 18:53:32 +02:00
Hendrik Leppkes d91e7aac12 Merge commit '0d3176e32f351d18d6174d8b05796829a75a4c6b'
* commit '0d3176e32f351d18d6174d8b05796829a75a4c6b':
  hwcontext_dxva2: do not assume the destination format during mapping is always the right one

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-04-01 18:53:27 +02:00
Hendrik Leppkes 14764b93e2 Merge commit '10065d9324c2e35ce7040b6a2b9ebf6079bcbf42'
* commit '10065d9324c2e35ce7040b6a2b9ebf6079bcbf42':
  hwcontext_dxva2: add support for the P8 format

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-03-30 11:37:39 +02:00
Hendrik Leppkes 9ca5d2de5d Merge commit '910973765417f06a4a9ccbd006e4df74c32ecb01'
* commit '910973765417f06a4a9ccbd006e4df74c32ecb01':
  hwcontext_dxva2: frame mapping support

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2017-03-30 11:33:51 +02:00
Clément Bœsch a5cf6628d6 Merge commit 'f01f7a7846529b7c3ef343f117eaa2c0a1457af0'
* commit 'f01f7a7846529b7c3ef343f117eaa2c0a1457af0':
  hwcontext_dxva2: use the special UC copy for downloading frames

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-20 08:37:40 +01:00
wm4 50708f4aa4 hwcontext_dxva2: support D3D9Ex
D3D9Ex uses different driver paths. This helps with "headless"
configurations when no user logs in. Plain D3D9 device creation will
fail if no user is logged in, while it works with D3D9Ex.

Signed-off-by: Anton Khirnov <anton@khirnov.net>

Merges Libav commit c2f97f0508.
2017-02-13 08:01:20 +01:00
Anton Khirnov e18ba2dfd2 hwcontext_dxva2: make sure the sw frame format is the right one during transfer 2016-11-18 10:31:53 +01:00
Anton Khirnov 5a1d605cea hwcontext_dxva2: split transfer_data() into upload/download functions
Just the presence of a hw frames context is not enough to detect whether
the transfer is an upload or a download, because hw frames mapped to
system memory will have a hw frames context attached.
2016-11-18 10:31:53 +01:00
Anton Khirnov 9d7026574b hwcontext_dxva2: fix handling of the mapping flags
D3DLOCK_READONLY properly corresponds to the absence of the write flag,
not to the presence of the read flag, while D3DLOCK_DISCARD is
equivalent to the overwrite flag.
2016-11-18 10:31:53 +01:00
Anton Khirnov 0d3176e32f hwcontext_dxva2: do not assume the destination format during mapping is always the right one
Handle the cases where it is unsupported or unset.
2016-11-18 10:31:53 +01:00
Hendrik Leppkes 3dfe97a841 Merge commit '2ef87815fec059504370ae3050cc243a53553915'
* commit '2ef87815fec059504370ae3050cc243a53553915':
  hwcontext_dxva2: add support for p010

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-14 15:15:19 +01:00
Anton Khirnov 10065d9324 hwcontext_dxva2: add support for the P8 format
This format is used internally by the QSV encoder to store the encoded
bitstream.

Signed-off-by: Maxym Dmytrychenko <maxym.dmytrychenko@intel.com>
2016-11-07 12:47:14 +01:00
Anton Khirnov 9109737654 hwcontext_dxva2: frame mapping support
Signed-off-by: Maxym Dmytrychenko <maxym.dmytrychenko@intel.com>
2016-11-07 12:46:59 +01:00
Matt Oliver 85db1f97eb avutil/hwcontext_dxva.c: Use new safe dlopen code.
Signed-off-by: Matt Oliver <protogonoi@gmail.com>
2016-11-05 18:08:43 +11:00
Anton Khirnov f01f7a7846 hwcontext_dxva2: use the special UC copy for downloading frames 2016-08-31 08:22:52 +02:00
Anton Khirnov 2ef87815fe hwcontext_dxva2: add support for p010 2016-07-02 09:39:24 +02:00
Hendrik Leppkes 06a0e18435 hwcontext_dxva2: Use GetDesktopWindow instead of GetShellWindow
Improves compatibility with some MinGW variants,
see 771537edcf
2016-06-26 15:34:40 +02:00
Hendrik Leppkes 162370b473 Merge commit '8e70385a8ed06f96f1e9e35cf7b6788a5c56eded'
* commit '8e70385a8ed06f96f1e9e35cf7b6788a5c56eded':
  hwcontext_dxva2: implement device creation

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-06-26 15:25:24 +02:00
Hendrik Leppkes 0c312a4562 hwcontext_dxva2: support P010 10-bit surfaces 2016-06-22 23:28:47 +02:00
Hendrik Leppkes 3689efea3d Merge commit 'c46db38cde8e8fd8ecb1c6602f10ec0e002f29a8'
* commit 'c46db38cde8e8fd8ecb1c6602f10ec0e002f29a8':
  hwcontext: add a dxva2 implementation

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-06-22 22:38:49 +02:00
Anton Khirnov 8e70385a8e hwcontext_dxva2: implement device creation 2016-05-26 15:40:33 +02:00
Anton Khirnov c46db38cde hwcontext: add a dxva2 implementation 2016-05-17 09:11:25 +02:00