Commit Graph

62 Commits

Author SHA1 Message Date
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
Hendrik Leppkes 24563c20f1 Merge commit 'e7d7cf86dcaba8eaaed62c80172ff0aff2588c2a'
* commit 'e7d7cf86dcaba8eaaed62c80172ff0aff2588c2a':
  qsvenc: support more RC methods

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-11-29 15:18:08 +01:00
Derek Buitenhuis 9c35b8e219 Merge commit 'fb8753ada23189076bdf903c1c001c0ca8287fae'
* commit 'fb8753ada23189076bdf903c1c001c0ca8287fae':
  qsvenc: factor out common options

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2015-11-24 13:48:28 +00:00
Derek Buitenhuis 98540a2c7d Merge commit '4d8f536b535487063a08609636e712ad86d2ad54'
* commit '4d8f536b535487063a08609636e712ad86d2ad54':
  qsvenc: print the actual video parameters used by MSDK

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2015-11-22 17:46:57 +00:00
Anton Khirnov fc4c27c4ed qsvenc: expose additional encoding options 2015-11-20 09:29:50 +01:00
Anton Khirnov e7d7cf86dc qsvenc: support more RC methods 2015-11-20 09:29:13 +01:00
Anton Khirnov fb8753ada2 qsvenc: factor out common options 2015-11-20 09:26:12 +01:00
Anton Khirnov 4d8f536b53 qsvenc: print the actual video parameters used by MSDK 2015-11-20 09:23:22 +01:00
Hendrik Leppkes 866a4174db Merge commit 'dc923bc23b3efd949d0bf67ff1abdb95059e5843'
* commit 'dc923bc23b3efd949d0bf67ff1abdb95059e5843':
  qsvenc: add an API for allocating opaque surfaces

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-22 15:55:43 +02:00
Hendrik Leppkes 760dbdd3c5 Merge commit '772c87c5a658f36d7c0612f5da583fc2bfa54f79'
* commit '772c87c5a658f36d7c0612f5da583fc2bfa54f79':
  qsvenc: support passing arbitrary external buffers to the encoder

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
2015-10-22 15:46:52 +02:00