mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 00:01:23 +00:00
codecparsers: h265: add helpers to convert quantization matrices
Add utility functions to convert quantization matrices from zig-zag scan order into raster scan order and vice-versa https://bugzilla.gnome.org/show_bug.cgi?id=747613
This commit is contained in:
parent
a86e7c1c1f
commit
989643ff7c
2 changed files with 139 additions and 0 deletions
|
@ -131,6 +131,24 @@ static const guint8 default_scaling_list2[64] = {
|
|||
54, 71, 71, 91
|
||||
};
|
||||
|
||||
static const guint8 zigzag_4x4[16] = {
|
||||
0, 1, 4, 8,
|
||||
5, 2, 3, 6,
|
||||
9, 12, 13, 10,
|
||||
7, 11, 14, 15,
|
||||
};
|
||||
|
||||
static const guint8 zigzag_8x8[64] = {
|
||||
0, 1, 8, 16, 9, 2, 3, 10,
|
||||
17, 24, 32, 25, 18, 11, 4, 5,
|
||||
12, 19, 26, 33, 40, 48, 41, 34,
|
||||
27, 20, 13, 6, 7, 14, 21, 28,
|
||||
35, 42, 49, 56, 57, 50, 43, 36,
|
||||
29, 22, 15, 23, 30, 37, 44, 51,
|
||||
58, 59, 52, 45, 38, 31, 39, 46,
|
||||
53, 60, 61, 54, 47, 55, 62, 63
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
guint par_n, par_d;
|
||||
|
@ -2385,3 +2403,103 @@ gst_h265_sei_free (GstH265SEIMessage * sei)
|
|||
pic_timing->du_cpb_removal_delay_increment_minus1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_quant_matrix_4x4_get_zigzag_from_raster:
|
||||
* @out_quant: (out): The resulting quantization matrix
|
||||
* @quant: The source quantization matrix
|
||||
*
|
||||
* Converts quantization matrix @quant from raster scan order to
|
||||
* zigzag scan order and store the resulting factors into @out_quant.
|
||||
*
|
||||
* Note: it is an error to pass the same table in both @quant and
|
||||
* @out_quant arguments.
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
void
|
||||
gst_h265_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
|
||||
const guint8 quant[16])
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (out_quant != quant);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
out_quant[i] = quant[zigzag_4x4[i]];
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_quant_matrix_4x4_get_raster_from_zigzag:
|
||||
* @out_quant: (out): The resulting quantization matrix
|
||||
* @quant: The source quantization matrix
|
||||
*
|
||||
* Converts quantization matrix @quant from zigzag scan order to
|
||||
* raster scan order and store the resulting factors into @out_quant.
|
||||
*
|
||||
* Note: it is an error to pass the same table in both @quant and
|
||||
* @out_quant arguments.
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
void
|
||||
gst_h265_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
|
||||
const guint8 quant[16])
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (out_quant != quant);
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
out_quant[zigzag_4x4[i]] = quant[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_quant_matrix_8x8_get_zigzag_from_raster:
|
||||
* @out_quant: (out): The resulting quantization matrix
|
||||
* @quant: The source quantization matrix
|
||||
*
|
||||
* Converts quantization matrix @quant from raster scan order to
|
||||
* zigzag scan order and store the resulting factors into @out_quant.
|
||||
*
|
||||
* Note: it is an error to pass the same table in both @quant and
|
||||
* @out_quant arguments.
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
void
|
||||
gst_h265_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
|
||||
const guint8 quant[64])
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (out_quant != quant);
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
out_quant[i] = quant[zigzag_8x8[i]];
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_h265_quant_matrix_8x8_get_raster_from_zigzag:
|
||||
* @out_quant: (out): The resulting quantization matrix
|
||||
* @quant: The source quantization matrix
|
||||
*
|
||||
* Converts quantization matrix @quant from zigzag scan order to
|
||||
* raster scan order and store the resulting factors into @out_quant.
|
||||
*
|
||||
* Note: it is an error to pass the same table in both @quant and
|
||||
* @out_quant arguments.
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
void
|
||||
gst_h265_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
|
||||
const guint8 quant[64])
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (out_quant != quant);
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
out_quant[zigzag_8x8[i]] = quant[i];
|
||||
}
|
||||
|
|
|
@ -1061,5 +1061,26 @@ gboolean gst_h265_sei_copy (GstH265SEIMessage * dest_sei,
|
|||
|
||||
void gst_h265_sei_free (GstH265SEIMessage * sei);
|
||||
|
||||
void gst_h265_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
|
||||
const guint8 quant[16]);
|
||||
|
||||
void gst_h265_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
|
||||
const guint8 quant[16]);
|
||||
|
||||
void gst_h265_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
|
||||
const guint8 quant[64]);
|
||||
|
||||
void gst_h265_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
|
||||
const guint8 quant[64]);
|
||||
|
||||
#define gst_h265_quant_matrix_16x16_get_zigzag_from_raster \
|
||||
gst_h265_quant_matrix_8x8_get_zigzag_from_raster
|
||||
#define gst_h265_quant_matrix_16x16_get_raster_from_zigzag \
|
||||
gst_h265_quant_matrix_8x8_get_raster_from_zigzag
|
||||
#define gst_h265_quant_matrix_32x32_get_zigzag_from_raster \
|
||||
gst_h265_quant_matrix_8x8_get_zigzag_from_raster
|
||||
#define gst_h265_quant_matrix_32x32_get_raster_from_zigzag \
|
||||
gst_h265_quant_matrix_8x8_get_raster_from_zigzag
|
||||
|
||||
G_END_DECLS
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue