codecparsers: h264: 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=708629
This commit is contained in:
Sreerenj Balachandran 2013-10-02 11:24:58 +03:00 committed by Sebastian Dröge
parent 5ff85dd16a
commit 8c9eaf0dc9
3 changed files with 116 additions and 0 deletions

View file

@ -40,6 +40,10 @@ gst_h264_nal_parser_new
gst_h264_nal_parser_free
gst_h264_parse_sps
gst_h264_parse_pps
gst_h264_video_quant_matrix_8x8_get_zigzag_from_raster
gst_h264_video_quant_matrix_8x8_get_raster_from_zigzag
gst_h264_video_quant_matrix_4x4_get_zigzag_from_raster
gst_h264_video_quant_matrix_4x4_get_raster_from_zigzag
<SUBSECTION Standard>
<SUBSECTION Private>
</SECTION>

View file

@ -2018,3 +2018,103 @@ error:
GST_WARNING ("error parsing \"Sei message\"");
return GST_H264_PARSER_ERROR;
}
/**
* gst_h264_video_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.4
*/
void
gst_h264_video_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_h264_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.4
*/
void
gst_h264_video_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];
}
/**
* gst_h264_video_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.4
*/
void
gst_h264_video_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_h264_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.4
*/
void
gst_h264_video_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];
}

View file

@ -759,5 +759,17 @@ GstH264ParserResult gst_h264_parse_sps (GstH264NalUnit *nalu,
GstH264ParserResult gst_h264_parse_pps (GstH264NalParser *nalparser,
GstH264NalUnit *nalu, GstH264PPS *pps);
void gst_h264_video_quant_matrix_8x8_get_zigzag_from_raster (guint8 out_quant[64],
const guint8 quant[64]);
void gst_h264_video_quant_matrix_8x8_get_raster_from_zigzag (guint8 out_quant[64],
const guint8 quant[64]);
void gst_h264_video_quant_matrix_4x4_get_zigzag_from_raster (guint8 out_quant[16],
const guint8 quant[16]);
void gst_h264_video_quant_matrix_4x4_get_raster_from_zigzag (guint8 out_quant[16],
const guint8 quant[16]);
G_END_DECLS
#endif