Commit graph

97 commits

Author SHA1 Message Date
Hyunjun Ko
f3302a0a79 libs: encoder: h264: set ROI params during encoding
Set ROI params during encoding each frame, which are set via
gst_vaapi_encoder_add_roi ()

https://bugzilla.gnome.org/show_bug.cgi?id=768248

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-12 11:12:56 +02:00
Sreerenj Balachandran
4f343f82e3 encoders: add quality level tuning
This patch adds the handling of VAEncMiscParameterTypeQualityLevel,
in gstreamer-vaapi encoders:

  The encoding quality could be set through this structure, if the
  implementation supports multiple quality levels. The quality level set
  through this structure is persistent over the entire coded sequence, or
  until a new structure is being sent. The quality level range can be queried
  through the VAConfigAttribEncQualityRange attribute. A lower value means
  higher quality, and a value of 1 represents the highest quality. The quality
  level setting is used as a trade-off between quality and speed/power
  consumption, with higher quality corresponds to lower speed and higher power
  consumption.

The quality level is set by the element's parameter "quality-level" with a
hard-coded range of 1 to 8.

Later, when the encoder is configured in run time, just before start
processing, the quality level is scaled to the codec range. If
VAConfigAttribEncQualityRange is not available in the used VA backend, then
the quality level is set to zero, which means "disabled".

All the available codecs now process this parameter if it is available.

https://bugzilla.gnome.org/show_bug.cgi?id=778733

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-05-11 11:51:56 +02:00
Sreerenj Balachandran
be990f5ed4 encoder: h264: Fix Backward ReferencePicture flag setting
This is a regression introduced by e829b62 which
override the reference flags and caused issues with
latest intel-vaapi-driver.
2017-03-31 14:14:08 -07:00
Sreerenj Balachandran
dbbe340906 encoder: h264: Fix B frame encoding artifacts
The current implementation is updating the POC values only
in Slice parameter Buffer.But we are not filling the
picture order count and reference flags in VAPictureH264
while populating VA Picture/Slice structures.The latest
intel-vaapi-driver is directly accessing the above fields
from VAPicutreH264 provided as RefPicLists, which resulted
some wrong maths and prediction errors in driver.

https://bugzilla.gnome.org/show_bug.cgi?id=780620
2017-03-28 10:53:20 -07:00
Hyunjun Ko
9ed6ac1f76 libs: h26x: adds gst_vaapi_utils_h26x_write_nal_unit()
Implements gst_vaapi_utils_h26x_write_nal_unit(), which writes NAL
unit length and data to a bitwriter.

Note that this helper function applies EPB (Emulation Prevention
Bytes), since otherwise produced codec_data might be broken when
decoder/parser considering EPB, starts parsing.

See sections 7.3 and 7.4 of the H264 and H264 specifications, which
describes the emulation_prevention_three_byte.

https://bugzilla.gnome.org/show_bug.cgi?id=778750

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2017-03-20 19:02:04 +01:00
Hyunjun Ko
49b370ed60 libs: utils: h26x: create vaapiutils_h26x
Since there is duplicated code in h264/265 encoder, we could
refactor it to avoid duplicated code.

https://bugzilla.gnome.org/show_bug.cgi?id=778750

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2017-03-20 18:11:00 +01:00
Hyunjun Ko
257cfb61fe libs: encoder: h264/5: fix wrong return value
https://bugzilla.gnome.org/show_bug.cgi?id=778750
2017-03-17 12:54:27 +01:00
Víctor Manuel Jáquez Leal
b1f6da98de libs: fix code style for errors 2016-11-03 12:51:44 +01:00
Víctor Manuel Jáquez Leal
ef3ee8b7bb encoder: h264,h265: fix regression in offset count
In commit dc35dafa a bug was introduced because I assumed that
GST_CLOCK_TIME_NONE is zero when is -1. This patch fixes that mistake.

https://bugzilla.gnome.org/show_bug.cgi?id=772259
2016-10-19 16:14:34 +02:00
Víctor Manuel Jáquez Leal
ad3b45ebc4 encoder: h264: fix C90 mixed declarations and code
Commit 4259d1a introduced this compilation error. This patch fixes it.
2016-08-10 13:29:45 +02:00
Víctor Manuel Jáquez Leal
68b9ab7818 encoder: h264,h265,mpeg2,vp8: use gst_util_uint64_scale() for bitrate
Use gst_util_uint64_scale() to calculate bitrate instead of normal arithmetic
to avoid overflows, underflows and loss of precision.

https://bugzilla.gnome.org/show_bug.cgi?id=768458
2016-08-10 12:20:48 +02:00
Víctor Manuel Jáquez Leal
4259d1aec7 vaapiencode: h264,h265: validate fps numerator
Validate that fps numerator is non-zero so it can be used to calculate
the duration of the B frame.

Also it gst_util_uint64_scale() is used instead of normal arithmetic in
order to aviod overflows, underflows and loss of precision.

https://bugzilla.gnome.org/show_bug.cgi?id=768458
2016-08-10 12:20:48 +02:00
Sreerenj Balachandran
6c6007ad94 encoder: h264: Fix MVC encode while enabling dct8x8
Pack the transform_8x8_mode_flag and other necessary rbsp data
in packed_pps header for MVC encode.

https://bugzilla.gnome.org/show_bug.cgi?id=768647
2016-07-15 14:41:27 +03:00
Scott D Phillips
4aec5bdd72 encoder: h264: Use high profile by default
Change defaults for max-bframes, cabac, and dct8x8 to be enabled
by default. This will cause the default profile to be high instead
of baseline. In most situations this is the right decision, and
the profile can still be lowered in the case of caps restrictions.

Signed-off-by: Scott D Phillips <scott.d.phillips@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2016-06-23 12:28:50 +02:00
Sreerenj Balachandran
c91de2398a encoder : h264: Disable b-frame encode in low-power mode
This is a workaround since vaapi-intel-driver doesn't have
support for B-frame encode when utilizing low-power-enc
hardware block.

Fixme :We should query the VAConfigAttribEncMaxRefFrames
instead of blindly disabling b-frame support and set b/p frame count,
buffer pool size etc based on the query result.

https://bugzilla.gnome.org/show_bug.cgi?id=766050
2016-05-13 11:45:20 +03:00
Sreerenj Balachandran
43af7c362c encoder: h264 : Use "tune=low-power" for enabling lowpower encode
Remove the duplicate property "low-power-enc" and use the
tune property for enabling low power encoding mode.

https://bugzilla.gnome.org/show_bug.cgi?id=766050
2016-05-13 11:44:57 +03:00
Sreerenj Balachandran
32ee78bc52 encoder: h264: Add support of low power/high performance encoding mode
Added a new property "low-power-enc" for enabling low power
encoding mode. Certain encoding tools may not be available
with the VAEntrypointEncSliceLP.

https://bugzilla.gnome.org/show_bug.cgi?id=766050
2016-05-11 12:05:36 +03:00
Víctor Manuel Jáquez Leal
d76d78cc8e libs: fix compiler warnings
After setting the release flags, the compiler warns about a couple
initialized variables.

Also marked a couple of set variables as unused, because they are only
used for assertion.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-02-03 20:22:46 +01:00
Víctor Manuel Jáquez Leal
28d01c0857 libs: small code style fixes
This a set of small code style fixes detected as-is by gst-indent.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-02-03 12:45:30 +01:00
Tim-Philipp Müller
ab28dea7c1 Fix some more compiler warning
Two (false) compiler warnings about variables potentially
being used uninitialized, and one about a variable being
set but not used.

https://bugzilla.gnome.org/show_bug.cgi?id=759192
2016-02-02 17:19:42 +01:00
Tim-Philipp Müller
24168a2093 vaapi: fix 'ISO C90 forbids mixed declarations and code' compiler warnings
Declare variables at the beginning of a code block, which
is how it's done in GStreamer.

https://bugzilla.gnome.org/show_bug.cgi?id=759192
2016-02-02 16:17:43 +01:00
Víctor Manuel Jáquez Leal
1c722efe54 Remove old gst version guards
As gstreamer-vaapi now only supports from GStreamer 1.6, this patch removes
all the old GStreamer version guards.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>
2016-01-25 12:09:40 +00:00
Jan Schmidt
b0194a1dc5 multiview: initial attempt at stereo/multiview support
Add support for marking caps and buffers for multiview or
stereoscopic output.

https://bugzilla.gnome.org/show_bug.cgi?id=750835
2015-08-31 17:51:56 +02:00
Sreerenj Balachandran
02d8092da9 encoder:h264: Fix the check for packed-header support
Use VA_ENC_PACKED_HEADER_* definition for checking.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2015-07-02 21:37:56 +03:00
Sreerenj Balachandran
a260426194 encoder: h264: submit SEI buffering_period() and picture_timing() messages for CBR mode
One buffering_period() SEI message shall be present in every IDR access unit
when NalHrdBpPresentFlag is inferred to be equal to 1. This is the case when we
use a non-CQP mode, e.g. CBR. In other words, when
nal_hrd_parameters_present_flag is set to 1.

