Commit graph

49 commits

Author SHA1 Message Date
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
Gwenole Beauchesne
1c5c5ea9b8 h264: review and report errors accordingly.
Use GST_ERROR() to report real errors instead of hiding them into
GST_DEBUG().
2012-09-21 16:43:38 +02:00
Gwenole Beauchesne
dde9232e10 h264: exclusively use GstAdapter, drop sub-buffer hack.
Maintaining the sub-buffer is rather suboptimal especially since we
were also maintaining a GstAdapter. Now, we only use the GstAdapter
thus requiring minor extra parsing when receiving avcC buffers.
2012-09-20 18:04:19 +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
7277f0e220 h264: skip all Filler Data NALs. 2012-03-23 17:11:18 +01:00
Gwenole Beauchesne
63e29adbf5 h264: fix slice_data_bit_offset calculation.
Unlike what VA-API documentation defines, the slice_data_bit_offset
represents the offset to the first macroblock in the slice data, minus
any emulation prevention bytes in the slice_header().

This fix copes with binary-only VA drivers that won't be fixed any
time soon. Besides, this aligns with the current FFmpeg behaviour
that was based on those proprietary drivers implementing the API
incorrectly.
2012-03-02 13:41:16 +01:00
Wind Yuan
c979d51da6 h264: skip all Access Unit (AU) NALs.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-03-01 10:35:58 +01:00
Wind Yuan
6b56c84c9b h264: fix modification process of reference picture lists.
Construction of RefPicList0/1 could be off by one element.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-03-01 10:35:58 +01:00
Gwenole Beauchesne
82dbd6f5be h264: complete any current picture decoder before SPS / PPS change.
This ensures the VA context is clear when the encoded resolution
changes. i.e. make sure older picture is decoded with the older
VA context before it changes.
2012-02-08 18:08:49 +01:00
Gwenole Beauchesne
6c5054e840 h264: create VA context earlier when SPS is parsed. 2012-02-08 18:07:14 +01:00
Gwenole Beauchesne
26c105a6ca h264: don't allocate too big data structures on stack. 2012-02-08 17:57:29 +01:00
Gwenole Beauchesne
0fb1147d9c Add header for system-dependent definitions. 2012-01-30 19:52:10 +01:00
Gwenole Beauchesne
5cd0242bbb h264: simplify RefPicList reconstruction. 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
d656b958a3 h264: flush DPB when the end of the sequence is reached. 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
e52ca4a2c8 h264: handle Decoded Picture Buffer (DPB). 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
425060a7a8 h264: fix pred_weight_table() reconstruction.
Only the explicit pred_weight_table(), possibly with the inferred default
values, shall be required. e.g. don't fill in the table if weighted_pred_flag
is not set for P/SP slices.
2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
8c37221fa5 h264: execute reference picture marking process (MMCO). 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
61753fd55a h264: fix presentation timestamps. 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
16ccf82363 h264: execute reference picture marking process (sliding window). 2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
5a795b439c h264: handle avcC format for decoding buffers. 2012-01-29 15:27:59 +01:00
Sreerenj Balachandran
6d61965531 h264: handle codec-data.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
2012-01-29 15:27:59 +01:00
Gwenole Beauchesne
c071f80f40 Add initial H.264 decoder. 2012-01-29 15:27:59 +01:00