Commit graph

39 commits

Author SHA1 Message Date
Sreerenj Balachandran
d446013ae4 gstvaapiencoder:Use internal api to dervie configured VAEntrypoint
https://bugzilla.gnome.org/show_bug.cgi?id=766050
2016-05-11 12:06:38 +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
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
Victor Jaquez
002ac0ba9e gstvaapiencoder: validate chroma according to the VA's RT format
Before, only YUV420 color space where supported. With this patch, the
encoder is queried to know the supported formats and admits YUV422
color space if its available.

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

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-13 17:20:19 +02:00
Victor Jaquez
351496a304 gstvaapiencoder: framerate 0/1 is valid too
Framerate 0/1 is valid, and it is particularly useful for picture
encoding, such as jpeg. This patch makes the encoder to admit that
framerate.

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

https://bugzilla.gnome.org/show_bug.cgi?id=744042
2015-08-04 19:41:51 +02:00
Sreerenj Balachandran
0f40843bb3 encoder: Only support YUV420 native format as input for now
Practically we should be able to support more formats, for eg:
JPEG Encoder can support YUV422, RGBA and all.
But this is causing more issues which need proper fix here and there.
2015-02-05 12:13:38 +02:00
Sreerenj Balachandran
beefadc7b7 gstvaapiencoder: Use hardcoded packed_raw_data flag for JPEG Encoding 2015-02-04 11:17:06 +02:00
Sreerenj Balachandran
3332c25ef6 gstvaapiencoder: Fix crash when handling rate control mask
Having a ratecontrol_mask equal to zero is not a bug, but the driver
might not be supporting any kind of rate control mechanisms.
Eg: JPEG Encoding
2015-02-04 11:16:37 +02:00
Sreerenj Balachandran
d48ab9a3d6 Encode: Add support for Picture level Entrypoint
This is useful for JPEG encoding which is utilizing picture level
entrypoint instead of slice level entrypoint like h264,mpeg2 etc.
2015-02-04 11:15:00 +02:00
Sreerenj Balachandran
cffe87df89 gstvaapiencoder: Fix the negotiation issue with _ENCODED format handling
Don't error out for the video format GST_VIDEO_FORMAT_ENCODED with in gstvaapiencoder,
since the vaaapi context creation (gstvaapicontext.c) can still use the
default chroma type which is YUV420.

https://bugzilla.gnome.org/show_bug.cgi?id=743567
https://bugzilla.gnome.org/show_bug.cgi?id=743035
2015-01-27 12:38:45 +02:00
Gwenole Beauchesne
14e9d383e3 encoder: derive chroma type from video format.
Cope with previous VA context change to derive the correct surface chroma
type from the input video format.
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
db7a3b8d3e libs: factor out usages of vaGetConfigAttributes().
Add gst_vaapi_get_config_attribute() helper function that takes a
GstVaapiDisplay and the rest of the arguments with VA types. The aim
is to have thread-safe VA helpers by default.
2014-01-23 18:51:59 +01: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
14ad694fdc context: move rate-control mode to encoder specific config.
Move usage-specific config out of the common GstVaapiContextInfo.
Create a specialized config for encoding and move rate-control mode
to there.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
0eb4070977 context: introduce concept of usage.
Introduce GstVaapiContextUsage so that to explicitly determine the
usage of a VA context. This is useful in view to simplifying the
creation of VA context for VPP too.
2014-01-23 14:29:09 +01:00
Gwenole Beauchesne
c85b080688 context: clean-ups. Strip down APIs.
Improve documentation and debug messages. Clean-up APIs, i.e. strip
them down to the minimal set of interfaces. They are private, so no
need expose getters for instance.
2014-01-23 14:29:09 +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
71113e4999 encoder: h264: only submit packed headers when required.
Make sure to submit the packed headers only if the underlying VA driver
requires those. Currently, only handle packed sequence and picture
headers.

https://bugzilla.gnome.org/show_bug.cgi?id=722737
2014-01-22 18:30:26 +01:00
Gwenole Beauchesne
d45c6a486f encoder: clean-up objects.
Various clean-ups to improve consistency and readability: rename some
variables, drop unused macro definitions, drop initialization of vars
that are zero-initialized from the base class, drop un-necessary casts,
allocate GPtrArrays with a destroy function.
2014-01-14 15:28:19 +01:00
Gwenole Beauchesne
21c95dbc42 encoder: add tuning options API.
Add encoder "tune" option to override the default behaviour that is to
favor maximum decoder compatibility at the expense of lower compression
ratios.

Expected tuning options to be developed are:
- "high-compression": improve compression, target best-in-class decoders;
- "low-latency": tune for low-latency decoding;
- "low-power": tune for encoding in low power / resources conditions.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
850a637d0f encoder: filter out the supported set of rate-control properties.
Only expose the exact static set of supported rate-control properties
to the upper layer. For instance, if the GstVaapiEncoderXXX class does
only support CQP rate control, then only add it the the exposed enum
type.

Add helper macros and functions to build a GType for an enum subset.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
59229b20a5 encoder: add keyframe period API.
Add gst_vaapi_encoder_set_keyframe_period() interface to allow the
user control the maximum distance between two keyframes. This new
property can only be set prior to gst_vaapi_encoder_set_codec_state().

