mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
va: No need to set the alignment for VideoMeta
The base va decoder's video_align is just used for calculation the real decoded buffer's width and height. It does not have meaning for the VideoMeta, because it does not align to the real picture in the output buffer. We will use VideoCropMeta to replace it later. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2298>
This commit is contained in:
parent
98cf9ce6f5
commit
c03350e234
1 changed files with 7 additions and 37 deletions
|
@ -39,8 +39,6 @@ struct _GstVaPool
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
gboolean force_videometa;
|
gboolean force_videometa;
|
||||||
gboolean add_videometa;
|
gboolean add_videometa;
|
||||||
gboolean need_alignment;
|
|
||||||
GstVideoAlignment video_align;
|
|
||||||
|
|
||||||
gboolean starting;
|
gboolean starting;
|
||||||
};
|
};
|
||||||
|
@ -75,10 +73,11 @@ gst_va_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstVaPool *vpool = GST_VA_POOL (pool);
|
GstVaPool *vpool = GST_VA_POOL (pool);
|
||||||
GstVideoAlignment video_align = { 0, };
|
GstVideoAlignment video_align = { 0, };
|
||||||
GstVideoInfo caps_info, alloc_info, orig_info;
|
GstVideoInfo caps_info, alloc_info;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
guint i, min_buffers, max_buffers;
|
guint i, min_buffers, max_buffers;
|
||||||
guint32 usage_hint;
|
guint32 usage_hint;
|
||||||
|
gboolean has_alignment;
|
||||||
|
|
||||||
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_buffers,
|
||||||
&max_buffers))
|
&max_buffers))
|
||||||
|
@ -100,7 +99,6 @@ gst_va_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
if (!gst_buffer_pool_config_get_va_allocation_params (config, &usage_hint))
|
if (!gst_buffer_pool_config_get_va_allocation_params (config, &usage_hint))
|
||||||
goto wrong_config;
|
goto wrong_config;
|
||||||
|
|
||||||
orig_info = caps_info;
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (&caps_info);
|
width = GST_VIDEO_INFO_WIDTH (&caps_info);
|
||||||
height = GST_VIDEO_INFO_HEIGHT (&caps_info);
|
height = GST_VIDEO_INFO_HEIGHT (&caps_info);
|
||||||
|
|
||||||
|
@ -111,10 +109,10 @@ gst_va_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
GST_BUFFER_POOL_OPTION_VIDEO_META);
|
||||||
|
|
||||||
/* parse extra alignment info */
|
/* parse extra alignment info */
|
||||||
vpool->need_alignment = gst_buffer_pool_config_has_option (config,
|
has_alignment = gst_buffer_pool_config_has_option (config,
|
||||||
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT);
|
||||||
|
|
||||||
if (vpool->need_alignment) {
|
if (has_alignment) {
|
||||||
gst_buffer_pool_config_get_video_alignment (config, &video_align);
|
gst_buffer_pool_config_get_video_alignment (config, &video_align);
|
||||||
|
|
||||||
width += video_align.padding_left + video_align.padding_right;
|
width += video_align.padding_left + video_align.padding_right;
|
||||||
|
@ -141,34 +139,10 @@ gst_va_pool_set_config (GstBufferPool * pool, GstStructure * config)
|
||||||
vpool->caps_info = caps_info;
|
vpool->caps_info = caps_info;
|
||||||
vpool->alloc_info = alloc_info;
|
vpool->alloc_info = alloc_info;
|
||||||
|
|
||||||
/* May adjust the stride alignment based on the real HW alignment:
|
|
||||||
*
|
|
||||||
* Counts the number of consecutive bits from lower significant
|
|
||||||
* bit. This number is then converted to the notion of alignment in
|
|
||||||
* GStreamer and passed as as constraint in GstVideoAlignment. The
|
|
||||||
* side effect is that the updated GstVideoInfo is now guarantied to
|
|
||||||
* endup with the same stride (ndufresne).
|
|
||||||
*/
|
|
||||||
if (vpool->need_alignment) {
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&alloc_info); i++) {
|
|
||||||
gint nth_bit;
|
|
||||||
|
|
||||||
nth_bit = g_bit_nth_lsf (GST_VIDEO_INFO_PLANE_STRIDE (&alloc_info, i), 0);
|
|
||||||
if (nth_bit >= 0)
|
|
||||||
video_align.stride_align[i] = (1U << nth_bit) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
vpool->video_align = video_align;
|
|
||||||
|
|
||||||
gst_buffer_pool_config_set_video_alignment (config, &video_align);
|
|
||||||
} else {
|
|
||||||
gst_video_alignment_reset (&vpool->video_align);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&caps_info); i++) {
|
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&caps_info); i++) {
|
||||||
if (GST_VIDEO_INFO_PLANE_STRIDE (&orig_info, i) !=
|
if (GST_VIDEO_INFO_PLANE_STRIDE (&caps_info, i) !=
|
||||||
GST_VIDEO_INFO_PLANE_STRIDE (&alloc_info, i) ||
|
GST_VIDEO_INFO_PLANE_STRIDE (&alloc_info, i) ||
|
||||||
GST_VIDEO_INFO_PLANE_OFFSET (&orig_info, i) !=
|
GST_VIDEO_INFO_PLANE_OFFSET (&caps_info, i) !=
|
||||||
GST_VIDEO_INFO_PLANE_OFFSET (&alloc_info, i)) {
|
GST_VIDEO_INFO_PLANE_OFFSET (&alloc_info, i)) {
|
||||||
GST_INFO_OBJECT (vpool, "Video meta is required in buffer.");
|
GST_INFO_OBJECT (vpool, "Video meta is required in buffer.");
|
||||||
vpool->force_videometa = TRUE;
|
vpool->force_videometa = TRUE;
|
||||||
|
@ -210,7 +184,6 @@ gst_va_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
GstBufferPoolAcquireParams * params)
|
GstBufferPoolAcquireParams * params)
|
||||||
{
|
{
|
||||||
GstBuffer *buf;
|
GstBuffer *buf;
|
||||||
GstVideoMeta *vmeta;
|
|
||||||
GstVaPool *vpool = GST_VA_POOL (pool);
|
GstVaPool *vpool = GST_VA_POOL (pool);
|
||||||
|
|
||||||
buf = gst_buffer_new ();
|
buf = gst_buffer_new ();
|
||||||
|
@ -237,15 +210,12 @@ gst_va_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
|
||||||
if (vpool->add_videometa) {
|
if (vpool->add_videometa) {
|
||||||
/* GstVaAllocator may update offset/stride given the physical
|
/* GstVaAllocator may update offset/stride given the physical
|
||||||
* memory */
|
* memory */
|
||||||
vmeta = gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
|
gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE,
|
||||||
GST_VIDEO_INFO_FORMAT (&vpool->caps_info),
|
GST_VIDEO_INFO_FORMAT (&vpool->caps_info),
|
||||||
GST_VIDEO_INFO_WIDTH (&vpool->caps_info),
|
GST_VIDEO_INFO_WIDTH (&vpool->caps_info),
|
||||||
GST_VIDEO_INFO_HEIGHT (&vpool->caps_info),
|
GST_VIDEO_INFO_HEIGHT (&vpool->caps_info),
|
||||||
GST_VIDEO_INFO_N_PLANES (&vpool->caps_info),
|
GST_VIDEO_INFO_N_PLANES (&vpool->caps_info),
|
||||||
vpool->alloc_info.offset, vpool->alloc_info.stride);
|
vpool->alloc_info.offset, vpool->alloc_info.stride);
|
||||||
|
|
||||||
if (vpool->need_alignment)
|
|
||||||
gst_video_meta_set_alignment (vmeta, vpool->video_align);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*buffer = buf;
|
*buffer = buf;
|
||||||
|
|
Loading…
Reference in a new issue