One picture_timing() SEI messages shall be present in every access unit
if CpbDpbDelaysPresentFlag is equal to 1 or pic_struct_present_flag is equal to 1

https://bugzilla.gnome.org/show_bug.cgi?id=722734
https://bugzilla.gnome.org/show_bug.cgi?id=751831

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2015-07-02 21:01:38 +03:00
Víctor Manuel Jáquez Leal
7c71f057b4 encoder: h264: casts slice_param->slice_type
slice_type in slice_param is defined as (char *), but it is compared against a
signed integer. clang complains about this comparison.

This patch casts the variable.

https://bugzilla.gnome.org/show_bug.cgi?id=747312
2015-04-08 16:20:55 +02:00
Sreerenj Balachandran
3f28da7f5a encoder: h264: add support for more than 2 views
Add support for H.264 MVC Multiview High profile encoding with
more than 2 views. All views within the same accesss unit are
provided in increasing order of view order index (VOIdx).

Upto 10 view are supported for now.

A new property "view-ids" has been provided for the plugins to
set the view ids (which is an array of guint values) to be used
for mvc encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=732453
2015-02-24 17:14:33 +02:00
Sreerenj Balachandran
8bf8f1104d encoder: h264: Fix the period between I/P frames
If the key-frame period is set as one, then ip_period shuld be zero

https://bugzilla.gnome.org/show_bug.cgi?id=734992
2014-11-27 12:11:03 +02:00
Sreerenj Balachandran
7e4e6fc019 encoder: h264: Provide intra_idr_period value for VAEncSequenceParameterBufferH264
https://bugzilla.gnome.org/show_bug.cgi?id=734993
2014-11-27 11:21:03 +02:00
Gwenole Beauchesne
88b481e530 encoder: h264: fix pixel-aspect-ratio in encoded stream.
Really report sample aspect ratio (SAR) as present, and make it match
what we have obtained from the user as pixel-aspect-ratio (PAR). i.e.
really make sure VUI parameter aspect_ratio_info_present_flag is set
to TRUE and that the indication from aspect_ratio_idc is Extended_SAR.

This is a leftover from git commit a12662f.

https://bugzilla.gnome.org/show_bug.cgi?id=740360
2014-11-27 11:13:20 +02:00
Gwenole Beauchesne
669e33418e encoder: h264: fix profile limits.
Fix ensure_profile_limits() to lower profile to the desired limits,
only if the latter are actually known and the profile needed to be
changed to fit.
2014-11-25 11:41:49 +01:00
Sreerenj Balachandran
95d7f95971 encoder: h264: generate new SPS only when codec config changed.
It is not necessary to periodically send SPS or subset SPS headers.
This is up to the upper layer (e.g. transport layer) to decide on
if/how to periodically submit those. For now, only generate new SPS
or subset SPS headers when the codec config changed.

Note: the upper layer could readily determine the config headers
(SPS/PPS) through the gst_vaapi_encoder_h264_get_codec_data() function.

https://bugzilla.gnome.org/show_bug.cgi?id=732083

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-27 20:26:21 +02:00
Gwenole Beauchesne
0d971bce26 encoder: h264: track encoder config changes.
Track and report when encoder configuration changed. For now, this covers
resolution, profile/level and bitrate changes.
2014-06-27 20:26:18 +02:00
Gwenole Beauchesne
a12662fd3e encoder: h264: add pixel-aspect-ratio to VUI parameters.
Report sample aspect ratio (SAR) as present, and make it match what
we have obtained from the user as pixel-aspect-ratio (PAR). i.e. the
VUI parameter aspect_ratio_info_present_flag now defaults to TRUE.
2014-06-27 13:15:13 +02:00
Sreerenj Balachandran
a4bd8450f7 encoder: h264: fix number of anchor and non-anchor reference pictures.
Set the value of num_anchor_refs_l0, num_anchor_refs_l1, num_non_anchor_refs_l0,
and num_non_anchor_refs_l1 to zero since the inter-view prediction is not yet
supported.
2014-06-27 11:51:32 +02:00
Sreerenj Balachandran
8ebf60124a encoder: h264: fix timing_info_present_flag value in subset SPS.
When the seq_parameter_set_data() syntax structure is present in a subset
sequence parameter set and vui_parameters_present_flag is equal to 1, then
timing_info_present_flag shall be equal to 0 (H.7.4.2.1.1).
2014-06-27 11:48:40 +02:00
Sreerenj Balachandran
619a79943a encoder: h264: add cpbBrNalFactor values for MVC profiles. 2014-06-27 11:48:36 +02:00
Sreerenj Balachandran
173f32d8e5 encoder: h264: fix NAL unit types in packed headers.
Submit Prefix NAL headers (nal_unit_type = 14) before every packed
slice header (nal_unit_type = 1 or 5) only for the base view. In non
base views, a Coded Slice Extension NAL header (nal_unit_type = 20)
is required, with an appropriate nal_unit_header_mvc_extension() in
the NAL header bytes.

