Commit graph

113 commits

Author SHA1 Message Date
Seungha Yang
86e312c1b1 codecs: h264decoder: Add support for output delay
Some decoding APIs support delayed output or a command for decoding
a frame doesn't need to be sequential to corresponding command for
getting decoded frame. For instance, subclass might be able to
request decoding for multiple frames and then get for one (oldest)
decoded frame or so.
If aforementioned case is supported by specific decoding API,
delayed output might show better throughput performance.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1925>
2021-01-29 16:22:28 +00:00
He Junyan
057fedd178 codecs: mpeg2decoder: Fix a typo in header file's comment.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1963>
2021-01-20 00:57:34 +08:00
Seungha Yang
ae7c20a6ed codecs: h264picture: Count only complete complementary field pair for dpb fullness decision
Our DPB implementation was designed as such that allowing
temporary DPB overflow in the middle of field picture decoding
and incomplete field pair should not trigger DPB bumping.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 23:27:27 +09:00
Seungha Yang
e14bbd7f5c codecs: h264decoder: Add support for field-pair input frame
In case that upstream pushed buffer as a frame unit, not picture
unit for interlaced stream, baseclass should be able to detect
AU boundary (i.e., complementary field pair).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 23:11:01 +09:00
Seungha Yang
6366435e19 codecs: h264decoder: Remove unused private variables
... and reset() method to clear internal status at one place

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1947>
2021-01-10 22:02:54 +09:00
Víctor Manuel Jáquez Leal
a926511df4 codecs: mpeg2decoder: decode only if B and not closed gop
Mark as decode only if picture type is B, without previous picture in DBP and
closed_gop is 0 as might be understood in "6.3.8 Group of pictures header".

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1939>
2021-01-06 16:47:42 +01:00
Víctor Manuel Jáquez Leal
ec15caff93 codecs: mpeg2decoder: rename variables
Since prev_picture and next_picture are plain pointers, not pointer to pointers,
it's misleading to name them with _ptr suffix.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1939>
2021-01-06 16:47:42 +01:00
He Junyan
41d2edc964 codecs: mpeg2decoder: Creating the field based on its arriving time.
Spec says:
In a frame picture top_field_first being set to ‘1’ indicates that the
top field of the reconstructed frame is the first field output by the
decoding process. top_field_first being set to ‘0’ indicates that the
bottom field of the reconstructed frame is the first field output by
decoding process.

Here, the "output" should be interpreted just as the output order, not
including the decoding order. The field should be decoded as the order
they comes in the stream. Namely, no matter top_field_first is 0 or 1,
the first coming field is the first one to be decoded.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1929>
2021-01-04 13:09:01 +00:00
He Junyan
459abad096 codecs: Add buffer_flags for mpeg2 picture.
We need to store the buffer flags such as GST_VIDEO_BUFFER_FLAG_INTERLACED
and GST_VIDEO_BUFFER_FLAG_TFF for interlaced video. Without these flags,
the VPP and display elements can not apply filter correctly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1929>
2021-01-04 13:09:01 +00:00
He Junyan
339a816c81 codecs: Reset the quant matrices for each sequence in mpeg2 decoder.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1929>
2021-01-04 13:09:01 +00:00
He Junyan
29be6ff83a codecs: Fix a typo in mpeg2 stateless decoder base class.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1915>
2020-12-28 17:13:22 +08:00
Víctor Manuel Jáquez Leal
060c54ab07 codecs: mpeg2decoder: fix documentation
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1798>
2020-12-28 13:15:50 +08:00
Víctor Manuel Jáquez Leal
5243048cb0 codecs: mpeg2decoder: simplify macros
For constructors, instead of casting to pointers, cast to the structures.

