Commit Graph

68 Commits

Author SHA1 Message Date
Mark Thompson 91534786fa vaapi_encode_h26[45]: Make the AUD option a boolean 2018-09-23 14:42:34 +01:00
Mark Thompson 851a63c22a vaapi_encode: Clean up the packed header configuration
Add a larger warning more clearly explaining the consequences of missing
packed header support in the driver.  Also only write the extradata if the
user actually requests it via the GLOBAL_HEADER flag.
2018-09-23 14:42:34 +01:00
Mark Thompson bf726c26fd vaapi_encode: Clean up the GOP structure configuration
Choose what types of reference frames will be used based on what types
are available, and make the intra-only mode explicit (GOP size one,
which must be used for MJPEG).
2018-09-23 14:42:33 +01:00
Mark Thompson 8479f99c7d vaapi_encode: Add support for max QP in rate control
This was added in libva 2.1.0 (VAAPI 1.1.0).  Use AVCodecContext.qmax,
matching the existing behaviour for qmin, and clean up the defaults so
that we only pass min/max when explicitly set.
2018-09-23 14:42:33 +01:00
Mark Thompson af532c9215 vaapi_encode: Clean up rate control configuration
Query which modes are supported and select between VBR and CBR based
on that - this removes all of the codec-specific rate control mode
selection code.
2018-09-23 14:42:33 +01:00
Mark Thompson aa2563aecc vaapi_encode: Add common options between all encoders
The only common option here is low_power - it was previously supported
for H.264 only, that specific option is removed.
2018-09-23 14:42:33 +01:00
Mark Thompson 3b188666f1 vaapi_encode: Choose profiles dynamically
Previously there was one fixed choice for each codec (e.g. H.265 -> Main
profile), and using anything else then required an explicit option from
the user.  This changes to selecting the profile based on the input format
and the set of profiles actually supported by the driver (e.g. P010 input
will choose Main 10 profile for H.265 if the driver supports it).

The entrypoint and render target format are also chosen dynamically in the
same way, removing those explicit selections from the per-codec code.
2018-09-23 14:42:33 +01:00
Mark Thompson c5b4ad247b vaapi_encode: Remove common priv_data and options fields
The codec-specific context now contains both the common context and the
codec-specific options directly.
2018-08-27 16:21:38 +01:00
Mark Thompson 46d1313fcd vaapi_encode_h265: Move options and common structures into context
Matching previous commit for H.264.
2018-08-27 16:21:37 +01:00
Haihao Xiang 0612e29b59 vaapi_encode_h265: Insert content light level information
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2018-05-10 20:55:42 +01:00
Haihao Xiang 345b6962b6 vaapi_encode_h265: Insert mastering display colour volume
'-sei xxx' is added to control SEI insertion, so far only mastering
display colour volume is available for testing.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2018-05-10 20:55:32 +01:00
Mark Thompson 0cc8e34a94 Merge commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2'
* commit 'ce5870a3a8f2b10668ee4f04c2ae0287f66f31b2':
  cbs: Refcount all the things!

Some changes for bitstream API.

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 22:22:54 +00:00
Mark Thompson f082dcab7c Merge commit '67eb2b16daa77f6ba3e04a28ca18e53193723b7f'
* commit '67eb2b16daa77f6ba3e04a28ca18e53193723b7f':
  vaapi_h265: Mark unused entries in RefPicList[01] as explicitly invalid

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 21:52:20 +00:00
Mark Thompson ce5870a3a8 cbs: Refcount all the things!
This makes it easier for users of the CBS API to get alloc/free right -
all subelements use the buffer API so that it's clear how to free them.
It also allows eliding some redundant copies: the packet -> fragment copy
disappears after this change if the input packet is refcounted, and more
codec-specific cases are now possible (but not included in this patch).
2018-02-20 22:04:12 +00:00
Mark Thompson 67eb2b16da vaapi_h265: Mark unused entries in RefPicList[01] as explicitly invalid
The iHD driver looks at entries beyond num_ref_idx_l[01]_active_minus1
for unknown reasons.
2018-02-20 22:04:12 +00:00
Mark Thompson 2651352988 cbs: Allocate the context inside the init function
... instead of making callers allocate it themselves.  This is more
consistent with other APIs in libav.
2018-02-20 22:04:12 +00:00
wm4 b945fed629 avcodec: add metadata to identify wrappers and hardware decoders
Explicitly identify decoder/encoder wrappers with a common name. This
saves API users from guessing by the name suffix. For example, they
don't have to guess that "h264_qsv" is the h264 QSV implementation, and
instead they can just check the AVCodec .codec and .wrapper_name fields.

Explicitly mark AVCodec entries that are hardware decoders or most
likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing
API users listing hardware decoders in a more generic way. The proposed
AVCodecHWConfig does not provide this information fully, because it's
concerned with decoder configuration, not information about the fact
whether the hardware is used or not.

AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software
implementations in case the hardware is not capable.

Based on a patch by Philip Langdale <philipl@overt.org>.

