5 years ago0.5.1. 0.5.1
Gwenole Beauchesne [Wed, 30 Jan 2013 08:37:38 +0000 (09:37 +0100)]

5 years agompeg2: implement GstVaapiDecoder::flush() as a DPB flush.
Sreerenj Balachandran [Wed, 23 Jan 2013 22:48:26 +0000 (00:48 +0200)]
mpeg2: implement GstVaapiDecoder::flush() as a DPB flush.

5 years agodecoder: fix documentation for GstVaapiDecoderFrame.
Sreerenj Balachandran [Thu, 24 Jan 2013 15:34:43 +0000 (17:34 +0200)]
decoder: fix documentation for GstVaapiDecoderFrame.

Drop superfluous reference to prev_slice member.

5 years agodecoder: assume current frame is complete at end-of-stream.
Gwenole Beauchesne [Tue, 29 Jan 2013 15:18:13 +0000 (16:18 +0100)]
decoder: assume current frame is complete at end-of-stream.

Assume we got a complete frame when the end-of-stream is reached and that
the current codec frame contains at least one slice data unit.

5 years agolegal: fix year for some copyright notices (2013).
Gwenole Beauchesne [Tue, 29 Jan 2013 13:14:45 +0000 (14:14 +0100)]
legal: fix year for some copyright notices (2013).

5 years agolegal: fix year for some copyright notices (2012).
Gwenole Beauchesne [Tue, 29 Jan 2013 13:03:27 +0000 (14:03 +0100)]
legal: fix year for some copyright notices (2012).

5 years agolegal: add Intel copyright on modified files.
Gwenole Beauchesne [Tue, 29 Jan 2013 13:00:04 +0000 (14:00 +0100)]
legal: add Intel copyright on modified files.

5 years agoNEWS: updates.
Gwenole Beauchesne [Tue, 29 Jan 2013 12:37:41 +0000 (13:37 +0100)]
NEWS: updates.

5 years agowayland: use a local event queue to avoid lock contention.
Gwenole Beauchesne [Mon, 28 Jan 2013 17:09:09 +0000 (18:09 +0100)]
wayland: use a local event queue to avoid lock contention.

This improves performance when rendering several surfaces from within
the same process. e.g. a tee of vaapidecode'd buffers to vaapisink.

5 years agowayland: fix thread-safe issues.
Gwenole Beauchesne [Mon, 28 Jan 2013 16:28:58 +0000 (17:28 +0100)]
wayland: fix thread-safe issues.

The Wayland API is not fully thread-safe and client applications shall
perform locking themselves on key functions. Besides, make sure to
release the lock if the _render() function fails.

5 years agowayland: really wait until the pending redraw completed.
Gwenole Beauchesne [Mon, 28 Jan 2013 15:37:28 +0000 (16:37 +0100)]
wayland: really wait until the pending redraw completed.

Introduce gst_vaapi_window_wayland_sync() helper function to wait for
the completion of the redraw request. Use it in _render() function to
actually block until the previous draw request is completed.

5 years agowayland: fix frame_redraw callback.
Gwenole Beauchesne [Wed, 23 Jan 2013 09:10:35 +0000 (10:10 +0100)]
wayland: fix frame_redraw callback.

The redraw callback needs to be attached to the surface prior to the
commit. Otherwise, the callback notifies the next surface repaint,
which is not the desired behaviour. i.e. we want to be notified for
the surface we have just filled.

Another isse was the redraw_pending was reset before the actual completion
of the frame redraw callback function, thus causing concurrency issues.
e.g. the callback could have been called again, but with a NULL buffer.

5 years agowayland: fix display sharing.
Gwenole Beauchesne [Mon, 28 Jan 2013 13:45:28 +0000 (14:45 +0100)]
wayland: fix display sharing.

When the Wayland display is shared, we still have to create our own local
shell and compositor objects, since they are not propagated from the cache.
Likewise, we also need to determine the display size or vaapisink would
fail to account for the display aspect ratio, and will try to create a 0x0

5 years agocodecparsers: update to gst-vaapi-branch commit 21a098e.
Gwenole Beauchesne [Thu, 24 Jan 2013 16:38:53 +0000 (17:38 +0100)]
codecparsers: update to gst-vaapi-branch commit 21a098e.

21a098e vc1: fix bitplanes decoding (DIFF6 or NORM6) [residual]
f8c836a vc1: fix bitplanes decoding (DIFF6 or NORM6)

5 years agovc1: handle frames with multiple slices.
Gwenole Beauchesne [Wed, 23 Jan 2013 15:38:24 +0000 (16:38 +0100)]
vc1: handle frames with multiple slices.

