video-format: use shifts when possible
https://bugzilla.gnome.org/show_bug.cgi?id=707361
This commit is contained in:
parent
980811c120
commit
33c486e5c1
@ -2084,7 +2084,7 @@ pack_I422_10BE (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_tile_NV12 (gint tile_width, gint tile_height, gint tile_size, gint tx,
|
get_tile_NV12 (gint tile_width, gint ts, gint tx,
|
||||||
gint ty, gint x_tiles, gint y_tiles,
|
gint ty, gint x_tiles, gint y_tiles,
|
||||||
const gpointer data[GST_VIDEO_MAX_PLANES],
|
const gpointer data[GST_VIDEO_MAX_PLANES],
|
||||||
const gint stride[GST_VIDEO_MAX_PLANES],
|
const gint stride[GST_VIDEO_MAX_PLANES],
|
||||||
@ -2096,19 +2096,18 @@ get_tile_NV12 (gint tile_width, gint tile_height, gint tile_size, gint tx,
|
|||||||
/* index of Y tile */
|
/* index of Y tile */
|
||||||
offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
|
offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
|
||||||
tx, ty, x_tiles, y_tiles);
|
tx, ty, x_tiles, y_tiles);
|
||||||
offset *= tile_size;
|
offset <<= ts;
|
||||||
tile_data[0] = ((guint8 *) data[0]) + offset;
|
tile_data[0] = ((guint8 *) data[0]) + offset;
|
||||||
tile_stride[0] = tile_width;
|
|
||||||
|
|
||||||
/* index of UV tile */
|
/* index of UV tile */
|
||||||
offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
|
offset = gst_video_tile_get_index (GST_VIDEO_TILE_MODE_ZFLIPZ_2X2,
|
||||||
tx, ty >> 1, x_tiles, (y_tiles + 1) >> 1);
|
tx, ty >> 1, x_tiles, (y_tiles + 1) >> 1);
|
||||||
offset *= tile_size;
|
offset <<= ts;
|
||||||
/* On odd rows we return the second part of the UV tile */
|
/* On odd rows we return the second part of the UV tile */
|
||||||
if (ty & 1)
|
offset |= (ty & 1) << (ts - 1);
|
||||||
offset += tile_width * (tile_height >> 1);
|
|
||||||
tile_data[1] = ((guint8 *) data[1]) + offset;
|
tile_data[1] = ((guint8 *) data[1]) + offset;
|
||||||
tile_stride[1] = tile_width;
|
|
||||||
|
tile_stride[0] = tile_stride[1] = tile_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PACK_NV12T GST_VIDEO_FORMAT_AYUV, unpack_NV12T, 1, pack_NV12T
|
#define PACK_NV12T GST_VIDEO_FORMAT_AYUV, unpack_NV12T, 1, pack_NV12T
|
||||||
@ -2120,15 +2119,17 @@ unpack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
const GstVideoFormatInfo *unpack_info, *finfo;
|
const GstVideoFormatInfo *unpack_info, *finfo;
|
||||||
guint8 *line = dest;
|
guint8 *line = dest;
|
||||||
gint x_tiles, y_tiles;
|
gint x_tiles, y_tiles;
|
||||||
gint tile_width, tile_height, tile_size;
|
gint ws, hs, ts, tile_width;
|
||||||
gint ntx, tx, ty;
|
gint ntx, tx, ty;
|
||||||
gint unpack_pstride;
|
gint unpack_pstride;
|
||||||
|
|
||||||
tile_width = 1 << info->w_sub[3];
|
ws = info->w_sub[GST_VIDEO_COMP_TILEINFO];
|
||||||
tile_height = 1 << info->h_sub[3];
|
hs = info->h_sub[GST_VIDEO_COMP_TILEINFO];
|
||||||
tile_size = tile_width * tile_height;
|
ts = ws + hs;
|
||||||
|
|
||||||
x_tiles = stride[0] / 64;
|
tile_width = 1 << ws;
|
||||||
|
|
||||||
|
x_tiles = stride[0] >> ws;
|
||||||
y_tiles = stride[2];
|
y_tiles = stride[2];
|
||||||
|
|
||||||
/* we reuse these unpack functions */
|
/* we reuse these unpack functions */
|
||||||
@ -2139,14 +2140,14 @@ unpack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
unpack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (unpack_info, 0);
|
unpack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (unpack_info, 0);
|
||||||
|
|
||||||
/* first x tile to convert */
|
/* first x tile to convert */
|
||||||
tx = x / tile_width;
|
tx = x >> ws;
|
||||||
/* Last tile to convert */
|
/* Last tile to convert */
|
||||||
ntx = (x + width) / tile_width;
|
ntx = (x + width) >> ws;
|
||||||
/* The row we are going to convert */
|
/* The row we are going to convert */
|
||||||
ty = y / tile_height;
|
ty = y >> hs;
|
||||||
|
|
||||||
/* y position in a tile */
|
/* y position in a tile */
|
||||||
y = y & (tile_height - 1);
|
y = y & ((1 << hs) - 1);
|
||||||
/* x position in a tile */
|
/* x position in a tile */
|
||||||
x = x & (tile_width - 1);
|
x = x & (tile_width - 1);
|
||||||
|
|
||||||
@ -2155,7 +2156,7 @@ unpack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
gint tstride[GST_VIDEO_MAX_PLANES];
|
gint tstride[GST_VIDEO_MAX_PLANES];
|
||||||
gint unpack_width;
|
gint unpack_width;
|
||||||
|
|
||||||
get_tile_NV12 (tile_width, tile_height, tile_size, tx, ty, x_tiles, y_tiles,
|
get_tile_NV12 (tile_width, ts, tx, ty, x_tiles, y_tiles,
|
||||||
data, stride, tdata, tstride);
|
data, stride, tdata, tstride);
|
||||||
|
|
||||||
/* the number of bytes left to unpack */
|
/* the number of bytes left to unpack */
|
||||||
@ -2178,15 +2179,17 @@ pack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
const GstVideoFormatInfo *pack_info, *finfo;
|
const GstVideoFormatInfo *pack_info, *finfo;
|
||||||
guint8 *line = src;
|
guint8 *line = src;
|
||||||
gint x_tiles, y_tiles;
|
gint x_tiles, y_tiles;
|
||||||
gint tile_width, tile_height, tile_size;
|
gint ws, hs, ts, tile_width;
|
||||||
gint ntx, tx, ty;
|
gint ntx, tx, ty;
|
||||||
gint pack_pstride;
|
gint pack_pstride;
|
||||||
|
|
||||||
tile_width = 1 << info->w_sub[3];
|
ws = info->w_sub[GST_VIDEO_COMP_TILEINFO];
|
||||||
tile_height = 1 << info->h_sub[3];
|
hs = info->h_sub[GST_VIDEO_COMP_TILEINFO];
|
||||||
tile_size = tile_width * tile_height;
|
ts = ws + hs;
|
||||||
|
|
||||||
x_tiles = stride[0] / 64;
|
tile_width = 1 << ws;
|
||||||
|
|
||||||
|
x_tiles = stride[0] >> ws;
|
||||||
y_tiles = stride[2];
|
y_tiles = stride[2];
|
||||||
|
|
||||||
/* we reuse these pack functions */
|
/* we reuse these pack functions */
|
||||||
@ -2197,19 +2200,19 @@ pack_NV12T (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
|
|||||||
pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0);
|
pack_pstride = GST_VIDEO_FORMAT_INFO_PSTRIDE (pack_info, 0);
|
||||||
|
|
||||||
/* Last tile to convert */
|
/* Last tile to convert */
|
||||||
ntx = width / tile_width;
|
ntx = width >> ws;
|
||||||
/* The row we are going to convert */
|
/* The row we are going to convert */
|
||||||
ty = y / tile_height;
|
ty = y >> hs;
|
||||||
|
|
||||||
/* y position in a tile */
|
/* y position in a tile */
|
||||||
y = y & (tile_height - 1);
|
y = y & ((1 << hs) - 1);
|
||||||
|
|
||||||
for (tx = 0; tx < ntx; tx++) {
|
for (tx = 0; tx < ntx; tx++) {
|
||||||
gpointer tdata[GST_VIDEO_MAX_PLANES];
|
gpointer tdata[GST_VIDEO_MAX_PLANES];
|
||||||
gint tstride[GST_VIDEO_MAX_PLANES];
|
gint tstride[GST_VIDEO_MAX_PLANES];
|
||||||
gint pack_width;
|
gint pack_width;
|
||||||
|
|
||||||
get_tile_NV12 (tile_width, tile_height, tile_size, tx, ty, x_tiles, y_tiles,
|
get_tile_NV12 (tile_width, ts, tx, ty, x_tiles, y_tiles,
|
||||||
data, stride, tdata, tstride);
|
data, stride, tdata, tstride);
|
||||||
|
|
||||||
/* the number of bytes left to pack */
|
/* the number of bytes left to pack */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user