1
0
Fork 0
Commit Graph

63 Commits

Author SHA1 Message Date
Andreas Rheinhardt d692c42938 avcodec/qsv: Use RefStruct API for memory id (mids) array
Avoids allocations and therefore error checks and cleanup code;
also avoids indirections.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-04-19 13:18:04 +02:00
Sil Vilerino a9a2ddaea8 lavu/hwcontext_qsv: Update after adding support for VAAPI on Windows
- qsv_internal.h: Remove unnecessary include va_drm.h
- qsv_internal.h: Enable AVCODEC_QSV_LINUX_SESSION_HANDLE on Linux/VA only
- hwcontext_qsv.c: Do not allow child_device_type VAAPI for Windows until
  support is added, keep D3D11/DXVA2 as more prioritary defaults.

Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/

Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
2023-04-24 13:24:41 +08:00
Haihao Xiang 71cded6aa3 lavc/qsvdec: update HDR side data on output AVFrame
The SDK may provides HDR metadata for HDR streams via mfxExtBuffer
attached on output mfxFrameSurface1

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-12-01 09:36:58 +08:00
Haihao Xiang dc26bd8e6d lavc/qsvenc: enlarge the maximum number of ExtParam buffers on mfxEncodeCtrl
The next commit and other commits in future will use more ExtParam
buffers.

And combine 2 free functions into single one

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-10-25 08:49:48 +08:00
Haihao Xiang 3f28116ea2 lavc/qsv: specify Shift for each format too
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-10-10 09:31:34 +08:00
Haihao Xiang 6900feef06 lavc/qsv: create mfx session using oneVPL for decoding/encoding
If qsv hwdevice is available, use the mfxLoader handle in qsv hwdevice
to create mfx session. Otherwise create mfx session with a new mfxLoader
handle.

This is in preparation for oneVPL support
2022-08-12 10:43:39 +08:00
Haihao Xiang c77149bc37 qsv: restrict OPAQUE memory to MFX_VERSION < 2.0
OPAQUE memory isn't supported for MFX_VERSION >= 2.0[1][2]. This is in
preparation for oneVPL support