https://bugzilla.gnome.org/show_bug.cgi?id=732083
2014-06-26 11:08:32 +02:00
Sreerenj Balachandran
a7c27bb7d5 encoder: h264: add missing field in packed Subset SPS header.
Write the missing num_level_values_signalled_minus1 syntax element
into the packed header for subset sequence parameter set.

https://bugzilla.gnome.org/show_bug.cgi?id=732083
2014-06-26 11:00:47 +02:00
Sreerenj Balachandran
781abad2c7 encoder: h264: fix multiple slices support in packed headers mode.
Handle packedi slice headers and packed raw data on a per-slice basis,
which is necessary for multi slice encoding.
2014-06-17 16:05:11 +02:00
Gwenole Beauchesne
885ebf4c72 encoder: h264: drop extraneous definitions.
Re-use definitions from the codecparser headers instead of duplicating
them here again. That covers NALU definitions and slice types.
2014-06-03 14:30:39 +02:00
Sreerenj Balachandran
e1976df1a1 encoder: h264: remove unnecessary calcualtion of max_pic_order_cnt.
https://bugzilla.gnome.org/show_bug.cgi?id=727418
2014-06-03 13:53:46 +02:00
Sreerenj Balachandran
6df5c74081 encoder: h264: don't allow CABAC with Extended profile.
The H.264 specification does not support CABAC entropy coding for the
Extended profile.

https://bugzilla.gnome.org/show_bug.cgi?id=727418
2014-06-03 13:53:43 +02:00
Sreerenj Balachandran
dba440b164 encoder: h264: use packed headers mode for MVC encoding.
Exclusively use VA drivers that support raw packed headers for encoding.
i.e. simply submit packed headers Subset SPS and Prefix NAL units. This
provides for better compatibility accross the various VA drivers and HW
generations since no particular API is needed beyond what readily exists.
2014-06-02 18:25:13 +02:00
Sreerenj Balachandran
0de9fd6347 encoder: h264: add support for packed slice headers.
https://bugzilla.gnome.org/show_bug.cgi?id=722905
2014-06-02 18:25:13 +02:00
Sreerenj Balachandran
73355a680f encoder: h264: store subset sps to generate the codec-data
Store the SubsetSPS nal unit which we need for MVC specific
codec_data generation.
2014-06-02 18:25:13 +02:00
Sreerenj Balachandran
f0924ba0d1 encoder: h264: fix MVC pipeline hang while encoding with B-frames.
Since we are encoding each view independently from each other, we
need a higher number of pre-allocated surfaces to be used as the
reconstructed frames. For Stereo High profile encoding, this means
to effectively double the number of frames to be stored in the DPB.
2014-06-02 18:25:13 +02:00
Li Xiaowei
7bdf3fa177 encoder: h264: add initial support for H.264 Stereo High profile.
Add initial support for Subset SPS, Prefix NAL and Slice Extension NAL
for non-base-view streams encoding, and the usual SPS, PPS and Slice
NALs for base-view encoding.

The H.264 Stereo High profile encoding mode will be turned on when the
"num-views" parameter is set to 2. The source (raw) YUV frames will be
considered as Left/Right view, alternatively.

Each of the two views has its own frames reordering pool and reference
frames list management system. Inter-view references are not supported
yet, so the views are encoded independently from each other.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
[limited to Stereo High profile per the definition of MAX_NUM_VIEWS]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-02 18:25:13 +02:00
Li Xiaowei
5323570a35 encoder: h264: wrap pools for refs and frames reordering.
Create structures to maintain the reference frames list (RefPool) and
frames reordering (ReorderPool) logic.

This is a prerequisite for H.264 MVC support.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
2014-06-02 18:25:13 +02:00
Li Xiaowei
4beee390e5 encoder: h264: add provisional support for subset SPS headers.
Add provisions to write subset SPS headers to the bitstream in view
to supporting the H.264 MVC specification.

This assumes the libva "staging" branch is in use.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
2014-06-02 18:25:13 +02:00