Commit graph

172 commits

Author SHA1 Message Date
Gwenole Beauchesne
bea0d07042 decoder: h264: fix marking of non-reference picture into DPB.
Fix search for a picture in the DPB that has a lower POC value than
the current picture. The dpb_find_lowest_poc() function will return
a picture with the lowest POC in DPB and that is marked as "needed
for output", but an additional check against the actual POC value
of the current picture is needed.

This is a regression from 1c46990.

https://bugzilla.gnome.org/show_bug.cgi?id=732130
2014-06-25 22:38:35 +02:00
Gwenole Beauchesne
8db72147c7 decoder: h264: fix DPB clear when no decoding actually started.
Fix dpb_clear() to clear previous frame buffers only if they actually
exist to begin with. If the decoder bailed out early, e.g. when it
does not support a specific profile, that array of previous frames
might not be allocated beforehand.
2014-06-19 17:08:47 +02:00
Sreerenj Balachandran
cb9f98f0d5 decoder: h264: add support for NALU "alignment" optimization.
We can avoid scanning for start codes again if the bitstream is fed
in NALU chunks. Currently, we always scan for start codes, and keep
track of remaining bits in a GstAdapter, even if, in practice, we
are likely receiving one GstBuffer per NAL unit. i.e. h264parse with
"nal" alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=723284