5 years agocodecparsers: update to gst-vaapi-branch commit 3fba492.
Gwenole Beauchesne [Wed, 23 Jan 2013 16:01:34 +0000 (17:01 +0100)]
codecparsers: update to gst-vaapi-branch commit 3fba492.

3fba492 vc1: add API to parse slice headers

5 years agovc1: handle CLOSED_ENTRY.
Gwenole Beauchesne [Wed, 23 Jan 2013 10:11:25 +0000 (11:11 +0100)]
vc1: handle CLOSED_ENTRY.

When CLOSED_ENTRY == 0, and if the B pictures that follow an entry-point
lack a reference anchor picture, these B pictures shall be discarded.

5 years agovc1: cope with latest codecparser changes.
Gwenole Beauchesne [Wed, 23 Jan 2013 09:25:52 +0000 (10:25 +0100)]
vc1: cope with latest codecparser changes.

Fix build with newer VC-1 codecparser where dqsbedge was renamed to
dqbedge, and now represents either DQSBEDGE or DQDBEDGE depending on
the actual value of DQPROFILE.

5 years agocodecparsers: update to gst-vaapi-branch commit 3d2c67c.
Gwenole Beauchesne [Wed, 23 Jan 2013 09:24:04 +0000 (10:24 +0100)]
codecparsers: update to gst-vaapi-branch commit 3d2c67c.

3d2c67c vc1: simplify GstVC1VopDquant structure

5 years agocodecparsers: update to gst-vaapi-branch commit 5d33da8.
Gwenole Beauchesne [Tue, 22 Jan 2013 09:51:40 +0000 (10:51 +0100)]
codecparsers: update to gst-vaapi-branch commit 5d33da8.

5d33da8 vc1: fix bitplanes decoding
562bdc4 vc1: fix VOPDQUANT parser for DQUANT == 2
0b13d2b vc1: fix calculation of ALTPQUANT
ba88e63 vc1: fix parser for DQPROFILE in VOPDQUANT

5 years agovc1: fix size of encapsulated BDU.
Gwenole Beauchesne [Tue, 22 Jan 2013 14:47:09 +0000 (15:47 +0100)]
vc1: fix size of encapsulated BDU.

Fix size of encapsulated BDUs since GstVC1BDU.size actually represents
the size of the BDU data, starting from offset, i.e. after any start
code is parsed.

This fixes a buffer overflow during the unescaping process.

5 years agovc1: fix decoding of WMV3 videos in AVI format.
Wind Yuan [Fri, 11 Jan 2013 09:08:00 +0000 (17:08 +0800)]
vc1: fix decoding of WMV3 videos in AVI format.

The AVI demuxer (avidemux) does not set a proper "format" attribute
to the generated caps. So, try to recover the video codec format from
the "wmvversion" property instead.

Signed-off-by: Gwenole Beauchesne <>
5 years agovc1: review and report errors accordingly.
Gwenole Beauchesne [Tue, 22 Jan 2013 12:28:13 +0000 (13:28 +0100)]
vc1: review and report errors accordingly.

Use GST_ERROR() to report real errors instead of hiding them into

5 years agovc1: don't create GstBuffers for all decoder units.
Gwenole Beauchesne [Tue, 22 Jan 2013 12:50:39 +0000 (13:50 +0100)]
vc1: don't create GstBuffers for all decoder units.

Don't create temporary GstBuffers for all decoder units, even if they
are lightweight "sub-buffers", since it is not really necessary to keep
the buffer data around.

5 years agovc1: implement flush() hook.
Gwenole Beauchesne [Tue, 22 Jan 2013 15:03:18 +0000 (16:03 +0100)]
vc1: implement flush() hook.

Make it a simple DPB flush.

5 years agovc1: implement {start,end}_frame() hooks.
Gwenole Beauchesne [Tue, 22 Jan 2013 12:44:32 +0000 (13:44 +0100)]
vc1: 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.

5 years agovc1: fix next POC for new sequence layers.
Gwenole Beauchesne [Tue, 22 Jan 2013 08:30:04 +0000 (09:30 +0100)]
vc1: fix next POC for new sequence layers.

Fix next POC when a new sequence layer is reached. At this point, we
need to reset any previous reference picture, i.e. non B-frame.

5 years agovc1: port to common GstVaapiDpb interface.
Sreerenj Balachandran [Thu, 2 Aug 2012 14:15:26 +0000 (17:15 +0300)]
vc1: port to common GstVaapiDpb interface.

