summaryrefslogtreecommitdiff
path: root/include/gst/video/video-tile.h
blob: 8992bb351d0bd5df1f72dbe8082546b1612985c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/* GStreamer
 * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifndef __GST_VIDEO_TILE_H__
#define __GST_VIDEO_TILE_H__

#include <gst/gst.h>
#include <gst/video/video-prelude.h>

G_BEGIN_DECLS

/**
 * GstVideoTileType:
 * @GST_VIDEO_TILE_TYPE_INDEXED: Tiles are indexed. Use
 *   gst_video_tile_get_index () to retrieve the tile at the requested
 *   coordinates.
 *
 * Enum value describing the most common tiling types.
 */
typedef enum
{
  GST_VIDEO_TILE_TYPE_INDEXED = 0
} GstVideoTileType;

#define GST_VIDEO_TILE_TYPE_SHIFT     (16)

/**
 * GST_VIDEO_TILE_TYPE_MASK: (value 65535)
 */
#define GST_VIDEO_TILE_TYPE_MASK      ((1 << GST_VIDEO_TILE_TYPE_SHIFT) - 1)

/**
 * GST_VIDEO_TILE_MAKE_MODE:
 * @num: the mode number to create
 * @type: the tile mode type
 *
 * use this macro to create new tile modes.
 */
#define GST_VIDEO_TILE_MAKE_MODE(num, type) \
    (((num) << GST_VIDEO_TILE_TYPE_SHIFT) | (GST_VIDEO_TILE_TYPE_ ##type))

/**
 * GST_VIDEO_TILE_MODE_TYPE:
 * @mode: the tile mode
 *
 * Get the tile mode type of @mode
 */
#define GST_VIDEO_TILE_MODE_TYPE(mode)       ((mode) & GST_VIDEO_TILE_TYPE_MASK)

/**
 * GST_VIDEO_TILE_MODE_IS_INDEXED:
 * @mode: a tile mode
 *
 * Check if @mode is an indexed tile type
 */
#define GST_VIDEO_TILE_MODE_IS_INDEXED(mode) (GST_VIDEO_TILE_MODE_TYPE(mode) == GST_VIDEO_TILE_TYPE_INDEXED)


#define GST_VIDEO_TILE_Y_TILES_SHIFT     (16)

/**
 * GST_VIDEO_TILE_X_TILES_MASK: (value 65535)
 */
#define GST_VIDEO_TILE_X_TILES_MASK      ((1 << GST_VIDEO_TILE_Y_TILES_SHIFT) - 1)

/**
 * GST_VIDEO_TILE_MAKE_STRIDE:
 * @x_tiles: number of tiles in X
 * @y_tiles: number of tiles in Y
 *
 * Encode the number of tile in X and Y into the stride.
 */
#define GST_VIDEO_TILE_MAKE_STRIDE(x_tiles, y_tiles) \
    (((y_tiles) << GST_VIDEO_TILE_Y_TILES_SHIFT) | (x_tiles))

/**
 * GST_VIDEO_TILE_X_TILES:
 * @stride: plane stride
 *
 * Extract the number of tiles in X from the stride value.
 */
#define GST_VIDEO_TILE_X_TILES(stride) ((stride) & GST_VIDEO_TILE_X_TILES_MASK)

/**
 * GST_VIDEO_TILE_Y_TILES:
 * @stride: plane stride
 *
 * Extract the number of tiles in Y from the stride value.
 */
#define GST_VIDEO_TILE_Y_TILES(stride) ((stride) >> GST_VIDEO_TILE_Y_TILES_SHIFT)

/**
 * GstVideoTileMode:
 * @GST_VIDEO_TILE_MODE_UNKNOWN: Unknown or unset tile mode
 * @GST_VIDEO_TILE_MODE_ZFLIPZ_2X2: Every four adjacent blocks - two
 *    horizontally and two vertically are grouped together and are located
 *    in memory in Z or flipped Z order. In case of odd rows, the last row
 *    of blocks is arranged in linear order.
 * @GST_VIDEO_TILE_MODE_LINEAR: Tiles are in row order. (Since: 1.18)
 *
 * Enum value describing the available tiling modes.
 */
typedef enum
{
  GST_VIDEO_TILE_MODE_UNKNOWN = 0,
  GST_VIDEO_TILE_MODE_ZFLIPZ_2X2 = GST_VIDEO_TILE_MAKE_MODE (1, INDEXED),
  /**
   * GST_VIDEO_TILE_MODE_LINEAR:
   *
   * Tiles are in row order.
   *
   * Since: 1.18
   */
  GST_VIDEO_TILE_MODE_LINEAR = GST_VIDEO_TILE_MAKE_MODE (2, INDEXED),
} GstVideoTileMode;

GST_VIDEO_API
guint           gst_video_tile_get_index                (GstVideoTileMode mode, gint x, gint y,
                                                         gint x_tiles, gint y_tiles);


G_END_DECLS

#endif /* __GST_VIDEO_TILE_H__ */