Merges Libav commit 47687a2f8a.
2017-12-14 19:37:56 +01:00
wm4 47687a2f8a avcodec: add metadata to identify wrappers and hardware decoders
Explicitly identify decoder/encoder wrappers with a common name. This
saves API users from guessing by the name suffix. For example, they
don't have to guess that "h264_qsv" is the h264 QSV implementation, and
instead they can just check the AVCodec .codec and .wrapper_name fields.

Explicitly mark AVCodec entries that are hardware decoders or most
likely hardware decoders with new AV_CODEC_CAPs. The purpose is allowing
API users listing hardware decoders in a more generic way. The proposed
AVCodecHWConfig does not provide this information fully, because it's
concerned with decoder configuration, not information about the fact
whether the hardware is used or not.

AV_CODEC_CAP_HYBRID exists specifically for QSV, which can have software
implementations in case the hardware is not capable.

Based on a patch by Philip Langdale <philipl@overt.org>.

Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
2017-12-14 16:58:45 +01:00
Mark Thompson 3ff8fbbf5a vaapi_h265: Add named options for setting profile and level
Also fixes the default, which previously contained a nonsense value.
2017-12-06 22:33:53 +00:00
Mark Thompson 71421f382f vaapi_h265: Add named options for setting profile and level
Also fixes the default, which previously contained a nonsense value.
2017-12-04 23:25:37 +00:00
Jun Zhao e7adf2250b vaapi_h265: Enable VBR mode
To match vaapi_h264.

From ffmpeg commit 385cafb07a.

Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-12-02 15:21:30 +00:00
James Almer f1fdd17d39 Merge commit 'f940c859c23ae201b0170cf541ea8f6b7a52dd49'
* commit 'f940c859c23ae201b0170cf541ea8f6b7a52dd49':
  Revert "vaapi_h265: Reduce the amount of padding in the stream"

Merged-by: James Almer <jamrial@gmail.com>
2017-11-11 14:07:09 -03:00
James Almer e6d70494ce Merge commit 'a14a12ca137bf1526452b97bedfc9f7b301d4e04'
* commit 'a14a12ca137bf1526452b97bedfc9f7b301d4e04':
  vaapi_h265: Reduce the amount of padding in the stream

Merged-by: James Almer <jamrial@gmail.com>
2017-11-11 00:49:43 -03:00
Mark Thompson 038a51258c vaapi_h265: Add support for AUD NAL units
Matching the H.264 encoder.

(cherry picked from commit e3e8eab359)
2017-10-17 20:56:30 +01:00
Mark Thompson 00179664bc vaapi_h265: Convert to use coded bitstream infrastructure
Also improves the metadata and generally makes the configuration
a bit cleaner.

(cherry picked from commit ac12486714)
2017-10-17 20:56:30 +01:00
Mark Thompson f940c859c2 Revert "vaapi_h265: Reduce the amount of padding in the stream"
This reverts commit a14a12ca13.

The CTU size is always 32x32; the surface size is what actually sets
the desired property, and it is already correct.
2017-09-12 22:11:52 +01:00
Jun Zhao 385cafb07a lavc/vaapi_encode_h265: Enable VBR mode
Follow vaapi_h264 style, enable the VBR mode.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-08-28 11:47:55 +01:00
Mark Thompson a14a12ca13 vaapi_h265: Reduce the amount of padding in the stream
It is not necessary to pad to the CTU size.  The CB size of 8x8 should be
sufficient, but due to constraints in the Intel driver (the one usable
implementation of this) it has to be padded to 16x16 like in H.264.
2017-08-13 17:55:02 +01:00
Mark Thompson e3e8eab359 vaapi_h265: Add support for AUD NAL units
Matching the H.264 encoder.
2017-08-13 17:55:02 +01:00
Mark Thompson ac12486714 vaapi_h265: Convert to use coded bitstream infrastructure
Also improves the metadata and generally makes the configuration
a bit cleaner.
2017-08-13 17:55:02 +01:00
Jun Zhao 5b8a708492 lavc/vaapi_encode_h265: Remove duplicate slice_segment_address.
the VAEncSliceParameterBufferHEVC in libva have support this field,
so remove the duplicate field in VAAPIEncodeH265MiscSliceParams.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-07-18 22:56:24 +01:00
Mark Thompson b658b5399e vaapi_encode: Use gop_size consistently in RC parameters
The non-H.26[45] codecs already use this form.  Since we don't
currently generate I frames for codecs which support them separately
to IDR, the p_per_i variable is set to infinity by default so that it
doesn't interfere with any other calculation.  (All the code for I
frames still exists, and it works for H.264 if set manually.)

(cherry picked from commit 6af014f402)
2017-06-14 22:26:32 +01:00
Mark Thompson 6af014f402 vaapi_encode: Use gop_size consistently in RC parameters
The non-H.26[45] codecs already use this form.  Since we don't
currently generate I frames for codecs which support them separately
to IDR, the p_per_i variable is set to infinity by default so that it
doesn't interfere with any other calculation.  (All the code for I
frames still exists, and it works for H.264 if set manually.)
2017-04-26 22:00:33 +01:00
James Almer dc39ccdc3b Merge commit '0bfdcce4d42a6e654c00ea5f9237dc987626457f'
* commit '0bfdcce4d42a6e654c00ea5f9237dc987626457f':
  hevc: move the SliceType enum to hevc.h

