1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-02 03:06:28 +02:00
Commit Graph

81 Commits

Author SHA1 Message Date
Mark Thompson
177a90b1a3 lavc/vaapi_encode: Fix leak in error case
Fixes CID 1442564.
2020-02-09 20:36:44 +00:00
Linjie Fu
efefba61f8 lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers
Currently, assigning new buffer for pkt when multiple buffers were returned
from vaMapBuffer will overwrite the previous encoded pkt data and lead
to encode issues.

Iterate through the buf_list first to find out the total buffer size
needed for the pkt, allocate the whole pkt to avoid repeated reallocation
and memcpy, then copy data from each buf to pkt.

Signed-off-by: Linjie Fu <linjie.fu@intel.com>
2019-12-17 07:57:03 +08:00
Michael Niedermayer
9b57b90c4c avcodec/vaapi_encode: Simplify code with av_clip_int8()
Reviewed-by: "Li, Zhong" <zhong.li@intel.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-08-30 20:23:02 +02:00
Aman Gupta
0821bc4eee avcodec/vaapi_encode: respect -force_key_frames setting
This was a regression in 5fdcf85bbf

Signed-off-by: Aman Gupta <aman@tmm1.net>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2019-08-26 16:09:11 -07:00
Mark Thompson
3387147860 vaapi_encode: Add ROI support 2019-07-28 22:34:26 +01:00
Mark Thompson
2880a32c66 vaapi_encode: Refactor encode misc parameter buffer creation
This removes the use of the nonstandard combined structures, which
generated some warnings with clang and will cause alignment problems
with some parameter buffer types.
2019-06-03 21:16:22 +01:00
Mark Thompson
7056002796 vaapi_encode: Remove unused function 2019-06-03 21:16:22 +01:00
Mark Thompson
909bcedc58 vaapi_encode: Warn if input has cropping information
Cropping is not supported by VAAPI encode.
2019-06-02 17:30:41 +01:00
Mark Thompson
f4d7bd6cdb vaapi_encode: Support more RC modes
Allow setting the mode explicitly, and try to make a sensible choice
given the available parameters if not.
2019-02-25 23:32:23 +00:00
Mark Thompson
494bd8df78 vaapi_encode: Let the reconstructed frame pool be sized dynamically
No supported encode driver requires the pool to be fixed-size, so just
remove this constraint.
2019-01-23 23:04:11 +00:00
Mark Thompson
5fdcf85bbf vaapi_encode: Convert to send/receive API
This attaches the logic of picking the mode of for the next picture to
the output, which simplifies some choices by removing the concept of
the picture for which input is not yet available.  At the same time,
we allow more complex reference structures and track more reference
metadata (particularly the contents of the DPB) for use in the
codec-specific code.

It also adds flags to explicitly track the available features of the
different codecs.  The new structure also allows open-GOP support, so
that is now available for codecs which can do it.
2019-01-23 23:04:11 +00:00
Mark Thompson
26ce3a43a3 vaapi_encode: Allocate picture-private data in generic code 2019-01-23 23:04:11 +00:00
Mark Thompson
b674357020 vaapi_encode: Improve log message for unsupported profiles 2018-11-18 18:22:07 +00:00
Mark Thompson
fef2162b6e vaapi_encode: Add flag to mark encoders supporting only constant-quality
And set it for MJPEG.
2018-10-27 19:35:35 +01:00
Mark Thompson
2923ed247e vaapi_encode: Support configurable slices
This adds common code to query driver support and set appropriate
address/size information for each slice.  It only supports rectangular
slices for now, since that is the most common use-case.
2018-10-27 19:35:35 +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
2562dd9e78 vaapi_encode: Always reapply global parameters after the sequence header
The codec sequence headers may contain fields which can overwrite the
fine parameters given in the specific settings (e.g. a crude bitrate
value vs. the max-rate / target-percentage / etc. values in
VAEncMiscParameterRateControl).  Always reapply all global parameters
after a sequence header to avoid this causing problems.
2018-09-23 14:42:33 +01:00
Mark Thompson
ac31d84506 vaapi_encode: Clean up the encode quality configuration 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
38ec5b4aa4 vaapi_encode: Factorise out adding global parameters 2018-08-27 16:21:38 +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
Haihao Xiang
7e78801fa5 vaapi_encode: Add an assert in vaapi_encode_truncate_gop()
The flag of input_available must be set when pic_start is not NULL, so
add an assert to ensure it is true. In addition, the assert on last_pic
is unnecessary now, so remove this assert.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
2018-05-10 19:52:53 +01:00
Haihao Xiang
00ae5c1d3d lavc/vaapi_encode: Don't return error if the underlying driver doesn't support B frames
The underlying driver need not support B frames - since they are enabled
by default for some codecs, it is better to disable them rather than
returning an error in this case.  This makes the default settings usable
for low-power encoding on Intel platforms.

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2018-03-08 00:30:23 +00:00
Mark Thompson
9e3e9a3728 Merge commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7'
* commit '216c44dfc17252ec0681dcb0bbeeb45a9d14eca7':
  vaapi_encode: Destroy output buffer pool before VA context

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 21:51:28 +00:00
Mark Thompson
fe1fb48e2b Merge commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6'
* commit 'c8e135ea9225137050a6315fd9ba9c0f242c90b6':
  vaapi_encode: Allocate slice structures and parameter buffers dynamically

