Commit graph

691 commits

Author SHA1 Message Date
Gwenole Beauchesne
ee181d1b85 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.
2013-01-23 10:25:52 +01:00
Gwenole Beauchesne
df411e435f 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.
2013-01-22 16:59:40 +01:00
Wind Yuan
a68c218c8e 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 <gwenole.beauchesne@intel.com>
2013-01-22 16:10:07 +01:00
Gwenole Beauchesne
d69cb4389f vc1: review and report errors accordingly.
Use GST_ERROR() to report real errors instead of hiding them into
GST_DEBUG().
2013-01-22 16:10:07 +01:00
Gwenole Beauchesne
b134a97d42 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.
2013-01-22 16:10:07 +01:00
Gwenole Beauchesne
ec3c4576c0 vc1: implement flush() hook.
Make it a simple DPB flush.
2013-01-22 16:09:45 +01:00
Gwenole Beauchesne
1513f52fc1 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.
2013-01-22 16:08:25 +01:00
Gwenole Beauchesne
823f16d7ce 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.
2013-01-22 09:30:04 +01:00
Sreerenj Balachandran
472f3473e0 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 <gwenole.beauchesne@intel.com>
2013-01-21 19:08:00 +01:00
Gwenole Beauchesne
142e13f637 vc1: fix decode_sequence_end() to return success, not EOS. 2013-01-21 16:35:58 +01:00
Gwenole Beauchesne
b24752da4f decoder: simplify gst_vaapi_decoder_get_surface().
Avoid extraenous branches, i.e. immediately return with success once we
have a decoded frame available.
2013-01-18 17:00:18 +01:00
Gwenole Beauchesne
a811a5de3d 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.
2013-01-18 16:56:15 +01:00
Gwenole Beauchesne
cd52fa315a display: move "vaapi" debug init to libgstvaapi_init_once(). 2013-01-18 14:49:15 +01:00
Gwenole Beauchesne
655f400e1c display: dump gstreamer-vaapi version for debugging purposes. 2013-01-18 14:49:15 +01:00
Gwenole Beauchesne
319f87f142 h264: implement GstVaapiDecoder::flush() as a DPB flush. 2013-01-17 18:40:36 +01:00
Gwenole Beauchesne
34162f5001 h264: handle end-of-stream NALU.
Handle <end-of-stream> NAL unit to actually flush any pending picture
from the DPB.
2013-01-17 18:40:36 +01:00
Gwenole Beauchesne
60acedb56e decoder: add GstVaapiDecoder::flush() hook. 2013-01-17 18:39:22 +01:00
Gwenole Beauchesne
e4e3a58bc0 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.
2013-01-17 18:39:22 +01:00
Gwenole Beauchesne
cc347cb41e 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.
2013-01-17 18:39:22 +01:00
Gwenole Beauchesne
059e032103 docs: expose new interfaces. 2013-01-14 12:58:41 +01:00
Gwenole Beauchesne
9372f14f94 dpb: cosmetics (clean-ups). 2013-01-14 10:58:49 +01:00
Gwenole Beauchesne
e44d8ee6e3 dpb: port to GstVaapiMiniObject. 2013-01-14 10:46:50 +01:00
Gwenole Beauchesne
6f4e01258d 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.
2013-01-14 10:21:53 +01:00
Sreerenj Balachandran
eafdd771ae 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 <gwenole.beauchesne@intel.com>
2013-01-14 10:11:21 +01:00
Holger Kaelberer
082a56599b overlay: fix build without advanced GstVideoOverlayFormatFlags.
Check for global-alpha support in GstVideoOverlayComposition API.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-11 15:47:46 +01:00
Gwenole Beauchesne
7e1a8eabfe overlay: fix ordering of composition layers.
Make sure to maintain the association order of composition layers when
GstVideoOverlayRectangle objects are kept around (cached).
2013-01-11 15:32:17 +01:00
Holger Kaelberer
2ecb955626 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
value.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
e6390d6e5f 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.
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
e876d9a581 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.
2013-01-11 15:29:12 +01:00
Gwenole Beauchesne
a14d259060 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.
2013-01-11 15:29:11 +01:00
Gwenole Beauchesne
ad6cdc0b52 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
GPtrArray.

