rawvideoparse: Fix tiling support
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Tue, 14 Jul 2020 14:42:01 +0000 (10:42 -0400)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 14 Jul 2020 17:33:31 +0000 (17:33 +0000)
When using tile format, the stride has a different meaning. It used
the MSB and LSB 16bits to encode respectively the width and height in
number of tiles.

This issue was introduce with commit e5b70d384c which was fixing
missing size recalculation when strides and offset is updated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/753>

gst/rawparse/gstrawvideoparse.c

index cb090af..2b77f05 100644 (file)
@@ -1154,10 +1154,19 @@ gst_raw_video_parse_update_info (GstRawVideoParseConfig * config)
     }
   }
 
-  last_plane_size =
-      GST_VIDEO_INFO_PLANE_STRIDE (info,
-      last_plane) * GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info->finfo,
-      last_plane, config->height);
+  if (GST_VIDEO_FORMAT_INFO_IS_TILED (info->finfo)) {
+    gint stride = GST_VIDEO_INFO_PLANE_STRIDE (info, last_plane);
+    gint x_tiles = GST_VIDEO_TILE_X_TILES (stride);
+    gint y_tiles = GST_VIDEO_TILE_Y_TILES (stride);
+    gint tile_width = 1 << GST_VIDEO_FORMAT_INFO_TILE_WS (info->finfo);
+    gint tile_height = 1 << GST_VIDEO_FORMAT_INFO_TILE_HS (info->finfo);
+    last_plane_size = x_tiles * y_tiles * tile_width * tile_height;
+  } else {
+    last_plane_size =
+        GST_VIDEO_INFO_PLANE_STRIDE (info,
+        last_plane) * GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info->finfo,
+        last_plane, config->height);
+  }
 
   GST_VIDEO_INFO_SIZE (info) = last_plane_offset + last_plane_size;