codecparsers: mpeg2: store quantization matrices in zigzag scan order.

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>
This commit is contained in:
Cong Zhong 2013-01-31 16:13:22 +08:00 committed by Gwenole Beauchesne
parent 7fafbe2e22
commit 46c01de05d
2 changed files with 11 additions and 13 deletions

View 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);
}
}

View 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
{