Commit graph

1585 commits

Author SHA1 Message Date
Hyunjun Ko
5796750604 libs: encoder: h264/h265: keep min_qp as is unless it's over init_qp
Creates new variable for QP for I frame and keep it at configuration and
use this for pic_init_qp and slice_qp_delta setting.

Since changing min qp doesn't make sense, keep min qp as is.

https://bugzilla.gnome.org/show_bug.cgi?id=785923
2017-09-13 10:47:22 +02:00
Hyunjun Ko
e7c099b957 libs: encoder: h265: Add mbbrc property
This property supports Macroblock level Bitrate Control as the
following (same as h264 encoder):
0: auto
1: on
2: off

https://bugzilla.gnome.org/show_bug.cgi?id=785917
2017-09-13 10:45:49 +02:00
Hyunjun Ko
6816d7c151 libs: encoder: h264: Add mbbrc property
This property supports Macroblock level Bitrate Control as the
following:
0: auto
1: on
2: off

https://bugzilla.gnome.org/show_bug.cgi?id=785917
2017-09-13 10:45:49 +02:00
Hyunjun Ko
aa6aa996d6 libs: encoder: h265: add multi reference support
This is doing the same as h264 encoder as the following:

Using num_ref_frames provided and the result of the Query
VAConfigAttribEncMaxRefFrames, it determines the size of reference list
and perform encoding with multi reference frames as the following:

1\ The num_ref_frames is being considered as the number of
reference picture list0
2\ Encoder adds 1 reference frame more to the reference picture list1
internally if b-frame encoding.
3\ If num_ref_frames is bigger than the number of refrence frames
supported in the driver, it will be lowered.

Also this patch includes:
- Set num_negative_pics and num_positive_pics according to the number of
refs.
- Set delta_poc according to the number of refs.
- Increase max_dec_pic_buffering according to the number of refs
- Change max_num_reorder_pics according to num of bframes

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
3dbf440373 libs: encoder: h265: add refs property
Users can provide the number of reference frame by this property,
which is exaclty same as h264.

The value of the property will be considered as the number of
reference picture list0 and will add 1 reference frame more to the
reference picture list1 internally if b-frame encoding.

If the value provided is bigger than the number of refrence frames
supported in the driver, it will be lowered.

The maximum value is aligned to the value of the driver supported now.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
f14563759a libs: encoder: h264/5: determine num_ref_idx_active_override_flag according to reference list
Follows the specification as below:

7.4.7.1 in Rec. ITU-T H.265 v4 (12/2016)
num_ref_idx_active_override_flag equal to 1 specifies that the syntax
element num_ref_idx_l0_active_minus1 is present for P and B slices and
that the syntax element num_ref_idx_l1_active_minus1 is present for B
slices.
num_ref_idx_active_override_flag equal to 0 specifies that the syntax
elements num_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1
are not present.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
Hyunjun Ko
f7886008e3 libs: encoder: h265: keep idr_period equal to keyframe period
Remove FIXME code, which makes previous assignation spurious.
This also means to make idr_period equal to keyframe period,
which is same as h264 encoder.

https://bugzilla.gnome.org/show_bug.cgi?id=783804
2017-09-13 10:36:34 +02:00
U. Artie Eoff
6e3bfbc014 libs: encoder: h264_fei: VA-API 1.0 compat
Use VA_ENC_PACKED_HEADER_H264_SEI compat macro for VA-API 1.0
compatibility.

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

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2017-09-05 10:58:57 -07:00
Sreerenj Balachandran
7e0d5b934b FEI: libs: Add FEI encoder
Adding FEI encoder to core lib.

The code is splitted into three session:

1: gstvaapiencoder_h264_fei.{h,c}
This is the replica of gstvaapiencoder_h264.{c,h} but with FEI.
All the modes ENC, PAK and ENC_PAK are running based
the code in these files.

2: gstvaapifeienc_h264.{h,c}
Abstract implementation intended for ENC (only VME) operation.

3: gstvaapifeipak_h264.{h,c}
Abstrct implementation intended for PAK (only the PAK module)

Right now ENC_PAK, ENC and PAK are running based on code
in gstvaapiencoder_h264_fei.{h,c}. The abstract implementations
in gstvaapifeienc_h264.{h,c} and gstvaapifeipak_h264.{h,c} are
needed if user request for ENC+PAK mode operation.

ENC+PAK: Here we need to invoke two sequence of
vaBeginPicture/vaRenderPicutre/vaEndPicture for each frame,
first for the ENC only and the second for PAK only.
Each mode associated with separate context ,but same pool of surfaces are
shared between the modes.
This is more useful once we have custom BRC algorithms.

Other Contributors:
                   Wang, Yi <yi.a.wang@intel.com>
                   Leilei <leilei.shang@intel.com>
                   Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
                   xiaominc <xiaomin.chen@intel.com>
                   Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:36:13 +02:00
Sreerenj Balachandran
de2e4cd9bc FEI: libs: Add fei codec objects to GstVaapiEncPicture
All the codec objects(vaapi buffers) supposed to be
submited in vaRenderPicutre are associated with a GstVaapiEncPicture
for each frame, follow the same design for FEI too.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
132eacde79 FEI: libs: Add fei codec objects in codedbufferproxy
MbCode, MV and Distortion buffers (fei codec objects)
can be treated as output of different fei modes based user request.
For eg: MbCode and MV are the output of ENC only. MbCode, MV and Dist
can be dumped as output in ENC_PAK mode for analysis purpose.
So treating them as a part of CodedBufferProxy too.
Here we avoided Qp, MbControl and MvPredictor codec objects since
there is no practical use case of treating them as "output buffers".

Other contributors:
               Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
               xiaominc <xiaomin.chen@intel.com>
               Leilei <leilei.shang@intel.com>
               Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
d5542fa8c0 FEI: libs: Add fei codec objects to surface proxy
Add fei codec objects to surface proxy since handling the
fei buffers(codec objects here) external to gstvaapisurfaceproxy
will make the code complicated. Especially considering the behavior
of encoder where the input frame order from upstream and output
frame order to the downstream are not sequential.

Other contributors:
              Zhong, Xiaoxia <xiaoxia.zhong@intel.com>
              xiaominc <xiaomin.chen@intel.com>
              Leilei <leilei.shang@intel.com>
              Li, Jing B <jing.b.li@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