Use GstVaapiDpb interface instead of maintaining our own prev and next
picture pointers. While doing so, try to derive a sensible POC value.

Signed-off-by: Gwenole Beauchesne <>
5 years agovc1: fix decode_sequence_end() to return success, not EOS.
Gwenole Beauchesne [Tue, 15 Jan 2013 16:10:56 +0000 (17:10 +0100)]
vc1: fix decode_sequence_end() to return success, not EOS.

5 years agodecoder: simplify gst_vaapi_decoder_get_surface().
Gwenole Beauchesne [Fri, 18 Jan 2013 16:00:18 +0000 (17:00 +0100)]
decoder: simplify gst_vaapi_decoder_get_surface().

Avoid extraenous branches, i.e. immediately return with success once we
have a decoded frame available.

5 years agodecoder: optimize and clean decode_step() up.
Gwenole Beauchesne [Fri, 18 Jan 2013 15:56:15 +0000 (16:56 +0100)]
decoder: optimize and clean decode_step() up.

Avoid usage of goto. Simplify decode_step() process to first accumulate all
pending buffers into the GstAdapter, and then parse and decode units from
that input adapter. Stop the process once a frame is fully decoded or an
error occurred.

5 years agodisplay: move "vaapi" debug init to libgstvaapi_init_once().
Gwenole Beauchesne [Fri, 18 Jan 2013 13:46:23 +0000 (14:46 +0100)]
display: move "vaapi" debug init to libgstvaapi_init_once().

5 years agodisplay: dump gstreamer-vaapi version for debugging purposes.
Gwenole Beauchesne [Fri, 18 Jan 2013 13:17:34 +0000 (14:17 +0100)]
display: dump gstreamer-vaapi version for debugging purposes.

5 years agotests: simple-decoder: fix build with built-in videoutils.
Gwenole Beauchesne [Fri, 18 Jan 2013 13:30:48 +0000 (14:30 +0100)]
tests: simple-decoder: fix build with built-in videoutils.

Fix build with built-in videoutils, i.e. when system GStreamer installation
does not know about GstVideoDecoder API.

5 years agotests: simple-decoder: flush decoded frames at EOS.
Gwenole Beauchesne [Fri, 18 Jan 2013 09:35:44 +0000 (10:35 +0100)]
tests: simple-decoder: flush decoded frames at EOS.

Flush the remaining decoded frames when an end-of-stream is reached.

5 years agotests: simple-decoder: drop use of GstVaapiVideoMeta.
Gwenole Beauchesne [Fri, 18 Jan 2013 09:25:14 +0000 (10:25 +0100)]
tests: simple-decoder: drop use of GstVaapiVideoMeta.

Don't use GstVaapiVideoMeta since that object is not guaranteed to live
in libgstvaapi forever. Rather, that'd move to plugin elements at some

5 years agotests: simple-decoder: add benchmark mode.
Gwenole Beauchesne [Wed, 16 Jan 2013 12:53:43 +0000 (13:53 +0100)]
tests: simple-decoder: add benchmark mode.

Add --benchmark option to enable benchmark mode where rendering is not
synchronized with presentation timestamps of the decoded surfaces.

5 years agotests: simple-decoder: honour framerate from the bitstream.
Gwenole Beauchesne [Wed, 16 Jan 2013 12:29:06 +0000 (13:29 +0100)]
tests: simple-decoder: honour framerate from the bitstream.

Try to honour the framerate from the bitstream, or cap the playback to
60 fps by default.

5 years agotests: simple-decoder: set window size to the surface dimensions.
Gwenole Beauchesne [Tue, 15 Jan 2013 17:49:28 +0000 (18:49 +0100)]
tests: simple-decoder: set window size to the surface dimensions.

Set the window size to the decoded surface dimensions, if the user has
not requested the application to run in full-screen mode. Besides, no
effort is made to preserve aspect ratio or to center the video within
the mapped window.

5 years agotests: add simple decoder application.
Gwenole Beauchesne [Tue, 15 Jan 2013 16:33:18 +0000 (17:33 +0100)]
tests: add simple decoder application.

Add simple decoder application to show off decoding capabilities from
raw bitstreams, for debugging or performance evaluation purposes.

5 years agotests: add codec helper utils.
Gwenole Beauchesne [Tue, 15 Jan 2013 16:30:57 +0000 (17:30 +0100)]
tests: add codec helper utils.

Add helper functions to determine the codec type from a specific file
or utility functions to convert from codec type to GstCaps or from
codec name to codec type.

5 years agotests: allow fullscreen mode.
Gwenole Beauchesne [Tue, 15 Jan 2013 16:47:13 +0000 (17:47 +0100)]
tests: allow fullscreen mode.

