diff options
author | lyb <andy_liu_china@163.com> | 2015-08-24 08:06:15 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-08-24 21:28:08 +0300 |
commit | 497f3726687bac932eaf7313b9f0d31800ff473b (patch) | |
tree | e2ae88ac325603785d72013201b0befb272f5cab | |
parent | 26e350f0bf865594315f7af194d2a5a980e00f41 (diff) | |
download | gstreamer-plugins-bad-497f3726687bac932eaf7313b9f0d31800ff473b.tar.gz |
codecparsers: h265: Add APIs for up-right-diagonal/raster scan conversion
As per 7-42 and 7-43 the ScalingFactor's scanIdx is 0,
which is "up-right-diagonal" scan. Add APIs for converting
up-right-diagonal to raster and vise versa.
https://bugzilla.gnome.org/show_bug.cgi?id=754024
-rw-r--r-- | gst-libs/gst/codecparsers/gsth265parser.c | 120 | ||||
-rw-r--r-- | gst-libs/gst/codecparsers/gsth265parser.h | 21 |
2 files changed, 141 insertions, 0 deletions
diff --git a/gst-libs/gst/codecparsers/gsth265parser.c b/gst-libs/gst/codecparsers/gsth265parser.c index 841f430e7..5a5f15727 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.c +++ b/gst-libs/gst/codecparsers/gsth265parser.c @@ -149,6 +149,24 @@ static const guint8 zigzag_8x8[64] = { 53, 60, 61, 54, 47, 55, 62, 63 }; +static const guint8 uprightdiagonal_4x4[16] = { + 0, 4, 1, 8, + 5, 2, 12, 9, + 6, 3, 13, 10, + 7, 14, 11, 15 +}; + +static const guint8 uprightdiagonal_8x8[64] = { + 0, 8, 1, 16, 9, 2, 24, 17, + 10, 3, 32, 25, 18, 11, 4, 40, + 33, 26, 19, 12, 5, 48, 41, 34, + 27, 20, 13, 6, 56, 49, 42, 35, + 28, 21, 14, 7, 57, 50, 43, 36, + 29, 22, 15, 58, 51, 44, 37, 30, + 23, 59, 52, 45, 38, 31, 60, 53, + 46, 39, 61, 54, 47, 62, 55, 63 +}; + typedef struct { guint par_n, par_d; @@ -2594,3 +2612,105 @@ gst_h265_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64], for (i = 0; i < 64; i++) out_quant[zigzag_8x8[i]] = quant[i]; } + +/** + * gst_h265_quant_matrix_4x4_get_uprightdiagonal_from_raster: + * @out_quant: (out): The resulting quantization matrix + * @quant: The source quantization matrix + * + * Converts quantization matrix @quant from raster scan order to + * uprightdiagonal 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_uprightdiagonal_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[uprightdiagonal_4x4[i]]; +} + +/** + * gst_h265_quant_matrix_4x4_get_raster_from_uprightdiagonal: + * @out_quant: (out): The resulting quantization matrix + * @quant: The source quantization matrix + * + * Converts quantization matrix @quant from uprightdiagonal 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_uprightdiagonal (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[uprightdiagonal_4x4[i]] = quant[i]; +} + +/** + * gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster: + * @out_quant: (out): The resulting quantization matrix + * @quant: The source quantization matrix + * + * Converts quantization matrix @quant from raster scan order to + * uprightdiagonal 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_uprightdiagonal_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[uprightdiagonal_8x8[i]]; +} + +/** + * gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal: + * @out_quant: (out): The resulting quantization matrix + * @quant: The source quantization matrix + * + * Converts quantization matrix @quant from uprightdiagonal 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_uprightdiagonal (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[uprightdiagonal_8x8[i]] = quant[i]; +} diff --git a/gst-libs/gst/codecparsers/gsth265parser.h b/gst-libs/gst/codecparsers/gsth265parser.h index 9f426253e..c9cce6941 100644 --- a/gst-libs/gst/codecparsers/gsth265parser.h +++ b/gst-libs/gst/codecparsers/gsth265parser.h @@ -1084,5 +1084,26 @@ void gst_h265_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64], #define gst_h265_quant_matrix_32x32_get_raster_from_zigzag \ gst_h265_quant_matrix_8x8_get_raster_from_zigzag +void gst_h265_quant_matrix_4x4_get_uprightdiagonal_from_raster (guint8 out_quant[16], + const guint8 quant[16]); + +void gst_h265_quant_matrix_4x4_get_raster_from_uprightdiagonal (guint8 out_quant[16], + const guint8 quant[16]); + +void gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster (guint8 out_quant[64], + const guint8 quant[64]); + +void gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal (guint8 out_quant[64], + const guint8 quant[64]); + +#define gst_h265_quant_matrix_16x16_get_uprightdiagonal_from_raster \ + gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster +#define gst_h265_quant_matrix_16x16_get_raster_from_uprightdiagonal\ + gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal +#define gst_h265_quant_matrix_32x32_get_uprightdiagonal_from_raster \ + gst_h265_quant_matrix_8x8_get_uprightdiagonal_from_raster +#define gst_h265_quant_matrix_32x32_get_raster_from_uprightdiagonal\ + gst_h265_quant_matrix_8x8_get_raster_from_uprightdiagonal + G_END_DECLS #endif |