d0d9f5e274 FEI: Add codec objects for fei usecase
There are 6 new va buffer types, each defined as a specific codec object.
Borrowed the code from gstvaapicodecobject , but made a clear separation
to avoid any possible mess-up. Because unlike the other gstvaaicodecobjects,
feicodecobjects can be shared between elements and also can be accessed
from different thread.

Unlike the other fei codecs object, VAEncMiscParameterTypeFEIFrameControl
object is not shared between elements.So we utilize the already
existing gst_vaapi_enc_misc_param_new(), but still keeping the code
in gstvaapfei_objects_priv.h in order to have a better
code readability.

Fixme:
-- Probably we need _locked_map() and _unlocked_map()
-- Context can be associated with PreEnc(not just Enoder)
once we have the proper support inplace, but for now we don't have
PreEnc support, so should be safe enough to use GstVaapiEncoder.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
0b91ebeb2c FEI: libs: add H264 fei specific utility functions
Added enum/flag type definitions for a number of FEI
input and output parameters.

Original author of the patch: Wang, Yi <yi.a.wang@intel.com>

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

Signed-off-by: Wang, Yi <yi.a.wang@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
94483de40f FEI: libs: Add virtual method for secondary context creation.
Add a new vitrual method ensure_secondary_context to the
base encoder which is only required for the FEI entrypoint, that too
only when user configures the ENC+PAK mode. ENC+PAK mode is not something
supported directly by libva or driver, but this can be enabled
from the middleware.

Original Author of this idea: Leilei Shang <leilei.shang@intel.com>

Signed-off-by: Leilei Shang <leilei.shang@intel.com>
Signed-off-by: xiaominc <xiaomin.chen@intel.com>
Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
ac1de3d39a FEI: libs: make sure the default context creation works as expected.
Current code always guess the entrypoint during init phase in case
if there is no entrypoint already configured in GstVaapiContextInfo.
Make sure FEI Entrypoint is not messing up with this logic.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:24 +02:00
Sreerenj Balachandran
7d77cdd9f7 FEI: libs: Add FEI functional mode configuration
FEI Entrypoint can work in either one of the 3 different modes:
VA_FEI_FUNCTION_ENC, VA_FEI_FUNCTION_PAK or VA_FEI_FUNCTION_ENC_PAK.

Add infrastructure in gstvaapicontext and gstvaapiencoder for this
functioal mode configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:32:07 +02:00
Sreerenj Balachandran
6bbe79925c FEI: libs: Add FEI Entrypoint mapping
Define the new mapping GST_VAAPI_ENTRYPOINT_SLICE_ENCODE_FEI
for VAEntrypointFEI.

https://bugzilla.gnome.org/show_bug.cgi?id=785712
https://bugzilla.gnome.org/show_bug.cgi?id=784667
2017-09-01 11:27:28 +02:00
Orestis Floros
0955752898 libs: decoder: h264: decode SVC base layer only
Drops non-base NALs when the base-only property is set to TRUE.
This modifies the behavior for MVC streams with base-only too: All the
non-base units are dropped before they are decoded instead of dropping
the non-base frames.

The relevant part from the H264 spec is:
> Decoders that conform to one or more of the profiles specified in
Annex A rather than the profiles specified in Annexes G or H shall
ignore (remove from the bitstream and discard) the contents of all NAL
units with nal_unit_type equal to 14, 15, or 20.

To eliminate side effects from the offending units:
- PPS's with a broken seq_parameter_set_id (referring to dropped subset
SPS's) are ignored.
- The NAL parsing is skipped and their flags are set to
GST_VAAPI_DECODER_UNIT_FLAG_SKIP.
- Prefix units are not stored in prev_pi. Otherwise, parse_slice() would
use them even if they are flagged to be skipped. Subset SPS's and slice
extension units are not stored there either.

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

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-08-28 17:32:57 -07:00
Orestis Floros
a016aa181b libs: decoder: h264: check nalu validity in parser info finalize
https://bugzilla.gnome.org/show_bug.cgi?id=732266

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
2017-08-28 17:31:22 -07:00
Víctor Manuel Jáquez Leal
3bfb29e4c2 libs: encoder: remove unused cast macro
Remove internal macro to cast structure that are already declared
in the header.
2017-08-28 19:20:42 +02:00
Víctor Manuel Jáquez Leal
9c2246740b Revert "libs: encoders: remove unused cast macros"
This reverts commit fd7d38f7d2.
2017-08-28 19:09:07 +02:00
Víctor Manuel Jáquez Leal
fd7d38f7d2 libs: encoders: remove unused cast macros
They are only used inside the code, where another macro is defined.
Thus these exported macros have no use.
2017-08-28 18:32:36 +02:00
Víctor Manuel Jáquez Leal
d9c88f4785 libs: decoder: h264: improve code-style
https://bugzilla.gnome.org/show_bug.cgi?id=786173
2017-08-25 16:51:38 +02:00
Víctor Manuel Jáquez Leal
b942f9e17f libs: encoder: h264: handle deprecated enum
In VA-API 1.0 the enum VAEncPackedHeaderH264_SEI is deprecated, and
instead VAEncPackedHeaderRawData should be used.

This patch creates a compatibility symbol,
VA_ENC_PACKED_HEADER_H264_SEI, to expose the used enum according the
VA-API version.

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 16:44:27 +02:00
Víctor Manuel Jáquez Leal
585628d2a2 libs: guard deprecated symbols
In VA-API 1.0 the H.264 baseline profile is deprecated. This patch
guards the H.264 baseline usage. Consider this commit as a
continuation of commit e0e0a474

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 16:07:34 +02:00
Víctor Manuel Jáquez Leal
e8148cea0d libs: macro to get a renamed value in VA-API 1.0
In VA-API 1.0 the union bits in VAEncMiscParameterBufferROI has
renamed one member from roi_value_is_qp_delat to
roi_value_is_qp_delta, which is the correct name.

In order to keep back compatibility a macro has added to access this
union member.

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-08-25 15:57:39 +02:00
Víctor Manuel Jáquez Leal
ffffb99473 libs: encoder: h264: fix enum namespace 2017-08-18 18:16:18 +02:00
Víctor Manuel Jáquez Leal
75fd0d4ff0 libs: encoder: h264: remove spurious assignation
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

