video-tile.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* GStreamer
  2. * Copyright (C) <2013> Wim Taymans <[email protected]>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Library General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Library General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Library General Public
  15. * License along with this library; if not, write to the
  16. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #ifndef __GST_VIDEO_TILE_H__
  20. #define __GST_VIDEO_TILE_H__
  21. #include <gst/gst.h>
  22. G_BEGIN_DECLS
  23. /**
  24. * GstVideoTileType:
  25. * @GST_VIDEO_TILE_TYPE_INDEXED: Tiles are indexed. Use
  26. * gst_video_tile_get_index () to retrieve the tile at the requested
  27. * coordinates.
  28. *
  29. * Enum value describing the most common tiling types.
  30. */
  31. typedef enum
  32. {
  33. GST_VIDEO_TILE_TYPE_INDEXED = 0
  34. } GstVideoTileType;
  35. #define GST_VIDEO_TILE_TYPE_SHIFT (16)
  36. #define GST_VIDEO_TILE_TYPE_MASK ((1 << GST_VIDEO_TILE_TYPE_SHIFT) - 1)
  37. /**
  38. * GST_VIDEO_TILE_MAKE_MODE:
  39. * @num: the mode number to create
  40. * @type: the tile mode type
  41. *
  42. * use this macro to create new tile modes.
  43. */
  44. #define GST_VIDEO_TILE_MAKE_MODE(num, type) \
  45. (((num) << GST_VIDEO_TILE_TYPE_SHIFT) | (GST_VIDEO_TILE_TYPE_ ##type))
  46. /**
  47. * GST_VIDEO_TILE_MODE_TYPE:
  48. * @mode: the tile mode
  49. *
  50. * Get the tile mode type of @mode
  51. */
  52. #define GST_VIDEO_TILE_MODE_TYPE(mode) ((mode) & GST_VIDEO_TILE_TYPE_MASK)
  53. /**
  54. * GST_VIDEO_TILE_MODE_IS_INDEXED:
  55. * @mode: a tile mode
  56. *
  57. * Check if @mode is an indexed tile type
  58. */
  59. #define GST_VIDEO_TILE_MODE_IS_INDEXED(mode) (GST_VIDEO_TILE_MODE_TYPE(mode) == GST_VIDEO_TILE_TYPE_INDEXED)
  60. #define GST_VIDEO_TILE_Y_TILES_SHIFT (16)
  61. #define GST_VIDEO_TILE_X_TILES_MASK ((1 << GST_VIDEO_TILE_Y_TILES_SHIFT) - 1)
  62. /**
  63. * GST_VIDEO_TILE_MAKE_STRIDE:
  64. * @x_tiles: number of tiles in X
  65. * @y_tiles: number of tiles in Y
  66. *
  67. * Encode the number of tile in X and Y into the stride.
  68. */
  69. #define GST_VIDEO_TILE_MAKE_STRIDE(x_tiles, y_tiles) \
  70. (((y_tiles) << GST_VIDEO_TILE_Y_TILES_SHIFT) | (x_tiles))
  71. /**
  72. * GST_VIDEO_TILE_X_TILES:
  73. * @stride: plane stride
  74. *
  75. * Extract the number of tiles in X from the stride value.
  76. */
  77. #define GST_VIDEO_TILE_X_TILES(stride) ((stride) & GST_VIDEO_TILE_X_TILES_MASK)
  78. /**
  79. * GST_VIDEO_TILE_Y_TILES:
  80. * @stride: plane stride
  81. *
  82. * Extract the number of tiles in Y from the stride value.
  83. */
  84. #define GST_VIDEO_TILE_Y_TILES(stride) ((stride) >> GST_VIDEO_TILE_Y_TILES_SHIFT)
  85. /**
  86. * GstVideoTileMode:
  87. * @GST_VIDEO_TILE_MODE_UNKNOWN: Unknown or unset tile mode
  88. * @GST_VIDEO_TILE_MODE_ZFLIPZ_2X2: Every four adjacent blocks - two
  89. * horizontally and two vertically are grouped together and are located
  90. * in memory in Z or flipped Z order. In case of odd rows, the last row
  91. * of blocks is arranged in linear order.
  92. *
  93. * Enum value describing the available tiling modes.
  94. */
  95. typedef enum
  96. {
  97. GST_VIDEO_TILE_MODE_UNKNOWN = 0,
  98. GST_VIDEO_TILE_MODE_ZFLIPZ_2X2 = GST_VIDEO_TILE_MAKE_MODE (1, INDEXED),
  99. } GstVideoTileMode;
  100. guint gst_video_tile_get_index (GstVideoTileMode mode, gint x, gint y,
  101. gint x_tiles, gint y_tiles);
  102. G_END_DECLS
  103. #endif /* __GST_VIDEO_TILE_H__ */