A value of zero for "keyframe-period" gets it re-evaluated to the
actual framerate during encoder reconfiguration.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
8788ea99a8 encoder: improve codec reconfiguration.
Improve codec reconfiguration to be performed only through a single
function. That is, remove the _set_context_info() hook as subclass
should not alter the parent GstVaapiContextInfo itself. Besides, the
VA context is constructed only at the final stages of reconfigure().
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
20ab910d15 encoder: fix possible memory leak of coded buffer pools.
Fix gst_vaapi_encoder_reconfigure_internal() to re-/allocate the coded
buffer pool only if the coded buffer size actually changed.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
5394c75461 encoder: add video codec-state API.
Add interface to communicate the encoder resolution and related info
like framerate, interlaced vs. progressive, etc. This new interface
supersedes gst_vaapi_encoder_set_format() and doesn't use any GstCaps
but rather use GstVideoCodecState.

Note that gst_vaapi_encoder_set_codec_state() is also a synchronization
point for codec config. This means that the encoder is reconfigured
there to match the latest properties.
2014-01-13 17:31:55 +01:00
Gwenole Beauchesne
dcc7a94408 encoder: add properties API.
Add interface to communicate configurable properties to the encoder.
This covers both the common ones (rate-control, bitrate), and the
codec specific properties.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
70b3600f11 encoder: add bitrate API.
Add gst_vaapi_encoder_set_bitrate() interface to allow the user control
the bitrate for encoding. Currently, changing this parameter is only
valid before the first frame is encoded. Should the value be modified
afterwards, then GST_VAAPI_ENCODER_STATUS_ERROR_OPERATION_FAILED is
returned.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
a24c52e4d0 encoder: add rate control API.
Add gst_vaapi_encoder_set_rate_control() interface to request a new
rate control mode for encoding. Changing the rate control mode is
only valid prior to encoding the very first frame. Afterwards, an
error ("operation-failed") is issued.

https://bugzilla.gnome.org/show_bug.cgi?id=719529
2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
01af353116 encoder: fix indentation. 2014-01-13 17:31:54 +01:00
Gwenole Beauchesne
b864d1f71a encoder: fix computation of max coded buffer size.
Fix coded buffer size for each codec. A generic issue was that the
number of macroblocks was incorrectly computed. The second issue was
specific to MPEG-2 were the max number of bits per macroblock, and
as defined by the standard, was incorrectly mapped to the (lower)
H.264 requirement. i.e. 4608 bits vs. 3200 bits limit.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
fd9c855f14 encoder: simplify VA context initialization process.
Change get_context_info() into a set_context_info() function that
initializes common defaults into the base class, thus allowing the
subclasses to specialize the context info further on.

The set_context_info() hook is also the location where additional
context specific data could be initialized. At this point, we are
guaranteed to have valid video resolution size and framerate. i.e.
gst_vaapi_encoder_set_format() was called beforehand.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
2f5e5f0784 encoder: clean-ups and document public APIs.
Clean public APIs up so that to better align with the decoder APIs.
Most importantly, gst_vaapi_encoder_get_buffer() is changed to only
return the VA coded buffer proxy. Also provide useful documentation
for the public APIs.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
26726b18fc encoder: avoid extra allocations of GstVaapiEncoderSyncPic objects.
Kill GstVaapiEncoderSyncPic objects that are internally and temporarily
allocated. Rather, associate a GstVaapiEncPicture to a coded buffer
through GstVaapiCodedBufferProxy user-data facility.

Besides, use a GAsyncQueue to maintain a thread-safe queue object of
coded buffers.

Partial fix for the following report:
https://bugzilla.gnome.org/show_bug.cgi?id=719530
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
038149b69b encoder: refactor status codes.
Drop obsolete or unused status codes. Align some status codes with the
decoder counterparts.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
8ecc35ecf2 encoder: fix subclassing process.
Fix the GstVaapiEncoderClass parent class type. Make sure to validate
subclass hooks as early as possible, i.e. in gst_vaapi_encoder_init(),
thus avoiding useless run-time checks. Also simplify the subclass
initialization process to be less error prone.
2013-12-04 19:14:38 +01:00
Gwenole Beauchesne
0fb7c60508 encoder: rework GstVaapiCodedBuffer and related proxy.
Refactor the GstVaapiCodedBuffer APIs so that to more clearly separate
public and private interfaces. Besides, the map/unmap APIs should not
be exposed as is but appropriate accessors should be provided instead.

* GstVaapiCodedBuffer: VA coded buffer abstraction
- gst_vaapi_coded_buffer_get_size(): get coded buffer size.
- gst_vaapi_coded_buffer_copy_into(): copy coded buffer into GstBuffer

* GstVaapiCodedBufferPool: pool of VA coded buffer objects
- gst_vaapi_coded_buffer_pool_new(): create a pool of coded buffers of
  the specified max size, and bound to the supplied encoder

* GstVaapiCodedBufferProxy: pool-allocated VA coded buffer object proxy
- gst_vaapi_coded_buffer_proxy_new_from_pool(): create coded buf from pool
- gst_vaapi_coded_buffer_proxy_get_buffer(): get underlying coded buffer
- gst_vaapi_coded_buffer_proxy_get_buffer_size(): get coded buffer size

Rationale: more optimized transfer functions might be provided in the
future, thus rendering the map/unmap mechanism obsolete or sub-optimal.

https://bugzilla.gnome.org/show_bug.cgi?id=719775
2013-12-04 19:14:38 +01:00
Wind Yuan
8174a35737 Add initial infrastructure for video encoding.
Add initial API for video encoding: only basic interfaces and small
encoder objects are implemented so far.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-11-24 16:52:05 +01:00