1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-05 15:58:07 +02:00
Commit Graph

71 Commits

Author SHA1 Message Date
Haihao Xiang
115f5e8035 lavc/qsvenc: allows the SDK runtime to choose LowPower/non-LowPower modes
The SDK supports LowPower and non-LowPower modes, but some features are
available only under one of the two modes. Currently non-LowPower mode
is always chosen in FFmpeg if the mode is not set to LowPower
explicitly. User will experience some SDK errors if a LowPower related
feature is specified but the mode is not set to LowPower. With this
patch, the mode is set to unknown by default in FFmpeg, the SDK is able
to choose a workable mode for the specified features.

Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-12 22:25:11 -03:00
Soft Works
4b3906bd7e libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
Signed-off-by: softworkz <softworkz@hotmail.com>
2021-08-11 09:54:20 -03:00
Haihao Xiang
65fdc0e589 lavc/qsvenc: pass the color properties to the SDK
Otherwise the color properties won't be encoded into the bitstream
header

Reviewed-by: Xiang, Haihao <haihao.xiang@intel.com>
Reviewed-by: Soft Works <softworkz@hotmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
2021-08-04 10:06:26 -03:00
Mark Thompson
cd322794ee lavc: Mark hw_config pointer arrays as const
They are read-only just like the HWConfig structures they point to.
2020-11-08 18:54:42 +00:00
Mark Thompson
5a1ff44907 lavc/qsvenc: Add hardware config metadata
All of these encoders can accept libmfx surfaces directly in a hardware
frames context, or they can accept software frames if a suitable device
is supplied to use.
2020-04-26 18:38:25 +01:00
Linjie Fu
8446318502 lavc/qsvenc: add Tiles encode support for HEVC
Add -tile_rows and -tile_cols option to specify the number of tile rows
and columns for ICL+ (gen 11) platform.

A tile must wholly contain all the slices within it. Slices cannot cross
tile boundaries. So the slice number would be implicitly resized to the
max(nSlice, nTile).

Example:
    ffmpeg -v verbose -hwaccel qsv -init_hw_device qsv=hw
    -filter_hw_device hw -f rawvideo -s:v 1920x1080 -i ./input.nv12 -vf
    format=nv12,hwupload=extra_hw_frames=64 -c:v hevc_qsv -tile_rows 2
    -tile_cols 2 -slices 4 -y output.h265

Also dump the actual quantity of encoded tiled rows and columns in run
time.

Fix the enhancement #8400.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2019-12-12 23:43:06 +08:00
Linjie Fu
df625057af lavc/qsvenc: Fix some code indentations
Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2019-11-28 23:34:40 +08:00
Zhong Li
33583803e1 lavc/qsvenc: enable vp9 encoder
1. must enable low_power mode since just VDENC can be supported by iHD
driver right now
2. Coding option1 and extra_data are not supported by MSDK
3. IVF header will be inserted in MSDK by default, but it is not needed
for FFmpeg, so disable it.

Signed-off-by: Zhong Li <zhongli_dev@126.com>
2019-11-03 16:45:35 +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
1125277bc6 lavc/qsvenc: enable hevc gpb option
GPB is the default type, just contains forward references but the
slice_type is B slice with higher encoding efficiency than regular P
slice, but lower performance.

Add an option to allow user to set regular P slice.

Fix ticket#6870

Test data on Intel Kabylake (i7-7567U CPU @ 3.50GHz):
1. ffmpeg -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 -vsync passthrough
-vframes 1000  -c:v hevc_qsv -gpb 0 -bf 0 -q 25 test_gpb_off_bf0_kbl.mp4

transcoding fps: 85
encoded file size of test_gpb_off_bf0_kbl.mp4: 21960100 (bytes)

2. ffmpeg -hwaccel qsv -c:v h264_qsv -i bbb_sunflower_1080p_30fps_normal.mp4 -vsync passthrough
-vframes 1000  -c:v hevc_qsv -gpb 1 -bf 0 -q 25 test_gpb_on_bf0_kbl.mp4