Make GstVaapiOverlayRectangle a reference counted object. Also make
sure that overlay_rectangle_new() actually creates and associates the
VA subpicture.
2013-01-11 15:28:25 +01:00
Holger Kaelberer
2d2334afed 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 <gwenole.beauchesne@intel.com>
2013-01-11 14:23:08 +01:00
Holger Kaelberer
1cd4a8fc04 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 <gwenole.beauchesne@intel.com>
2013-01-11 14:23:06 +01:00
Gwenole Beauchesne
1307a5b4ef 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.
2013-01-11 14:17:30 +01:00
Gwenole Beauchesne
fc1f9a64e4 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.
2013-01-11 14:17:30 +01:00
Gwenole Beauchesne
591b637cfc 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.
2013-01-10 10:14:42 +01:00
Gwenole Beauchesne
0ecb3a627b 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
results.
2013-01-09 16:05:39 +01:00
Gwenole Beauchesne
3bc6078f32 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.
2013-01-09 16:05:18 +01:00
Gwenole Beauchesne
0180ef635c mpeg2: drop useless gst_adapter_peek().
Drop useless gst_adapter_peek() since the returned buffer was not used
and this could incur superfluous memcpy().
2013-01-08 16:41:44 +01:00
Gwenole Beauchesne
4a69e395cd mpeg2: cosmetics: move parse_slice() down. 2013-01-07 16:12:42 +01:00
Gwenole Beauchesne
6dd8eab023 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.
2013-01-07 16:12:42 +01:00
Gwenole Beauchesne
8c403c2d98 decoder: decoder units are no longer dynamically allocated objects. 2013-01-07 14:11:39 +01:00
Gwenole Beauchesne
a486d1af66 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.
2013-01-07 14:11:39 +01:00
Gwenole Beauchesne
4fd99cc989 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.
2013-01-07 14:10:13 +01:00
Gwenole Beauchesne
2c449e42ca 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.
2013-01-07 14:10:13 +01:00
Gwenole Beauchesne
78e9a78de8 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.
2013-01-07 14:10:09 +01:00
Gwenole Beauchesne
8d2b7241fc 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.
2013-01-07 10:48:57 +01:00
Sreerenj Balachandran
0963afce0b 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 <sreerenj.balachandran@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-01-06 19:20:15 +01:00
Gwenole Beauchesne
d6bbc652b4 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.
2013-01-05 18:02:31 +01:00
Gwenole Beauchesne
b1636c3585 videobuffer: add video meta information.
Add new GstVaapiVideoMeta object that holds all information needed to
convey gst-vaapi specific data as a GstBuffer.
2013-01-05 18:02:31 +01:00
Gwenole Beauchesne
492cafdbc1 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.
2013-01-03 13:05:47 +01:00
Gwenole Beauchesne
3f60f136cc h264: don't create sub-buffer for slice data. 2013-01-03 11:23:40 +01:00
Gwenole Beauchesne
9bba1e5fe3 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.
2013-01-03 11:16:44 +01:00
Gwenole Beauchesne
eda01ab027 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.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
4556b1fd47 mpeg2: minor clean-ups.
Drop explicit initialization of most fields that are implicitly set to
zero. Remove some useless checks for NULL pointers.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
7ca43932e5 mpeg2: 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.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
9458bbdc16 mpeg2: use sequence_display_extension() to compute PAR.
Also compute pixel-aspect-ratio from sequence_display_extension(),
should it exist in the bitstream.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
65ede48b7b mpeg2: handle sequence_display_extension(). 2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
748a8dbdc6 mpeg2: 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.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
4a39efa9f6 mpeg2: parse slice() header earlier.
Parse slice() header and first macroblock position earlier in _parse()
function instead of waiting for the _decode() stage. This doesn't change
anything but readability.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
549b5a9389 mpeg2: add codec specific decoder unit.
Introduce new GstVaapiDecoderUnitMpeg2 object, which holds the standard
GstMpegVideoPacket and additional parsed header info. Besides, we now
parse as early as in the _parse() function so that to avoid un-necessary
creation of sub-buffers in _decode() for video packets that are not slices.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
63a7e42484 decoder: introduce lists of units to decode before/after frame.
Theory of operations: all units marked as "slice" are moved to the "units"
list. Since this list only contains slice data units, the prev_slice pointer
was removed. Besides, we now maintain two extra lists of units to be decoded
before or after slice data units.

