Commit graph

580 commits

Author SHA1 Message Date
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
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
Gwenole Beauchesne
c59d935505 h264: split remove_reference_at() into finer units.
Split remove_reference_at() into a function that actually removes the
specified entry from the short-term or long-term reference picture array,
and a function that sets reference flags to the desired value, possibly
zero. The latters marks the picture as "unused for reference".
2012-11-14 17:39:19 +01:00
Gwenole Beauchesne
e11f815b0d decoder: fix gst_vaapi_picture_new_field() object type.
Fix gst_vaapi_picture_new_field() to preserve the original picture type.
e.g. gst_vaapi_picture_new_field() with a GstVaapiPictureH264 argument
shall generate a GstVaapiPictureH264 object.
2012-11-14 17:39:19 +01:00
Gwenole Beauchesne
e530c57741 h264: add picture structure for reference picture marking process.
Introduce new `structure' field to the H.264 specific picture structure
so that to simplify the reference picture marking process. That local
picture structure is derived from the original picture structure, as
defined by the syntax elements field_pic_flag and bottom_field_flag.
2012-11-14 17:39:19 +01:00
Gwenole Beauchesne
bbbf3741ff h264: introduce new frame store structure.
The frame store represents a Decoded Picture Buffer entry, which can
hold up to two fields. So far, the frame store is only used to hold
full frames.
2012-11-14 17:39:19 +01:00
Gwenole Beauchesne
afddf11e22 h264: minor clean-ups.
Move DPB flush up if the current picture to decode is an IDR. Besides,
don't bother to check for IDR pictures in dpb_add() function since an
explicit DPB flush was already performed in this case.
2012-10-31 16:37:14 +01:00
Gwenole Beauchesne
d180a3a9f6 h264: simplify reference picture marking process.
... to build the short_ref[] and long_ref[] lists from the DPB, instead
of maintaining them separately. This avoids refs/unrefs while making it
possible to generate the list based on the actual picture structure.

This also ensures that the list of generated ReferenceFrames[] actually
matches what reference frames are available in the DPB. i.e. short_ref[]
and long_ref[] entries are implied from the DPB, so there is no risk of
having "dangling" references.
2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
3480fcc8d7 h264: introduce per-field POC in GstVaapiPictureH264.
Use the POC member available in the GstVaapiPicture base class and
get rid of the dependency on the local VAPictureH264 TopFieldOrderCnt
and BottomFieldOrderCnt. Rather, use a simple field_poc[] array
initialized to INT_MAX, so that to simplify picture POC calculation
for non frame pictures.
2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
3c721e1123 h264: introduce GST_VAAPI_PICTURE_{SHORT,LONG}_TERM_REFERENCE flags.
Further get rid of GstVaapiPictureH264-local VAPictureH264.flags for
reference bits, thus simplifying the reference picture marking process
to only track a single set of reference flags. Also introduce a new
long_term_frame_idx member.
2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
af22813f59 h264: introduce GST_VAAPI_PICTURE_FLAG_IDR flag. 2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
b35ccab294 h264: fill in GstVaapiPicture structure.
... and get rid of local VAPictureH264.flags fields in GstVaapiPictureH264.
2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
49774b3c58 h264: add vaapi_fill_picture() helper.
Add vaapi_fill_picture() helper function to convert GstVaapiPictureH264
to VAPictureH264 structure. This is preparatory work to get rid of the
local VAPictureH264 member in GstVaapiPictureH264.
2012-10-31 15:05:54 +01:00
Gwenole Beauchesne
e30a518267 h264: fix activation order of picture and sequence parameters.
Delay ensure_context() until we actually need a VA context for allocating
new VA surfaces, and then GstVaapiPictures, but also when a real activation
of a new picture parameter set occurs, thus also implying an activation
of the related sequence parameter set.

The most important thing was to drop the global pps and sps pointers since
they may not have matched the currently activated picture parameter or
sequence parameter sets at the specified decode point.

Anoter positive side-effect is that this cleans up all occurrences of
decode_current_picture() to only keep those useful in decode_picture(),
before a new picture is allocated, or in decode_sequence_end() when
an end-of-stream or end-of-sequence condition occurred.
2012-10-26 16:30:33 +02:00
Gwenole Beauchesne
015879cafe h264: fix scaling list generation.
... aka fix regression from efaab79. In particular, ScalingList8x8[]
array was partially copied to the VAIQMatrixBufferH264. While we are
at it, also improve bounds checking and avoid copying 8x8 scaling
lists if transform_8x8_mode_flag is set to 0.
2012-10-26 14:41:36 +02:00
Gwenole Beauchesne
6398bc7d3c h264: fix detection of picture boundaries.
Strictly follow the standard (7.4.1.2.4) to detect the first VCL NAL
unit of a primary coded picture.
2012-10-24 18:23:09 +02:00
Gwenole Beauchesne
efaab79e89 h264: optimize handling of scaling lists.
Don't copy scaling lists twice to an intermediate state. Rather, directly
use the scaling lists from GstH264PPS since they would match those provided
by SPS header, if necessary. i.e. if PPS-specific scaling lists are not
available in the bitstream.
2012-10-24 18:01:14 +02:00
Gwenole Beauchesne
97979ee6de h264: simplify code when MMCO is 5.
Remove exit_picture() and exit_picture_poc() since PicOrderCnt(CurrPic)
is now updated accordingly to the standard. Besides, MMCO = 5 specific
operations are moved up to exec_ref_pic_marking_adaptive_mmco_5().
2012-10-23 10:37:47 +02:00
Gwenole Beauchesne
d9b5e47585 h264: fix MMCO-based reference picture marking process.
Fix adaptive memory control decoded reference picture marking process
implementation for operations 2 to 6, thus also fixing support for
long-term reference pictures.
2012-10-22 17:26:00 +02:00
Gwenole Beauchesne
04bbd8cc11 h264: move MMCO handlers out of the loop (cosmetics).
This change only splits each individual MMCO handler into several functions
dedicated for each operation. This is needed to perform further work later
on.
2012-10-22 17:21:32 +02:00
Gwenole Beauchesne
2e8949d77b h264: add flag to compile with strict DPB ordering mode.
Allow build with strict DPB ordering mode whereby evicted entries
are replaced by the next entries, in order instead of optimizing
it away with the last entry in the DPB.

This is only useful for debugging purpose, against a reference SW
decoder for example.
2012-10-16 16:52:04 +02:00
Gwenole Beauchesne
26b7c46eda h264: drop extra code covered by built-in codecparsers.
GstH264SliceHdr.n_emulation_prevention_bytes is bound to exist now that
a newer version of codecparsers/ are used if the system provided one is
now recent enough to have those required extensions.
2012-10-16 16:46:17 +02:00