Already present as e4a6eb70f4, one minor
fix for libav merged.

Merged-by: Mark Thompson <sw@jkqxz.net>
2018-02-21 21:46:09 +00:00
Mark Thompson
216c44dfc1 vaapi_encode: Destroy output buffer pool before VA context
The buffers are created associated with the context, so they should be
destroyed before the context is.  This is enforced by the iHD driver.
2018-02-20 22:04:12 +00:00
Jun Zhao
c8e135ea92 vaapi_encode: Allocate slice structures and parameter buffers dynamically
This removes the arbitrary limit on the allowed number of slices and
parameter buffers.

From ffmpeg commit e4a6eb70f4.

Signed-off-by: Mark Thompson <sw@jkqxz.net>
2018-02-20 22:04:12 +00:00
Jun Zhao
a31a482611 lavc/vaapi_encode: give a debug message if attrs unsupported.
Give a debug message when query attribute get VA_ATTRIB_NOT_SUPPORTED,
it's will help to trace and debug some issue.

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-12-19 23:02:31 +00:00
Mark Thompson
bfc83acfd6 vaapi: Always free parameter buffers after vaEndPicture() with libva2
This is an ABI change in libva2: previously the Intel driver had this
behaviour and it was implemented as a driver quirk, but now it is part
of the specification so all drivers must do it.
2017-10-25 00:00:49 +01:00
Mark Thompson
e339411691 vaapi: Always free parameter buffers after vaEndPicture() with libva2
This is an ABI change in libva2: previously the Intel driver had this
behaviour and it was implemented as a driver quirk, but now it is part
of the specification so all drivers must do it.
2017-10-09 00:11:53 +01:00
James Almer
318778de9e Merge commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3'
* commit 'fd9212f2edfe9b107c3c08ba2df5fd2cba5ab9e3':
  Mark some arrays that never change as const.

Merged-by: James Almer <jamrial@gmail.com>
2017-09-26 16:02:40 -03:00
Jun Zhao
e4a6eb70f4 lavc/vaapi_encode: Change the slice/parameter buffers to dynamic alloc.
Change the slice/parameter buffers to be allocated dynamically.

Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-08-28 11:49:57 +01:00
Mark Thompson
9c878651db 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.

(cherry picked from commit 19388a7200)
2017-08-20 12:56:24 +01:00
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
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
92bd089745 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.

(cherry picked from commit 17aeee5832)
2017-06-14 22:23:43 +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
Jun Zhao
08087f5462 lavc/vaapi_encode: fix p_per_i calculate issue.
now gop_size <= (max_b_frames + 1) * p_per_i + 1 (IDR frame),
so celing p_per_i = (gop_size - 1 + max_b_frames) / (max_b_frames + 1)

Signed-off-by: Jun Zhao <jun.zhao@intel.com>
Signed-off-by: Leilei <leilei.shang@intel.com>
Signed-off-by: Mark Thompson <sw@jkqxz.net>
2017-04-02 23:28:54 +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
Mark Thompson
be6546a4ff 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.

(cherry picked from commit ff35aa8ca4)
2017-02-08 19:14:05 +00:00
Mark Thompson
ceb28c3cc4 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.

(cherry picked from commit f033ba470f)
2017-02-08 19:14:05 +00:00
Mark Thompson
3b95c7c17d vaapi_encode: Add MPEG-2 support
(cherry picked from commit ca6ae3b77a)
2017-02-08 19:14:05 +00:00
Mark Thompson
c667c0979c vaapi_encode: Support forcing IDR frames via AVFrame.pict_type
(cherry picked from commit a3c3a5eac2)
2017-02-08 19:14:04 +00:00
Mark Thompson
760f1a7727 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.

(cherry picked from commit 37fab0661a)
2017-02-08 19:14:04 +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