ip_period is assigned first to be rewritter inmediatly after. The
first assignation is spurious.
2017-08-17 11:03:35 +02:00
Víctor Manuel Jáquez Leal
a07ff9641c libs: remove unused header
Since libgstvaapi is not distributed, there is no need to check for
private header inclusion. Thus removing it.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
3b8b2ff36c libs: utils: move gstvaapisurface.h to private headers
Since the utils don't expose API defined in gstvaapisource.h, it is
moved to their private headers where they are used.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
3f9ad1ffd8 libs: utils: remove va.h include in header
And include gstvaapicompat.h in the C files, since the VA-API is not
exposed in the headers.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
aaca75fefb libs: encoder: remove va.h include
Since it is already managed by gstvaapicompat.h

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
9891f1a9e2 build: consolidate the VA sub API includes
Include all VA sub APIs headers in a single point (gstvaapicompat.h),
since they are all already included in va.h after VA-API 0.38.

https://bugzilla.gnome.org/show_bug.cgi?id=786119
2017-08-13 18:08:19 +02:00
Víctor Manuel Jáquez Leal
241b95dad2 libs: decoder: h265: remove spurious code
Coverity scan:

Logically dead code: The indicated dead code may have performed some
action; that action will never occur.

By using pointer arithmetic is impossible to get NULL.
2017-08-09 19:06:59 +02:00
Víctor Manuel Jáquez Leal
e42ec3ad3c libs: context: use attribs index instead pointers
Coverity scan bug:

Out-of-bounds write. This could cause an immediate crash or incorrect
computations.

Coverity basically found that it is possible to assign more than 4
attribs in the array.

In my opinion this was produced because code pattern used pointer
arithmetic, which is not readable nor maintainable.

This patch refactors config_create() to use an array index rather than
pointer arithmetic. Also a run-time check for index size was added.
2017-08-08 18:52:37 +02:00
Víctor Manuel Jáquez Leal
775f912247 libs: windows: wayland: fail if cannot remove last frame
Converity scan bug:

If the function returns an error value, the error value may be
mistaken for a normal value.

If g_atomic_pointer_compare_and_exchange() fails because the frame is
not the last one, the function fails. Thus, logging an info message.
2017-08-08 17:29:54 +02:00
Víctor Manuel Jáquez Leal
fbffda4e2f libs: utils: glx: check return value
Coverity scan bug:

If the function returns an error value, the error value may be
mistaken for a normal value.

Function sscanf returns the number of assignations done. Validate this
return value with the number of expected variables to match.
2017-08-08 17:21:52 +02:00
Víctor Manuel Jáquez Leal
d99d5704a4 libs: vaapi: object: remove unrequired NULL check
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

Variable klass has been validated as non-NULL several time before in
gst_vaapi_object_new() function, so there is no need to check it
again.
2017-08-08 17:12:06 +02:00
Víctor Manuel Jáquez Leal
d65ce31f14 libs: encoder: h265: remove spurious assignation
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

ip_period is assigned first to be rewritter inmediatly after. The
first assignation is spurious.
2017-08-08 17:06:17 +02:00
Víctor Manuel Jáquez Leal
f197749343 libs: encoder: h264: fix copy & paste error
Coverity scan bug:

The copied code will not have its intended effect.

This is a bug from commit cdaf15b2, where the intention is to
initialize RefPicList1 while setting RefPicList0.
2017-08-08 16:57:12 +02:00
Víctor Manuel Jáquez Leal
bd7716a739 libs: encoder: h265: fix possible integer overflow
Coverity scan bug:

Unintentional integer overflow. The expression's value may not be what
the programmer intended, because the expression is evaluated using a
narrow (i.e. few bits) integer type.

Cast operator to guint64 before computation to avoid narrowing.

merge with 3c5a6add
2017-08-08 16:56:58 +02:00
Víctor Manuel Jáquez Leal
4e27245f28 libs: decoder: mpeg4: fail if return value is not OK
Coverity scan bug:

An assigned value that is never used may represent unnecessary
computation, an incorrect algorithm, or possibly the need for cleanup
or refactoring.

In the return value of decode_slice() or
gst_mpeg4_parse_video_packet_header() are not success, thus fail
decode_packet() function.
2017-08-08 16:15:46 +02:00
Víctor Manuel Jáquez Leal
067968ae74 libs: decoder: h265: check for null
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

While looking for hte lowest poc, according to rest of the code, the
picture in the dbp (decoded picture buffer) might be NULL, thus we
could check for a NULL picture before assigned as found.

Also, split a comma operator because it is considered as a bad
practice because it possible side effects.
2017-08-08 16:15:45 +02:00
Víctor Manuel Jáquez Leal
d879664a0a libs: decoder: h265: untaint loop control variable
Coverity scan bug:

Scalars (for example, integers) are not properly
bounds-checked (sanitized) before being used as array or pointer
indexes, loop boundaries, or function arguments are considered as
tainted.

In this case, num_nals were not checked before used as loop control.
2017-08-08 15:38:16 +02:00
Víctor Manuel Jáquez Leal
9eddf6c004 libs: decoder: h264: remove unrequired NULL check
Coverity scan bug:

Dereference after null check: Either the check against null is
unnecessary, or there may be a null pointer dereference.

In the original commit for fill_picture_gaps() (commit 5abd2b90) the
prev_picture could be NULL, that's why the code did a null check. But,
since commit 52adebe7, the previous reference frames are tracked, thus
there is no need to check null anymore.
2017-08-08 13:46:56 +02:00
orestisf
ac9ddc5e8d libs: decoder: h264: decode MVC base view only
If processed SPS has mvc profile and the configuration is set to
base-only, the frame is drop.

https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:14 +02:00
orestisf
1dd03ac2fd libs: decoder: h264: add setter for base-only mode
https://bugzilla.gnome.org/show_bug.cgi?id=732265
2017-08-03 17:07:09 +02:00
Víctor Manuel Jáquez Leal
a1fc1e9822 libs: encoder: h264: missing property enum documentation 2017-08-02 11:40:17 +02:00
Hyunjun Ko
cdaf15b24d libs: encoder: h264: add multi reference support
Using num_ref_frames provided and the result of the Query
VAConfigAttribEncMaxRefFrames, it determines the size of reference list
and perform encoding with multi reference frames as the following:

