Commit graph

57 commits

Author SHA1 Message Date
Seungha Yang
efe35a3f6c h264parse, h265parse: Fix potential integer overflow
Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2961
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5295>
2023-09-08 12:45:12 +00:00
Seungha Yang
2c4cb82afc h264parse, h265parse: Fix timecode parsing
The scaling factor for nFrame part should be "(1 + nuit_field_based_flag) / 2"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5254>
2023-09-01 06:44:52 +00:00
Fabian Orccon
dd47fa53d8 h265parse: Parse SEI unregistered user data
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5070>
2023-07-25 18:28:26 +00:00
Jakub Adam
f7b719ae91 av1parse: calculate framerate from AV1 timing info
When framerate info isn't provided by upstream elements, try to extract
it from AV1 timing info, if present.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5041>
2023-07-19 20:45:05 +00:00
Stéphane Cerveau
2974c18a5c codecparsers: keep naming consistency in GST_H264_LEVEL
GST_H264_LEVEL_2 should be used instead of GST_H264_LEVEL_2_0

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4737>
2023-06-26 10:47:36 +00:00
Shengqi Yu
b092c3f580 h264parse: adjust some logs printing level in h264parse
adjust log level from GST_ERROR to GST_WARNING when h264 caps have
codec_data but no avc format or have no codec data or stream-format.
Because theses are not real errors, it is easy to mislead if print error
logs.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4675>
2023-05-20 02:07:36 +00:00
Seungha Yang
e9d8bf7532 h264parser: Define level enum values
... and stop duplicating it

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4595>
2023-05-17 21:29:25 +00:00
Nicolas Dufresne
c883fea19e h265parse: Don't override upstream framerate
The framerate should only be replaced (and corrected for alternating field)
when it is parsed from the bitstream. Otherwise, the upstream framerate
from caps should be trusted and assumed correct.

Related to gst-plugins-bad!2020

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4259>
2023-04-05 13:33:39 -04:00
Nicolas Dufresne
93904f1921 h265parse: Rename parsed_framerate to framerate_from_caps
That meaning of parsed_framerate is ambigious, it is set whenever the
framerate has been parsed from caps, which can be confused with being
parsed from the bitstream. Rename this as framerate_from_caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4259>
2023-04-05 13:33:39 -04:00
Nicolas Dufresne
9deb3d6aa4 h264parse: Stop considering NO_NAL as an error
The NO_NAL return value simply means that the buffer did not contain
enough data to identity a NAL. This should lead to waiting for more data not
considering the stream as invalid.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3234>
2023-03-17 21:25:49 +00:00
Tim-Philipp Müller
81716a1097 gst-plugins-bad: re-indent with GNU indent 2.2.12
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4182>
2023-03-17 03:18:54 +00:00
Seungha Yang
ad30fb87c2 h264parse: Validate VUI framerate
A few streams contain invalid/wrong framerate in VUI. Do validate
it based on the spec and ignore invalid VUI framerate values.

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1753
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4127>
2023-03-08 11:59:52 +00:00
Seungha Yang
8c596aeb5b h265parse: Use gst_h265_parser_parse_decoder_config_record()
Stop duplicating code and use newly added parsing method instead

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2759>
2023-03-06 12:50:41 +00:00
Mengkejiergeli Ba
eab15c8659 h265parse: Fix to check returned value
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3968>
2023-03-02 11:00:20 +00:00
Seungha Yang
5b84439711 h265parse: Always set profile on src caps
h265parse should provide profile for autoplugging

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4026>
2023-02-23 10:13:54 +00:00
Thibault Saunier
e49e0198f1 h264parse: Avoid setting wrong colorimetry info if the stream doesn't contain it
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3543>
2022-12-07 17:30:51 +00:00
He Junyan
e7d584a816 h265parse: Add the missing timestamp when splitting a frame.
When splitting a frame, the gst_buffer_copy_region() does not copy
the timestamp correctly for sub frames when the offset is not 0.
We still need those timestamps for each output sub frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3448>
2022-11-22 21:47:49 +00:00
He Junyan
dae73d6686 h264parse: Add the missing timestamp when splitting a frame.
When splitting a frame, the gst_buffer_copy_region() does not copy
the timestamp correctly for sub frames when the offset is not 0.
We still need those timestamps for each output sub frame.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3448>
2022-11-22 21:47:49 +00:00
Seungha Yang
32b13a883a vp9parse: Set subsampling to src caps even if GBR stream
Some muxer elements will need the subsampling information

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3297>
2022-10-31 11:29:38 +00:00
Seungha Yang
47f1dc837f vp9parse: Delaying src caps until frame is parsed if profile > 0
subsampling and/or bitdepth information will be required for
negotiation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3297>
2022-10-31 11:29:38 +00:00
He Junyan
242401915f av1parse: Correct the pts for frames and OBUs inside a TU.
When the output alignment is smaller than the input alignment, for
example, When the output alignment is "FRAME" and the parse is likely
connecting to a decoder, the current PTS setting for AV1 frames inside
a TU is not very correct.