Add new --fullscreen|-f option to create new windows in fullscreen mode.

5 years agoh264: implement GstVaapiDecoder::flush() as a DPB flush.
Gwenole Beauchesne [Thu, 17 Jan 2013 17:35:58 +0000 (18:35 +0100)]
h264: implement GstVaapiDecoder::flush() as a DPB flush.

5 years agoh264: handle end-of-stream NALU.
Gwenole Beauchesne [Thu, 17 Jan 2013 17:07:03 +0000 (18:07 +0100)]
h264: handle end-of-stream NALU.

Handle <end-of-stream> NAL unit to actually flush any pending picture
from the DPB.

5 years agovaapidecode: handle EOS events.
Gwenole Beauchesne [Thu, 17 Jan 2013 17:22:49 +0000 (18:22 +0100)]
vaapidecode: handle EOS events.

Flush all decoded frames to downstream when EOS is received. This is
performed by implementing GstVideoDecoder::finish() hook.

5 years agovaapidecode: split gvd_handle_frame() into decode/push frames.
Gwenole Beauchesne [Thu, 17 Jan 2013 17:19:14 +0000 (18:19 +0100)]
vaapidecode: split gvd_handle_frame() into decode/push frames.

Split GstVideoDecoder::handle_frame() implementation into two functions:
(i) one for decoding the provided GstVideoCodecFrame and (ii) another one
for purging all decoded frames and submit them downstream.

5 years agodecoder: add GstVaapiDecoder::flush() hook.
Gwenole Beauchesne [Thu, 17 Jan 2013 17:33:32 +0000 (18:33 +0100)]
decoder: add GstVaapiDecoder::flush() hook.

5 years agodecoder: fix check for end-of-stream in raw API mode.
Gwenole Beauchesne [Tue, 15 Jan 2013 16:21:50 +0000 (17:21 +0100)]
decoder: fix check for end-of-stream in raw API mode.

Make sure to immediately return GST_VAAPI_DECODER_STATUS_END_OF_STREAM
if the end-of-stream was already reached at the previous iteration.

5 years agodecoder: make decode_step() return once the frame is decoded.
Gwenole Beauchesne [Tue, 15 Jan 2013 15:55:29 +0000 (16:55 +0100)]
decoder: make decode_step() return once the frame is decoded.

Make sure we always have a free surface left to use for decoding the
current frame. This means that decode_step() has to return once a frame
gets decoded. If the current adapter contains more buffers with valid
frames, they will get parsed and decoded on subsequent iterations.

5 years agocodecparsers: update to gst-vaapi-branch commit b47983a.
Gwenole Beauchesne [Thu, 17 Jan 2013 14:47:17 +0000 (15:47 +0100)]
codecparsers: update to gst-vaapi-branch commit b47983a.

8840c2d h264: zero-initialize SPS VUI parameters

5 years agoBump version for development.
Gwenole Beauchesne [Tue, 15 Jan 2013 08:21:36 +0000 (09:21 +0100)]
Bump version for development.

5 years ago0.5.0. 0.5.0
Gwenole Beauchesne [Tue, 15 Jan 2013 08:21:08 +0000 (09:21 +0100)]

5 years agodocs: expose new interfaces.
Gwenole Beauchesne [Mon, 14 Jan 2013 10:48:58 +0000 (11:48 +0100)]
docs: expose new interfaces.

5 years agoNEWS: updates.
Gwenole Beauchesne [Mon, 14 Jan 2013 11:58:20 +0000 (12:58 +0100)]
NEWS: updates.

5 years agodpb: cosmetics (clean-ups).
Gwenole Beauchesne [Mon, 14 Jan 2013 09:58:49 +0000 (10:58 +0100)]
dpb: cosmetics (clean-ups).

5 years agodpb: port to GstVaapiMiniObject.
Gwenole Beauchesne [Mon, 14 Jan 2013 09:46:25 +0000 (10:46 +0100)]
dpb: port to GstVaapiMiniObject.

5 years agodpb: drop GstVaapiDpb2 interface, keep only one class.
Gwenole Beauchesne [Mon, 14 Jan 2013 09:21:53 +0000 (10:21 +0100)]
dpb: drop GstVaapiDpb2 interface, keep only one class.

Keep only one DPB interface and rename gst_vaapi_dpb2_get_references()
to gst_vaapi_dpb_get_neighbours() so that to retrieve pictures in DPB
around the specified picture POC.