1\ The num_ref_frames is being considered as the number of
reference picture list0
2\ Encoder adds 1 reference frame more to the reference picture list1
internally if b-frame encoding.
3\ If num_ref_frames is bigger than the number of refrence frames
supported in the driver, it will be lowered.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:21:02 +02:00
Hyunjun Ko
cd6a9736bd libs: encoder: h264: add refs property
Users can provide the number of reference frame by this property.

The value of the property will be considered as the number of
reference picture list0 and will add 1 reference frame more to the
reference picture list1 internally if b-frame encoding.

If the value provided is bigger than the number of refrence frames
supported in the driver, it will be lowered.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:20:35 +02:00
Hyunjun Ko
ec76a9a7e3 libs: encoder: implements gst_vaapi_encoder_ensure_max_num_ref_frames
This function will query VAConfigAttribEncMaxRefFrames to get the
maximum number of reference frames supported in the driver.
This will be used for h264/h265 encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=783803
2017-08-02 11:17:39 +02:00
Tomas Rataj
c181308904 libs: display: when appending formats change pointers to indexes
Thus, it fixes an invalid read when YV12 or I420 are not supported by
the driver.

https://bugzilla.gnome.org/show_bug.cgi?id=785085
2017-08-01 16:23:22 +02:00
Sreerenj Balachandran
aa3543929b libs: encoder: h264: Add uncompliant mode reducing coded buffer size
Added a new property "compliance-mode", which default is the normal
strict compliant mode.

The second mode, "restrict-buf-alloc", is to limit the coded buffer
allocation size to improve performance in some specific Intel
platforms (there is asignificant performance improvement in parallel
encodings). Under this new mode, we use the MinCR field in A.3.1 for
pre-calculating the coded-buffer size.

https://bugzilla.gnome.org/show_bug.cgi?id=784590
2017-08-01 14:37:44 +02:00
Sreerenj Balachandran
f775bbfe07 libs: utils_h264: Extend LevelLimit table with MinCR field
Add MinCR(Minimum Compression Ratio) field to GstVaapiH264LevelLimits
based on Annex A.3

https://bugzilla.gnome.org/show_bug.cgi?id=784590
2017-08-01 14:32:30 +02:00
Víctor Manuel Jáquez Leal
777bba473e libs: utils: libva 1.0 changed the logging
The logging mechanism in libva has changed it's functions
signatures. This patch updates that for libva versions >= 1.0

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-07-31 18:17:06 +02:00
Víctor Manuel Jáquez Leal
e0e0a47476 libs: decoder: h264: libva 1.0 deprecated baseline
libva 1.0 deprecated H.264 baseline profile and FMO support
(commit b4f332b3).

https://bugzilla.gnome.org/show_bug.cgi?id=784398
2017-07-31 18:17:06 +02:00
Víctor Manuel Jáquez Leal
8a7354380c build: meson: remove gstvaapidisplaycache.c
This is a missing bit of commit ec3e10f6
2017-07-26 20:32:09 +02:00
Hyunjun Ko
d78e094fd4 libs: display: x11: add gst_vaapi_display_x11_new_with_va_display()
Implements new API function so that users could create GstVaapiDisplay
with their own VADisplay within a native display as backend.

https://bugzilla.gnome.org/show_bug.cgi?id=766704
2017-07-18 18:50:39 +02:00
Hyunjun Ko
356212214b libs: display: pass display info when foreign display
When creating a GstVaapiDisplay using a foreign VADisplay, and render
with that display, it also requires native display of the backend.

https://bugzilla.gnome.org/show_bug.cgi?id=766704
2017-07-18 18:43:06 +02:00
Víctor Manuel Jáquez Leal
ec3e10f666 libs: display: remove cache
Remove a bunch of code that handles the VADisplay cache, since the
context sharing should be doing this correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=747946
2017-07-18 18:20:21 +02:00
Víctor Manuel Jáquez Leal
a9c13a0934 libs: encoder: vp9: array terminated in zeros
There is a crash when setting ref-pic-mode since the #GEnumValue
array is not terminated with a structured with all memvers being
zero.

https://bugzilla.gnome.org/show_bug.cgi?id=785032
2017-07-17 18:59:13 +02:00
Matt Staples
66d26da39f libs: decoder: h264: push frames as soon as possible
Push frames downstream as soon as possible instead of waiting until
they are ejected from the DPB.

This patch makes the decoder not comply with the H.264 specification,
but it is required for some video cameras.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-07-10 19:30:46 +02:00
Víctor Manuel Jáquez Leal
28d1d048a6 libs: decoder: h264: add getter/setter for low latency mode
https://bugzilla.gnome.org/show_bug.cgi?id=783588
2017-07-07 19:32:11 +02:00
Hyunjun Ko
6ebf7b10ae libs: encoder: h264: submit sps in case of IDR picture
If the picture is IDR, also submit a SPS header.

This means when frame number reaches to keyframe-period or an force
key unit event arrives, we insert SPS/PPS again.

https://bugzilla.gnome.org/show_bug.cgi?id=776712
2017-07-04 14:25:39 +02:00
Hyunjun Ko
465d5868d9 libs: encoder: h264: set the frame as IDR if forced key unit
GST_VIDEO_CODEC_FRAME_IS_FORCE_KEYFRAME() is a flag usually used to manage
the `frame-lost` event in the case of streaming, such as RTP.

In case of this event, it is needed to start new GOP rather than just
produce an I-frame.

https://bugzilla.gnome.org/show_bug.cgi?id=776712
2017-07-04 14:25:39 +02:00
Sreerenj Balachandran
02a6e9a273 libs: encoder: h264: insert AU delimiter
Insert an AUD as the first NAL of each encoded frame.

Some applications require Access Unit Delimiter for decoding the
stream.

The AU delimeter insertion is done only when the aud parameter is
TRUE (by default is disabled). The reason of this it is because this
header is only available from Intel Gen9 and the VA intel driver
should be 1.8 or superior. Otherwise, the output will be corrupted.

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

Signed-off-by: Victor Jaquez <vjaquez@igalia.com>
2017-07-04 14:22:52 +02:00
Hyunjun Ko
9b73b31c7a libs: encoder: h264: initialize all elements of view_ids
Currently when num_views is changed by multiview-mode on sink caps, it produces
wrong MVC encoded stream since the array view_ids is not set properly according
to changed num_views.