For example, a TU may begin with non-displayed frames and end with a
displayed frame. The current way will assign the PTS to the first
non-displayed frame, which is a decode-only frame and the PTS will be
discarded in the video decoder. While the last displayed frame has
invalid PTS, and so the video decoder needs to guess its PTS based on
the frame rate and previous frame's PTS. This is not a decent and
robust way. And more important, when the previous frames provide DTS,
the video decoder will also guess the PTS based on the previous frames'
DTS and trigger the warning like:

  gstvideodecoder.c:3147:gst_video_decoder_prepare_finish_frame: \
  <vavp9dec0> decreasing timestame

It sets the reordered_output and makes the decoder in free run mode.

We should correct the PTS for a TU, let the non-displayed frames have
no PTS while set the correct PTS to the displayed one. Also, when the
AV1 stream has multi spatial layers, there are more than one displayed
frames inside one TU with the same PTS.

Note: If the input alignment is not TU aligned, we can not know the
exact PTS of this TU, and so we just clear the PTS of the decode only
frame and leave others unchanged.

We also correct all the PTS if the output is OBU aligned. All their
PTS and DTS are set to the input buffer's PTS.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3182>
2022-10-21 11:16:13 +00:00
He Junyan
a1f352196f av1parse: Only check the TU bound when the alignment is TU.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3182>
2022-10-21 11:16:13 +00:00
He Junyan
ee5d7ce075 av1parse: push all data once when input alignment not smaller than output.
When the incoming data has big alignment than the output, we do not need to
call finish_frame() and exit the current handle_frame() for each splitted
frame. We can push them all at one shot with in one handle_frame(), whcih
may improve the performance and can help us to find the edge of TU.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3182>
2022-10-21 11:16:13 +00:00
He Junyan
b7d3a219ab av1parse: Set the output buffer flags correctly.
The current code forgets to clear some flags and has some typo.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3182>
2022-10-21 11:16:13 +00:00
He Junyan
11436be268 vp9parse: The show_existing_frame buffer should not be decode only.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3155>
2022-10-13 06:41:06 +00:00
He Junyan
eac9c33cc1 vp9parse: Correct the pts for frames inside a super frame.
When the alignment is "FRAME" and the parse is likely connecting to
a decoder, the current PTS setting for VP9 frames inside a super
frame is not very correct.

For example, the super frame may begin with non-displayed frames and
end with a displayed frame. The current way will assign the PTS to
the first non-displayed frame, which is a decode-only frame and the
PTS will be discarded in the video decoder. While the last displayed
frame has invalid PTS, and so the video decoder needs to guess its
PTS based on the frame rate and previous frame's PTS. This is not a
decent and robust way. And more important, when the previous frames
provide DTS, the video decoder will also guess the PTS based on the
previous frames' DTS and trigger the warning like:

  gstvideodecoder.c:3147:gst_video_decoder_prepare_finish_frame: \
  <vavp9dec0> decreasing timestame

