Commit graph

217 commits

Author SHA1 Message Date
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
Sebastian Dröge
47bf425cba h264parse: Fix assertion when encountering an invalid NALU
Error out properly instead.

https://bugzilla.gnome.org/show_bug.cgi?id=775130
2016-11-26 12:16:58 +02:00
Sebastian Dröge
1dbfef93d6 h264parse: Ensure codec_data has the required size when reading number of SPS
https://bugzilla.gnome.org/show_bug.cgi?id=774896
2016-11-23 10:53:40 +02:00
Nirbheek Chauhan
bb0a83b018 plugins: Use explicit type conversion from enums
MSVC warns about this because it's a C++ compiler, and this actually
results in useful things such as the incorrect 'gboolean' return value
for functions that return GstFlowReturn, so let's do explicit
conversions to reduce the noise and increase its efficacy.
2016-10-27 23:06:26 +05:30
Sreerenj Balachandran
14cc51cddc videoparsers: h264: Add more scalable profiles to the profile list
Adding Scalable Constrained High (G.10.1.2.1) and
Scalable High Intra(G.10.1.3) profiles to the profile list

https://bugzilla.gnome.org/show_bug.cgi?id=769303
2016-08-02 14:26:40 +03:00
Edward Hervey
c19d1b46c3 h264parse: Drop filler data
When skipping data, check if they are filler bytes. If so, drop the
data instead of skipping. We don't want to output filler bytes, but they
shouldn't cause a discontinuity.

https://bugzilla.gnome.org/show_bug.cgi?id=768125
2016-06-30 10:32:01 +02:00
Jan Schmidt
92e7e3a3bf h264parse: When input alignment=AU, always drain each packet.
If the input alignment claims AU alignment, each received
buffer should contain a complete video frame, so never hold over parts
of buffers for later processing. Also reduces latency, as packets
are parsed/converted and output immediately instead of 1 buffer
later.

Fixes a problem where an (arguably disallowed) padding byte on the
end of a buffer is detected as an extra byte in the following
start code, and messes up the timestamping that should apply to
that start code.
2016-06-24 22:55:18 +10:00
Mats Lindestam
a0876aa750 h264parse: support for handling of config-interval = -1
Added support for handling of config-interval = -1.
config-inteval = -1 represents resending SPS and PPS for each
I-/IDR-frame.

https://bugzilla.gnome.org/show_bug.cgi?id=766803
2016-06-13 10:10:21 +01:00
Mats Lindestam
bf0d952387 h264parse: refactored handling of SPS/PPS when pushing frames
https://bugzilla.gnome.org/show_bug.cgi?id=766803
2016-06-13 10:10:05 +01:00
Mats Lindestam
0c04e004bb h264parse: change "config-interval" property type from uint to int
So we can use -1 as special value like in rtph264pay.

https://bugzilla.gnome.org/show_bug.cgi?id=766803
2016-06-13 10:08:22 +01:00
Sebastian Dröge
4bdda1d810 h264parse: H264 level idc 0 is not valid
Don't put level=0 into the caps, it confuses other elements.

https://bugzilla.gnome.org/show_bug.cgi?id=765538
2016-04-25 18:50:59 +03:00
Sebastian Dröge
0fa43aaab4 h264parse: constrained-baseline is a subset of baseline
We get into this code path if the profile is already constrained-baseline and
downstream does not support constrained-baseline. So we should try baseline
and the other compatible profiles.

https://bugzilla.gnome.org/show_bug.cgi?id=764448
2016-04-01 12:08:29 +03:00
Vineeth TM
8cdfb13658 bad: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763081
2016-03-24 14:56:51 +02:00
Aleksander Wabik
d8e681bb63 h264parse, h265parse: fix handling of downstream force-key-unit events
The parser handles the downstream force-key-unit event incorrectly,
it tries to parse it as an upstream force-key-unit event, does not
check the return value, and then uses uninitialized memory in
"all_headers" boolean variable.

https://bugzilla.gnome.org/show_bug.cgi?id=763793
2016-03-17 19:24:32 +00:00
Sreerenj Balachandran
cf7056a312 videoparsers: h264: Disable passthorugh mode enabling
Enabling passthorugh mode is causing multiple issue:
For nal aligned multiresoluton streams, passthrough mode
make h264parse unable to advertise the new resoultions.
Also causing issues while parsing MVC streams which have two
separate layers (base-view and non-base-view).

This fix is only a temporary workaround.

For MVC, proper fixes needed in many places:
(handle prefix nal unit, handle non-base-view slice nal extension,
fix the picture_start detection for multi-layer-mvc streams etc)

https://bugzilla.gnome.org/show_bug.cgi?id=758656
2016-02-29 12:35:58 +02:00
Luis de Bethencourt
63af4649c6 h264parse: remove unused mview_mode value
Since commit b77f8e172a the new value
assigned to mview_mode hasn't been used. That commit changed the following
"if" check to an "else if", which means the original value of mview_mode
is used.
2016-02-04 12:50:47 +00:00
Matthew Waters
72bc7d7f73 h264parse: increase caps equality check for no codec_data
When converting from avc to byte-stream, there will not be any codec_data
in the src caps.  Remove it before the equality check to avoid sending caps
events downstream on every SPS/PPS change.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-02-04 18:07:57 +11:00
Matthew Waters
f352691a04 h264parse: try the current caps before querying downstream
If we have a stream that contains an unchanging SPS/PPS for every video frame,
we don't need to to constantly query downstream for it's supported caps if the
current caps are compatible with the negotiated caps.

https://bugzilla.gnome.org/show_bug.cgi?id=761014
2016-02-04 18:07:47 +11:00
Dave Craig
88d7beb921 videoparsers: Check for NULL return value of gst_pad_get_current_caps()
https://bugzilla.gnome.org/show_bug.cgi?id=759503
2015-12-16 10:08:43 +01:00
Nicolas Dufresne
fe116092cd h26xparse: Resend PPS/SPS after seek
This is to support byte-stream decoder that does not remember the
PPS/SPS after a flush. This is not needed by all decoders, but is
harmless for those that do remember.

https://bugzilla.gnome.org/show_bug.cgi?id=758405
2015-12-05 19:05:26 -05:00
Nicolas Dufresne
b392a6e3b9 h264parse/h265parse: Fix negotiation crash
As it's recursive, gst_pad_get_allowed_caps() may also return
empty for anything incompatible downstream. EMPTY is not valid caps
value for gst_caps_fixate(). This lead to assertion and then crash.
Ideally, the negotiate function should be re-factored to have a return
value, and we could make the negotiation fails earlier.

https://bugzilla.gnome.org/show_bug.cgi?id=754122
2015-08-26 10:56:07 -04:00
Olivier Crête
567b1e8c46 videoparsers: Use gst_base_parse_merge_tags()
Instead of squashing all upstream tags

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-16 17:28:29 +01:00
Jan Schmidt
fdac09d843 h264parse: Clear SPS info after processing.
The SPS struct might be filled out by a call to
gst_h264_parser_parse_subset_sps, which fills out
dynamically allocated data and requires a call
to gst_h264_sps_clear() to free it. Also make sure
to clear out any allocated SPS data when returning
an error.

https://bugzilla.gnome.org/show_bug.cgi?id=753306
2015-08-15 15:39:23 +10:00