So this patch initializes all of the array sequentially to handle this case.
Side effect is not going to happen by this patch since this array is being
handled by num_views.

https://bugzilla.gnome.org/show_bug.cgi?id=784321
2017-07-04 13:27:56 +02:00
Hyunjun Ko
5b38e7fbe2 Revert "encoder: h264: Use high profile by default"
This reverts commit 4aec5bdd72.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-07-03 18:48:07 +02:00
Hyunjun Ko
ca84fd211a libs: encoder: h264: set profile via capsfilter
Until now, the encoder ignored the profile in src caps and chose one
according with the given parameters. But the encoder must honor the
profile specifed in src caps.

This patch do that, and if the encoder needs to choose the profile,
it will do it by following these rules:

1\ If given parameters are not compatible with given profile, the
   encoder will bail out with an error.
2\ The encoder will choose the higher profile indicated in the
   src caps.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-07-03 18:38:16 +02:00
Hyunjun Ko
9397cd7d4d libs: decoder: h264: initialize active_sps/pps in reset
Since commits in https://bugzilla.gnome.org/show_bug.cgi?id=781142 landed,
they introduced regression in seek.

Formerly, once seek is done, decoder drops P-frames until I-frame arrives.
But since the commits landed, it doesn't drop P-frame and does try to
decode it continuously because active_sps is still alive. See ensure_sps function.
But there are prev_frames and prev_ref_frames reset already, then it
causes assertion.

So it's necessary to reset active_sps/pps also in reset method.

https://bugzilla.gnome.org/show_bug.cgi?id=783726
2017-06-15 13:40:27 +02:00
Víctor Manuel Jáquez Leal
3ed2023c2c libs: encoder: fix compilation with old versions of libva
There are some symbols that are not used when compiling with old
version of libva and those generates a compilation error.

Original-patch-by: Matt Staples <staples255@gmail.com>
2017-06-15 13:24:56 +02:00
Sreerenj Balachandran
595f8b7d4b libs: encoder: Fix the quality level clamping
Change the hard-coded range of quality-level from {1-8} to {1-7},
since it is the range Intel Open source driver supports.
Also perform the range clamping only if the user provided
quality-level is greater than the max-range suppored by the driver,
because there could be non-intel drivers giving lower value than
the hard-coded max value 7.

https://bugzilla.gnome.org/show_bug.cgi?id=783567
2017-06-13 16:51:52 +02:00
Víctor Manuel Jáquez Leal
eee8a78173 libs: encoder: log out the name of the profile
Instead of printing a number, it is more readable to log out, in
case of error, the name of the failing profile.
2017-06-13 13:51:01 +02:00
Hyunjun Ko
3dce250236 libs: encoder: h264: changes raw number of profile to macro name of its
Changes raw number of profile to macro name of its to improve readability.

https://bugzilla.gnome.org/show_bug.cgi?id=757941
2017-06-13 13:39:19 +02:00
Víctor Manuel Jáquez Leal
94b41c8d38 libs: encoder: set framerate if bigger than 0/1
Just set the framerate parameter if the framerate numerator and
denominator are bigger than zero.

Otherwise, in Intel Gen6 driver, a warning is raised disabling the
bitrate control.

Original-patch-by: Hyunjun Ko <zzoon@igalia.com>

https://bugzilla.gnome.org/show_bug.cgi?id=783532
2017-06-08 13:21:42 +02:00
Víctor Manuel Jáquez Leal
f8afb1eea4 libs: encoder: bitrate target percentage calculation
If the rate control is set to Constant Bit Rate (CBR) the target
percentage is 100%, otherwise is 70%
2017-06-07 16:04:38 +02:00
Víctor Manuel Jáquez Leal
4b5ecca29c libs: encoder: h264,h265,mpeg2,vp8,vp9: refactor ratecontrol param
Centralize the common configuration for the Rate Control parameter,
thus can be overloaded per each specific encoder.
2017-06-07 16:04:38 +02:00
Víctor Manuel Jáquez Leal
035efded75 libs: encoder: h264,h265,mpeg2,vp8,vp9: refactor framerate param
Since the framerate VA parameter is calculated equally among all the
encoders, it is better to handle it in the base encoder class.
2017-06-07 12:43:55 +02:00
Sreerenj Balachandran
4bf8ef724b libs: encoder: vp9: Adds CBR and VBR Encoding support
https://bugzilla.gnome.org/show_bug.cgi?id=766832

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-06-07 12:08:10 +02:00
Hyunjun Ko
5d345b08fd libs: encoder: vp8: Adds VBR Encoding support
https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Hyunjun Ko
f68d0452be libs: encoder: h265: Adds VBR Encoding support
Enables Variable BitRate mode, which does set FrameRate and RateControl
parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Hyunjun Ko
cbd912b89b libs: encoder: Describes more detail about the bitrate property
https://bugzilla.gnome.org/show_bug.cgi?id=778732
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
81886682cd libs: encoder: h265: add rate control parameter
https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
d733714ef8 libs: encoder: h264,h265,mpeg2: add framerate parameter
https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
846c276e26 libs: encoder: vp8,h264,h265,mpeg2: set misc param once
Instead of recalculating the miscellaneous buffer parameters for
every buffer, it is only done once, when the encoder is configured.
And for every buffer, the same structures are just copied.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
acf106e1a7 libs: encoder: vp8,h264,h265,mpeg2: refactor misc parameters
This is patch pretends to decouple the assignation of the values
in the parameter structures and the VA buffer's parameters setting.

It may lead to some issues since HRD, framerate or controlrate may
not be handled by the specific encoder, but they are set in
the VA buffer's parameters.

I leave as it because this patch is just a transitional patch.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
daff4e9fbd libs: encoder: vp8: fix frame rate calculation
According to the VA documentation:

     The framerate is specified as a number of frames per second,
     as a fraction.  The denominator of the fraction is given in
     the top half (the high two bytes) of the framerate field, and
     the numerator is given in the bottom half (the low two bytes).

     For example, if framerate is set to (100 << 16 | 750), this is
     750 / 100, hence 7.5fps.

     If the denominator is zero (the high two bytes are both zero)
     then it takes the value one instead, so the framerate is just
     the integer in the low 2 bytes.

