Commit graph

239 commits

Author SHA1 Message Date
Nicolas Dufresne
ba8b605c6f h264parse: Propagate MARKER flag 2020-04-15 14:10:15 +00:00
Nicolas Dufresne
a194a87b26 h264parse: Don't wait for next NAL if input is aligned
Waiting for the next NAL increases the latency. If alignment=nal/au
has been negotiated, assumes that the buffer contains a complete
NAL and don't expect a second start-code. This way, nal -> nal,
au -> au and au -> nal no longer introduce latency.

As a side effect, the collect_pad() function was not able to poke at the
following NAL. This call is now moved before processing the NAL, so
it's looking at the current NAL before it's ingested into the parser
state in order to dermin if the end of an AU has been reached. The AUD
injection state as been adapted to support this.

This change will break pipelines if alignment=nal is used without respecting the
alignment. Effectively, the parser will no longer fix the broken aligment
which will result in parser error and the termination of the pipeline. Such
issue existed in tsdemux element and might exist in any forks of that code.

Related to https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1193
2020-04-15 14:10:15 +00:00
Nicolas Dufresne
ea99aee881 h264parse: Set PTS/DTS and DISCONT on crafted NAL
When we inject a NAL in the bitstream before another one, make
sure to pass both DTS and PTS. Also make sure to transfer the
DISCONT flag properly.
2020-04-15 14:10:15 +00:00
Nicolas Dufresne
596dfbdf37 h264parse: Remove no-op assignment
upstream was set to *out_ts, setting *out_ts to upstream here will
have no effect.
2020-04-15 14:10:15 +00:00
Seungha Yang
462a8130a6 h264parse: Remove useless comparison
sei_pic_struct is unsigned and GST_H264_SEI_PIC_STRUCT_FRAME is zero.

CID: 1461467
2020-04-13 12:28:14 +00:00
Nicolas Dufresne
eea520fe6d h264parse: Fix content light level value changes
Same as for H265, was found by Coverity.
2020-04-08 14:01:23 -04:00
Seungha Yang
be8cec5348 h264parse: Add support for inband timecode update
Add new property "update-timecode" to allow updating timecode
in picture timing SEI depending on timecode meta. Since the picture
timing SEI message requires proper VUI setting but we don't support
re-writing SPS, this might not work for some streams
2020-04-08 15:39:12 +00:00
Seungha Yang
fffbec11e4 h264parse: Don't unconditionally append timecode meta
If upstream buffer has its own timecode metatdata, don't append
new timecode meta into the buffer.
2020-04-08 15:39:12 +00:00
Seungha Yang
1a09251699 h264parser: Parse all SEI payload type even if it's not handled by parser
... so that user can handle it from outside of parser API
2020-04-08 15:39:12 +00:00
Seungha Yang
f05effe024 h264parse,h265parse: Update for video-hdr struct change
See the change of -base https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/594
2020-04-01 05:18:11 +00:00
Seungha Yang
d81438a69e h264parse: Print all the syntax elements of frame packing for debugging
Other values might be useful for debugging
2020-03-31 08:30:50 +00:00
Seungha Yang
82a7d1cd99 h264parse: In-band sps/pps update if only codec_data differs in src caps
Initially the case "only codec_data is different" was addressed in
https://bugzilla.gnome.org/show_bug.cgi?id=705333 in order for
unusual bitstreams to be handled. That's the case where sps and pps
are placed in bitstream. When sps/pps are signalled only via caps
by upstream, however, the updated codec_data is mandatory for decoder
and therefore we shouldn't ignore them.
2020-03-10 08:51:04 +00:00
Josep Torra
bebf20c906 h264parse: do not push wrong PTS with some raw files
Some raw h264 encoded files trigger the assignment of wrong PTS to buffers
when some SEI data is provided. This change prevents it to happen.

Also ensure this behavior is being tested.
2020-01-10 15:03:38 +00:00
Stéphane Cerveau
4b8c47ee37 h26xparse: Handle state change on IDR first slice
As the H265/H264 bitstream can support multiple slices,
mastering_display_info_state and content_light_level_state
should be changed only on first slice segment.

Fix #1152
2020-01-07 08:55:28 +00:00
Stéphane Cerveau
b481edd745 h264parser: add MDCV and CLL SEI message parsing
Allow to parse SEI message for:
- mastering display colour volume
- Light level infomation

Set to caps if necessary.

