From c03350e2346a8bda1fbcaf061ca29a37ef436716 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Mon, 7 Jun 2021 00:49:49 +0800 Subject: [PATCH] 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: --- sys/va/gstvapool.c | 44 +++++++------------------------------------- 1 file changed, 7 insertions(+), 37 deletions(-) diff --git a/sys/va/gstvapool.c b/sys/va/gstvapool.c index 5a0365cab3..4cf09354cf 100644 --- a/sys/va/gstvapool.c +++ b/sys/va/gstvapool.c @@ -39,8 +39,6 @@ struct _GstVaPool GstAllocator *allocator; gboolean force_videometa; gboolean add_videometa; - gboolean need_alignment; - GstVideoAlignment video_align; gboolean starting; }; @@ -75,10 +73,11 @@ gst_va_pool_set_config (GstBufferPool * pool, GstStructure * config) GstCaps *caps; GstVaPool *vpool = GST_VA_POOL (pool); GstVideoAlignment video_align = { 0, }; - GstVideoInfo caps_info, alloc_info, orig_info; + GstVideoInfo caps_info, alloc_info; gint width, height; guint i, min_buffers, max_buffers; guint32 usage_hint; + gboolean has_alignment; if (!gst_buffer_pool_config_get_params (config, &caps, NULL, &min_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)) goto wrong_config; - orig_info = caps_info; width = GST_VIDEO_INFO_WIDTH (&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); /* 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); - if (vpool->need_alignment) { + if (has_alignment) { gst_buffer_pool_config_get_video_alignment (config, &video_align); 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->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++) { - 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_OFFSET (&orig_info, i) != + GST_VIDEO_INFO_PLANE_OFFSET (&caps_info, i) != GST_VIDEO_INFO_PLANE_OFFSET (&alloc_info, i)) { GST_INFO_OBJECT (vpool, "Video meta is required in buffer."); vpool->force_videometa = TRUE; @@ -210,7 +184,6 @@ gst_va_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, GstBufferPoolAcquireParams * params) { GstBuffer *buf; - GstVideoMeta *vmeta; GstVaPool *vpool = GST_VA_POOL (pool); buf = gst_buffer_new (); @@ -237,15 +210,12 @@ gst_va_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer, if (vpool->add_videometa) { /* GstVaAllocator may update offset/stride given the physical * 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_WIDTH (&vpool->caps_info), GST_VIDEO_INFO_HEIGHT (&vpool->caps_info), GST_VIDEO_INFO_N_PLANES (&vpool->caps_info), vpool->alloc_info.offset, vpool->alloc_info.stride); - - if (vpool->need_alignment) - gst_video_meta_set_alignment (vmeta, vpool->video_align); } *buffer = buf;