This patch fixes the the framerate calculation in vp8 encoder
according to this.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
baac8dc8a3 libs: encoder: vp8: refactor FrameRate parameter
Move frame-rate parameter from ensure_misc_params() to
ensure_contro_rate_param() since it only has meaning when the
control rate is either VBR or CBR.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
fc5106bd31 libs: encoder: h264,h265,mpeg2,vp8: refactor HDR
Move the Hypothetical Reference Decoder (HRD) parameter, from
ensure_misc_params() to ensure_control_rate_params(), since it
only shall be defined when the control rate is either VBR or CBR.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
b538a86d4e libs: encoder: h264,vp8,mpeg2: refactor control rate
Instead of filling the control rate param in ensure_misc_params(),
this patch refactor it out, as a first step to merge the same code
for all the encoders.

https://bugzilla.gnome.org/show_bug.cgi?id=783449
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
5c05a8b436 libs: encoder: h264, h265, mpeg2: remove assert
Remove spurious asserts for misc parameters. If they cannot be
allocated, FALSE is already returned.
2017-06-07 11:24:38 +02:00
Víctor Manuel Jáquez Leal
37b81a7b69 libs: encoder: use VA quality level structure
Instead of using a proxy to story the buffer quality level, the
encoder now uses the native VA structure, which is copied to the
dynamically allocated VAEncMiscParameterBuffer.

This approach is computationally less expensive.
2017-06-07 11:24:08 +02:00
Víctor Manuel Jáquez Leal
0e31137dec libs: standardize the FIXME comment
This is a trivial patch that makes homogeneous the FIXME tag in
comments.

For more info about these comment style:
http://wiki.c2.com/?FixmeComment
2017-06-01 16:05:50 +02:00
Hyunjun Ko
e66aaf166c libs: encoder: vp8: set quality level regardless of rate control mode
https://bugzilla.gnome.org/show_bug.cgi?id=782957
2017-05-23 11:55:03 +02:00
Víctor Manuel Jáquez Leal
ed3360bf3b libs: encoder: check for maximum number of slices
Right now, H264 and HEVC can set as a property the number of slices to
process. But each driver can set a maximum number of slices, depending
on the supported profile & entry point.

This patch verifies the current num_slices to process against the maximum
permitted by the driver and the media size.

https://bugzilla.gnome.org/show_bug.cgi?id=780955
2017-05-19 16:33:27 +02:00
Víctor Manuel Jáquez Leal
58f6e78017 libs: utils: mark functions as internals
The functions in this header are internal to the library.
2017-05-15 18:36:21 +02:00
Víctor Manuel Jáquez Leal
3c31e8292a libs: context: add missing documentation
Document the region-of-interest configuration variables.
2017-05-15 18:35:40 +02:00
Hyunjun Ko
f09f21def7 libs: window: x11: fix src rect info when using vpp
Since we started using VPP in VaapiWindowX11, we need to care about
the case that src rect and window's size are different.

So, once VPP has converted to other format, we should honor the
size of the VPP's surface as source rect. Otherwise, it is cropped
according the previous size of the source rect.

https://bugzilla.gnome.org/show_bug.cgi?id=782542
2017-05-12 16:23:38 +02:00
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
Hyunjun Ko
7a6f690340 libs: encoder: add api gst_vaapi_encoder_add/del_roi
Implements and exposes new api gst_vaapi_encoder_add/del_roi to set ROI regions.

https://bugzilla.gnome.org/show_bug.cgi?id=768248
2017-05-12 11:12:56 +02:00
Hyunjun Ko
b41d72b7c5 libs: encoder/context: query region of interest support
Queries if the driver supports "Region of Interest" (ROI) during the config
creation.

  This attribute conveys whether the driver supports region-of-interest (ROI)
  encoding, based on user provided ROI rectangles.  The attribute value is
  partitioned into fields as defined in the VAConfigAttribValEncROI union.

  If ROI encoding is supported, the ROI information is passed to the driver
  using VAEncMiscParameterTypeROI.

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
Víctor Manuel Jáquez Leal
3ec7996d75 libs: encoder: fix a comment 2017-05-12 11:12:56 +02:00
Víctor Manuel Jáquez Leal
4269adf791 libs: encoder: guard quality level configuration
The quality level appeared in VA-API 0.36. So let's guard its
usage.
2017-05-11 12:23:28 +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
Hyunjun Ko
2d7c7630c9 libs: windows: wayland: fix leak if failure of sync
Sometimes gst_vaapi_window_wayland_sync returns FALSE when poll returns EBUSY
during destruction.
In this case, if GstVaapiWindow is using vpp, leak of vpp surface happens.
This surface is not attached to anything at this moment, so we should release
it manually.

https://bugzilla.gnome.org/show_bug.cgi?id=781695
2017-04-25 11:24:38 +02:00
Hyunjun Ko
824974e657 libs: window: wayland: mark frames as done
When the frame listener callbacks 'done', the number of pending
frames are decreased. Nonetheless, there might be occasions where
the buffer listener callbacks 'release', without calling previously
frame's 'done'. This leads to problem with
gst_vaapi_window_wayland_sync() operation.

This patch marks as done those frames which were callbacked, but if
the buffer callbacks 'release' and associated frame is not marked
as 'done' it is so, thus the number of pending frames keeps correct.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-24 13:16:03 +02:00
Víctor Manuel Jáquez Leal
3b314ba93e libs: window: wayland: don't sync at destroy()
Don't call gst_vaapi_window_wayland_sync() when destroying the
wayland window instance, since it might lead to a lock at
gst_poll_wait() when more than one instances of vaapisink are
rendering in the same pipeline, this is because they share the
same window.

Since now all the frames are freed we don't need to freed the
private last_frame, since its address is invalid now.

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

Signed-off-by: Hyunjun Ko <zzoon@igalia.com>
2017-04-24 13:14:05 +02:00
Hyunjun Ko
ca314a25cc libs: window: wayland: null buffer at destroy()
Fix leakage of the last wl buffer.

VAAPI wayland sink needs to send a null buffer while destruction,
it assures that all the wl buffers are released. Otherwise, the last
buffer's callback might be not called, which leads to leak of
GstVaapiDisplay.

This was inspired by gstwaylandsink.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-21 16:01:47 +02:00
Jagyum Koo
896a836f1d libs: window: wayland: rt event queue at destroy()
The proxy object of wl_buffer for the last frame remains in the
wl_map. Even though we call wl_buffer_destroy() in
frame_release_callback(), the proxy object remains without being
removed, since proxy object is deleted when wayland server sees the
delete request and sends 'delete_id' event.

