Commit graph

943 commits

Author SHA1 Message Date
Gwenole Beauchesne
d9ec93fe46 h264: implement {start,end}_frame() hooks.
Implement GstVaapiDecoder.start_frame() and end_frame() semantics so
that to create new VA context earlier and submit VA pictures to the
HW for decoding as soon as possible. i.e. don't wait for the next
frame to start decoding the previous one.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
f7f7393148 h264: optimize scan for the second start code.
Optimize scan for the second start code, on the next parse() call so that
to avoid scanning again earlier bytes where we didn't find any start code.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
63c455d28d h264: add codec specific decoder unit.
Introduce new GstVaapiDecoderUnitH264 object, which holds the standard
NAL unit header (GstH264NalUnit) and additional parsed header info.
Besides, we now parse headers as early as in the _parse() function so
that to avoid un-necessary creation of sub-buffers in _decode() for
NAL units that are not slices.

This is a performance win by ~+1.1% only.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
d19c59ba31 vaapisink: handle sub video-buffers.
Intermediate elements may produce a sub-buffer from a valid GstVaapiVideoBuffer
for non raw YUV cases. Make sure vaapisink now understands those buffers.
2012-12-18 15:31:51 +01:00
Sreerenj Balachandran
cb3c0a3e8f vaapidecode: use gst_vaapi_decoder_get_codec_state().
Directly use the GstVideoCodecState associated with the VA decoder
instead of parsing caps again.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
cfdc5c5b43 vaapidecode: use more standard helpers.
Use g_clear_object() [glib >= 2.28] and gst_caps_replace() helper functions
in more places.
2012-12-18 15:31:51 +01:00
Sreerenj Balachandran
9127f17d81 vaapidecode: move to GstVideoDecoder base class.
Make vaapidecode derive from the standard GstVideoDecoder base element
class. This simplifies the code to the strict minimum for the decoder
element and makes it easier to port to GStreamer 1.x API.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
ddc74f8a20 jpeg: initial port to new GstVaapiDecoder API 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
94982b5c05 vc1: initial port to new GstVaapiDecoder API 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
7e6660fcae h264: initial port to new GstVaapiDecoder API 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
8fbd05ca82 mpeg4: initial port to new GstVaapiDecoder API 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
50090d6138 mpeg2: initial port to new GstVaapiDecoder API. 2012-12-18 15:31:51 +01:00
Sreerenj Balachandran
e7e5c74a6e decoder: use GstVideoCodecState.
Use standard GstVideoCodecState throughout GstVaapiDecoder and expose
it with a new gst_vaapi_decoder_get_codec_state() function. This makes
it possible to drop picture size (width, height) information, framerate
(fps_n, fps_d) information, pixel aspect ratio (par_n, par_d) information,
and interlace mode (is_interlaced field).

This is a new API with backwards compatibility maintained. In particular,
gst_vaapi_decoder_get_caps() is still available.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
14a6e0f629 decoder: update gst_vaapi_decoder_get_surface() semantics.
Align gst_vaapi_decoder_get_surface() semantics with the rest of the
API. That is, return a GstVaapiDecoderStatus and the decoded surface
as a handle to GstVaapiSurfaceProxy in parameter.

This is an API/ABI change.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
798e84bd93 decoder: use standard helper functions.
Use g_clear_object(), gst_buffer_replace() and gst_caps_replace()
whenever necessary.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
6bed9ebe0f decoder: expose new parse/decode API.
Introduce new decoding process whereby a GstVideoCodecFrame is created
first. Next, input stream buffers are accumulated into a GstAdapter,
that is then passed to the _parse() function. The GstVaapiDecoder object
accumulates all parsed units and when a complete frame or field is
detected, that GstVideoCodecFrame is passed to the _decode() function.

Ultimately, the caller receives a GstVaapiSurfaceProxy if decoding
process was successful.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
ea9703362c decoder: add {start,end}_frame() hooks.
The start_frame() hook is called prior to traversing all decode-units
for decoding. The unit argument represents the first slice in the frame.
Some codecs (e.g. H.264) need to wait for the first slice in order to
determine the actual VA context parameters.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
66cc8754fc decoder: add new GstVaapiDecoder API.
Split decoding process into two steps: (i) parse incoming bitstreams
into simple decoder-units until the frame or field is complete; and
(ii) decode the whole frame or field at once.

This is an ABI change.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
f5e6444b78 decoder: add new "decoder-frame" object.
Introduce a new GstVaapiDecoderFrame that is just a list of decoder units
(GstVaapiDecoderUnit objects) that constitute a frame. This object is just
an extension to GstVideoCodecFrame for VA decoder purposes. It is available
as the user-data member element.