Merged-by: James Almer <jamrial@gmail.com>
2017-03-23 20:02:11 -03:00
James Almer c43fd1f279 Merge commit 'f9bb356e0eb38ab4df32df8276b71a0b2626538f'
* commit 'f9bb356e0eb38ab4df32df8276b71a0b2626538f':
  vaapi_h265: Include header for slice types

Merged-by: James Almer <jamrial@gmail.com>
2017-03-23 18:08:41 -03:00
James Almer 6397815be0 Merge commit 'c359d624d3efc3fd1d83210d78c4152bd329b765'
* commit 'c359d624d3efc3fd1d83210d78c4152bd329b765':
  hevcdec: move decoder-independent declarations into a separate header

Merged-by: James Almer <jamrial@gmail.com>
2017-03-23 14:27:48 -03:00
Clément Bœsch 038e6aef7a Merge commit '4abe3b049d987420eb891f74a35af2cebbf52144'
* commit '4abe3b049d987420eb891f74a35af2cebbf52144':
  hevc: rename hevc.[ch] to hevcdec.[ch]

Merged-by: Clément Bœsch <u@pkh.me>
2017-03-23 16:48:41 +01:00
Mark Thompson 37de9ce713 vaapi_h265: Fix CFR mode with framerate set in AVCodecContext
Same issue as 17a0f9481c.

(cherry picked from commit 7d81698b89)
2017-02-08 19:14:04 +00:00
Mark Thompson b9514756ba vaapi_h265: Add main 10 encode support
(cherry picked from commit 5a5df90d9c)
(cherry picked from commit d08e02d929)
2017-02-08 19:14:04 +00:00
Mark Thompson d08e02d929 vaapi_h265: Fix build failure with old libva without 10-bit surfaces
10-bit surface support was added in libva 1.6.2, earlier versions
support H.265 encoding in 8-bit only.
2017-01-04 21:49:41 +00:00
Mark Thompson 7d81698b89 vaapi_h265: Fix CFR mode with framerate set in AVCodecContext
Same issue as 17a0f9481c.
2016-12-10 16:55:44 +00:00
Mark Thompson f242e0a0ff vaapi_encode: Fix format specifier for bitrate logging
Same as e0df56f25d.  This was accidentally
reintroduced while merging c8241e730f.
2016-11-21 22:59:58 +00:00
Mark Thompson 30ebabca7c vaapi_h265: Fix buffering parameters
A decoder may need this to be set correctly to output frames in the
right order.

(cherry picked from commit b8cac1e830)
2016-11-21 22:13:41 +00:00
Mark Thompson ae0230cc3e vaapi_h265: Fix slice header writing
This was not observed earlier because the only syntax element which
it normally misses with the current setup is slice_qp_delta, but that
is always going to be zero (in IDR frames QP isn't varied on the
slice) which will always exp-golomb code as a single 1 bit.  The
immediately following part is the byte alignment, which is always a 1
bit followed by 0s which are ignored, so as long as the bitstream is
never aligned at that point we will never notice because the only
difference is that an ignored bit is a 1 instead of a 0.

(cherry picked from commit fc30a90898)
2016-11-21 22:13:41 +00:00
Mark Thompson 478a4b7e6d vaapi_encode: Check packed header capabilities
This improves behaviour with drivers which do not support packed
headers, such as AMD VCE on mesa/gallium.

(cherry picked from commit 892bbbcdc1)
2016-11-21 22:13:41 +00:00
Mark Thompson c8241e730f vaapi_encode: Refactor initialisation
This allows better checking of capabilities and will make it easier
to add more functionality later.

It also commonises some duplicated code around rate control setup
and adds more comments explaining the internals.

(cherry picked from commit 80a5d05108)
2016-11-21 22:13:41 +00:00
Anton Khirnov 0bfdcce4d4 hevc: move the SliceType enum to hevc.h
Those values are decoder-independent and are also use by the VA-API
encoder.
2016-10-21 10:11:20 +02:00
Mark Thompson f9bb356e0e vaapi_h265: Include header for slice types
The include was changed correctly in 4abe3b049d
but then mistakenly changed back by c359d624d3
(it's not just the NAL unit types which are used).
2016-10-17 20:53:28 +01:00
Anton Khirnov c359d624d3 hevcdec: move decoder-independent declarations into a separate header
This way they can be reused by other code without including the whole
decoder-specific hevcdec.h
Also, add the HEVC_ prefix to them, since similarly named values exist
for H.264 as well and are sometimes used in the same code.
2016-10-16 20:26:28 +02:00
Anton Khirnov 4abe3b049d hevc: rename hevc.[ch] to hevcdec.[ch]
This is more consistent with the rest of libav and frees up the hevc.h
name for decoder-independent shared declarations.
2016-10-16 20:26:17 +02:00