[use gst_adapter_available_fast() to determine the top buffer size]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-06-19 15:29:12 +02:00
Gwenole Beauchesne
95c781c34f decoder: h264: fix caps to report interlace-mode accordingly.
The `vaapipostproc' element could never determine if the H.264 stream
was interlaced, and thus always assumed it to be progressive. Fix the
H.264 decoder to report interlace-mode accordingly, thus allowing the
vaapipostproc element to automatically enable deinterlacing.
2014-06-19 15:13:04 +02:00
Gwenole Beauchesne
799d7b7d0e decoder: h264: cope with new gst_h264_quant_matrix_*() interfaces.
New gst_h264_quant_matrix_*_get_raster_from_zigzag() were renamed
from gst_h264_video_quant_matrix_*_get_raster_from_zigzag().
2014-06-13 11:36:56 +02:00
Gwenole Beauchesne
c65aec1aa6 decoder: h264: factor out DPB pruning for MVC.
Factor out the removal process of unused inter-view only reference
pictures from the DPB, prior to the possible insertion of the current
picture.

Ideally, the compiler could still opt for generating two loops. But
at least, the code is now clearer for maintenance.
2014-06-10 18:33:59 +02:00
Gwenole Beauchesne
63fde28dfd decoder: h264: clean-ups.
Fix GST_VAAPI_PICTURE_IS_{INTER_VIEW,ANCHOR}() definitions to use
the base GST_VAAPI_PICTURE_FLAG_IS_SET() macro.
2014-06-10 18:33:59 +02:00
Gwenole Beauchesne
428b038dba decoder: h264: improve pruning of unused MVC inter-view frames.
Improve process for the removal of pictures from DPB before possible
insertion of the current picture (C.4.4) for H.264 MVC inter-view only
reference components. In particular, handle cases where picture to be
inserted is not the last one of the access unit and if it was already
output and is no longer marked as used for reference, including for
decoding next view components within the same access unit.
2014-06-10 18:33:59 +02:00
Gwenole Beauchesne
42ab3e0669 decoder: h264: improve DPB bumping process for MVC.
While invoking the DPB bumping process in presence of many views,
it could be necessary to output previous pictures that are ready,
in a whole. i.e. emitting all view components from the very first
view order index zero to the very last one in its original access
unit; and not starting from the view order index of the picture
that caused the DPB bumping process to be invoked.

As a reminder, the maximum number of frames in DPB for MultiView
High profile with more than 2 views is not necessarily a multiple
of the number of views.

This fixes decoding of MVCNV-4.264.
2014-06-10 18:33:59 +02:00
Gwenole Beauchesne
e8fe78824b decoder: h264: fix inter-view references array growth.
Let the utility layer handle dynamic growth of the inter-view pictures
array. By definition, setting a new size to the array will effectively
grow the array, but would also fill in the newly created elements with
empty entries (NULL), thus also increasing the reported length, which
is not correct.
2014-06-06 17:58:50 +02:00
Gwenole Beauchesne
60af04901f decoder: h264: reduce ReferenceFrames entries to the essential set.
When decoding Multiview High profile streams with a large number of
views, it is not possible to make the VAPictureParameterBufferH264.
ReferenceFrames[] array hold the complete DPB, with all possibly
active pictures to be used for inter-view prediction in the current
access unit.

So reduce the scope of the ReferenceFrames[] array to only include
the set of reference pictures that are going to be used for decoding
the current picture. Basically, this is a union of all RefPicListX[]
array, for all slices constituting the decoded picture.
2014-06-06 17:34:02 +02:00
Gwenole Beauchesne
e670e36007 decoder: h264: fix MVC inter-view prediction process.
The inter-view reference components and inter-view only reference
components that are included in the reference picture lists shall
be considered as not being marked as "used for short-term reference"
or "used for long-term reference". This means that reference flags
should all be removed from VAPictureH264.flags.

This fixes decoding of MVCNV-2.264.
2014-06-04 19:10:44 +02:00
Gwenole Beauchesne
f36486a1e2 decoder: h264: fix detection of profile changes for MVC.
If the VA driver exposes ad-hoc H.264 MVC profiles, then we have to
be careful to detect profiles changes and not reset the underlying
VA context erroneously. In MVC situations, we could indeed get a
profile_idc change for every SPS that gets activated, alternatively
(base-view -> non-base view -> base-view, etc.).

An improved fix would be to characterize the exact profile to use
once and for all when SPS NAL units are parsed. This would also
allow for fallbacks to a base-view decoding only mode.
2014-06-04 19:08:18 +02:00
Gwenole Beauchesne
f0d3d9cd3c decoder: h264: compute view ids only once per slice.
Optimize lookups of view ids / view order indices by caching the result
of the calculatiosn right into the GstVaapiParserInfoH264 struct. This
terribly simplifies is_new_access_unit() and find_first_field() functions.
2014-05-22 10:13:34 +02:00
Gwenole Beauchesne
abcc8bb7a2 decoder: h264: add support for MVC interlaced streams.
Fix support for MVC Stereo High profile streams with interlaced frames.
Also improve the detection logic of the first field.
2014-05-21 20:04:35 +02:00
Gwenole Beauchesne
5d76afb40d decoder: h264: add MVC profiles compatibility logic.
Add safe fallbacks for MVC profiles:
- all MultiView High profile streams with 2 views at most can be decoded
  with a Stereo High profile compliant decoder ;
- all Stereo High profile streams with only progressive views can be
  decoded with a MultiView High profile compliant decoder ;
- all drivers that support slice-level decoding could normally support
  MVC profiles when the DPB holds at most 16 frames.
2014-05-21 20:04:35 +02:00
Gwenole Beauchesne
8c5e89c298 decoder: h264: add initial support for MVC.
https://bugzilla.gnome.org/show_bug.cgi?id=721772
2014-05-21 20:04:34 +02:00
Gwenole Beauchesne
42b112f8bd decoder: h264: dynamically allocate the DPB.
Dynamically allocate the Decoded Picture Buffer (DPB) and add provisions
for supporting the MVC allocation requirements.
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
ae1d8267d9 decoder: h264: fix detection of access unit boundaries.
In order to have a stricter conforming implementation, we need to carefully
detect access unit boundaries. Additional operations could be necessary to
perform at those boundaries.
2014-05-21 19:59:52 +02:00
Sreerenj Balachandran
a6215a0757 decoder: h264: detect the first VCL NAL unit of a picture for MVC.
Detect the first VCL NAL unit of a picture for MVC, based on the
view_id as per H.7.4.1.2.4. Note that we only need to detect new
view components.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-05-21 19:59:52 +02:00
Sreerenj Balachandran
e4166f5a91 decoder: h264: properly handle Prefix NAL units.
Always cache the previous NAL unit so that we could check whether
there is a Prefix NAL unit immediately preceding the current slice
or IDR NAL unit. In that case, the NAL unit metadata is copied into
the current NAL unit. Otherwise, some default values are inferred,
tentatively. e.g. view_id shall be set to 0 and inter_view_flag to 1.

[infer default values for slice if previous NAL was not a Prefix]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-05-21 19:59:52 +02:00
Xiaowei Li
79118904a0 decoder: h264: add support for MVC base views.
Allow decoding for base views of MVC encoded streams. For now, just skip
the slice extension and prefix NAL units, and skip non-base view frames.

Signed-off-by: Xiaowei Li <xiaowei.a.li@intel.com>
[fixed memory leak, improved check for MVC NAL units]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
1c46990ecd decoder: h264: simplify storage of decoded picture into DPB.
Factor out process by which the decoded picture with the lowest POC
is found, and possibly output. Likewise, the storage and marking of
a reference decoded, or non-reference decoded picture, into the DPB
could also be simplified as they mostly share the same operations.
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
a571350dee decoder: h264: minor clean-ups.
Make init_picture_ref_lists() more consistent with other functions
related to the reference marking process by supplying the current
picture as argument.
2014-05-21 19:59:52 +02:00
Gwenole Beauchesne
c12d80eb88 decoder: h264: fix assignment of LongTermFrameIdx.
Complement fix committed as e95a42e.

The H.264 AVC standard has to say: if the field is part of a reference
frame or a complementary reference field pair, and the other field of
the same reference frame or complementary reference field pair is also
marked as "used for long-term reference", the reference frame or
complementary reference field pair is also marked as "used for long-term
reference" and assigned LongTermFrameIdx equal to long_term_frame_idx.

This fixes decoding of MR9_BT_B in strict mode.

https://bugs.freedesktop.org/show_bug.cgi?id=64624
https://bugzilla.gnome.org/show_bug.cgi?id=724518
2014-05-12 19:29:37 +02:00
Gwenole Beauchesne
85a60441fa decoder: h264: properly support grayscale formats.
Request the correct chroma format for decoding grayscale streams.
i.e. make lookups of the VA chroma format more generic, thus possibly
supporting more formats in the future.

This means that, if a VA driver doesn't support grayscale formats,
it is now going to fail. We cannot safely assume that maybe grayscale
was implemented on top of some YUV 4:2:0 with the chroma components
all set to 0x80.
2014-05-10 06:29:25 +02:00
Cong Zhong
e95a42ea6e decoder: h264: fix long-term reference picture marking process.
Fix reference picture marking process with memory_management_control_op
set to 3 and 6, i.e. assign LongTermFrameIdx to a short-term reference
picture, or the current picture.

This fixes decoding of FRExt_MMCO4_Sony_B.

https://bugs.freedesktop.org/show_bug.cgi?id=64624
https://bugzilla.gnome.org/show_bug.cgi?id=724518

[squashed, edited to use GST_VAAPI_PICTURE_IS_COMPLETE() macro]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-04-26 22:16:19 +02:00
Gwenole Beauchesne
fac59d6fcf decoder: h264: fix initialization of RefPicLists for multiple slices.
The initialization of reference picture lists (8.2.4.2) applies to all
slices. So, the RefPicList0/1 lists need to be constructed prior to
each slice submission to the HW decoder.

This fixes decoding of video sequences where frames are encoded with
multiple slices of different types, e.g. 4 slices in this order I, P,
I, and P. More precisely, CABAST3_Sony_E and CABASTBR3_Sony_B.

https://bugzilla.gnome.org/show_bug.cgi?id=724518
2014-04-26 20:21:46 +02:00
Zhong Cong
3a6f6f97ab decoder: h264: skip SPS extension and auxiliary slice NALs.
When NAL units of type 13 (SPS extension) or type 19 (auxiliary slice)
are present in a video, decoders shall perform the (optional) decoding
process specified for these NAL units or shall ignore them (7.4.1).

Implement option 2 (skip) for now, as alpha composition is not
supported yet during the decoding process.

This fixes decoding of the primary coded video in alphaconformanceG.

https://bugzilla.gnome.org/show_bug.cgi?id=703928
https://bugzilla.gnome.org/show_bug.cgi?id=728869
https://bugzilla.gnome.org/show_bug.cgi?id=724518

[skip NAL units earlier, i.e. at parsing time]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-04-26 14:38:59 +02:00
Li Xiaowei
3f14745d61 decoder: h264: fix slice data bit offset with MVC NAL units.
When MVC slice NAL units (coded slice extension and prefix NAL) are
present, the number of NAL header bytes is 3, not 1 as usual.

Signed-off-by: Li Xiaowei <xiaowei.a.li@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
5a3e51472d decoder: h264: fix activation of picture and sequence parameters.
At the time the first VCL NAL unit of a primary coded picture is found,
and if that NAL unit was parsed to be an SPS or PPS, then the entries
in the parser may have been overriden. This means that, when the picture
is to be decoded, slice_hdr->pps could point to an invalid (the next)
PPS entry.

So, one way to solve this problem is to not use the parser PPS and
SPS info but rather maintain our own activation chain in the decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=724519
https://bugzilla.gnome.org/show_bug.cgi?id=724518
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
a365dfd269 decoder: h264: retain SEI messages until the end of frame.
Retain the SEI messages that were parsed from the access unit until we
have completely decoded the current frame. This is done so that we can
peek at that data whenever necessary during decoding. e.g. for exposing
3D stereoscopic information at a later stage.
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
fa7f9cd08c decoder: h264: add support for grayscale encoded clips.
Fix support for grayscale encoded video clips, and possibly others if
the underlying driver supports the non-YUV 4:2:0 formats. i.e. defer
the decision that a surface with the desired chroma format is not
supported to the actual VA driver implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=728144
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
dbf32a2521 decoder: default to YUV 4:2:0 VA surfaces.
Cope with context changes to support non-YUV 4:2:0 VA surfaces. Still,
make sure all codecs use YUV 4:2:0 output format for now, by default.
2014-04-25 19:24:07 +02:00
Gwenole Beauchesne
450092e371 decoder: h264: cope with new gst_h264_parser_parse_sei() interface.
The gst_h264_parse_parse_sei() function now returns an array of SEI
messages, instead of a single SEI message. Reason: it is allowed to
have several SEI messages packed into a single SEI NAL unit, instead
of multiple NAL units.
2014-04-18 19:37:16 +02:00
Gwenole Beauchesne
e52d394b9e decoder: h264: fix robustness patch for bytestream format.
Fix parser and decoder state to sync at the right locations. This is
because we could reset the parser state, while the decoder state was
not copied yet, e.g. when parsing several NAL units from multiple frames
whereas the current frame was not decoded yet.

This is a regression brought in by commit 6fe5496.
2014-02-19 06:14:12 +01:00
Gwenole Beauchesne
6bf3c1863c legal: update copyright notice dates. 2014-01-22 19:02:35 +01:00
Gwenole Beauchesne
589078f2a4 utils: h264: expose levels in public header.
Instal <gst/vaapi/gstvaapiutils_h264.h> header but only expose the
H.264 levels in there. The additional helper functions are meant
to be private for now.
2014-01-10 19:52:50 +01:00
Gwenole Beauchesne
6fe54964bb h264: improve robustness when packets are missing.
Improve robustness when some expected packets where not received yet
or that were not correctly decoded. For example, don't try to decode
a picture if there was no valid frame headers parsed so far.

https://bugs.freedesktop.org/show_bug.cgi?id=57902
2013-12-10 16:14:27 +01:00
Gwenole Beauchesne
1dd89800b0 decoder: h264: fix decoding of BA3_SVA_C.264.
Conformance test Base_Ext_Main_profiles/BA3_SVA_C.264 complys with
extended profile specifications. However, the SPS header has the
constraint_set1_flag syntax element set to 1. This means that, if
a Main profile compliant decoder is available, then it should be
able to decode this stream.

This changes makes it possible to fall-back from Extended profile
to Main profile if constraint_set1_flag is set to 1.

https://bugzilla.gnome.org/show_bug.cgi?id=720190
2013-12-10 15:22:40 +01:00
Wind Yuan
009e4522bf decoder: h264: add support for constrained baseline profile.
Recognize streams marked as conforming to the "Constrained Baseline
Profile". If VA driver supports that as is, fine. Otherwise, fallback
to baseline, main or high profile.

Constrained Baseline Profile conveys coding tools that are common
to baseline profile and main profile.

https://bugzilla.gnome.org/show_bug.cgi?id=719947

[Added fallbacks to main and high profiles]
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-12-09 13:11:56 +01:00
Gwenole Beauchesne
bd5ae1b220 decoder: h264: fix decoding of scaling lists.
The GStreamer codecparser layer now parses the scaling lists in zigzag
scan order, as expected, so that to match the original bitstream layout
and specification. However, further convert the scaling lists into
raster scan order to fit the existing practice in most VA drivers.

https://bugzilla.gnome.org/show_bug.cgi?id=706406
2013-12-09 12:46:45 +01:00
Gwenole Beauchesne
e2f137f149 utils: add helpers for H.264 levels.
- gst_vaapi_utils_h264_get_level():
  Returns GstVaapiLevelH264 from H.264 level_idc value
- gst_vaapi_utils_h264_get_level_idc():
  Returns H.264 level_idc value from GstVaapiLevelH264
- gst_vaapi_utils_h264_get_level_limits():
  Returns level limits as specified in Table A-1 of the H.264 standard
- gst_vaapi_utils_h264_get_level_limits_table():
  Returns the Table A-1 specification
2013-12-06 19:26:15 +01:00
Gwenole Beauchesne
47dee4db96 utils: add new H.264 helper functions.
* Profiles:
- gst_vaapi_utils_h264_get_profile():
  Returns GstVaapiProfile from H.264 profile_idc value
- gst_vaapi_utils_h264_get_profile_idc():
  Returns H.264 profile_idc value from GstVaapiProfile

* Chroma formats:
- gst_vaapi_utils_h264_get_chroma_type():
  Returns GstVaapiChromaType from H.264 chroma_format_idc value
- gst_vaapi_utils_h264_get_chroma_format_idc():
  Returns H.264 chroma_format_idc value from GstVaapiChromaType
2013-12-06 19:25:21 +01:00
Gwenole Beauchesne
15519ebe3d legal: add per-file authorship information.
Credit original authors on a per-file basis as we cannot expect people
to know all country-specific rules, or bother browsing through the git
history.
2013-11-22 06:39:15 +01:00
Sreerenj Balachandran
976d27841a h264: add support for video cropping.
If the encoded stream has the frame_cropping_flag set, then associate
the cropping rectangle to GstVaapiPicture.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2013-07-08 18:54:15 +02:00
Gwenole Beauchesne
3cc7b26961 libs: use GstVaapiMiniObject for video decoders.
Port GstVaapiDecoder and GstVaapiDecoder{MPEG2,MPEG4,JPEG,H264,VC1} to
GstVaapiMiniObject. Add gst_vaapi_decoder_set_codec_state_changed_func()
helper function to let the user add a callback to a function triggered
whenever the codec state (e.g. caps) changes.
2013-05-07 17:51:27 +02:00
Gwenole Beauchesne
6439169db5 libs: refine GstVaapiMiniObject.
Drop support for user-defined data since this capability was not used
so far and GstVaapiMiniObject represents the smallest reference counted
object type. Add missing GST_VAAPI_MINI_OBJECT_CLASS() helper macro.

Besides, since GstVaapiMiniObject is a libgstvaapi internal object, it
is also possible to further simplify the layout of the object. i.e. merge
GstVaapiMiniObjectBase into GstVaapiMiniObject.
2013-05-07 17:51:27 +02:00
Gwenole Beauchesne
788d337505 decoder: fix unpaired GstBuffer map/unmaps.
This possibly fixes a few memory leaks along the way.
2013-04-10 14:58:17 +02:00
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
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
57ed7e3f8b decoder: sanitize uses of codec frame input buffer (cosmetics).
Alias GST_VAAPI_DECODER_CODEC_FRAME(decoder)->input_buffer to a simple
"buffer" variable.
2013-03-21 13:28:05 +01:00
Gwenole Beauchesne
ddaaa42020 h264: set {luma,chroma}_log2_weight_denom to 0 if no pred_weight_table().
Force luma_log2_weight_denom and chroma_log2_weight_denom to zero if
there is no pred_weight_table() that was parsed.

This is a workaround for the VA intel-driver on Ivy Bridge.
2013-02-08 11:56:54 +01:00
Gwenole Beauchesne
0c3650e7e8 h264: use new profile definitions from codecparsers. 2013-02-07 15:42:55 +01:00
Gwenole Beauchesne
0c99f351fc legal: fix year for some copyright notices (2013). 2013-01-29 14:37:02 +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
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
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
3f60f136cc h264: don't create sub-buffer for slice data. 2013-01-03 11:23:40 +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
7e6660fcae h264: initial port to new GstVaapiDecoder API 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
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
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
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
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
Simon Farnsworth
fa87396905 h264: use pixel-aspect-ratio from SPS header.
Propagate pixel-aspect-ratio determined by the GStreamer codecparser
from the sequence headers.

Signed-off-by: Simon Farnsworth <simon.farnsworth@onelan.co.uk>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-10-10 11:29:00 +02:00
Gwenole Beauchesne
3f430b32a4 h264: add decode_nalu() helper function.
Split decode_buffer() into the core infrastructure that determines
the NAL units contained in the adapter and the actual function that
decodes the NAL unit.
2012-10-10 10:35:20 +02:00
Gwenole Beauchesne
6f2e885f11 h264: fix end-of-stream conditions (flush).
Decode pending data in the adapter prior to processing the actual
code for end-of-stream.
2012-10-10 10:31:39 +02:00