codecparsers: mpeg2: store quantization matrices in zigzag scan order.
authorCong Zhong <congx.zhong@intel.com>
Thu, 31 Jan 2013 08:13:22 +0000 (16:13 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 6 Feb 2013 13:22:41 +0000 (14:22 +0100)
Quantizer matrices are encoded in zigzag scan order in the bitstream,
but they are stored in raster scan order when they are parsed. However,
default matrices were also prepared in zigzag scan order, hence the
mismatch. i.e. the matrices were presented either in raster scan order
if they are explicitly present in the bitstream, or they were presented
in zigzag scan order if the default definitions were to be used instead.

One way to solve this problem is to always expose the quantization
matrices in zigzag scan order, since this is the role of the parser to
not build up stories from the source bitstream and just present what
is in there.

Utility functions will be provided to convert quantization matrices in
either scan order.

https://bugzilla.gnome.org/show_bug.cgi?id=693000

Signed-off-by: Cong Zhong <congx.zhong@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/codecparsers/gstmpegvideoparser.c
gst-libs/gst/codecparsers/gstmpegvideoparser.h

index 94726c7..c841139 100644 (file)
@@ -322,7 +322,7 @@ gst_mpeg_video_parse_sequence_header (GstMpegVideoSequenceHdr * seqhdr,
   if (load_intra_flag) {
     gint i;
     for (i = 0; i < 64; i++)
-      READ_UINT8 (&br, seqhdr->intra_quantizer_matrix[mpeg_zigzag_8x8[i]], 8);
+      READ_UINT8 (&br, seqhdr->intra_quantizer_matrix[i], 8);
   } else
     memcpy (seqhdr->intra_quantizer_matrix, default_intra_quantizer_matrix, 64);
 
@@ -331,8 +331,7 @@ gst_mpeg_video_parse_sequence_header (GstMpegVideoSequenceHdr * seqhdr,
   if (load_non_intra_flag) {
     gint i;
     for (i = 0; i < 64; i++)
-      READ_UINT8 (&br, seqhdr->non_intra_quantizer_matrix[mpeg_zigzag_8x8[i]],
-          8);
+      READ_UINT8 (&br, seqhdr->non_intra_quantizer_matrix[i], 8);
   } else
     memset (seqhdr->non_intra_quantizer_matrix, 16, 64);
 
@@ -564,31 +563,28 @@ gst_mpeg_video_parse_quant_matrix_extension (GstMpegVideoQuantMatrixExt * quant,
   READ_UINT8 (&br, quant->load_intra_quantiser_matrix, 1);
   if (quant->load_intra_quantiser_matrix) {
     for (i = 0; i < 64; i++) {
-      READ_UINT8 (&br, quant->intra_quantiser_matrix[mpeg_zigzag_8x8[i]], 8);
+      READ_UINT8 (&br, quant->intra_quantiser_matrix[i], 8);
     }
   }
 
   READ_UINT8 (&br, quant->load_non_intra_quantiser_matrix, 1);
   if (quant->load_non_intra_quantiser_matrix) {
     for (i = 0; i < 64; i++) {
-      READ_UINT8 (&br, quant->non_intra_quantiser_matrix[mpeg_zigzag_8x8[i]],
-          8);
+      READ_UINT8 (&br, quant->non_intra_quantiser_matrix[i], 8);
     }
   }
 
   READ_UINT8 (&br, quant->load_chroma_intra_quantiser_matrix, 1);
   if (quant->load_chroma_intra_quantiser_matrix) {
     for (i = 0; i < 64; i++) {
-      READ_UINT8 (&br, quant->chroma_intra_quantiser_matrix[mpeg_zigzag_8x8[i]],
-          8);
+      READ_UINT8 (&br, quant->chroma_intra_quantiser_matrix[i], 8);
     }
   }
 
   READ_UINT8 (&br, quant->load_chroma_non_intra_quantiser_matrix, 1);
   if (quant->load_chroma_non_intra_quantiser_matrix) {
     for (i = 0; i < 64; i++) {
-      READ_UINT8 (&br,
-          quant->chroma_non_intra_quantiser_matrix[mpeg_zigzag_8x8[i]], 8);
+      READ_UINT8 (&br, quant->chroma_non_intra_quantiser_matrix[i], 8);
     }
   }
 
index 88ab393..5685433 100644 (file)
@@ -193,8 +193,8 @@ typedef struct _GstMpegVideoPacket          GstMpegVideoPacket;
  * @bitrate_value: Value of the bitrate as is in the stream (400bps unit)
  * @bitrate: the real bitrate of the Mpeg video stream in bits per second, 0 if VBR stream
  * @constrained_parameters_flag: %TRUE if this stream uses contrained parameters.
- * @intra_quantizer_matrix: intra-quantization table
- * @non_intra_quantizer_matrix: non-intra quantization table
+ * @intra_quantizer_matrix: intra-quantization table, in zigzag scan order
+ * @non_intra_quantizer_matrix: non-intra quantization table, in zigzag scan order
  *
  * The Mpeg2 Video Sequence Header structure.
  */
@@ -283,7 +283,9 @@ struct _GstMpegVideoSequenceDisplayExt
  * @load_chroma_non_intra_quantiser_matrix:
  * @chroma_non_intra_quantiser_matrix:
  *
- * The Quant Matrix Extension structure
+ * The Quant Matrix Extension structure that exposes quantization
+ * matrices in zigzag scan order. i.e. the original encoded scan
+ * order.
  */
 struct _GstMpegVideoQuantMatrixExt
 {