diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-02-05 11:56:46 +0100 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-02-06 14:22:41 +0100 |
commit | 250555a7dec8f1a396a20994d28395249eb406d7 (patch) | |
tree | e3299d861ab9c39d16ea201b2bffc275ef84308e /gst-libs | |
parent | 46c01de05dbb50c74aca137298da5b3d16918034 (diff) | |
download | gstreamer-plugins-bad-250555a7dec8f1a396a20994d28395249eb406d7.tar.gz |
codecparsers: mpeg2: add helpers to convert quantization matrices.
Add utility functions to convert quantization matrices from zigzag scan
order (as encoded in the bitstream) into raster scan order. Also provide
another function to reverse the operation.
https://bugzilla.gnome.org/show_bug.cgi?id=693000
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/codecparsers/gstmpegvideoparser.c | 50 | ||||
-rw-r--r-- | gst-libs/gst/codecparsers/gstmpegvideoparser.h | 6 |
2 files changed, 56 insertions, 0 deletions
diff --git a/gst-libs/gst/codecparsers/gstmpegvideoparser.c b/gst-libs/gst/codecparsers/gstmpegvideoparser.c index c841139ad..25763e805 100644 --- a/gst-libs/gst/codecparsers/gstmpegvideoparser.c +++ b/gst-libs/gst/codecparsers/gstmpegvideoparser.c @@ -819,3 +819,53 @@ failed: GST_WARNING ("error parsing \"GOP\""); return FALSE; } + +/** + * gst_mpeg_video_quant_matrix_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.2 + */ +void +gst_mpeg_video_quant_matrix_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[mpeg_zigzag_8x8[i]] = quant[i]; +} + +/** + * gst_mpeg_video_quant_matrix_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.2 + */ +void +gst_mpeg_video_quant_matrix_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[mpeg_zigzag_8x8[i]]; +} diff --git a/gst-libs/gst/codecparsers/gstmpegvideoparser.h b/gst-libs/gst/codecparsers/gstmpegvideoparser.h index 568543383..daeec60fe 100644 --- a/gst-libs/gst/codecparsers/gstmpegvideoparser.h +++ b/gst-libs/gst/codecparsers/gstmpegvideoparser.h @@ -428,6 +428,12 @@ gboolean gst_mpeg_video_parse_sequence_display_extension (GstMpegVideoSequenceDi gboolean gst_mpeg_video_parse_quant_matrix_extension (GstMpegVideoQuantMatrixExt * quant, const guint8 * data, gsize size, guint offset); +void gst_mpeg_video_quant_matrix_get_raster_from_zigzag (guint8 out_quant[64], + const guint8 quant[64]); + +void gst_mpeg_video_quant_matrix_get_zigzag_from_raster (guint8 out_quant[64], + const guint8 quant[64]); + G_END_DECLS #endif |