It sets the reordered_output and makes the decoder in free run mode.

We should correct the PTS for a super frame, let the non-displayed
frames have no PTS while set the correct PTS to the displayed one.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3155>
2022-10-13 06:41:06 +00:00
Thibault Saunier
6a4425e46a meson: Call pkgconfig.generate in the loop where we declare plugins dependencies
Removing some copy pasted code

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2970>
2022-09-01 21:17:35 +00:00
Benjamin Gaignard
a275e1e029 videoparsers: h265: Be less restrictive between PPS and SPS parsing order
Allow to parse PPS to be parser even if SPS hasn't been parsered before.
This help to parse VPSSPSPPS_A_MainConcept_1 conformance test

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2575>
2022-07-22 16:13:47 -04:00
He Junyan
f0d4135b3a h265parse: Fix uninitialized width and height when update src caps.
The commit b90d0274 introduces uninitialized width and height when we
consider to change the "pixel-aspect-ratio" for some interlaced stream.
We need to check the resolution in the src caps, and if no resolution
info found, there is no need to consider the aspect ratio.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2630>
2022-06-21 15:47:45 +00:00
Vivia Nikolaidou
b90d02741e avviddec, video.c, h265parse: Workaround for broken field-based interlaced encoders
Some encoders (e.g. Makito) have H265 field-based interlacing, but then
also specify an 1:2 pixel aspect ratio. That makes it kind-of work with
decoders that don't properly support field-based decoding, but makes us
end up with the wrong aspect ratio if we implement everything properly.
As a workaround, detect 1:2 pixel aspect ratio for field-based
interlacing, and check if making that 1:1 would make the new display
aspect ratio common. In that case, we override it with 1:1.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2577>
2022-06-16 10:03:02 +00:00
Seungha Yang
a1b4c62b35 h264parse: Use newly added avcC data parsing API
Use gst_h264_parser_parse_decoder_config_record() method to parse
codec_data.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2449>
2022-06-15 19:58:59 +00:00
Andoni Morales Alastruey
77937f9398 videoparse: rename from _free to _clear
The function does not free the structure but the data
contained within.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1458>
2022-06-03 08:29:05 +00:00
Andoni Morales Alastruey
ca2eb9f65f h264parse: add support Precision Time Stamp in SEI messages
Expose User Data Unregistered as a new Meta and add
API to parse Precision Time Stamp (ST 0604).

Fixes #927

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1458>
2022-06-03 08:29:05 +00:00
He Junyan
b2aaf0f2e5 av1parse: Fix a latent memory leak in colorimetry setting.
Also delete the useless "have_cinfo" judgement.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2288>
2022-04-26 02:14:15 +00:00
He Junyan
164e01b14e av1parse: Correct the meaning of color_range flag.
According to spec:
color range equal to 0 shall be referred to as the studio swing
representation and color range equal to 1 shall be referred to as
the full swing representation.

The current status is just the opposite.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2288>
2022-04-26 02:14:15 +00:00
Camilo Celis Guzman
8707d0cb26 gstav1parse: fixup various possible logical errors
Found via an analyzed build for Clang. Specifically we had:

gstav1parse.c[1850,11] in gst_av1_parse_detect_stream_format: Logic error: The left operand of '==' is a garbage value
gstav1parse.c[1606,11] in gst_av1_parse_handle_to_small_and_equal_align: Logic error: The left operand of '==' is a garbage value

Also a couple of false-positives:

gstav1parse.c[1398,24] in gst_av1_parse_handle_one_obu: Logic error: Branch condition evaluates to a garbage value
gstav1parse.c[1440,37] in gst_av1_parse_handle_one_obu: Logic error: The left operand of '-' is a garbage value

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2230>
2022-04-19 18:36:38 +00:00
Vivia Nikolaidou
cb8da91f7a h264parse: Include coded-picture-structure info in caps
This reverts commit 652773de36 and
modifies it to rename the caps field name to coded-picture-structure.