For compare, use inlined functions.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1798>
2020-12-28 13:14:51 +08:00
He Junyan
0e161dd363 codecs: Add mpeg2 stateless decoder base class.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1798>
2020-12-28 13:05:29 +08:00
Víctor Manuel Jáquez Leal
1a5862dd39 codecs: h264decoder: fix memory leak
gst_h264_dbp_get_picture_all() returns a full transfer of the GArray, which
needs be unrefed. But it is not unrefed in
gst_h264_decoder_find_first_field_picture() leaking it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1827>
2020-11-23 15:23:35 +01:00
Seungha Yang
64ea751cd2 codecs: h264decoder: Add support for field ref picture list modification
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:57:30 +09:00
Seungha Yang
88ebe8031a codecs: h264decoder: Add more option arguments for reference picture getter
In case that "pic_order_cnt_type" is equal to zero, ref picture
list for B slice should not include non-existing picture
as per spec 8.2.4.2.3. And, the second field is not needed
for the process of frame picture reference list construction
since it needs to be frame unit, not field picture in that case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:44:04 +09:00
Seungha Yang
e1adc572a7 codecs: h264decoder: Split gap picture as well if needed
field pair pictures might be required for reference list
depending on context.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:08:47 +09:00
Nicolas Dufresne
4ee6167616 h264dec: Fix POC calculation for type 0
This is mostly for future use as it only fixes the caclulation for interlaced
cases, the case of frame seemed correct already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 19:00:39 +09:00
Seungha Yang
11509fded1 codecs: h264decoder: Don't try to construct RefPicList0 and RefPicList1 if not required
We were trying to construct reference picture list even for
I slice before this commit. Reference list is required only for
P, SP and B slices. Also, if all existing reference pictures
are gap pictures, we don't need to construct lists.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1812>
2020-11-17 18:29:54 +09:00
Seungha Yang
fec686145e codecs: h264decoder: Fix MMCO type 1 for interlaced stream
If field_pic_flag of current picture is equal to zero,
both field of reference field pair should be marked as
"unused for reference"

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1810>
2020-11-16 14:25:36 +00:00
Seungha Yang
b83d452cc2 codecs: h264decoder: Fix MMCO type 3 for interlaced stream
Depending on short-ref picture corresponding to picNumX value,
there's a condition that only one field should be updated to
be non-reference picture.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1810>
2020-11-16 14:25:36 +00:00
Seungha Yang
caa5eb65d1 codecs: h264decoder: Split frame picture into field pictures if needed
In case of interlaced stream, frame pictures need to be splitted
into field for reference marking process.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1810>
2020-11-16 14:25:36 +00:00
Seungha Yang
7b42b1f9fb codecs: h264decoder: Add util macro for frame/field picture identification
Add a macro to check whether given GstH264Picture is for frame or field
decoding.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1810>
2020-11-16 14:25:36 +00:00
Seungha Yang
f9af93d841 codecs: h264decoder: Don't give up to decode due to missing reference picture
Missing reference picture is very common thing for broken/malformed stream.
Decoder should be able to keep decoding if it's not a very critical error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1809>
2020-11-14 16:17:18 +00:00
Seungha Yang
0b9f975b36 codecs: h264decoder: Add support for interlaced stream
Initial support for interlaced stream. Subclass should implement
new_field_picture() vfunc. Otherwise, baseclass will assume that
subclass doesn't support interlaced stream.

Restrictions:
* Reference picture modification process for interlaced stream
  is not implemented yet
* PAFF (Picture Adaptive Frame Field) is not properly implemented.
* Field display ordering (e.g., top-field-first) decision should
  be enhanced via picture timing SEI parsing
* Gap in field picture should be handled

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:43 +00:00
Seungha Yang
52a8864076 codecs: h264decoder: Rename DPB methods
Clarify wheter it's for picture(field) or frame in order to
support interlaced stream, because DPB size is frame unit, not picture
in case of interlaced stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
9bd6b5f0b4 codecs: h264decoder: Remove interlaced stream related constraints
... and add new_field_picture() vfunc so that ensure interlaced
decoding support by subclass.
The method will be used later with interlaced stream support.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
5585314b56 codecs: h264decoder: Move to inline GstH264DecoderClass documentation
Don't duplicate documentation for class vfunc. Hotdoc doesn't seem
to be happy with duplicated documentation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
7a53d7a4aa codecs: h264decoder: Store reference picture type using enum value
Managing reference picture type by using two variables
(ref and long_term) seems to be redundant and that can be
represented by using a single enum value.

This is to sync this implementation with gstreamer-vaapi so that
make comparison between this and gstreamer-vaapi easier and also
in order to minimize the change required for subclass to be able
to support interlaced.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
157210eb19 codecs: h264decoder: Minor documentation fix
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1534>
2020-11-13 15:25:42 +00:00
Seungha Yang
227456d240 codecs: h264decoder: Remove DPB size related spammy debug message
It's not informative at all if SPS wasn't updated. Also we are printing
DPB size related debug message in another place already.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1806>
2020-11-13 14:50:09 +00:00
Seungha Yang
6a6f8c967c codecs: h264decoder: Don't fill gap picture if it's not allowed
We should fill gap picture only if sps->gaps_in_frame_num_value_allowed_flag
is set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1801>
2020-11-12 14:38:56 +00:00
He Junyan
04472c5adb codecs: vp8decoder: Fix two typo of struct name.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1797>
2020-11-11 18:52:37 +00:00
Seungha Yang
5342b05390 codecs: h264decoder: Fix missing drain handling in bumping
Should've included in the commit 5527cc4a2e

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1783>
2020-11-09 14:40:06 +00:00
Seungha Yang
64c1218948 codecs: h264decoder: Try reference picture marking process in any case
... even if there is some invalid conditions
(because of broken stream, our implementation fault or so).
Otherwise baseclass will keep such reference pictures and
it would result to DPB full.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1783>
2020-11-09 14:40:06 +00:00
Seungha Yang
81151145b2 codecs: h264decoder: Reset frame number per MMCO type 5
It should be cleared so that avoid wrong frame gap detection
for following pictures.

