Commit graph

76 commits

Author SHA1 Message Date
Sreerenj Balachandran
51151e7aa1 Add initial support for GStreamer 1.0.
This integrates support for GStreamer API >= 1.0 only in the libgstvaapi
core decoding library. The changes are kept rather minimal here so that
the library retains as little dependency as possible on core GStreamer
functionality.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-04-10 14:58:16 +02:00
Gwenole Beauchesne
6e82da1e93 decoder: delegate surface size check to VA context reset.
Now that the surface pool is reference counted in the surface proxy wrapper,
we can safely ignore surface size checks in gst_vaapi_decoder_ensure_context().
Besides, this check is already performed in gst_vaapi_context_reset_full().
2013-04-03 13:34:59 +02:00
Gwenole Beauchesne
4009430bec decoder: sanitize codec-data decoding.
Add a new GstVaapiDecoder::decode_codec_data() hook to actually decode
codec-data in the decoder sub-class. Provide a common shared helper
function to do the actual work and delegating further to the sub-class.
2013-03-21 14:38:06 +01:00
Gwenole Beauchesne
4499f39274 decoder: handle decode-only frames in raw API mode.
Fix gst_vaapi_decoder_get_surface() to only return frames with a valid
surface proxy, i.e. with a valid VA surface. This means that any frame
marked as decode-only is simply skipped.
2013-01-30 19:04:16 +01:00
Gwenole Beauchesne
2305b0db46 decoder: allow frames to be dropped.
If the decoder was not able to decode a frame because insufficient
information was available, e.g. missing sequence or picture header,
then allow the frame to be gracefully dropped without generating
any error.

It is also possible that a frame is not meant to be displayed but
only used as a reference, so dropping that frame is also a valid
operation since GstVideoDecoder base class has extra references to
that GstVideoCodecFrame that needs to be released.
2013-01-30 16:38:48 +01:00
Gwenole Beauchesne
aee91a31ba 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.
2013-01-29 16:18:13 +01:00
Gwenole Beauchesne
0c99f351fc legal: fix year for some copyright notices (2013). 2013-01-29 14:37:02 +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
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
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
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
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
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
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
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
86981eea41 decoder: refine semantics of gst_vaapi_decoder_put_buffer().
Improve the semantics for gst_vaapi_decoder_put_buffer() when an empty
buffer is passed on. An empty buffer is a buffer with a NULL data pointer
or with a size equals to zero. In this case, that buffer is simply
skipped and the function returns TRUE. A NULL buffer argument still
marks the end-of-stream.
2012-10-09 15:04:36 +02:00
Gwenole Beauchesne
d7fccc351a decoder: drop unused functions. 2012-10-09 14:40:00 +02:00
Gwenole Beauchesne
5549dbc3c0 vaapidecode: don't reset decoder if codec type is the same.
Reset, i.e. destroy then create, the decoder in _setcaps() handler only
if the underlying codec type actually changed. This makes it possible
to be more tolerant with certain MPEG-2 streams that get parsed to
form caps that are compatible with the previous state but minor changes
to "codec-data".
2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
6c19849cd2 decoder: propagate buffer duration downstream. 2012-09-11 17:08:47 +02:00
Gwenole Beauchesne
a10b3d3032 decoder: cope with new GstVaapiContextInfo based API.
Update decoders to report the maximum number of reference frames to use.
2012-09-10 18:27:40 +02:00
Gwenole Beauchesne
61cc02f54b libs: fix build in strict ISO C mode. 2012-09-07 16:23:42 +02:00
Gwenole Beauchesne
cdc6329182 decoder: drop extraneous return for void function. 2012-09-07 11:58:53 +02:00
Javier Jardón
5157a01942 decoder: use g_object_notify_by_pspec().
Use g_object_notify_by_pspec() instead of g_object_notify() so that to
avoid a property name lookup. i.e. this makes notifications faster to
the `vaapidecode' element.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-08-27 09:56:47 +02:00
Holger Kaelberer
82f11ffb30 decoder: maintain caps for interlaced streams.
Extend GstVaapiDecoder base object to maintain caps with "interlaced"
property.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-03-19 18:43:06 +01:00
Gwenole Beauchesne
d75d70d395 mpeg2: fix crash when there is no free surface to decode into. 2012-02-06 15:54:42 +01:00
Gwenole Beauchesne
0fb1147d9c Add header for system-dependent definitions. 2012-01-30 19:52:10 +01:00
Gwenole Beauchesne
7b19745141 decoder: simplify output of decoded frames.
Drop obsolete gst_vaapi_decoder_push_surface() that was no longer used.
Change gst_vaapi_decoder_push_surface_proxy() semantics to assume PTS
is already set correctly and reference count increased, if necessary.
2012-01-27 13:28:12 +01:00
Gwenole Beauchesne
e5d12e8853 decoder: rework the internal VA objects API.
The new API simplifies a lot reference counting and makes it more
flexible for future additions/changes. The GstVaapiCodecInfo is
also gone. Rather, new helper macros are provided to allocate
picture, slice and quantization matrix parameter buffers.
2012-01-27 13:28:11 +01:00
Gwenole Beauchesne
dbba1f6107 decoder: allow slices to be attached to pictures later. 2012-01-24 10:21:45 +01:00
Gwenole Beauchesne
74d3680381 decoder: add ref_count to GstVaapiPicture. 2012-01-24 10:15:52 +01:00
Gwenole Beauchesne
92f11799d1 legal: fix year for some copyright notices. 2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
14cc1cf061 legal: fix copyright notices to include "Copyright" term. 2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
5aea02a66f vc1: fix bitplanes decoding. 2012-01-16 11:40:51 +01:00
Gwenole Beauchesne
3360f7f3e3 Add VA decoder helpers. 2012-01-16 11:40:50 +01:00
Gwenole Beauchesne
3e1d235c1a decoder: fix possible leak of VA surfaces.
Under some circumstances, we could have leaked a surface, thus not
releasing it to the pool of available surfaces in the VA context.
The strategy is now to use a proxy earlier and automatically ref/unref
whenever necessary. In particular, during the lifetime needed for FFmpeg.
2012-01-05 17:35:43 +01:00
Gwenole Beauchesne
3b9a165037 decoder: fix use of invalid data at the end-of-stream. 2011-10-19 17:33:36 +02:00
Gwenole Beauchesne
00bb1ca6b4 Add Intel copyright information. 2011-08-01 14:15:39 +02:00
Gwenole Beauchesne
2f91c9e8c1 Report caps update only once per video resolution change. 2011-07-22 15:42:26 +02:00
Gwenole Beauchesne
1701ce3107 Update copyright notice. 2011-06-14 13:54:07 +02:00