1/* GStreamer
2 * Copyright (C) <2013> Wim Taymans <wim.taymans@gmail.com>
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
20#ifndef __GST_VIDEO_TILE_H__
21#define __GST_VIDEO_TILE_H__
22
23#include <gst/gst.h>
24#include <gst/video/video-prelude.h>
25
26G_BEGIN_DECLS
27
28/**
29 * GstVideoTileType:
30 * @GST_VIDEO_TILE_TYPE_INDEXED: Tiles are indexed. Use
31 * gst_video_tile_get_index () to retrieve the tile at the requested
32 * coordinates.
33 *
34 * Enum value describing the most common tiling types.
35 */
36typedef enum
37{
38 GST_VIDEO_TILE_TYPE_INDEXED = 0
39} GstVideoTileType;
40
41#define GST_VIDEO_TILE_TYPE_SHIFT (16)
42
43/**
44 * GST_VIDEO_TILE_TYPE_MASK: (value 65535)
45 */
46#define GST_VIDEO_TILE_TYPE_MASK ((1 << GST_VIDEO_TILE_TYPE_SHIFT) - 1)
47
48/**
49 * GST_VIDEO_TILE_MAKE_MODE:
50 * @num: the mode number to create
51 * @type: the tile mode type
52 *
53 * use this macro to create new tile modes.
54 */
55#define GST_VIDEO_TILE_MAKE_MODE(num, type) \
56 (((num) << GST_VIDEO_TILE_TYPE_SHIFT) | (GST_VIDEO_TILE_TYPE_ ##type))
57
58/**
59 * GST_VIDEO_TILE_MODE_TYPE:
60 * @mode: the tile mode
61 *
62 * Get the tile mode type of @mode
63 */
64#define GST_VIDEO_TILE_MODE_TYPE(mode) ((mode) & GST_VIDEO_TILE_TYPE_MASK)
65
66/**
67 * GST_VIDEO_TILE_MODE_IS_INDEXED:
68 * @mode: a tile mode
69 *
70 * Check if @mode is an indexed tile type
71 */
72#define GST_VIDEO_TILE_MODE_IS_INDEXED(mode) (GST_VIDEO_TILE_MODE_TYPE(mode) == GST_VIDEO_TILE_TYPE_INDEXED)
73
74
75#define GST_VIDEO_TILE_Y_TILES_SHIFT (16)
76
77/**
78 * GST_VIDEO_TILE_X_TILES_MASK: (value 65535)
79 */
80#define GST_VIDEO_TILE_X_TILES_MASK ((1 << GST_VIDEO_TILE_Y_TILES_SHIFT) - 1)
81
82/**
83 * GST_VIDEO_TILE_MAKE_STRIDE:
84 * @x_tiles: number of tiles in X
85 * @y_tiles: number of tiles in Y
86 *
87 * Encode the number of tile in X and Y into the stride.
88 */
89#define GST_VIDEO_TILE_MAKE_STRIDE(x_tiles, y_tiles) \
90 (((y_tiles) << GST_VIDEO_TILE_Y_TILES_SHIFT) | (x_tiles))
91
92/**
93 * GST_VIDEO_TILE_X_TILES:
94 * @stride: plane stride
95 *
96 * Extract the number of tiles in X from the stride value.
97 */
98#define GST_VIDEO_TILE_X_TILES(stride) ((stride) & GST_VIDEO_TILE_X_TILES_MASK)
99
100/**
101 * GST_VIDEO_TILE_Y_TILES:
102 * @stride: plane stride
103 *
104 * Extract the number of tiles in Y from the stride value.
105 */
106#define GST_VIDEO_TILE_Y_TILES(stride) ((stride) >> GST_VIDEO_TILE_Y_TILES_SHIFT)
107
108typedef struct _GstVideoTileInfo GstVideoTileInfo;
109
110/**
111 * GstVideoTileMode:
112 * @GST_VIDEO_TILE_MODE_UNKNOWN: Unknown or unset tile mode
113 * @GST_VIDEO_TILE_MODE_ZFLIPZ_2X2: Every four adjacent blocks - two
114 * horizontally and two vertically are grouped together and are located
115 * in memory in Z or flipped Z order. In case of odd rows, the last row
116 * of blocks is arranged in linear order.
117 * @GST_VIDEO_TILE_MODE_LINEAR: Tiles are in row order. (Since: 1.18)
118 * @GST_VIDEO_TILE_MODE_LINEAR_SUBSAMPLED: Tiles are in row order, with
119 * variable tile size according to subsampling. (Since: 1.20)
120 *
121 * Enum value describing the available tiling modes.
122 */
123typedef enum
124{
125 GST_VIDEO_TILE_MODE_UNKNOWN = 0,
126 GST_VIDEO_TILE_MODE_ZFLIPZ_2X2 = GST_VIDEO_TILE_MAKE_MODE (1, INDEXED),
127 /**
128 * GST_VIDEO_TILE_MODE_LINEAR:
129 *
130 * Tiles are in row order.
131 *
132 * Since: 1.18
133 */
134 GST_VIDEO_TILE_MODE_LINEAR = GST_VIDEO_TILE_MAKE_MODE (2, INDEXED),
135} GstVideoTileMode;
136
137
138/**
139 * GstVideoTileInfo:
140 *
141 * Description of a tile. This structure allow to describe arbitrary tile
142 * dimensions and sizes.
143 *
144 * Since: 1.22
145 */
146struct _GstVideoTileInfo
147{
148 /**
149 * GstVideoTileInfo.width:
150 *
151 * The width in pixels of a tile. This value can be zero if the number of
152 * pixels per line is not an integer value.
153 *
154 * Since: 1.22
155 */
156 guint width;
157
158 /**
159 * GstVideoTileInfo::height:
160 *
161 * The width in pixels of a tile. This value can be zero if the number of
162 * pixels per line is not an integer value.
163 *
164 * Since: 1.22
165 */
166 guint height;
167
168 /**
169 * GstVideoTileInfo.stride:
170 *
171 * The stride (in bytes) of a tile line. Regardless if the tile have sub-tiles
172 * this stride multiplied by the height should be equal to
173 * #GstVideoTileInfo.size. This value is used to translate into linear stride
174 * when older APIs are being used to expose this format.
175 *
176 * Since: 1.22
177 */
178 guint stride;
179
180 /**
181 * GstVideoTileInfo.size:
182 *
183 * The size in bytes of a tile. This value must be divisible by
184 * #GstVideoTileInfo.stride.
185 *
186 * Since: 1.22
187 */
188 guint size;
189
190 /* <private> */
191 guint32 padding[GST_PADDING];
192};
193
194GST_VIDEO_API
195guint gst_video_tile_get_index (GstVideoTileMode mode, gint x, gint y,
196 gint x_tiles, gint y_tiles);
197
198
199G_END_DECLS
200
201#endif /* __GST_VIDEO_TILE_H__ */
202

source code of include/gstreamer-1.0/gst/video/video-tile.h