5 years agodpb: rename GstVaapiDpbMpeg2 to GstVaapiDpb2.
Sreerenj Balachandran [Thu, 2 Aug 2012 12:56:54 +0000 (15:56 +0300)]
dpb: rename GstVaapiDpbMpeg2 to GstVaapiDpb2.

Move GstVaapiDpbMpeg2 API to a more generic version that could also be
useful to other decoders that require 2 reference pictures, e.g. VC-1.

Signed-off-by: Gwenole Beauchesne <>
5 years agoBump version for pre-release.
Gwenole Beauchesne [Fri, 11 Jan 2013 15:04:30 +0000 (16:04 +0100)]
Bump version for pre-release.

5 years agoNEWS: updates.
Gwenole Beauchesne [Fri, 11 Jan 2013 14:57:09 +0000 (15:57 +0100)]
NEWS: updates.

5 years agooverlay: fix build without advanced GstVideoOverlayFormatFlags.
Holger Kaelberer [Fri, 20 Jul 2012 10:36:33 +0000 (12:36 +0200)]
overlay: fix build without advanced GstVideoOverlayFormatFlags.

Check for global-alpha support in GstVideoOverlayComposition API.

Signed-off-by: Gwenole Beauchesne <>
5 years agotests: add support for global-alpha subpictures.
Gwenole Beauchesne [Fri, 4 Jan 2013 09:19:56 +0000 (10:19 +0100)]
tests: add support for global-alpha subpictures.

Add --global-alpha option to test-subpicture.

5 years agotests: use GstVideoOverlayComposition API for subpicture test.
Gwenole Beauchesne [Thu, 10 Jan 2013 12:09:28 +0000 (13:09 +0100)]
tests: use GstVideoOverlayComposition API for subpicture test.

5 years agotests: use common decoder helpers for subpicture test.
Gwenole Beauchesne [Thu, 10 Jan 2013 10:26:17 +0000 (11:26 +0100)]
tests: use common decoder helpers for subpicture test.

Use common decoder helpers for subpicture test, thus allowing to decode
sample images in an alternate format.

5 years agotests: add decoder helpers.
Gwenole Beauchesne [Thu, 10 Jan 2013 10:22:38 +0000 (11:22 +0100)]
tests: add decoder helpers.

5 years agooverlay: fix ordering of composition layers.
Gwenole Beauchesne [Fri, 11 Jan 2013 14:19:45 +0000 (15:19 +0100)]
overlay: fix ordering of composition layers.

Make sure to maintain the association order of composition layers when
GstVideoOverlayRectangle objects are kept around (cached).

5 years agooverlay: fix support for global-alpha.
Holger Kaelberer [Tue, 15 May 2012 08:24:08 +0000 (10:24 +0200)]
overlay: fix support for global-alpha.

Fix support for global-alpha subpictures. The previous changes brought
the ability to check for GstVideoOverlayRectangle changes by comparing
the underlying pixel buffer pointers. If sequence number and pixel data
did not change, then this is an indication that only the global-alpha
value changed. Now, try to update the underlying VA subpicture global-alpha

Signed-off-by: Gwenole Beauchesne <>
5 years agooverlay: detect render-rect changes.
Gwenole Beauchesne [Fri, 11 Jan 2013 10:53:05 +0000 (11:53 +0100)]
overlay: detect render-rect changes.

Don't re-upload VA subpicture if only the render rectangle changed.
Rather deassociate the subpicture and re-associate it with the new
render rectangle.

5 years agooverlay: fix check for pixels buffer change.
Gwenole Beauchesne [Fri, 11 Jan 2013 10:12:26 +0000 (11:12 +0100)]
overlay: fix check for pixels buffer change.

A GstVideoOverlayRectangle is created whenever the underlying pixels data
change. However, when global-alpha is supported, it is possible to re-use
the same GstVideoOverlayRectangle but with a change to the global-alpha
value. This process causes a change of sequence number, so we can no longer
check for that.

Still, if sequence numbers did not change, then there was no change in
global-alpha either. So, we need a way to compare the underlying GstBuffer
pointers. There is no API to retrieve the original pixels buffer from
a GstVideoOverlayRectangle. So, we use the following heuristics:

1. Use gst_video_overlay_rectangle_get_pixels_unscaled_argb() with the same
   format flags from which the GstVideoOverlayRectangle was created. This
   will work if there was no prior consumer of the GstVideoOverlayRectangle
   with alternate (non-"native") format flags.