Passing 4 more conformance bitstream tests
* MR2_TANDBERG_E
* MR3_TANDBERG_B
* MR4_TANDBERG_C
* MR5_TANDBERG_C

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1768>
2020-11-05 14:56:28 +00:00
Seungha Yang
e78dc91f9e codecs: h264decoder: Fix for MMCO type 2
As per 8.2.5.4.2, we should mark a picture which has
LongTermPicNum == long_term_pic_num as "unused for reference",
not pic_num.

Passing conformance bitstream test with MR2_MW_A

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1768>
2020-11-05 14:56:28 +00:00
Seungha Yang
0e53668a9b codecs: h264picture: Add more trace log
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1768>
2020-11-05 14:56:28 +00:00
Nicolas Dufresne
c1502a2bdf h265decoder: Remove unsued WpOffsetHalfRangeC
This is only needed for VA implementation of weight tables and isn't used
within the base class.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1714>
2020-11-04 17:53:23 +00:00
Seungha Yang
5527cc4a2e codecs: h264decoder: Rework for DPB management
Sync with recent h265decoder DPB implementation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1761>
2020-11-05 02:26:47 +09:00
Seungha Yang
b70ceb4235 codecs: h264decoder: Remove unused pts variable
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1761>
2020-11-05 00:33:34 +09:00
Seungha Yang
d1f397e754 codecs: h265picture: Minor update for coding style
It's GstH265Dpb, not GstH265Decoder

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1755>
2020-11-02 20:20:56 +00:00
Seungha Yang
db10288382 codecs: h265decoder: Make GstVideoCodecFrame hold the last reference of the buffer
The functionality of passing the last reference of GstH265Picture
was silently dropped by the commit eeffd91109
This commit will make it work again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1755>
2020-11-02 20:20:56 +00:00
Seungha Yang
b69840711e codecs: h265decoder: Clear GstVideoCodecFrame on DPB clear if needed
h265decoder might need to clear DPB depending on context even if
it's not flushing case. So associated GstVideoCodecFrame needs to be
released in case non-flushing case.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1755>
2020-11-02 20:20:56 +00:00
Seungha Yang
16b4fe3d0b codecs: h265decoder: Don't drain DPB on EOB/EOS/IDR nalu
DPB bumping decision per end-of-bitstream, end-of-sequence or IDR nal
should done by spec. In short, draining on EOB/EOS/IDR is undefined
behavior as per spec.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1755>
2020-11-02 20:20:56 +00:00
Nicolas Dufresne
849b7a315c h265decoder: Complete dependent slice header
This will save the last independent slice and fill in the missing
information for dependent slices. This was left over during the porting
from gstreamer-vaapi. The private variable prev_independent_slice was
already there.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1750>
2020-11-02 18:20:32 +00:00
Nicolas Dufresne
e3fb5f894f h265decoder: Prevent possible infinite loop
Theoretically, one could produce a broken stream that would lead to
infinite in the specified algorithm to calculate l0/l1 reference lists.
This patch will pearly exit if this condition is met.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1750>
2020-11-02 18:20:32 +00:00
Seungha Yang
eeffd91109 codecs: h265decocer: Rework for DPB management
* Move all DPB bumping process into GstH265Dpb internal
* Handle DPB add process in GstH265Dpb struct
* Make implementation to be 1:1 mappable with hevc specification
* Fix wrong DPB bumping implementation especially when no_output_of_prior_pics_flag
  was specified.

With fixes from Nicolas Dufresne <nicolas.dufresne@collabora.com>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1748>
2020-11-01 21:46:12 +09:00
He Junyan
002cddf131 codecs: h265decoder: Fix picture leaks because of reference set.
The last frame's reference set has no one to cleanup. We need to
clean all pictures in the stop() func.
We also add a helper function to cleanup all the pictures in the
reference picture set.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1717>
2020-10-23 16:21:15 +00:00