transcoding fps: 79
encoded file size oftest_gpb_on_bf0_kbl.mp4:  21211449 (bytes)

In this case, enable gpb can bring about 7% performance drop but 3.4% encoding efficiency improvment.

Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-04-03 23:00:15 +08:00
Zhong Li
d071a1117d lavc/qsvenc: get vps extradata from MSDK
Signed-off-by: Zhong Li <zhong.li@intel.com>
Reviewed-by: Mark Thompson <sw@jkqxz.net>
2019-04-01 19:21:48 +08:00
Linjie Fu
a8355eed36 lavc/qsvenc: expose low_power as a common option for QSV encoder
Always exposes low_power option for all qsv encoder, and reports a warning
if VDENC is not supported in current version of MSDK.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-04-01 19:21:42 +08:00
Zhong Li
391f884675 lavc/qsvenc_h264: remove the privite option trellis
There are many problems of current qsv trellis option:
1. Duplicated with AVCodecContext definition
2. MFX_TRELLIS_XXX is introduced by MSDK API 1.17
   Currently Without MSDK API checking thus may cause compilation issue.
3. user is inclined to enable trellis when set "-trellis 1", but
   actually it is to disable since MFX_TRELLIS_OFF is equal to 1.
4. It is too complex for user to enable trellis for every frame(I/P/B).