We need to call roundtrip before destroying event_queue so that the
proxy object is removed. Otherwise, it would be mess up as receiving
'delete_id' event from previous play, when playing in the next
va/wayland window with the same wl_display connection.

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

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
2017-04-21 16:01:46 +02:00
Víctor Manuel Jáquez Leal
9c3a4edf05 libs: window: wayland: cancel read at poll message
Always call wl_display_cancel_read() when an errno is set, but
different to EAGAIN or EINTR.

https://bugzilla.gnome.org/show_bug.cgi?id=780442
2017-04-21 16:01:34 +02:00
Jan Schmidt
bae56fe0c2 h264 decoder: Implement reset() for faster flush
Implement a custom reset() function for faster flushes
that just clear the reference pictures but don't reallocate
the DPB or clear out SPS/PPS

https://bugzilla.gnome.org/show_bug.cgi?id=781142
2017-04-12 10:43:49 +10:00
Jan Schmidt
a7a9b33ad9 Implement decoder reset on flush, rather than recreating
Clear decoders out on a flush but keep the same instance,
rather than completely recreating them. That avoids
unecessarily freeing and recreating surface pools
and contexts, which can be quite expensive

https://bugzilla.gnome.org/show_bug.cgi?id=781142
2017-04-12 10:43:49 +10:00
Víctor Manuel Jáquez Leal
bd2e304ea4 libs: window: don't add an unused function
The macro GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE only defines
a function that is never used, thus when compiling we might see
this warning (clang):

gstvaapiwindow.c:147:1: warning: unused function 'gst_vaapi_window_class' [-Wunused-function]
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiWindow,
^

https://bugzilla.gnome.org/show_bug.cgi?id=759533
2017-04-11 19:22:38 +02:00
Víctor Manuel Jáquez Leal
8e8280efbf libs: window: remove surface_format member
Since we always convert to NV12, there is no need to keep a
variable for that. Let us hard code it.

https://bugzilla.gnome.org/show_bug.cgi?id=759533
2017-04-11 19:22:38 +02:00
Hyunjun Ko
c5b3577e88 libs: window: x11/wayland: use new api for conversion
Since gst_vaapi_window_vpp_convert_internal is created,
GstVaapiWindowX11/Wayland can use it for conversion.

Note that once it chooses to use vpp, it's going to use vpp
until the session is finished.

https://bugzilla.gnome.org/show_bug.cgi?id=759533
2017-04-11 19:20:38 +02:00
Hyunjun Ko
ccfbca733d libs: window: add gst_vaapi_window_vpp_convert_internal()
If a backend doesn't support specific format, we can use vpp for conversion
and make it playing.

This api is originated from GstVaapiWindowWayland and moved to GstVaapiWindow,
so that GstVaapiWindowX11 could use it.

https://bugzilla.gnome.org/show_bug.cgi?id=759533
2017-04-11 19:20:24 +02:00
Hyunjun Ko
4752f68a37 libs: window: x11/wayland: chaining up to GstVaapiWindow
Currently, GstVaapiWindowX11/Wayland are not descendants of GstVaapiWindow.
This patch chains them up to GstVaapiWindow to handle common members in GstVaapiWindow.

https://bugzilla.gnome.org/show_bug.cgi?id=759533
2017-04-11 16:41:41 +02:00
Víctor Manuel Jáquez Leal
3532dca16a libs: encoder: h265: chroma and luma with format
If the profile is main-10 the bit_depth_luma_minus8, in the sequence
parameter buffer, shall be the color format bit depth minus 8, 10-8
which is 2. Also for bit_depth_chroma_minus8.

This patch gets the negotiated sink caps format and queries its
luma's depth and uses that value to fill the mentioned parameters.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-07 12:04:51 +02:00
Víctor Manuel Jáquez Leal
d744aeb5fa libs: encoder: admit YUV420_10BPP as valid chroma
Accepts as supported the GST_VAAPI_CHROMA_TYPE_YUV420_10BPP chroma
type.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
48e21d6ba8 libs: encoder: h265: ensures profile given format
Set the VA profile as GST_VAAPI_PROFILE_H265_MAIN10 if the
configured color format is P010_10LE.

Otherwise, keep GST_VAAPI_PROFILE_H265_MAIN

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
e534ff5609 libs: encode: merge all possible surface formats
When the function gst_vaapi_encoder_get_surface_formats() was added
it was under the assumption that any VA profile of the specific codec
supported the same format colors. But it is not, for example the
profiles that support 10bit formats.

In other words, different VA profiles of a same codec may support
different color formats in their upload surfaces.

In order to expose all the possible color formats, if no profile is
specified via source caps, or if the encoder doesn't have yet a
context, all the possible VA profiles for the specific codec are
iterated and their color formats are merged.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
7153b4597d libs: encoder: pass profile to get_surface_formats()
In order to get the supported surface formats within a specific
profile this patch adds the GstVaapiProfile as property to
gst_vaapi_encoder_get_surface_formats().