2. In overlay_rectangle_has_changed_pixels(), we have to use the same
   gst_video_overlay_rectangle_get_pixels_unscaled_argb() function but
   with flags that match the subpicture. This is needed to cope with
   platforms that don't support global-alpha in HW, so the gst-video
   layer takes care of that and fixes this up with a possibly new
   GstBuffer, and hence pixels data (or) in-place by caching the current
   global-alpha value applied. So we have to determine the rectangle
   was previously used, based on what previous flags were used to
   retrieve the ARGB pixels buffer.

5 years agooverlay: optimize cache at the GstVideoOverlayRectangle level.
Gwenole Beauchesne [Thu, 10 Jan 2013 17:42:37 +0000 (18:42 +0100)]
overlay: optimize cache at the GstVideoOverlayRectangle level.

We previously assumed that an overlay composition changed if the number
of overlay rectangles in there actually changed, or that the rectangle
was updated, and thus its seqnum was also updated.

Now, we can cope with cases where the GstVideoOverlayComposition grew
by one or a few more overlay rectangles, and the initial overlay rectangles
are kept as is.

5 years agooverlay: simplify caching of GstVideoOverlayComposition objects.
Gwenole Beauchesne [Thu, 10 Jan 2013 12:41:39 +0000 (13:41 +0100)]
overlay: simplify caching of GstVideoOverlayComposition objects.

Create the GPtrArray once in the _init() function and destroy it only
in the _finalize() function. Then use overlay_clear() to remove all
subpicture associations for intermediate updates, don't recreate the

Make GstVaapiOverlayRectangle a reference counted object. Also make
sure that overlay_rectangle_new() actually creates and associates the
VA subpicture.

5 years agooverlay: add support for global-alpha.
Holger Kaelberer [Tue, 15 May 2012 08:24:08 +0000 (10:24 +0200)]
overlay: add support for global-alpha.

Handle global-alpha from GstVideoOverlayComposition API. Likewise,
the same code path could also work for premultiplied-alpha but this
was not tested.

Signed-off-by: Gwenole Beauchesne <>
5 years agosubpicture: add support for global-alpha.
Holger Kaelberer [Tue, 15 May 2012 08:24:08 +0000 (10:24 +0200)]
subpicture: add support for global-alpha.

Add the necessary helpers in GstVaapiDisplay to determine whether subpictures
with global alpha are supported or not. Also add accessors in GstVaapiSubpicture
to address this feature.

Signed-off-by: Gwenole Beauchesne <>
5 years agosubpicture: add premultiplied-alpha and global-alpha feature flags.
Gwenole Beauchesne [Fri, 4 Jan 2013 08:41:25 +0000 (09:41 +0100)]
subpicture: add premultiplied-alpha and global-alpha feature flags.

Add premultiplied-alpha and global-alpha feature flags, along with converters
between VA-API and gstreamer-vaapi definitions. Another round of helpers is
also necessary for GstVideoOverlayComposition API.

5 years agodisplay: allow image/subpicture formats with additional flags.
Gwenole Beauchesne [Thu, 3 Jan 2013 17:02:49 +0000 (18:02 +0100)]
display: allow image/subpicture formats with additional flags.

Introduce new GstVaapiFormatInfo to store the actual GstVaapiImageFormat
and any additional flags needed. Currently, all flags are set to zero.

5 years agolibs: fix build of submodule wrappers.
Gwenole Beauchesne [Fri, 11 Jan 2013 12:34:45 +0000 (13:34 +0100)]
libs: fix build of submodule wrappers.

Make sure to build codecparsers/ and videoutils/ sources against the
newly generated headers when out-of-source builds are used.

5 years agoconfigure: fix checks for packages installed in non-standard roots.
Gwenole Beauchesne [Fri, 11 Jan 2013 13:11:39 +0000 (14:11 +0100)]
configure: fix checks for packages installed in non-standard roots.

5 years agodecoder: fix mini object implementation on 64-bit systems.
Gwenole Beauchesne [Thu, 10 Jan 2013 09:12:25 +0000 (10:12 +0100)]
decoder: fix mini object implementation on 64-bit systems.

Use GPOINTER_TO_SIZE() instead of GPOINTER_TO_UINT() while manipulating
pointers. The latter is meant to be 32-bit only, not uintptr_t like size.
Only a gsize can hold all bits of a pointer.

Thanks to Ouping Zhang for spotting this error.

5 years agompeg2: optimize scan for the end of the frame.
Gwenole Beauchesne [Wed, 9 Jan 2013 15:05:39 +0000 (16:05 +0100)]
mpeg2: optimize scan for the end of the frame.

Heuristic: if the second start-code is available, check whether that
one marks the start of a new frame because e.g. this is a sequence
or picture header. This doesn't save much, since we already cache the

