gstreamer/subprojects/gst-plugins-base/gst-libs/gst/video/video-tile.h
Nicolas Dufresne c9b127dae3 video: Add NV12_16L32S aka Mediatek MM21 support
Unlike other simple tiled formats, the Mediatek HW use different tile size
per-plane. The tile size is scaled according to the subsampling. Effectively,
using the name 16L32S to represent linearly layout tiles of size 16x32 bytes
in the Y plane, and 16x16 in the UV plane. In order to make this specificity
discoverable, a new SUBTILES flags have been added.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1567>
2022-02-20 22:32:55 +00:00

142 lines
4.1 KiB
C

/* 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)
* @GST_VIDEO_TILE_MODE_LINEAR_SUBSAMPLED: Tiles are in row order, with
* variable tile size according to subsampling. (Since: 1.20)
*
* 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__ */