Currently the extracted formats are only those related with the
default profile of the element's codec.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
9aa63e4595 libs: encoder: dummy context for get_surface_formats()
Instead of creating (if it doesn't exist, yet) the encoder's context
the method gst_vaapi_encoder_get_surface_formats() now it creates
dummy contexts, unless the encoder has it already created.

The purpose of this is to avoid setting a encoder's context with a
wrong profile.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
31d326c9ee libs: encoder: refactor init_context_info()
In order to generate vaapi contexts iterative, the function
init_context_info() is refactored to pass, as parameters the
GstVaapiContextInfo and the GstVaapiProfile.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Víctor Manuel Jáquez Leal
db7268117d libs: encoder: initialize chroma_type
Instead of initialize the chroma_type with a undefined value, which
will be converted to GST_VAAPI_CHROMA_TYPE_YUV420 by GstVaapiContext,
this patch queries the VA config, given the received
GstVaapiContextInfo's parameters, and gets the first response.

In order to get the GstVaapiChromaType value, also it was needed to
add a new utility function: to_GstVaapiChromaType(), which, given a
VA_RT_FORMAT_* will return the associated GstVaapiChromaType.

https://bugzilla.gnome.org/show_bug.cgi?id=771291
2017-04-06 22:00:05 +02:00
Scott D Phillips
123672a9bd libs: encoder: vp9: Fix initialization of ref_list
gcc 7.0.1 gives a memset-elt-size warning in gst_vaapi_encoder_vp9_init:

 'memset' used with length equal to number of elements without
 multiplication by element size [-Werror=memset-elt-size]

https://bugzilla.gnome.org/show_bug.cgi?id=780947
2017-04-06 11:03:12 +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
Víctor Manuel Jáquez Leal
834557d5b6 libs: encoder: h265: fix code style
Trivial patch to remove a double ';' as end of instruction.
2017-03-29 13:24:41 +02: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
Víctor Manuel Jáquez Leal
7f8b325450 libs: encoder: h265: remove unused macro definition
Since the h265 encoder doesn't use GValueArray, there is no need to
disable the Glib deprecation warnings, thus removing the macro
definition.
2017-03-21 16:13:56 +01: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
Hyunjun Ko
7f38b3b9f2 libs: encoder: h265: fix reserved length of bits
Fix reserved length of bits for bit_depth_luma_minus8 and bit_depth_chroma_minus8

https://bugzilla.gnome.org/show_bug.cgi?id=778749
2017-03-14 16:54:39 +01:00
Thomas Petazzoni
159e3c3f08 O_CLOEXEC needs _GNU_SOURCE defined
From man open(2):

    The O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags are not specified
    in POSIX.1-2001, but are specified in POSIX.1-2008.  Since glibc
    2.12, one can obtain their definitions by defining either
    _POSIX_C_SOURCE with a value greater than or equal to 200809L or
    _XOPEN_SOURCE with a value greater than or equal to 700.  In glibc
    2.11 and earlier, one obtains the definitions by defining
    _GNU_SOURCE.

And indeed, with the uClibc C library, O_CLOEXEC is not exposed if
_GNU_SOURCE is not defined. Therefore, this commit fixes the build of
gstreamer-vaapi with the uClibc C library.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

https://bugzilla.gnome.org/show_bug.cgi?id=779953
2017-03-14 16:12:27 +01:00
Hyunjun Ko
c4ef779931 libs: window: wayland: handle more VAStatus to use vpp
Since the commit landed https://github.com/01org/intel-vaapi-driver/pull/55,
we should consider more returned VAStatus to use vpp.

https://bugzilla.gnome.org/show_bug.cgi?id=779400
2017-03-02 02:22:26 +01:00
Hyunjun Ko
6468bf2ddf libs: encoder: ensure profile when context initialization
We can't be sure that encoder's profile is assgined already or not
at context initialization.

https://bugzilla.gnome.org/show_bug.cgi?id=779120
2017-02-28 18:26:44 +01:00
Hyunjun Ko
04a844ced0 libs: encoder: set rate control info only when query succeed
Currently, it set rate control information even when query fails.
In addition, it doesn't update any more since the flag
got_rate_control_mask is set to TRUE.

https://bugzilla.gnome.org/show_bug.cgi?id=779120
2017-02-28 18:26:44 +01:00
Víctor Manuel Jáquez Leal
a0a2f7bfe8 libs: encoder: caps can change at any time
The encoder should be able to change its caps even it is already
processing a stream.

This is suppose to happen after a flush so the codedbuf_queue should
be empty.

https://bugzilla.gnome.org/show_bug.cgi?id=775490
2017-02-22 05:19:06 +01:00
Víctor Manuel Jáquez Leal
7b3a51f145 libs: encoder: h265: bail if nal unit type fails
Bail out if the NAL unit type is not recognized.

https://bugzilla.gnome.org/show_bug.cgi?id=778782
2017-02-22 05:19:06 +01:00
Víctor Manuel Jáquez Leal
d6738f3f93 libs: decoder: h264,h265 avoid uninitialized variable
Configuring GCC to verify possible usage of uninitialized variables,
shows that found_index might be used without previous assignation.

This patch assigns a initial value to found_index, also avoid a
branching when returning the result value.

https://bugzilla.gnome.org/show_bug.cgi?id=778782
2017-02-16 18:46:35 +01:00
Scott D Phillips
884e0bece2 build: rename USE_HEVC_DECODER to USE_H265_DECODER
Rename to be consistent with H.264 and also H.265 encoder. The
meson build assumed this was already consistently named, and so
previously was not able to actually build the H.265 decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=778576
2017-02-16 17:27:50 +01:00
Hyunjun Ko
b6a3e88059 libs: encoder: vp8: add CBR encoding mode
This patch enables the Constant BitRate encoding mode in VP8 encoder.
Basically it adds the configuration parameters required by libva to
CBR enconding.

Original-Patch-By: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=749950
2017-02-10 13:11:21 +01:00
Hyunjun Ko
ffc5b43da7 libs: encoder: vp8: fix bitrate calculation
Base encoder's unit of bitrate is in Kbps. We should honor it so
we use the value of bitrate in VA, in which is expressed in bps.

https://bugzilla.gnome.org/show_bug.cgi?id=749950
2017-02-10 13:10:10 +01:00
Scott D Phillips
412dd13e86 vaapi: add meson build
https://bugzilla.gnome.org/show_bug.cgi?id=778250
2017-02-09 11:27:44 +01:00
Scott D Phillips
3cc4eb7b81 make: remove gstvaapiversion.h generation
https://bugzilla.gnome.org/show_bug.cgi?id=778250
2017-02-09 11:27:44 +01:00
Hyunjun Ko
2d463f79f2 libs: utils: add HEVC profiles representation
https://bugzilla.gnome.org/show_bug.cgi?id=778318
2017-02-08 10:42:28 +01:00
Hyunjun Ko
d89a3bd258 libs: decoder: h264: reduce frame number of gaps
Reduce frame num gaps so that we don't have to create unnecessary
dummy pictures, just throw them away.

Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=777506
2017-02-07 11:30:02 +01:00
Julien Isorce
4f037a036b libs: surface: add gst_vaapi_surface_{set,peek}_buffer_proxy()
These functions are useful when a dmabuf-based memory is instantiated in
order to relate the generated buffer @proxy with the processed @surface.

https://bugzilla.gnome.org/show_bug.cgi?id=755072
2017-02-02 20:33:36 +01:00