5 years agompeg2: optimize scan for start codes.
Gwenole Beauchesne [Wed, 9 Jan 2013 12:44:18 +0000 (13:44 +0100)]
mpeg2: optimize scan for start codes.

Accelerate scan for start codes by skipping up to 3 bytes per iteration.
A start code prefix is defined by the following bytes: 00 00 01. Thus,
for any group of 3 bytes (xx yy zz), we have the following possible cases:

  1. If zz != 1, this cannot be a start code, then skip 3 bytes;
  2. If yy != 0, this cannot be a start code, then skip 2 bytes;
  3. If xx != 0 or zz != 1, this cannot be a start code, then skip 1 byte;
  4. xx == 00, yy == 00, zz == 1, we have match!

This algorithm requires to peek bytes from the adapter. This increases the
amount of bytes copied to a temporary buffer, but this process is much faster
than scanning for all the bytes and using shift/masks. So, overall, this is
a win.

5 years agompeg2: drop useless gst_adapter_peek().
Gwenole Beauchesne [Tue, 8 Jan 2013 15:41:44 +0000 (16:41 +0100)]
mpeg2: drop useless gst_adapter_peek().

Drop useless gst_adapter_peek() since the returned buffer was not used
and this could incur superfluous memcpy().

5 years agompeg2: cosmetics: move parse_slice() down.
Gwenole Beauchesne [Mon, 7 Jan 2013 15:07:38 +0000 (16:07 +0100)]
mpeg2: cosmetics: move parse_slice() down.

5 years agompeg2: avoid too many allocations of parser info objects.
Gwenole Beauchesne [Mon, 7 Jan 2013 14:24:51 +0000 (15:24 +0100)]
mpeg2: avoid too many allocations of parser info objects.

Move parsing back to decoding step, but keep functions separate for now.
This is needed for future optimizations that may introduce some meta data
for parsed info attached to codec frames.

5 years agodecoder: decoder units are no longer dynamically allocated objects.
Gwenole Beauchesne [Mon, 7 Jan 2013 13:04:22 +0000 (14:04 +0100)]
decoder: decoder units are no longer dynamically allocated objects.

5 years agodecoder: optimize pre-allocation of decoder units.
Gwenole Beauchesne [Mon, 7 Jan 2013 12:59:07 +0000 (13:59 +0100)]
decoder: optimize pre-allocation of decoder units.

Optimize pre-allocation of decoder units, thus avoiding un-necessary
memory reallocations. The heuristic used is that we could have around
one slice unit per macroblock line.

5 years agodecoder: use an array of units instead of a single-linked list.
Gwenole Beauchesne [Mon, 7 Jan 2013 12:41:59 +0000 (13:41 +0100)]
decoder: use an array of units instead of a single-linked list.

Use a GArray to hold decoder units in a frame, instead of a single-linked
list. This makes 'append' calls faster, but not that much. At least, this
makes things clearer.

5 years agodecoder: refactor decoder unit API.
Gwenole Beauchesne [Mon, 7 Jan 2013 10:13:07 +0000 (11:13 +0100)]
decoder: refactor decoder unit API.

Allocate decoder unit earlier in the main parse() function and don't
delegate this task to derived classes. The ultimate purpose is to get
rid of dynamic allocation of decoder units.

5 years agompeg2: introduce parser info instead of MPEG-2 specific decoder unit.
Gwenole Beauchesne [Mon, 7 Jan 2013 09:48:27 +0000 (10:48 +0100)]
mpeg2: introduce parser info instead of MPEG-2 specific decoder unit.

Use a new GstVaapiParserInfoMpeg2 data structure instead of deriving
from GstVaapiDecoderUnit for MPEG-2 specific parser information.

5 years agoh264: introduce parser info instead of H.264 specific decoder unit.
Gwenole Beauchesne [Mon, 7 Jan 2013 09:22:54 +0000 (10:22 +0100)]
h264: introduce parser info instead of H.264 specific decoder unit.

Use a new GstVaapiParserInfoH264 data structure instead of deriving
from GstVaapiDecoderUnit for H.264 specific parser information.

5 years agoh264: set default values for some header fields.
Sreerenj Balachandran [Sat, 5 Jan 2013 10:33:06 +0000 (12:33 +0200)]
h264: set default values for some header fields.

The SPS, PPS and slice headers are not fully zero-initialized in the
codecparsers/ library. Rather, the standard upstream behaviour is to
initialize only certain syntax elements with some inferred values if
they are not present in the bitstream.

At the gstreamer-vaapi decoder level, we need to further initialize
certain syntax elements with some sensible default values so that to
not complicate VA drivers that just pass those verbatim to the HW,
and also avoid an memset() of the whole decoder unit.

