Commit Graph

23 Commits

Author SHA1 Message Date
Mark Thompson
19388a7200 vaapi_encode: Move quality option to common code
Use AVCodecContext.compression_level rather than a private option,
replacing the H.264-specific quality option (which stays only for
compatibility).

This now works with the H.265 encoder in the i965 driver, as well as
the existing cases with the H.264 encoder.
2017-08-06 14:42:04 +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
Mark Thompson
17aeee5832 vaapi_encode: Discard output buffer if picture submission fails
Previously this was leaking, though it actually hit an assert making
sure that the buffer had already been cleared when freeing the picture.
2017-02-16 20:58:42 +00:00
Anton Khirnov
fd9212f2ed Mark some arrays that never change as const. 2017-02-01 10:42:59 +01:00
Mark Thompson
ff35aa8ca4 vaapi_encode: Pass framerate parameters to driver
Only do this when building for a recent VAAPI version - initial
driver implementations were confused about the interpretation of the
framerate field, but hopefully this will be consistent everywhere
once 0.40.0 is released.
2017-01-30 22:52:54 +00:00
Mark Thompson
f033ba470f vaapi_encode: Support VBR mode
This includes a backward-compatibility hack to choose CBR anyway on
old drivers which have no CBR support, so that existing programs will
continue to work their options now map to VBR.
2017-01-30 22:52:54 +00:00
Mark Thompson
ca6ae3b77a vaapi_encode: Add MPEG-2 support 2017-01-29 13:28:31 +00:00
Mark Thompson
a3c3a5eac2 vaapi_encode: Support forcing IDR frames via AVFrame.pict_type 2017-01-11 23:03:58 +00:00
Mark Thompson
37fab0661a vaapi_encode: Fix GOP sizing
This change makes the configured GOP size be respected exactly -
previously the value could be exceeded slightly due to flaws in the
frame type selection logic.
2017-01-11 23:03:58 +00:00
Mark Thompson
0cf86fabfa vaapi_encode: Write sequence header as extradata
Only works if packed headers are supported, where we can know the
output before generating the first frame.
2016-10-17 21:07:25 +01:00
Mark Thompson
314b421dd8 vaapi_encode: Decide on GOP setup before initialising sequence parameters
This was always too late; several fields related to it have been incorrectly
zero since the encoder was added.
2016-10-02 20:23:18 +01:00
Mark Thompson
086e4b58b5 vaapi_encode: Sync to input surface rather than output
While outwardly bizarre, this change makes the behaviour consistent
with other VAAPI encoders which sync to the encode /input/ picture in
order to wait for /output/ from the encoder.  It is not harmful on
i965 (because synchronisation already happens in vaRenderPicture(),
so it has no effect there), and it allows the encoder to work on
mesa/gallium which assumes this behaviour.
2016-09-28 22:54:11 +01:00
Mark Thompson
892bbbcdc1 vaapi_encode: Check packed header capabilities
This improves behaviour with drivers which do not support packed
headers, such as AMD VCE on mesa/gallium.
2016-09-28 22:54:11 +01:00
Mark Thompson
80a5d05108 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.
2016-09-28 22:54:10 +01:00
Mark Thompson
221ffca631 vaapi_encode: Respect driver quirks around buffer destruction
No longer leaks memory when used with a driver with the "render does
not destroy param buffers" quirk (i.e. Intel i965).
2016-07-02 14:09:58 +01:00
Mark Thompson
8a62d2c28f vaapi_encode: Maintain a pool of bitstream output buffers
Previously we would allocate a new one for every frame.  This instead
maintains an AVBufferPool of them to use as-needed.

Also makes the maximum size of an output buffer adapt to the frame
size - the fixed upper bound was a bit too easy to hit when encoding
large pictures at high quality.
2016-06-26 19:40:56 +01:00
Mark Thompson
11b8030309 vaapi_encode: Fix fallback when input does not match any format
Just a typo.  Add a comment to make it clearer what it's doing.
2016-06-21 20:42:22 +01:00
Mark Thompson
19d7667a81 vaapi_encode: Add support for writing arbitrary additional packed headers 2016-06-09 21:15:39 +01:00
Mark Thompson
2bfa067d0b vaapi_encode: Check config attributes before creating config
This prevents attempts to use unsupported modes, such as low-power
H.264 mode on non-Skylake targets.  Also fixes a crash on invalid
configuration, when trying to destroy an invalid VA config/context.
2016-05-27 10:56:45 +01:00
Vittorio Giovara
41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +02:00
Mark Thompson
69b06ed428 vaapi_encode: Add support for codec-local options
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-15 10:07:05 +02:00
Mark Thompson
f6b8552369 vaapi_encode: Refactor slightly to allow easier setting of global options
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-04-15 10:07:04 +02:00
Mark Thompson
104c804bca lavc: VAAPI encode common infrastructure
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2016-03-30 09:05:28 +02:00