Fix #958
2020-01-07 08:55:28 +00:00
Stéphane Cerveau
c6eb17be6e h264parse: Align GST_H264_PROFILE_HIGH_422 to H264 standards
According to H264 ITU standards from 06/19, GST_H264_PROFILE_HIGH_422
(profile_idc = 122) with constraint_set1_flag = 0 and
constraint_set3_flag = 0 can be mapped to high-4:2:2 or high-4:4:4.
GST_H264_PROFILE_HIGH_422 with constraint_set1_flag = 0 and
constraint_set3_flag = 1 can be mapped to high-4:2:2, high-4:4:4,
high-4:2:2-intra or high-4:4:4-intra.
2019-12-18 03:03:40 +00:00
Aaron Boxer
e3297be433 h264parse: buffer mismatch in map/unmap 2019-11-26 13:07:47 -05:00
Vivia Nikolaidou
851682629e videoparsers: Disable gst_base_parse_set_infer_ts
From the documentation of gst_base_parse_set_infer_ts, it should be
disabled for non-audio data. Currently just disabling for all video
parsers that have reordered data: h264, h265, mpeg, mpeg4, vc1. Was
already disabled in h263.
2019-11-19 10:23:31 +02:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Yeongjin Jeong
0318458b0e h264parse: Fix wrong NALU minimum length check
Fixes a problem where an EOS/EOB NALU placed at the end of
an AU is detected as an other AU and create a buffer that
does not have valid pts.
2019-11-04 14:16:49 +09:00
Guillaume Desmottes
e0d9722a1b h264parse: fix colorimetry in src caps if sink caps has no structure
We do want to include the colorimetry in the src caps if the sink caps
doesn't have any structure associated.
2019-08-27 06:06:01 +00:00
Aaron Boxer
b7558bd190 h264parse: use gstvideoparseutils to handle user data 2019-08-26 18:14:17 -04:00
Matthew Waters
062ca5e55b h264parse: don't critical on VUI parameters > 2^31
A guint32 greater than 2^31 would be interpreted as negative by
gst_util_uint64_scale_int() and critical. Use the 64-bit integer version
of the function instead.
2019-08-20 18:12:56 +10:00
Fuwei Tang
f3587c61ba h264parse: fix issue that caps "interlace-mode" can't be updated correctly
Upstream overrides the info "interlace-mode", otherwise update it with
SPS info.
2019-08-06 09:47:36 +08:00
Mathieu Duponchelle
2305bf272c h26{4,5}parse: add support for forward predicted trick mode
Also stop assigning TRUE to fields with |=
2019-07-18 13:46:45 +00:00
Seungha Yang
06d85ca487 h264parse: Update caps per pixel aspect ratio change
Output caps should be updated per pixel aspect ratio change.
2019-07-16 17:53:42 +00:00
Seungha Yang
375acd5a79 h264parse: Expose parsed colorimetry when VUI provided it
... and also if upstream did not specify the colorimetry.
2019-07-16 17:53:42 +00:00
Jan Schmidt
8899a471e3 h264parse lib: Remove the SPS parse_vui_params flag
The SPS parsing functions take a parse_vui_param flag
to skip VUI parsing, but there's no indication in the output
SPS struct that the VUI was skipped.

The only caller that ever passed FALSE seems to be the
important gst_h264_parser_parse_nal() function, meaning - so the
cached SPS were always silently invalid. That needs changing
anyway, meaning noone ever passes FALSE.

I don't see any use for saving a few microseconds in
order to silently produce garbage, and since this is still
unstable API, let's remove the parse_vui_param.
2019-07-05 00:17:59 +10:00
Nicola Murino
c22b52ef4d h264parse: update parser state and header flag when using fallback sps
When sps parsing fails we use a fallback sps from the caps, since we
have got an sps we need to update parser state and header as in the case the
sps was successfully parsed

Closes #503
2019-06-15 20:02:10 -04:00
Thibault Saunier
475628c20e h264parse: Post a WARNING when data is broken 2019-06-15 23:13:43 +00:00
Xavier Claessens
63562d0b0a h264parse: Fix typo when setting multiview mode and flags 2019-05-02 12:06:36 +00:00
Tim-Philipp Müller
76f1ed15fb h264parse: extract CEA-708 closed captions
Expose SEI data in the H.264 bitstream parser API and
extract closed captions and other things that are not
specified in the H.264 spec itself in the videoparser.

Based on patch by: Mathieu Duponchelle <mathieu@centricular.com>

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/940
2019-04-08 19:21:34 +01:00
Mathieu Duponchelle
0e89f2a6d9 h264parse, h265parse: take unit_field_based_flag into account ..
when computing timecode metas. Depending on the value of that flag,
n_frames is to be interpreted as a number of fields or a number of
frames. As GstVideoTimeCodeMeta always deals with frames, we want
to scale that number when needed.
2019-04-02 15:18:03 +02:00
Mathieu Duponchelle
7c425cf339 h264parse: forward time codes
This transforms time codes from the timing SEI into
GstVideoTimeCodeMeta
2019-04-01 10:02:33 +00:00
Seungha Yang
8766a45ee4 h26{4,5}parse: Don't confuse nal of codec_data with frame
vps/sps/pps in codec_data shouldn't be considered as inband data.
Otherwise, h26{4,5}parse never insert them to nal when transform
(packetized to byte-stream) use case
2018-12-13 10:32:30 +00:00
Guillaume Desmottes
5ac4a6e003 h264parse: mark SEI Recovery Point as keyframes
The spec states that "recovery point SEI message assists a decoder in
determining when the decoding process will produce acceptable
pictures for display after the decoder initiates random access or after the
encoder indicates a broken link in the coded video sequence."

