Commit graph

17 commits

Author SHA1 Message Date
He Junyan
77a2ad5b1a va: basedec: Fix some artifact when do the crop copy.
The default video converter setting will add some artifact into
the picture for 10/12 bits conversion. This make the MD5 checksum
change from the original picture.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2379>
2021-07-05 14:36:36 +00:00
He Junyan
85c56c1f07 va: basedec: Copy the frames into other_pool if needed.
If decoder's crop_top/left value > 0 and the downstream does not
support the VideoCropMeta, we need to manually copy the frames
into the other_pool and output it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2298>
2021-06-28 15:16:39 +00:00
He Junyan
55302c9705 va: basedec: Setup the other_pool to copy output if crop_left/top.
If the decoder has crop_top/left value > 0(e.g. the conformance
window in the H265). Which means that the real output picture
locates in the middle of the decoded buffer. If the downstream can
support VideoCropMeta, a VideoCropMeta is added to notify the
real picture's coordinate and size. But if not, we need to copy
it manually and the other_pool is needed. We always assume that
decoded picture starts from top-left corner, and so there is no
need to do this if crop_bottom/right value > 0.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2298>
2021-06-28 15:16:39 +00:00
He Junyan
8d7e6bfb86 va: Improve the default mapping between rt_format and video format.
We add 12 bits entries into this default mapping. And the old mapping
is not precise. For example, the NV12 should not be used as the default
mapping for VA_RT_FORMAT_YUV422 and VA_RT_FORMAT_YUV444, it is even not
a 422 or 444 format.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2332>
2021-06-16 14:12:59 +00:00
He Junyan
64b596103a va: Do not use a common parent_class in vabasedec.
We have only one copy of gst_va_base_dec_parent_class inside the
vabasedec, so it can not handle the case when there are multi va
decoders inside one pipeline. The pipeline:

  gst-launch-1.0 filesrc location=xxx.h264 ! h264parse \
      ! vah264dec ! msdkh265enc ! vah265dec ! fakesink

generates a assertion of

"invalid cast from 'GstVaH264Dec' to 'GstH265Decoder"

and gets a crash.

We should keep the parent_class for each decoder type.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2231>
2021-05-10 22:47:11 +08:00
Víctor Manuel Jáquez Leal
43cb1b5dcf va: basedec: refactor context query
Context query is handled either by source and sink queries. This patch
factors-out its handling in a common utility function.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1999>
2021-02-05 21:25:20 +01:00
He Junyan
0158849145 va: Fix some gst_object_unref error because the pointer is NULL.
!1957 introduces some error of gst_object_unref for NULL pointer.
Fixes all of them.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1959>
2021-01-17 14:00:50 +08:00
He Junyan
6b1e1924fd va: Fix a latent race condition in vabasedec.
The vabasedec's display and decoder are created/destroyed between
the gst_va_base_dec_open/close pair. All the data and event handling
functions are between this pair and so the accessing to these pointers
are safe. But the query function can be called anytime. So we need to:
1. Make these pointers operation in open/close and query atomic.
2. Hold an extra ref during query function to avoid it destroyed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1957>
2021-01-15 20:40:10 +08:00
He Junyan
7a8ac90010 va: basedec: Improve the decide_allocation().
In decide_allocation(), we now just use the other_pool for frames
copy when the src caps is raw. This can make the logic a little
clear. There is no need for us to check the alignment and video
meta again.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1711>
2020-11-17 01:21:54 +08:00
He Junyan
672a30d0de va: basedec: fallback to system memory if downstream caps is any.
When the downstream element reports an ANY caps, and it also fails to
support VideoMeta, we should fallback to the system memory.
Note: the basetransform kind elements never return valid allocation
query before set_caps(). So, if a basetransform return an ANY sink
caps, we always fallback to system memory for it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1711>
2020-11-17 01:21:45 +08:00
Víctor Manuel Jáquez Leal
5876f232ee va: comments to explain code
There are a couple part where code seems, at least to me, a bit oscure or
confusing. So let's better add an explanation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1802>
2020-11-12 13:33:26 +01:00
He Junyan
6e72f45a8f va: basedec: No need to call base class' decide_allocation().
We have already done the jobs in gst_va_base_dec_decide_allocation()
and no need to call base class' decide_allocation() again. The base
class' decide_allocation() will set_format() again and let use do the
image/surface testing again, which is low performance and no needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1698>
2020-10-27 14:18:07 +00:00
He Junyan
4af33eda76 va: basedec: Create the other pool anyway.
Fix a bug in _create_other_pool(). The old way of checking the
base->other_pool make that other_pool never be changed until the
gst_va_base_dec_stop() to stop the current decoding context.
But in some stream, the resolution may change during the decoding
process, and we need to re-negotiate the buffer pool. Then, the
old other_pool can not be clean correctly and the new correct one
can not be created.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1692>
2020-10-15 13:22:33 +00:00
He Junyan
ee739003e8 va: basedec: Should unmap src frame when dst frame map failing.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1692>
2020-10-15 13:22:33 +00:00
Víctor Manuel Jáquez Leal
18444fd993 va: basedec: copy frames logic to decide_allocation()
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1673>
2020-10-10 17:18:04 +00:00
Víctor Manuel Jáquez Leal
5658c4182a va: basedec: refactor the other video pool instantiation
Just a code clean up

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1673>
2020-10-10 17:18:04 +00:00
Víctor Manuel Jáquez Leal
a6398eca17 va: basedec: add gstvabasedec helper
This is a helper for all decoders.

It is not an abstract subclass, just merely a helper that avoids code
duplication among the decoders.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1673>
2020-10-10 17:18:04 +00:00