It was previously removed because it confuses the decoder and we didn't
have a valid use case for including it in the encoded caps at this
stage. We now do have such a use case but still don't want to confuse
the decoder, so the field is renamed.

However, it is still not accurate without looking at the SEI picture
structure of each frame, so it was named coded-picture-structure. If its
value is "frame" it is most likely progressive, if it's "field" it is
most likely interlaced or mixed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2177>
2022-04-18 11:00:29 +00:00
He Junyan
2d624a1d6b av1parse: Add a comment when the detection of TU fails.
Also update the print message.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1863>
2022-03-05 11:45:15 +08:00
He Junyan
9c4adf5a64 av1parse: check the error return when parse_alignment_from_caps()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
He Junyan
81bae87079 av1parse: Use the intersected caps to decide the alignment.
When we negotiate with downstream, We should use the intersected
caps of input and output to decide the alignment and stream format.
The current code just uses the input caps which may lack the stream
format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
He Junyan
4c8777667a av1parse: Only detect the stream format when input alignment is tu.
The demux now outputs the AV1 stream in "tu" alignment, so we do not need
to detect the input alignment. But the annex b stream format is not recognized
by the demux, we still need to detect that stream format for the first input.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
Nicolas Dufresne
29826aa80e av1parse: Save the default alignment
Otherwise the transformation is not applied and decoders may not
get the appropriate format despite the caps being negotiated
correctly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
Nicolas Dufresne
f627d6aafc av1parse: Remove duplicated check
The case of both strings being empty is already checked in the
helper function. No functional changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
Nicolas Dufresne
57c2adeeb2 vp9parse: Fix auto-plugging of HW frame decoder
Decoders that required frame aligmment and didn't have an associated
alpha decoder were skipped. This is because the parser was constructing
caps based on the software alpha decoder, which specify super-frame
alignment.

Iterate over the caps to filter the one that have a matching codec-alpha, with
the semantic the no codec-alpha field means codec-alpha=false. Then if
everything was removed, callback to the original, so that the first non-alpha
decoder will be picked.

Fixes #820

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1855>
2022-03-04 21:24:17 +00:00
He Junyan
90cea4fadf av1parse: Add temporal unit check when TD is absent.
The current manner for deciding the new temporal unit is based on
temporal delimiter(TD) OBU. We only start a new temporal unit when
the TD comes.
But some streams do not have TD at all, which makes the output "TU"
alignment fail to work. We now add check based on the relationship
between the different layers and it can successfully judge the TU edge.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1634>
2022-02-11 14:34:04 +08:00
He Junyan
a7ca0b2079 av1parse: let the parse continue when MISSING_OBU_REFERENCE error.
Some streams may have verbose OBUs before a valid sequence header. We
should let the parse continue rather than return a error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1634>
2022-02-11 14:21:34 +08:00
He Junyan
348658dd0a av1parse: Continue when we fail to detect the alignment.
Some streams may have problematic OBUs at the beginning, which causes
the parse fail to detect the alignment and return error. For example,
there may be verbose OBUs before a valid sequence, which should be
discarded until we meet a valid sequence. We should let the parse
continue when we meet such cases, rather than just return error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1634>
2022-02-11 14:20:13 +08:00
He Junyan
d334c08b55 av1parse: Set the "tu" as the default alignment.
The tu(temporal unit) is more widely used than the current alignment.
We now change the default alignment to tu.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1468>
2022-01-05 08:47:06 +00:00
He Junyan
cfd69b0467 av1parse: Fix the wrong DELTA_UNIT flag setting for key frames.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1468>
2022-01-05 08:47:06 +00:00
He Junyan
2266f70d79 av1parse: Copy the PTS and DURATION when we create data.
We need to create header buffers for annex b format. This kind of
buffers should inherit the PTS and DURATION from the original buffers.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1468>
2022-01-05 08:47:06 +00:00