This is a libgstvaapi internal object.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
49dbb9af50 decoder: add new "decoder-unit" object.
Introduce GstVaapiDecoderUnit which represents a fragment of the source
stream to be decoded. For instance, a decode-unit will be a NAL unit for
H.264 streams, an EBDU for VC-1 streams, and a video packet for MPEG-2
streams.

This is a libgstvaapi internal object.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
74533de9c6 Port GstVaapiFrameStore to GstVaapiMiniObject. 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
f88374d642 Port codec objects to GstVaapiMiniObject. 2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
1130a46837 surfaceproxy: port to GstVaapiMiniObject.
GstVaapiSurfaceProxy does not use any particular functionality from
GObject. Actually, it only needs a basic object type with reference
counting.

This is an API and ABI change.
2012-12-18 15:31:50 +01:00
Gwenole Beauchesne
44945ac9eb Add GstVaapiMiniObject.
Introduce a new reference counted object that is very lightweight and
also provides flags and user-data functionalities. Initialization and
finalization times are reduced by up to a factor 5x vs GstMiniObject
from GStreamer 0.10 stack.

This is a libgstvaapi internal object.
2012-12-18 15:31:50 +01:00
Gwenole Beauchesne
0e5895c318 tests: add test for MPEG-4:2 decoding. 2012-12-17 14:33:52 +01:00
Gwenole Beauchesne
1bd5ab4db3 h264: initialize VA context before allocating the first slice.
Fix decode_slice() to ensure a VA context exists prior to creating a
new GstVaapiSliceH264, which invokes vaCreateBuffer() with some VA
context ID. i.e. the latter was not initialized, thus causing failures
on Cedar Trail for example.
2012-12-17 14:33:52 +01:00
Zhao Halley
8e8dc03677 configure: install plugin elements in GST_PLUGIN_PATH, if set.
If GST_PLUGIN_PATH environment variable exists and points to a valid
directory, then use it as the system installation path for gst-vaapi
plugin elements.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-12-17 14:33:52 +01:00
Gwenole Beauchesne
4c01e25a15 configure: downgrade glib required version to 2.28. 2012-12-17 14:33:52 +01:00
Gwenole Beauchesne
48f4f0564e libs: fix compatibility with glib 2.28.
Always prefer non deprecated APIs by default and provide compatibility
glue for older glib versions when necessary.
2012-12-17 14:33:52 +01:00
Gwenole Beauchesne
97c3b2ddff libs: use glib >= 2.32 semantics for mutexes.
Use glib >= 2.32 semantics for GMutex and GRecMutex wrt. initialization
and termination. Basically, the new mutex objects can be used as static
mutex objects from the deprecated APIs, e.g. GStaticMutex and GStaticRecMutex.
2012-12-17 14:33:45 +01:00
Gwenole Beauchesne
1d669a3e12 libs: only export gst_vaapi_*() symbols.
This fixes symbol clashes between the gst-vaapi built-in codecparsers/
library and the system-provided one, mainly used by videoparses/. Now,
only symbols with the gst_vaapi_* prefix will be exported, if they are
not marked as "hidden" to libgstvaapi.
2012-12-17 14:12:15 +01:00
Gwenole Beauchesne
df1eb6e01e vaapiupload: reset direct-rendering to zero when changing caps.
Make sure to reset direct-rendering flag to zero when caps are changed,
and only derive it to one when the next checks succeed.
2012-11-20 18:21:41 +01:00
Gwenole Beauchesne
237a4adb0c vaapiupload: fix sink caps to report the supported set of YUV caps.
Try to allocate the GstVaapiUploader helper object prior to listing the
supported image formats. Otherwise, only a single generic caps is output
with no particular pixel format referenced in there.
2012-11-20 16:04:51 +01:00
Zhao Halley
c2a610735f vaapiupload: use new GstVaapiUploader helper.
Use GstVaapiUploader helper that automatically handles direct rendering
mode, thus making the "direct-rendering" property obsolete and hence it
is now removed.

The "direct-rendering" level 2, i.e. exposing VA surface buffers, was never
really well supported and it could actually trigger degraded performance.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-11-20 16:04:51 +01:00
Gwenole Beauchesne
d4a4a49168 vaapisink: compute and expose the supported set of YUV caps.
Make vaapisink expose only the set of supported caps for raw YUV buffers.

Add gst_vaapi_uploader_get_caps() helper function to determine the set
of supported YUV caps as source (for images). This function actually
tries to zero and upload each image to a 64x64 test surface. Of course,
this relies on VA drivers to not claim success if vaPutImage() is not
correctly supported.
2012-11-20 16:04:51 +01:00
Gwenole Beauchesne
499e0dd981 vaapisink: add support for raw YUV buffers.
Add new GstVaapiUploader helper to upload raw YUV buffers to VA surfaces.
It is up to the caller to negotiate source caps (for images) and output
caps (for surfaces). gst_vaapi_uploader_has_direct_rendering() is available
to help decide between the creation of a GstVaapiVideoBuffer or a regular
GstBuffer on sink pads.