Signed-off-by: Sreerenj Balachandran <>
Signed-off-by: Gwenole Beauchesne <>
5 years agocodecparsers: update to gst-vaapi-rebased commit b47983a.
Gwenole Beauchesne [Sun, 6 Jan 2013 18:05:49 +0000 (19:05 +0100)]
codecparsers: update to gst-vaapi-rebased commit b47983a.

b47983a h264: add inferred value for slice_beta_offset_div2

5 years agoplugins: cope with new GstVaapiVideoMeta API.
Gwenole Beauchesne [Sat, 5 Jan 2013 16:55:47 +0000 (17:55 +0100)]
plugins: cope with new GstVaapiVideoMeta API.

Update plugin elements with the new GstVaapiVideoMeta API.

This also fixes support for subpictures/overlay because GstVideoDecoder
generates a sub-buffer from the GstVaapiVideoBuffer. So, that sub-buffer
is marked as read-only. However, when comes in the textoverlay element
for example, it checks whether the input buffer is writable. Since that
buffer read-only, then a new GstBuffer is created. Since gst_buffer_copy()
does not preserve the parent field, the generated buffer in textoverlay
is not exploitable because we lost all VA specific information.

Now, with GstVaapiVideoMeta information attached to a standard GstBuffer,
all information are preserved through gst_buffer_copy() since the latter
does copy metadata (qdata in this case).

5 years agovideobuffer: wrap video meta into a surface buffer.
Gwenole Beauchesne [Sat, 5 Jan 2013 16:37:13 +0000 (17:37 +0100)]
videobuffer: wrap video meta into a surface buffer.

Make GstVaapiVideoBuffer a simple wrapper for video meta. This buffer is
no longer necessary but for compatibility with GStreamer 0.10 APIs or users
expecting a GstSurfaceBuffer like Clutter.

5 years agovideobuffer: add video meta information.
Gwenole Beauchesne [Sat, 5 Jan 2013 07:31:24 +0000 (08:31 +0100)]
videobuffer: add video meta information.

Add new GstVaapiVideoMeta object that holds all information needed to
convey gst-vaapi specific data as a GstBuffer.

5 years agovaapidecode: fix calculation of the time-out value.
Gwenole Beauchesne [Thu, 3 Jan 2013 12:10:33 +0000 (13:10 +0100)]
vaapidecode: fix calculation of the time-out value.

Fix calculation of the time-out value for cases where no VA surface is
available for decoding. In this case, we need to wait until downstream
sink consumed at least one surface. The time-out was miscalculated as
it was always set to <current-time> + one second, which is not suitable
for streams with larger gaps.

5 years agodecoder: always use the calculated presentation timestamp.
Gwenole Beauchesne [Thu, 3 Jan 2013 12:05:47 +0000 (13:05 +0100)]
decoder: always use the calculated presentation timestamp.

Use PTS value computed by the decoder, which could also be derived from
the GstVideoCodecFrame PTS. This makes it possible to fix up the PTS if
the original one was miscomputed or only represented a DTS instead.

5 years agoh264: don't create sub-buffer for slice data.
Gwenole Beauchesne [Wed, 2 Jan 2013 16:33:15 +0000 (17:33 +0100)]
h264: don't create sub-buffer for slice data.

5 years agodecoder: create new context when encoded resolution changes.
Gwenole Beauchesne [Thu, 3 Jan 2013 10:16:44 +0000 (11:16 +0100)]
decoder: create new context when encoded resolution changes.

Create a new VA context if the encoded surface size changes because we
need to keep the underlying surface pool until the last one was released.
Otherwise, either of the following cases could have happened: (i) release
a VA surface to an inexistent pool, or (ii) release VA surface to an
existing surface pool, but with different size.

5 years agompeg2: don't create sub-buffer for slice data.
Gwenole Beauchesne [Wed, 2 Jan 2013 16:23:53 +0000 (17:23 +0100)]
mpeg2: don't create sub-buffer for slice data.

Avoid creating a GstBuffer for slice data. Rather, directly use the codec
frame input buffer data. This is possible because the codec frame is valid
until end_frame() where we submit the VA buffers for decoding. Anyway, the
slice data buffer is copied into the VA buffer when it is created.

5 years agompeg2: minor clean-ups.
Gwenole Beauchesne [Wed, 2 Jan 2013 13:45:50 +0000 (14:45 +0100)]
mpeg2: minor clean-ups.

Drop explicit initialization of most fields that are implicitly set to
zero. Remove some useless checks for NULL pointers.