Just simply remove the private option, and switch to the AVCodecContext
definition. Compatibility should not a big problem (except can't exact map)
since the option name is same as AVCodecContext.

Signed-off-by: Zhong Li <zhong.li@intel.com>
Reviewed-by: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Reviewed-by: Moritz Barsnick <barsnick@gmx.net>
2019-03-28 21:52:51 +08:00
Zhong Li
b47446cc39 lavc/qsvenc: make the queried libmfx version easily reused
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-03-28 21:48:09 +08:00
Zhong Li
74cf2dc3ac lavc/qsvenc: enable QVBR mode
QVBR mode is to use the variable bitrate control algorithm
with constant quality.
mfxExtCodingOption3 should be supported to enable QVBR mode.

It is neccesary to specify a max_rate for QVBR, else it may be ICQ mode.
Example usage: ffmpeg -hwaccel qsv -c:v h264_qsv -i input.mp4 -c:v
h264_qsv -global_quality 25 -maxrate 2M test_qvbr.mp4 -v verbose

Clip QVBR quality range to be [0, 51] as Mark's commments.
It is similar to qp range of CQP but possibly should be updated when VP8/VP9
encoding can be supported.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-01-25 16:53:27 +08:00
Linjie Fu
e92ce340e6 lavc/qsvenc: add VDENC support for H264
Add VDENC(lowpower mode) support for QSV H264

It's an experimental function(like lowpower in vaapi) with
some limitations:
- CBR/VBR require HuC which should be explicitly loaded via i915
module parameter(i915.enable_guc=2 for linux kernel version >= 4.16)

Use option "-low_power 1" to enable VDENC.
Add in dump_video_param() to show the status of VDENC in runtime log.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2019-01-10 21:48:07 +08:00
Zhong Li
c9f0cff5ef lavc/qsvenc: add an option to set h264 pps for every frame
RepeatPPS is enabled by default in mfx. It is not necessary mostly and
wasting encoding bits.
Add an option to control it and disable it by default.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-12-07 17:13:36 +08:00
Zhong Li
ac0bcd6b61 lavc/qsvenc: add forced_idr option
This option can be used to repect original input I/IDR frame type.

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-11-30 17:53:00 +08:00
Zhong Li
518b963d2c lavc/qsvenc: enable ICQ and ICQ_LA on Linux
ICQ/ICQ_LA are enabled with MSDK V1.28

Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-11-30 17:51:49 +08:00
James Almer
7167ac33a8 Merge commit 'c1bcd321ea2c2ae1765a1e64f03278712221d726'
* commit 'c1bcd321ea2c2ae1765a1e64f03278712221d726':
  avcodec/qsv: fix async support

Merged-by: James Almer <jamrial@gmail.com>
2018-09-02 19:23:26 -03:00
James Almer
8e789d244c Merge commit '4ce701b4e640d4723a4005d664f31f8342fac40e'
* commit '4ce701b4e640d4723a4005d664f31f8342fac40e':
  qsvenc: remove vcm option on Linux

Merged-by: James Almer <jamrial@gmail.com>
2018-09-02 19:12:52 -03:00
Zhong Li
900487043b lavc/qsvenc: add quality status to side_data
Add fix a memory leak issue as James's comments.

V2: use a local pict_type since coded_frame is deprecated.

Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-08-22 15:26:35 +08:00
Zhong Li
6088b7b037 lavc/qsvenc: expose qp of encoded frames
Requirement from ticket #7254.
Currently only H264 supported by MSDK.

Signed-off-by: Zhong Li <zhong.li@intel.com>
2018-08-07 11:26:37 +08:00
Dmitry Rogozhkin
c1bcd321ea avcodec/qsv: fix async support
Current implementations of qsv components incorrectly work with async level, they
actually try to work in async+1 level stepping into MFX_WRN_DEVICE_BUSY and polling
loop. This change address this misbehaviour.

Signed-off-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Cc: Maxym Dmytrychenko <maxim.d33@gmail.com>
Cc: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-07-26 09:57:54 +02:00
Timo Rothenpieler
3f953379e1 avcodec/qsvenc: fix version detection on cygwin 2018-06-27 16:04:08 +02:00
Zhong Li
4ce701b4e6 qsvenc: remove vcm option on Linux
1. vcm mode is only available for H264.
2. vcm is not supported on Linux, but it is shown when run "./avconv -h
encoder=h264_qsv |grep vcm". This shouldn't happen.

Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-06-11 13:33:52 +02: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
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
James Almer
b065c71e9d Merge commit 'deefca02c275ce4bc5ccbee690463ffef81a18b8'
* commit 'deefca02c275ce4bc5ccbee690463ffef81a18b8':
  qsvenc: add the Access Unit Delimiter NAL Unit support

Merged-by: James Almer <jamrial@gmail.com>
2018-03-29 20:34:43 -03:00
Zhong Li
deefca02c2 qsvenc: add the Access Unit Delimiter NAL Unit support
Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2018-03-16 13:36:30 +01:00
Mark Thompson
de3be1d09f Merge commit '8bb9824fcbc5a6ebf68391d70a2c4f03447990d2'
* commit '8bb9824fcbc5a6ebf68391d70a2c4f03447990d2':
  qsvenc: AVBR is not supported on non-windows OS

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-12 23:01:24 +00:00
Ruiling Song
9b09792c90 lavc/qsv: default la_ds to MFX_LOOKAHEAD_DS_UNKNOWN
MFX_LOOKAHEAD_DS_UNKNOWN means auto.
-1 is not a valid value.

Signed-off-by: Ruiling Song <ruiling.song@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-02-12 00:34:45 +01:00
Zhong Li
8bb9824fcb qsvenc: AVBR is not supported on non-windows OS
AVBR is supported from API 1.3 but only available for Windows

Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2018-02-12 00:34:34 +01:00
James Almer
374f818bfb Merge commit '508378556631dc18d32247b4a4e35703758e1ca9'
* commit '508378556631dc18d32247b4a4e35703758e1ca9':
  qsv: Support explicit lookahead downscaling

Merged-by: James Almer <jamrial@gmail.com>
2017-12-14 19:05:55 -03:00
James Almer
2ca3c049cd Merge commit 'bddb2ce179c57db6e3c79fdc3363c165d90850b0'
* commit 'bddb2ce179c57db6e3c79fdc3363c165d90850b0':
  lavc/qsvenc: ICQ/VCM/QVBR are not avilable on Linux

Merged-by: James Almer <jamrial@gmail.com>
2017-12-14 18:45:20 -03:00
Luca Barbato
5083785566 qsv: Support explicit lookahead downscaling 2017-12-12 15:43:02 +00:00
Li, Zhong
bddb2ce179 lavc/qsvenc: ICQ/VCM/QVBR are not avilable on Linux
Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2017-12-12 13:58:18 +01:00
James Almer
dde7b1d485 Merge commit 'b843b343d8a3210ae37a2342b1904a5bd1e5fc6e'
* commit 'b843b343d8a3210ae37a2342b1904a5bd1e5fc6e':
  qsvenc: cavlc option is only available for h264

Merged-by: James Almer <jamrial@gmail.com>
2017-11-29 21:05:57 -03:00
Li, Zhong
b843b343d8 qsvenc: cavlc option is only available for h264
Moving option definition to h264 implementation and fixing command line defaults
in order to properly respect cavlc input value

Signed-off-by: Zhong Li <zhong.li@intel.com>
Signed-off-by: Maxym Dmytrychenko <maxim.d33@gmail.com>
2017-11-24 19:38:52 +01:00
Aaron Levinson
ae5b67ee64 qsvenc: Make sure the interlaced encoding works
Purpose: qsvenc: make sure that interlaced encoding works.  Also,
reduce the vertical alignment constraint when possible to reduce
memory usage.

Note: Most of this code used to be present in ffmpeg and was
eliminated in revision 1f26a23 on Oct. 31, 2016 (qsv: Merge libav
implementation, at
https://github.com/FFmpeg/FFmpeg/commit/1f26a231bb065276cd80ce02957c759f3197
edfa#diff-7d84a34d58597bb7aa4b8239dca1f9f8).  Already applied to
libav.

Reviewed-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 8fd8f91e47)
Signed-off-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: Aaron Levinson <alevinsn@aracnet.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-05-09 03:22:14 +02:00
Aaron Levinson
8fd8f91e47 qsvenc: Make sure the interlaced encoding works
And reduce the vertical alignment constraint when possible to reduce the
memory usage.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2017-04-23 16:15:05 +02:00
Luca Barbato
f8f7ad758d qsv: Set the correct range for la_depth
Setting an invalid range for it makes the encoder behave inconsistently.
2017-01-13 08:42:10 +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
ad9c9440d5 qsvenc: support getting the session from an AVHWFramesContext 2016-06-21 19:53:38 +02:00
Derek Buitenhuis
c63da6e916 Merge commit '9cac1b4b4f1532fb2aeef54799285360656be5eb'
* commit '9cac1b4b4f1532fb2aeef54799285360656be5eb':
  qsvenc: Add private option to replace coder_type

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-16 16:51:45 +00:00
Derek Buitenhuis
2e9b995e4f Merge commit '0e6c8532215790bbe560a9eea4f3cc82bb55cf92'
* commit '0e6c8532215790bbe560a9eea4f3cc82bb55cf92'
  lavc: Move b_frame_strategy and b_sensitivity to codec private options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-01-27 20:18:04 +00:00
Vittorio Giovara
9cac1b4b4f qsvenc: Add private option to replace coder_type
Missing from be00ec832c.
2016-01-25 12:00:16 -05:00
Vittorio Giovara
0e6c853221 lavc: Move b_frame_strategy and b_sensitivity to codec private options
The b_frame_strategy option is only used by mpegvideoenc, qsv, x264, and
xavs, while b_sensitivity is only used by mpegvideoenc.

These are very codec-specific options, so deprecate the global variants.
Set proper limits to the maximum allowed values.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2016-01-21 15:33:19 -05: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
Hendrik Leppkes
5bc9c7a6db Merge commit 'fc4c27c4edfc6a5f9bc7c696e823652474a65ce8'
* commit 'fc4c27c4edfc6a5f9bc7c696e823652474a65ce8':
  qsvenc: expose additional encoding options

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-29 15:22:53 +01:00