Commit graph

88 commits

Author SHA1 Message Date
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
Gwenole Beauchesne
4481c155b8 encoder: notify the encoder of the submitted packed headers.
Make sure to configure the encoder with the set of packed headers we
intend to generate and submit. i.e. make selection of packed headers
to submit more robust.
2014-01-23 15:48:58 +01:00
Gwenole Beauchesne
1dc9837dd9 encoder: fix and factor out check for supported rate-control modes.
Cache the first compatible GstVaapiProfile found if the encoder is not
configured yet. Next, factor out the code to check for the supported
rate-control modes by moving out vaGetConfigAttributes() to a separate
function, while also making sure that the attribute type is actually
supported by the encoder.

Also fix the default set of supported rate control modes to not the
"none" variant. It's totally useless to expose it at this point.
2014-01-23 15:48:58 +01:00
Gwenole Beauchesne
6bf3c1863c legal: update copyright notice dates. 2014-01-22 19:02:35 +01:00
Gwenole Beauchesne
1c95903b98 legal: add per-file authorship information. 2014-01-22 18:49:20 +01:00
Gwenole Beauchesne
deff9c775c encoder: h264: disable NAL HRD parameters for now.
Don't emit NAL HRD parameters for now in the SPS headers because the
SEI buffering_period() and picture_timing() messages are not handled
yet. Some additional changes are necessary to get it right.

https://bugzilla.gnome.org/show_bug.cgi?id=722734
2014-01-22 18:30:26 +01:00
Gwenole Beauchesne
9d5fc53899 encoder: h264: fix default CPB buffer size.
Fix default CPB buffer size to something more reasonable (1500 ms)
and that still fits the level limits. This is a non configurable
property for now. The initial CPB removal delay is also fixed to
750 ms.

https://bugzilla.gnome.org/show_bug.cgi?id=722087
2014-01-22 18:30:26 +01:00
Gwenole Beauchesne
9d42c86422 encoder: h264: fix bitrate encoding for HRD conformance.
Round down the calculated, or supplied, bitrate (kbps) into a multiple
of the HRD bitrate scale factor. Use a bitrate scale factor of 64 so
that to have less losses in precision. Likewise, don't round up because
that could be a strict constraint imposed by the user.
2014-01-22 18:30:26 +01:00
Gwenole Beauchesne
4c04a1bc88 encoder: h264: fix level lookup constraints wrt. bitrate.
Fix the level calculation involving bitrate limits. Since we are
targetting NAL HRD conformance, the check against MaxBR from the
Table A-1 limits shall involve cpbBrNalFactor depending on the
active profile.
2014-01-22 18:30:26 +01:00
Gwenole Beauchesne
1e502d63d5 encoder: h264: submit sequence parameter only once.
Submit sequence parameter buffers only once, or when the bitstream
was reconfigured in a way that requires such. Always submit packed
sequence parameter buffers at I-frame period, if the VA driver needs
those.

https://bugzilla.gnome.org/show_bug.cgi?id=722737
2014-01-22 18:30:26 +01:00