Signed-off-by: Zhao Halley <halley.zhao@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-11-20 16:04:51 +01:00
Gwenole Beauchesne
c38c0853eb image: fix GstVaapiImage map and unmap.
Fix gst_vaapi_image_map() to return TRUE and the GstVaapiImageRaw
structure correctly filled in if the image was already mapped.
Likewise, make gst_vaapi_image_unmap() return TRUE if the image
was already unmapped.
2012-11-20 14:38:19 +01:00
Wind Yuan
5fac9d4b55 videobuffer: fix memory leak for surface and image.
Fix reference leak of surface and image in GstVaapiVideoBuffer wrapper,
thus resulting on actual memory leak of GstVaapiImage when using them
for downloads/uploads from VA surfaces and more specifically surfaces
when the pipeline is shutdown. i.e. vaTerminate() was never called
because the resources were not unreferenced, and thus not deallocated
in the end.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-11-19 11:22:03 +01:00
Gwenole Beauchesne
a9f8e17ec5 NEWS: updates. 2012-11-19 10:09:20 +01:00
Gwenole Beauchesne
cb0da4ed7a h264: fix picture size in macroblocks.
The picture size signalled by sps->{width,height} is the actual size with
cropping applied, not the original size derived from pic_width_in_mbs_minus1
and pic_height_in_map_units_minus1. VA driver expects that original size,
uncropped.

There is another issue pending: frame cropping information needs to be
taken care of.
2012-11-16 18:05:28 +01:00
Gwenole Beauchesne
9ab3ce2932 codecparsers: always build parserutils first.
Fix commit 18245b4 so that to link and build parserutils.[ch] first.
This is needed since that's the common dependency for actual codec
parsers (gstvc1parser.c for instance).
2012-11-16 16:18:52 +01:00
Gwenole Beauchesne
18245b484d codecparsers: always build the VC-1 parser library.
... this is useful to make sure pixel-aspect-ratio and framerate
information are correctly parsed since we have no means to detect
that at configure time.
2012-11-15 17:50:45 +01:00
Sreerenj Balachandran
9367c8ea58 mpeg2: fix PAR calculation from commit bd11bae.
Invoke gst_mpeg_video_finalise_mpeg2_sequence_header() to get the
correct PAR values. While doing so, require a newer version of the
bitstream parser library.

Note: it may be necessary to also parse the Sequence_Display_Extension()
header.

Signed-off-by: Sreerenj Balachandran <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-11-15 16:23:27 +01:00
Gwenole Beauchesne
ca8b5035de Fix build with the GNU gold linker.
In particular, fix libgstvaapi-glx DSO dependencies to include libgstbase
and libgstvideo libs, e.g. for gst_video_buffer_get_overlay_composition().
2012-11-15 15:02:23 +01:00
Rob Bradford
b794f6cb92 wayland: port to 1.0 version of the protocol.
This patch updates to relect the 1.0 version of the protocol. The main
changes are the switch to wl_registry for global object notifications
and the way that the event queue and file descriptor is processed.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-11-15 14:31:33 +01:00
Gwenole Beauchesne
1e506ad6ee h264: fix incorrect integration of previous commit (4d31e1e).
git am got confused somehow, though the end result doesn't change at
all since we require both SPS and PPS to be parsed prior to decoding
the first slice.
2012-11-14 19:23:32 +01:00
Gwenole Beauchesne
4d31e1e58a h264: start decoding slices after first SPS/PPS activation.
Only start decoding slices when at least one SPS and PPS got activated.
This fixes cases when a source represents a substream of another stream
and no SPS and PPS was inserted before the first slice of the generated
substream.
2012-11-14 18:55:05 +01:00
Gwenole Beauchesne
1fc397affd h264: fix VAPictureParameterBufferH264.ReferenceFrames[] construction.
... for interlaced streams. The short_ref[] and long_ref[] arrays may
contain up to 32 fields but VA ReferenceFrames[] array expects up to
16 reference frames, thus including both fields.
2012-11-14 17:53:57 +01:00
Gwenole Beauchesne
f196605fc8 h264: fix interlaced stream decoding with MMCO.
Fix decoding of interlaced streams when adaptive_ref_pic_marking_mode_flag
is equal to 1, i.e. when memory management control operations are used. In
particular, when field_pic_flag is set to 0, the new reference flags shall
be applied to both fields.
2012-11-14 17:53:57 +01:00
Gwenole Beauchesne
2c13b17cdb h264: add initial support for interlaced streams.
Decoded frames are only output when they are complete, i.e. when both
fields are decoded. This also means that the "interlaced" caps is not
propagated to vaapipostproc or vaapisink elements. Another limitation
is that interlaced bitstreams with MMCO are unlikely to work.
2012-11-14 17:53:55 +01:00