[1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
2022-08-12 10:43:39 +08:00
Haihao Xiang 6aea224382 qsv: restrict user plugin to MFX_VERSION < 2.0
User plugin isn't supported for MFX_VERSION >= 2.0[1][2]. This is in
preparation for oneVPL Support

[1] https://spec.oneapi.io/versions/latest/elements/oneVPL/source/VPL_intel_media_sdk.html#msdk-full-name-feature-removals
[2] https://github.com/oneapi-src/oneVPL
2022-08-12 10:43:39 +08:00
Haihao Xiang 3e61b7dd7f qsv: remove mfx/ prefix from mfx headers
The following Cflags has been added to libmfx.pc, so mfx/ prefix is no
longer needed when including mfx headers in FFmpeg.
   Cflags: -I${includedir} -I${includedir}/mfx

Some old versions of libmfx have the following Cflags in libmfx.pc
   Cflags: -I${includedir}

We may add -I${includedir}/mfx to CFLAGS when running 'configure
--enable-libmfx' for old versions of libmfx, if so, mfx headers without
mfx/ prefix can be included too.

If libmfx comes without pkg-config support, we may do a small change to
the settings of the environment(e.g. set -I/opt/intel/mediasdk/include/mfx
instead of -I/opt/intel/mediasdk/include to CFLAGS), then the build can
find the mfx headers without mfx/ prefix

After applying this change, we won't need to change #include for mfx
headers when mfx headers are installed under a new directory.

This is in preparation for oneVPL support (mfx headers in oneVPL are
installed under vpl directory)
2022-08-12 10:43:39 +08:00
Wenbin Chen 97141ffeec libavcodec/qsvenc: add ROI support to qsv encoder
Use The mfxEncoderCtrl parameter to enable ROI. Get side data
"AVRegionOfInterest" and use it to configure "mfxExtEncoderROI" which is
the MediaSDK's ROI configuration.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-06-17 13:09:35 +08:00
Wenbin Chen e0ae810da3 libavcodec/qsvdec: Add more pixel format support to qsvdec
Qsv decoder only supports directly output nv12 and p010 to system
memory. For other format, we need to download frame from qsv format
to system memory. Now add other supported format to qsvdec.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
2022-04-06 17:12:26 +08:00
Haihao Xiang 8ca06a8148 lavc/qsvdec: export AVFilmGrainParams side data
When AV_CODEC_EXPORT_DATA_FILM_GRAIN is present, AV1 decoder should
disable film grain application and export the corresponding side data

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-29 12:02:52 +08:00
Haihao Xiang 8dd507bf0d lavc/qsv: allow to add more parameter buffers to QSV frame
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2022-01-29 12:02:52 +08:00
Andreas Rheinhardt 1cdbccaa16 avcodec/qsvenc: Fix leak and crash when encoding H.264 due to A53_CC
Since commit 3bbe0c210b, the Payloads
array of every QSVFrame leaks as soon as the frame is reused;
the leak is small and not very noticeable, but if there is an attempt
to use said array the ensuing crash is much more noticeable.
This happens when encoding H.264 with A53 CC side data.

Furthermore, if said array can not be allocated at all, an AVFrame
leaks.

Fix all of this by not allocating the array separately at all; put it
in QSVFrame instead and restore the Payloads array upon reusing the
frame.

Finally, use av_freep() instead of av_free() to free the payload
entries.

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-11-30 17:16:32 +01:00
Andreas Rheinhardt 25394eb72e avcodec/qsv: Make ff_qsv_map_error() static
It is only an auxiliary function to ff_qsv_print_(error|warning)().

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-09-08 22:59:14 +02:00
Artem Galin 776d5a7472 libavcodec/qsv: enabling d3d11va support, added mfxhdlpair
Adding DX11 relevant device type checks and adjusting callbacks with
proper MediaSDK pair type support.

Extending structure for proper MediaSDK pair type support.

Signed-off-by: Artem Galin <artem.galin@intel.com>
2021-09-08 17:42:52 -03:00
Andreas Rheinhardt c0d7d5f595 avcodec/qsv: Remove unused ff_qsv_level_to_mfx()
Unused since 00d0a4aa9e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2021-08-08 18:40:46 +02:00
Jun Zhao ab9ff762c1 lavc/qsv: fix make checkheaders warning
make checkheaders will get warning as follow:

In file included from libavcodec/qsv_internal.h.c:1:
./libavcodec/qsv_internal.h:24:5: warning: "CONFIG_VAAPI" is not defined, evaluates to 0 [-Wundef]
   24 | #if CONFIG_VAAPI
      |     ^~~~~~~~~~~~

include "config.h" to fix the warning

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
2020-06-14 12:26:51 +08:00
Zhong Li 755ad01dd1 lavc/qsv: remove the unused funtion ff_qsv_profile_to_mfx()
Signed-off-by: Zhong Li <zhongli_dev@126.com>
2019-12-29 20:23:07 +08:00
Linjie Fu 5345965b3f lavc/qsvdec: Add GPU-accelerated memory copy support
GPU copy enables or disables GPU accelerated copying between video
and system memory. This may lead to a notable performance improvement.
Memory must be sequent and aligned with 128x64.

CMD:
ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv
                    -gpu_copy on -i input.h264 -f null -
or:
ffmpeg -c:v h264_qsv -gpu_copy on -i input.h264 -f null -

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: ChaoX A Liu <chaox.a.liu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-10-09 11:27:34 +08:00
Zhong Li 525de95679 lavc/qsv: add memory type message
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-09-26 13:44:11 +08:00
Zhong Li 74007dd86a lavc/qsv: Fix MSDK initialization failure in system memory mode
MSDK does not create internal acceleration device on Linux,
So MFXVideoCORE_SetHandle() is necessary.
It has been added for ff_qsv_init_session_device().
But missed for ff_qsv_init_internal_session() due to commit
1f26a23 overwrited commit db89f45

Fix #7030

Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-09-26 13:44:02 +08:00
Zhong Li f3dfd34f27 lavc/qsv: make function qsv_map_fourcc() can be called externally
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-08-20 13:34:02 +08:00
Zhong Li f115a2b763 lavc/qsvdec: add function ff_qsv_map_picstruct()
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-08-20 13:34:01 +08:00
Zhong Li 94ab39ec78 lavc/qsvdec: fix hevc level incorrectly map
libmfx hevc level defination is same as h264, not level_idc of SPEC.

Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-05-07 11:00:14 +08:00
Zhong Li 4131b0619c qsv: fix the dangerous macro definitions
Signed-off-by: Zhong Li <zhong.li@intel.com>
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
2019-03-28 21:49:04 +08:00
James Almer f790410b6b Merge commit 'cca5e4f040971db6de0bfe6968f00c021d8a9c42'
* commit 'cca5e4f040971db6de0bfe6968f00c021d8a9c42':
  qsv: adding Multi Frame Encode support

Merged-by: James Almer <jamrial@gmail.com>
2018-04-13 20:34:23 -03:00
James Almer 6f277e1f76 Merge commit '52ed83fa1a7f5170447eff6fad0b6c57119596e9'
* commit '52ed83fa1a7f5170447eff6fad0b6c57119596e9':
  lavc/qsvdec: expose frame pic_type and key_frame

Merged-by: James Almer <jamrial@gmail.com>
2018-04-13 19:58:05 -03:00
Maxym Dmytrychenko cca5e4f040 qsv: adding Multi Frame Encode support
Starting from API 1.25 helps to improve performance of the simultaneous
encode, 1:N scenario, like:

./avconv  -y -hwaccel qsv -c:v h264_qsv -r 30000/1001 -i
~/bbb_sunflower_1080p_60fps_normal.mp4  -vframes 600 -an \
    -filter_complex "split=2[s1][s2]; [s1]scale_qsv=1280:720[o1];
[s2]scale_qsv=960:540[o2]" \
    -map [o1] -c:v h264_qsv -b:v 3200k -minrate 3200k -maxrate 3200k -f
rawvideo /tmp/3200a.264 \
    -map [o2] -c:v h264_qsv -b:v 1750k -minrate 1750k -maxrate 1750k -f
rawvideo /tmp/1750a.264

Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-04-08 20:47:59 +02:00
Zhong Li 52ed83fa1a lavc/qsvdec: expose frame pic_type and key_frame
Currently pict_type and key_frame are unset.
Add an extra param to fetch the picture type from qsv decoder

The judgement “key frame is equal to IDR frame” only suitable for H264.
For HEVC, all IRAP frames are key frames, and other codecs have no IDR
frame.

Signed-off-by: ChaoX A Liu <chaox.a.liu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-04-08 20:47:59 +02:00
Mark Thompson 91c3b50d74 qsv: Add ability to create a session from a device
(cherry picked from commit 4936a48b1e)
2017-06-14 22:26:32 +01:00
Mark Thompson 4936a48b1e qsv: Add ability to create a session from a device 2017-04-02 19:06:33 +01:00
Mark Thompson ff821fdfce Merge commit '4ab61cd983b539749bd621ea271624ddb5196a8e'
* commit '4ab61cd983b539749bd621ea271624ddb5196a8e':
  qsv{enc,dec}: extend the internal frame allocator

Merged-by: Mark Thompson <sw@jkqxz.net>
2017-03-30 22:07:57 +01:00
Mark Thompson c0f2a8eac1 Merge commit '00aeedd84105a17f414185bd33ecadebeddb3a27'
* commit '00aeedd84105a17f414185bd33ecadebeddb3a27':
  qsv{dec,enc}: use a struct as a memory id with internal memory allocator

Merged-by: Mark Thompson <sw@jkqxz.net>
2017-03-30 22:06:03 +01:00
Mark Thompson 2f18e452f8 Merge commit '404e51478ecad060249d5b9bee6ab39a8a9d8c1c'
* commit '404e51478ecad060249d5b9bee6ab39a8a9d8c1c':
  qsv{dec,enc}: always use an internal mfxFrameSurface1

Minor fixups for differences in the QSV encoder because of a53cc.

Merged-by: Mark Thompson <sw@jkqxz.net>
2017-03-30 22:00:03 +01:00
Mark Thompson a7434ef195 Merge commit '8e07c22e508b349d145b9f142aa3ee8b3ce1d3a4'
* commit '8e07c22e508b349d145b9f142aa3ee8b3ce1d3a4':
  qsvenc: print warnings from encode/init

Merged-by: Mark Thompson <sw@jkqxz.net>
2017-03-12 15:21:41 +00:00
Mark Thompson 15887a410c Merge commit '95414eb2dc63a6f934275b4ed33dedd4369f2c49'
* commit '95414eb2dc63a6f934275b4ed33dedd4369f2c49':
  qsv: print more complete error messages

Merged-by: Mark Thompson <sw@jkqxz.net>
2017-03-12 15:19:05 +00:00
Mark Thompson cd1047f391 qsvdec: Pass the correct profile to libmfx
This was correct for H.26[45], because libmfx uses the same values
derived from profile_idc and the constraint_set flags, but it is
wrong for other codecs.

Also avoid passing FF_LEVEL_UNKNOWN (-99) as the level, as this is
certainly invalid.
2016-11-14 19:38:19 +00:00
Hendrik Leppkes 1bc6cdf2fc Merge commit '536bb17e9659c5ed7576a218d4085cdd6d5742fa'
* commit '536bb17e9659c5ed7576a218d4085cdd6d5742fa':
  qsvdec: make ff_qsv_map_pixfmt() return a MFX fourcc as well

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2016-11-14 15:19:43 +01:00
Anton Khirnov 4ab61cd983 qsv{enc,dec}: extend the internal frame allocator
Handle the internal frame requests, which is required by the HEVC
encoding plugin.

Signed-off-by: Maxym Dmytrychenko <maxym.dmytrychenko@intel.com>
2016-11-07 12:48:00 +01:00
Anton Khirnov 00aeedd841 qsv{dec,enc}: use a struct as a memory id with internal memory allocator
This will allow implementing the allocator more fully, which is needed
by the HEVC encoder plugin with video memory input.

Signed-off-by: Maxym Dmytrychenko <maxym.dmytrychenko@intel.com>
2016-11-07 12:47:54 +01:00
Anton Khirnov 404e51478e qsv{dec,enc}: always use an internal mfxFrameSurface1
For encoding, this avoids modifying the input surface, which we are not
allowed to do.
This will also be useful in the following commits.

Signed-off-by: Maxym Dmytrychenko <maxym.dmytrychenko@intel.com>
2016-11-07 12:47:46 +01:00
Mark Thompson 1f26a231bb qsv: Merge libav implementation
Merged as-at libav 398f015, and therefore includes outstanding
skipped merges 04b17ff and 130e1f1.

All features not in libav are preserved, and no options change.
2016-10-31 19:23:40 +00:00
Anton Khirnov 8e07c22e50 qsvenc: print warnings from encode/init 2016-07-22 19:08:13 +02:00
Anton Khirnov 95414eb2dc qsv: print more complete error messages
Include the libmfx error code and its description
2016-07-22 19:08:13 +02:00
Anton Khirnov 536bb17e96 qsvdec: make ff_qsv_map_pixfmt() return a MFX fourcc as well
Stop hardcoding NV12.

Also, move this function to the shared code, it will be used by the
encoder as well.
2016-07-03 09:13:29 +02:00
Anton Khirnov a0524d9b1e qsvdec: support getting the session from an AVHWFramesContext 2016-06-21 19:53:38 +02:00
Derek Buitenhuis 0d4c0240af Merge commit '9c0bc1e980a99106d6749ec632f166b87275871e'
* commit '9c0bc1e980a99106d6749ec632f166b87275871e':
  qsv: add a missing #include

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:22:43 +00:00
Anton Khirnov 9c0bc1e980 qsv: add a missing #include
Needed for enum AVCodecID
2016-02-18 08:47:33 +01:00
Will Kelleher 0eac93da0f qsvenc: write a53 caption data to SEI
Signed-off-by: Will Kelleher <wkelleher@gogoair.com>
Previous version reviewed-by: Ivan Uskov <ivan.uskov@nablet.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2015-11-30 23:31:12 +01:00