Mark those as keyframes so muxers will mark them as seek points and
decoders will be able to start decoding from them rather than waiting
for an IDR.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/790
2018-12-02 02:07:39 +00:00
Seungha Yang
4f7fe897b9 h264parse: Don't duplicate SPS/PPS per config-interval if exists
Don't need to manually insert SPS/PPS since inband data could be useable.

Fixes #824
2018-11-30 02:19:17 +00:00
Guillaume Desmottes
5a5bf4b3e3 h264parse: add constrained and progressive profiles
Those profiles have been added in the version 2012-01
and 2011-06 of the AVC spec.

https://bugzilla.gnome.org/show_bug.cgi?id=794127
2018-04-25 09:12:45 +02:00
Brendan Shanks
8e3827b7be h264parse: reset internal 'state' variable properly
Reset the internal 'state' variable when the parser is started, fixes
errors when parser is being re-used.

https://bugzilla.gnome.org/show_bug.cgi?id=794537
2018-03-21 09:12:28 +02:00
Nicolas Dufresne
7e45b9f03f Revert "h264parse: early set src caps when input is avc"
This reverts commit 5ac886d85a.
2018-03-02 10:37:45 -05:00
Guillaume Desmottes
a1b271d2ec h26{4,5}parse: expose chroma format and bit depth in caps
This information could be used for example to pick a decoder supporting
a specific chroma and/or bit depth, like 4:2:2 10 bits.
It can also be used to inform earlier decoder about the format it is
about to decode.

https://bugzilla.gnome.org/show_bug.cgi?id=792039
2018-01-24 11:50:54 -05:00
Tim-Philipp Müller
c0226e08e3 h264parse: make caps writable before modifying them
https://bugzilla.gnome.org/show_bug.cgi?id=790628
2017-12-07 19:17:07 +00:00
Guillaume Desmottes
5ac886d85a h264parse: early set src caps when input is avc
When input is in AVC format there is no need to wait for the first buffer
before setting src caps. We already have all the information from the
input codec_data.

This allow us to already configure downstream elements allowing them,
for example, to already allocate their internal buffers as they know
the format of the input they are about to receive.

https://bugzilla.gnome.org/show_bug.cgi?id=790709
2017-11-24 11:13:05 +02:00
Guillaume Desmottes
d5067b42de h264parse: put downstream caps first if possible on sink caps
Try prioritizing downstream's caps over upstream's if possible so the
parser can configured in "passthrough" if possible and save it from
doing useless conversions.

https://bugzilla.gnome.org/show_bug.cgi?id=790628
2017-11-22 17:38:04 +02:00
Vincent Penquerc'h
a06423efa4 h264parse: fix caps leak in renegotiation 2017-05-12 11:15:00 +01:00
Sebastian Dröge
8f8c5e25fa h264parse: frame->buffer can't be NULL in pre_push_frame()
CID 1402118
2017-03-08 14:22:52 +02:00
Hyunjun Ko
a997a99fdd h264parse: fix some failures in testcases
Move logic of judgement whether or not to insert AU Delimiter before
draining.
Besides, aud_needed flag is reset to TRUE when skip.

https://bugzilla.gnome.org/show_bug.cgi?id=736213
2017-03-08 14:18:18 +02:00
Hyunjun Ko
201e71c3aa h264parse: insert AU delimiter only in case of byte-stream
Inserts AU delimeter by default if missing au delimeter from upstream.
This should be done only in case of byte-stream format.

Note that:
We have to compensate for the new bytes added for the AU, otherwise
insertion of PPS/SPS will use wrong offsets and overwrite wrong data.

Also mark the AU delimiter blob const, and use frame->out_buffer for
storing the output to keep baseparse assumptions valid.

Original-Patch-By: Michal Lazo <michal.lazo@mdragon.org>
Helped by Sebastian Dröge <sebastian@centricular.com>

https://bugzilla.gnome.org/show_bug.cgi?id=736213
2017-03-07 13:27:33 +02:00
Thibault Saunier
b75a61342f h264parse: Include interlace-mode in caps
Those are the rules:

In the SPS:
  * if frame_mbs_only_flag=1 => all frame progressive
  * if frame_mbs_only_flag=0 => field_pic_flag defines if each frame is
    progressive or interlaced, thus the mode is 'mixed' in GStreamer
    terms.

https://bugzilla.gnome.org/show_bug.cgi?id=779309
2017-02-27 15:28:31 -03:00
Sebastian Dröge
55043aff12 h264parse: Fix indentation 2016-11-26 12:16:58 +02:00