In particular, all units in the "pre_units" list will be decoded before
GstVaapiDecoder::start_frame() is called and units in the "post_units"
list will be decoded after GstVaapiDecoder::end_frame() is called.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
c727e5b6d6 decoder: drop useless checks for codec objects.
Codec objects are used internally only and they are bound to be created
with a valid GstVaapiDecoder object.
2013-01-03 09:08:19 +01:00
Gwenole Beauchesne
9e643a6147 Add videoutils submodule for GstVideoDecoder APIs. 2012-12-21 16:01:16 +01:00
Gwenole Beauchesne
f5294b813a Bump library major version.
Increase library major so that to cope with API/ABI incompatible changes
since 0.4.x series and avoid user issues.
2012-12-18 15:31:52 +01:00
Gwenole Beauchesne
9dcf082002 surfaceproxy: minor clean-ups. 2012-12-18 15:31:52 +01:00
Gwenole Beauchesne
51d028a628 surfaceproxy: drop accessors to obsolete attributes.
Make GstVaapiSurfaceProxy only a thin wrapper around a VA context and a
VA surface. i.e. drop any other attribute like timestamp, duration,
interlaced or top-field-first.
2012-12-18 15:31:52 +01:00
Gwenole Beauchesne
8c2d9bcd24 decoder: maintain decoded frames as GstVideoCodecFrame objects.
Maintain decoded surfaces as GstVideoCodecFrame objects instead of
GstVaapiSurfaceProxy objects. The latter will tend to be reduced to
the strict minimum: a context and a surface.
2012-12-18 15:31:52 +01:00
Gwenole Beauchesne
09c9e20379 decoder: add gst_vaapi_decoder_get_frame() API.
Add new gst_vaapi_decoder_get_frame() function meant to be used with
gst_vaapi_decoder_decode(). The purpose is to return the next decoded
frame as a GstVideoCodecFrame and the associated GstVaapiSurfaceProxy
as the user-data object.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
098eb2624e h264: optimize initialization process of decoder units.
Decoder units were zero-initialized, including the SPS/PPS/slice headers.
The latter don't require zero-initialization since the codecparsers/ lib
will do so for key variables already. This is not a great value per se but
at least it makes it possible to check whether the default initialization
decisions made in the codecparsers/ lib were right or not.

This can be reverted if this exposes too many issues.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
0b2e399235 h264: minor clean-ups.
Drop explicit initialization of most fields that are implicitly set to
zero. Drop helper macros for casting to GstVaapiPictureH264 or
GstVaapiFrameStore. Also remove some useless checks for NULL pointers.
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
4992e7c60f h264: drop GstVaapiSliceH264 object.
Use standard GstVaapiSlice object from now on since we already have
parsed and recorded the slice headers (GstH264SliceHdr decode units).
2012-12-18 15:31:51 +01:00
Gwenole Beauchesne
f8a9e49fd8 h264: detect new pictures from decode-units.
Update is_new_picture() to cope with GstVaapiDecoderUnitH264, instead
of assuming frame boundaries when first_mb_in_slice is zero.
2012-12-18 15:31:51 +01:00
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
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
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
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
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
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