f73897c6bb16523ea1adbf8340d9e69752632606
[platform/upstream/gstreamer.git] / gst-libs / gst / video / video-tile.h
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
25 G_BEGIN_DECLS
26
27 /**
28  * GstVideoTileType:
29  * @GST_VIDEO_TILE_TYPE_INDEXED: Tiles are indexed. Use
30  *   gst_video_tile_get_index () to retrieve the tile at the requested
31  *   coordinates.
32  *
33  * Enum value describing the most common tiling types.
34  */
35 typedef enum
36 {
37   GST_VIDEO_TILE_TYPE_INDEXED = 0
38 } GstVideoTileType;
39
40 #define GST_VIDEO_TILE_TYPE_SHIFT     (16)
41 #define GST_VIDEO_TILE_TYPE_MASK      ((1 << GST_VIDEO_TILE_TYPE_SHIFT) - 1)
42
43 /**
44  * GST_VIDEO_TILE_MAKE_MODE:
45  * @num: the mode number to create
46  * @type: the tile mode type
47  *
48  * use this macro to create new tile modes.
49  */
50 #define GST_VIDEO_TILE_MAKE_MODE(num, type) \
51     (((num) << GST_VIDEO_TILE_TYPE_SHIFT) | (GST_VIDEO_TILE_TYPE_ ##type))
52
53 /**
54  * GST_VIDEO_TILE_MODE_TYPE:
55  * @mode: the tile mode
56  *
57  * Get the tile mode type of @mode
58  */
59 #define GST_VIDEO_TILE_MODE_TYPE(mode)       ((mode) & GST_VIDEO_TILE_TYPE_MASK)
60
61 /**
62  * GST_VIDEO_TILE_MODE_IS_INDEXED:
63  * @mode: a tile mode
64  *
65  * Check if @mode is an indexed tile type
66  */
67 #define GST_VIDEO_TILE_MODE_IS_INDEXED(mode) (GST_VIDEO_TILE_MODE_TYPE(mode) == GST_VIDEO_TILE_TYPE_INDEXED)
68
69
70 #define GST_VIDEO_TILE_Y_TILES_SHIFT     (16)
71 #define GST_VIDEO_TILE_X_TILES_MASK      ((1 << GST_VIDEO_TILE_Y_TILES_SHIFT) - 1)
72
73 /**
74  * GST_VIDEO_TILE_MAKE_STRIDE:
75  * @x_tiles: number of tiles in X
76  * @y_tiles: number of tiles in Y
77  *
78  * Encode the number of tile in X and Y into the stride.
79  */
80 #define GST_VIDEO_TILE_MAKE_STRIDE(x_tiles, y_tiles) \
81     (((y_tiles) << GST_VIDEO_TILE_Y_TILES_SHIFT) | (x_tiles))
82
83 /**
84  * GST_VIDEO_TILE_X_TILES:
85  * @stride: plane stride
86  *
87  * Extract the number of tiles in X from the stride value.
88  */
89 #define GST_VIDEO_TILE_X_TILES(stride) ((stride) & GST_VIDEO_TILE_X_TILES_MASK)
90
91 /**
92  * GST_VIDEO_TILE_Y_TILES:
93  * @stride: plane stride
94  *
95  * Extract the number of tiles in Y from the stride value.
96  */
97 #define GST_VIDEO_TILE_Y_TILES(stride) ((stride) >> GST_VIDEO_TILE_Y_TILES_SHIFT)
98
99 /**
100  * GstVideoTileMode:
101  * @GST_VIDEO_TILE_MODE_UNKNOWN: Unknown or unset tile mode
102  * @GST_VIDEO_TILE_MODE_ZFLIPZ_2X2: Every four adjacent blocks - two
103  *    horizontally and two vertically are grouped together and are located
104  *    in memory in Z or flipped Z order. In case of odd rows, the last row
105  *    of blocks is arranged in linear order.
106  *
107  * Enum value describing the available tiling modes.
108  */
109 typedef enum
110 {
111   GST_VIDEO_TILE_MODE_UNKNOWN = 0,
112   GST_VIDEO_TILE_MODE_ZFLIPZ_2X2 = GST_VIDEO_TILE_MAKE_MODE (1, INDEXED),
113 } GstVideoTileMode;
114
115 GST_EXPORT
116 guint           gst_video_tile_get_index                (GstVideoTileMode mode, gint x, gint y,
117                                                          gint x_tiles, gint y_tiles);
118
119
120 G_END_DECLS
121
122 #endif /* __GST_VIDEO_TILE_H__ */