codecparsers: VC1: Implement Sequence Layer Data Structures

Instead of having a single VC1SequenceHeader structure, use the 3 structs
from the "Table 265: Sequence Layer Data Structure" of the specification
for the library to be more flexible.

Implement the functions to parse them
This commit is contained in:
Thibault Saunier 2011-10-05 12:15:00 -03:00
parent 446e0a5216
commit fc09e45108
4 changed files with 497 additions and 255 deletions

View file

@ -61,7 +61,10 @@ GstVC1Condover
GstVC1MvMode GstVC1MvMode
GstVC1SeqHdr GstVC1SeqHdr
GstVC1AdvancedSeqHdr GstVC1AdvancedSeqHdr
GstVC1SimpleMainSeqHdr GstVC1SeqLayer
GstVC1SeqStructA
GstVC1SeqStructB
GstVC1SeqStructC
GstVC1HrdParam GstVC1HrdParam
GstVC1EntryPointHdr GstVC1EntryPointHdr
GstVC1FrameHdr GstVC1FrameHdr
@ -72,6 +75,10 @@ GstVC1VopDquant
GstVC1BDU GstVC1BDU
gst_vc1_identify_next_bdu gst_vc1_identify_next_bdu
gst_vc1_parse_sequence_header gst_vc1_parse_sequence_header
gst_vc1_parse_sequence_layer
gst_vc1_parse_sequence_header_struct_a
gst_vc1_parse_sequence_header_struct_b
gst_vc1_parse_sequence_header_struct_c
gst_vc1_parse_entry_point_header gst_vc1_parse_entry_point_header
gst_vc1_parse_frame_header gst_vc1_parse_frame_header
<SUBSECTION Standard> <SUBSECTION Standard>

View file

@ -565,28 +565,28 @@ get_unary (GstBitReader * br, gint stop, gint len)
} }
static inline void static inline void
calculate_framerate_bitrate (GstVC1SeqHdr * seqhdr) calculate_framerate_bitrate (guint8 frmrtq_postproc, guint8 bitrtq_postproc,
guint * framerate, guint * bitrate)
{ {
/* Calulate bitrate and framerate */ if (frmrtq_postproc == 0 && bitrtq_postproc == 30) {
if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 30) { *framerate = 0;
seqhdr->framerate = 0; *bitrate = 0;
seqhdr->bitrate = 0; } else if (frmrtq_postproc == 0 && bitrtq_postproc == 30) {
} else if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 30) { *framerate = 2;
seqhdr->framerate = 2; *bitrate = 1952;
seqhdr->bitrate = 1952; } else if (frmrtq_postproc == 0 && bitrtq_postproc == 31) {
} else if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 31) { *framerate = 6;
seqhdr->framerate = 6; *bitrate = 2016;
seqhdr->bitrate = 2016;
} else { } else {
if (seqhdr->frmrtq_postproc == 7) { if (frmrtq_postproc == 7) {
seqhdr->framerate = 30; *framerate = 30;
} else { } else {
seqhdr->framerate = 2 + (seqhdr->frmrtq_postproc * 4); *framerate = 2 + (frmrtq_postproc * 4);
} }
if (seqhdr->bitrtq_postproc == 31) { if (bitrtq_postproc == 31) {
seqhdr->bitrate = 2016; *bitrate = 2016;
} else { } else {
seqhdr->bitrate = 32 + (seqhdr->bitrtq_postproc * 64); *bitrate = 32 + (bitrtq_postproc * 64);
} }
} }
} }
@ -630,20 +630,22 @@ failed:
static GstVC1ParserResult static GstVC1ParserResult
parse_sequence_header_advanced (GstVC1SeqHdr * seqhdr, GstBitReader * br) parse_sequence_header_advanced (GstVC1SeqHdr * seqhdr, GstBitReader * br)
{ {
GstVC1AdvancedSeqHdr *advanced = &seqhdr->profile.advanced; GstVC1AdvancedSeqHdr *advanced = &seqhdr->advanced;
GST_DEBUG ("Parsing sequence header in advanced mode"); GST_DEBUG ("Parsing sequence header in advanced mode");
READ_UINT8 (br, advanced->level, 3); READ_UINT8 (br, advanced->level, 3);
READ_UINT8 (br, seqhdr->colordiff_format, 2); READ_UINT8 (br, advanced->colordiff_format, 2);
READ_UINT8 (br, seqhdr->frmrtq_postproc, 3); READ_UINT8 (br, advanced->frmrtq_postproc, 3);
READ_UINT8 (br, seqhdr->bitrtq_postproc, 5); READ_UINT8 (br, advanced->bitrtq_postproc, 5);
calculate_framerate_bitrate (seqhdr);
calculate_framerate_bitrate (advanced->frmrtq_postproc,
advanced->bitrtq_postproc, &advanced->framerate, &advanced->bitrate);
GST_DEBUG ("level %u, colordiff_format %u , frmrtq_postproc %u," GST_DEBUG ("level %u, colordiff_format %u , frmrtq_postproc %u,"
" bitrtq_postproc %u", advanced->level, seqhdr->colordiff_format, " bitrtq_postproc %u", advanced->level, advanced->colordiff_format,
seqhdr->frmrtq_postproc, seqhdr->bitrtq_postproc); advanced->frmrtq_postproc, advanced->bitrtq_postproc);
if (gst_bit_reader_get_remaining (br) < 32) if (gst_bit_reader_get_remaining (br) < 32)
goto failed; goto failed;
@ -659,13 +661,13 @@ parse_sequence_header_advanced (GstVC1SeqHdr * seqhdr, GstBitReader * br)
advanced->pulldown = gst_bit_reader_get_bits_uint8_unchecked (br, 1); advanced->pulldown = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
advanced->interlace = gst_bit_reader_get_bits_uint8_unchecked (br, 1); advanced->interlace = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
advanced->tfcntrflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1); advanced->tfcntrflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
seqhdr->finterpflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1); advanced->finterpflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
GST_DEBUG ("postprocflag %u, max_coded_width %u, max_coded_height %u," GST_DEBUG ("postprocflag %u, max_coded_width %u, max_coded_height %u,"
"pulldown %u, interlace %u, tfcntrflag %u, finterpflag %u", "pulldown %u, interlace %u, tfcntrflag %u, finterpflag %u",
advanced->postprocflag, advanced->max_coded_width, advanced->postprocflag, advanced->max_coded_width,
advanced->max_coded_height, advanced->pulldown, advanced->max_coded_height, advanced->pulldown,
advanced->interlace, advanced->tfcntrflag, seqhdr->finterpflag); advanced->interlace, advanced->tfcntrflag, advanced->finterpflag);
/* Skipping reserved bit */ /* Skipping reserved bit */
gst_bit_reader_skip_unchecked (br, 1); gst_bit_reader_skip_unchecked (br, 1);
@ -727,7 +729,7 @@ static GstVC1ParserResult
parse_frame_header_advanced (GstBitReader * br, GstVC1FrameHdr * framehdr, parse_frame_header_advanced (GstBitReader * br, GstVC1FrameHdr * framehdr,
GstVC1SeqHdr * seqhdr) GstVC1SeqHdr * seqhdr)
{ {
GstVC1AdvancedSeqHdr *advhdr = &seqhdr->profile.advanced; GstVC1AdvancedSeqHdr *advhdr = &seqhdr->advanced;
GstVC1PicAdvanced *pic = &framehdr->pic.advanced; GstVC1PicAdvanced *pic = &framehdr->pic.advanced;
GstVC1EntryPointHdr *entrypthdr = &advhdr->entrypoint; GstVC1EntryPointHdr *entrypthdr = &advhdr->entrypoint;
guint8 mvmodeidx; guint8 mvmodeidx;
@ -737,7 +739,7 @@ parse_frame_header_advanced (GstBitReader * br, GstVC1FrameHdr * framehdr,
GST_DEBUG ("Parsing Frame header advanced %u", advhdr->interlace); GST_DEBUG ("Parsing Frame header advanced %u", advhdr->interlace);
/* Set the conveninence fields */ /* Set the conveninence fields */
framehdr->profile = seqhdr->profiletype; framehdr->profile = seqhdr->profile;
framehdr->dquant = entrypthdr->dquant; framehdr->dquant = entrypthdr->dquant;
if (advhdr->interlace) { if (advhdr->interlace) {
@ -798,7 +800,7 @@ parse_frame_header_advanced (GstBitReader * br, GstVC1FrameHdr * framehdr,
GST_DEBUG ("uvsamp %u", pic->uvsamp); GST_DEBUG ("uvsamp %u", pic->uvsamp);
} }
if (seqhdr->finterpflag) { if (advhdr->finterpflag) {
READ_UINT8 (br, framehdr->interpfrm, 1); READ_UINT8 (br, framehdr->interpfrm, 1);
GST_DEBUG ("interpfrm %u", framehdr->interpfrm); GST_DEBUG ("interpfrm %u", framehdr->interpfrm);
} }
@ -988,31 +990,28 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr,
{ {
guint8 mvmodeidx; guint8 mvmodeidx;
GstVC1PicSimpleMain *pic = &framehdr->pic.simple; GstVC1PicSimpleMain *pic = &framehdr->pic.simple;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr->profile.simplemain; GstVC1SeqStructC *structc = &seqhdr->struct_c;
guint width = seqhdr->mb_width;
guint height = seqhdr->mb_height;
GST_DEBUG ("Parsing frame header in simple or main mode"); GST_DEBUG ("Parsing frame header in simple or main mode");
/* Set the conveninence fields */ /* Set the conveninence fields */
framehdr->profile = seqhdr->profiletype; framehdr->profile = seqhdr->profile;
framehdr->dquant = simplehdr->dquant; framehdr->dquant = structc->dquant;
framehdr->interpfrm = 0; framehdr->interpfrm = 0;
if (seqhdr->finterpflag) if (structc->finterpflag)
READ_UINT8 (br, framehdr->interpfrm, 1); READ_UINT8 (br, framehdr->interpfrm, 1);
READ_UINT8 (br, pic->frmcnt, 2); READ_UINT8 (br, pic->frmcnt, 2);
pic->rangeredfrm = 0; pic->rangeredfrm = 0;
if (simplehdr->rangered) { if (structc->rangered) {
READ_UINT8 (br, pic->rangeredfrm, 2); READ_UINT8 (br, pic->rangeredfrm, 2);
} }
/* Figuring out the picture type */ /* Figuring out the picture type */
READ_UINT8 (br, framehdr->ptype, 1); READ_UINT8 (br, framehdr->ptype, 1);
if (simplehdr->maxbframes) { if (structc->maxbframes) {
if (!framehdr->ptype) { if (!framehdr->ptype) {
READ_UINT8 (br, framehdr->ptype, 1); READ_UINT8 (br, framehdr->ptype, 1);
@ -1055,7 +1054,7 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr,
GST_DEBUG ("pqindex %u", framehdr->pqindex); GST_DEBUG ("pqindex %u", framehdr->pqindex);
/* compute pquant */ /* compute pquant */
if (simplehdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) if (structc->quantizer == GST_VC1_QUANTIZER_IMPLICITLY)
framehdr->pquant = vc1_pquant_table[0][framehdr->pqindex]; framehdr->pquant = vc1_pquant_table[0][framehdr->pqindex];
else else
framehdr->pquant = vc1_pquant_table[1][framehdr->pqindex]; framehdr->pquant = vc1_pquant_table[1][framehdr->pqindex];
@ -1069,20 +1068,20 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr,
/* Set pquantizer */ /* Set pquantizer */
framehdr->pquantizer = 1; framehdr->pquantizer = 1;
if (simplehdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) if (structc->quantizer == GST_VC1_QUANTIZER_IMPLICITLY)
framehdr->pquantizer = framehdr->pqindex < 9; framehdr->pquantizer = framehdr->pqindex < 9;
else if (simplehdr->quantizer == GST_VC1_QUANTIZER_NON_UNIFORM) else if (structc->quantizer == GST_VC1_QUANTIZER_NON_UNIFORM)
framehdr->pquantizer = 0; framehdr->pquantizer = 0;
if (simplehdr->quantizer == GST_VC1_QUANTIZER_EXPLICITLY) if (structc->quantizer == GST_VC1_QUANTIZER_EXPLICITLY)
READ_UINT8 (br, framehdr->pquantizer, 1); READ_UINT8 (br, framehdr->pquantizer, 1);
if (simplehdr->extended_mv == 1) { if (structc->extended_mv == 1) {
pic->mvrange = get_unary (br, 0, 3); pic->mvrange = get_unary (br, 0, 3);
GST_DEBUG ("mvrange %u", pic->mvrange); GST_DEBUG ("mvrange %u", pic->mvrange);
} }
if (simplehdr->multires && (framehdr->ptype == GST_VC1_PICTURE_TYPE_P || if (structc->multires && (framehdr->ptype == GST_VC1_PICTURE_TYPE_P ||
framehdr->ptype == GST_VC1_PICTURE_TYPE_I)) { framehdr->ptype == GST_VC1_PICTURE_TYPE_I)) {
READ_UINT8 (br, pic->respic, 2); READ_UINT8 (br, pic->respic, 2);
GST_DEBUG ("Respic %u", pic->respic); GST_DEBUG ("Respic %u", pic->respic);
@ -1132,7 +1131,7 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr,
parse_vopdquant (br, framehdr, framehdr->dquant); parse_vopdquant (br, framehdr, framehdr->dquant);
} }
if (simplehdr->vstransform) { if (structc->vstransform) {
READ_UINT8 (br, pic->ttmbf, 1); READ_UINT8 (br, pic->ttmbf, 1);
GST_DEBUG ("ttmbf %u", pic->ttmbf); GST_DEBUG ("ttmbf %u", pic->ttmbf);
@ -1163,7 +1162,7 @@ parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr,
if (framehdr->dquant) if (framehdr->dquant)
parse_vopdquant (br, framehdr, framehdr->dquant); parse_vopdquant (br, framehdr, framehdr->dquant);
if (simplehdr->vstransform) { if (structc->vstransform) {
READ_UINT8 (br, pic->ttmbf, 1); READ_UINT8 (br, pic->ttmbf, 1);
if (pic->ttmbf) { if (pic->ttmbf) {
@ -1190,6 +1189,130 @@ failed:
return GST_VC1_PARSER_ERROR; return GST_VC1_PARSER_ERROR;
} }
static GstVC1ParserResult
parse_sequence_header_struct_a (GstBitReader * br, GstVC1SeqStructA * structa)
{
if (gst_bit_reader_get_remaining (br) < 64) {
GST_WARNING ("Failed to parse struct A");
return GST_VC1_PARSER_ERROR;
}
structa->vert_size = gst_bit_reader_get_bits_uint32_unchecked (br, 32);
structa->horiz_size = gst_bit_reader_get_bits_uint32_unchecked (br, 32);
return GST_VC1_PARSER_OK;
}
static GstVC1ParserResult
parse_sequence_header_struct_b (GstBitReader * br, GstVC1SeqStructB * structb)
{
if (gst_bit_reader_get_remaining (br) < 96) {
GST_WARNING ("Failed to parse sequence header");
return GST_VC1_PARSER_ERROR;
}
structb->level = gst_bit_reader_get_bits_uint8_unchecked (br, 3);
structb->cbr = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
/* res4 */
gst_bit_reader_skip_unchecked (br, 4);
structb->hrd_buffer = gst_bit_reader_get_bits_uint32_unchecked (br, 24);
structb->hrd_rate = gst_bit_reader_get_bits_uint32_unchecked (br, 32);
structb->framerate = gst_bit_reader_get_bits_uint32_unchecked (br, 32);
return GST_VC1_PARSER_OK;
}
static GstVC1ParserResult
parse_sequence_header_struct_c (GstBitReader * br, GstVC1SeqStructC * structc)
{
guint8 old_interlaced_mode, tmp;
READ_UINT8 (br, tmp, 2);
structc->profile = tmp;
if (structc->profile == GST_VC1_PROFILE_ADVANCED)
return GST_VC1_PARSER_OK;
GST_DEBUG ("Parsing sequence header in simple or main mode");
if (gst_bit_reader_get_remaining (br) < 29)
goto failed;
/* Reserved bits */
old_interlaced_mode = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
if (old_interlaced_mode)
GST_WARNING ("Old interlaced mode used");
structc->wmvp = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
if (structc->wmvp)
GST_DEBUG ("WMVP mode");
structc->frmrtq_postproc = gst_bit_reader_get_bits_uint8_unchecked (br, 3);
structc->bitrtq_postproc = gst_bit_reader_get_bits_uint8_unchecked (br, 5);
structc->loop_filter = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
calculate_framerate_bitrate (structc->frmrtq_postproc,
structc->bitrtq_postproc, &structc->framerate, &structc->bitrate);
/* Skipping reserved3 bit */
gst_bit_reader_skip_unchecked (br, 1);
structc->multires = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
/* Skipping reserved4 bit */
gst_bit_reader_skip_unchecked (br, 1);
structc->fastuvmc = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
structc->extended_mv = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
structc->dquant = gst_bit_reader_get_bits_uint8_unchecked (br, 2);
structc->vstransform = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
/* Skipping reserved5 bit */
gst_bit_reader_skip_unchecked (br, 1);
structc->overlap = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
structc->syncmarker = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
structc->rangered = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
structc->maxbframes = gst_bit_reader_get_bits_uint8_unchecked (br, 3);
structc->quantizer = gst_bit_reader_get_bits_uint8_unchecked (br, 2);
structc->finterpflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
GST_DEBUG ("frmrtq_postproc %u, bitrtq_postproc %u, loop_filter %u, "
"multires %u, fastuvmc %u, extended_mv %u, dquant %u, vstransform %u, "
"overlap %u, syncmarker %u, rangered %u, maxbframes %u, quantizer %u, "
"finterpflag %u", structc->frmrtq_postproc, structc->bitrtq_postproc,
structc->loop_filter, structc->multires, structc->fastuvmc,
structc->extended_mv, structc->dquant, structc->vstransform,
structc->overlap, structc->syncmarker, structc->rangered,
structc->maxbframes, structc->quantizer, structc->finterpflag);
if (structc->wmvp) {
if (gst_bit_reader_get_remaining (br) < 29)
goto failed;
structc->coded_width = gst_bit_reader_get_bits_uint16_unchecked (br, 11);
structc->coded_height = gst_bit_reader_get_bits_uint16_unchecked (br, 11);
structc->framerate = gst_bit_reader_get_bits_uint8_unchecked (br, 5);
gst_bit_reader_skip_unchecked (br, 1);
structc->slice_code = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
GST_DEBUG ("coded_width %u, coded_height %u, framerate %u slice_code %u",
structc->coded_width, structc->coded_height, structc->framerate,
structc->slice_code);
}
return GST_VC1_PARSER_OK;
failed:
GST_WARNING ("Failed to struct C");
return GST_VC1_PARSER_ERROR;
}
/**** API ****/ /**** API ****/
/** /**
* gst_vc1_identify_next_bdu: * gst_vc1_identify_next_bdu:
@ -1230,7 +1353,7 @@ gst_vc1_identify_next_bdu (const guint8 * data, gsize size, GstVC1BDU * bdu)
bdu->type = (GstVC1StartCode) (data[bdu->offset - 1]); bdu->type = (GstVC1StartCode) (data[bdu->offset - 1]);
if (bdu->type == GST_VC1_END_OF_SEQ) { if (bdu->type == GST_VC1_END_OF_SEQ) {
GST_DEBUG ("End-of-Sequence BDU found"); GST_DEBUG ("End-of-Seq BDU found");
bdu->size = 0; bdu->size = 0;
return GST_VC1_PARSER_OK; return GST_VC1_PARSER_OK;
} }
@ -1252,10 +1375,135 @@ gst_vc1_identify_next_bdu (const guint8 * data, gsize size, GstVC1BDU * bdu)
} }
/** /**
* gst_vc1_parse_sequence_header: * gst_vc1_parse_sequence_layer:
* @data: The data to parse * @data: The data to parse
* @size: the size of @data * @size: the size of @data
* @seqhdr: The #GstVC1SeqHdr to set. * @structa: The #GstVC1SeqLayer to set.
*
* Parses @data, and fills @seqlayer fields.
*
* Returns: a #GstVC1ParserResult
*/
GstVC1ParserResult
gst_vc1_parse_sequence_layer (const guint8 * data, gsize size,
GstVC1SeqLayer * seqlayer)
{
guint32 tmp;
GstBitReader br = GST_BIT_READER_INIT (data, size);
g_return_val_if_fail (seqlayer != NULL, GST_VC1_PARSER_ERROR);
ensure_debug_category ();
READ_UINT32 (&br, tmp, 8);
if (tmp != 0xC5)
goto failed;
READ_UINT32 (&br, seqlayer->numframes, 24);
if (parse_sequence_header_struct_c (&br, &seqlayer->struct_c) ==
GST_VC1_PARSER_ERROR)
goto failed;
READ_UINT32 (&br, tmp, 32);
if (tmp != 0x04)
goto failed;
if (parse_sequence_header_struct_a (&br, &seqlayer->struct_a) ==
GST_VC1_PARSER_ERROR)
goto failed;
READ_UINT32 (&br, tmp, 32);
if (tmp != 0x0C)
goto failed;
if (parse_sequence_header_struct_b (&br, &seqlayer->struct_b) ==
GST_VC1_PARSER_ERROR)
goto failed;
return GST_VC1_PARSER_OK;
failed:
GST_WARNING ("Failed to parse sequence layer");
return GST_VC1_PARSER_ERROR;
}
/**
* gst_vc1_parse_sequence_header_struct_a:
* @data: The data to parse
* @size: the size of @data
* @structa: The #GstVC1SeqStructA to set.
*
* Parses @data, and fills @structa fields.
*
* Returns: a #GstVC1ParserResult
*/
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_a (const guint8 * data,
gsize size, GstVC1SeqStructA * structa)
{
GstBitReader br = GST_BIT_READER_INIT (data, size);
g_return_val_if_fail (structa != NULL, GST_VC1_PARSER_ERROR);
ensure_debug_category ();
return parse_sequence_header_struct_a (&br, structa);
}
/**
* gst_vc1_parse_sequence_header_struct_b:
* @data: The data to parse
* @size: the size of @data
* @structa: The #GstVC1SeqStructB to set.
*
* Parses @data, and fills @structb fields.
*
* Returns: a #GstVC1ParserResult
*/
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_b (const guint8 * data,
gsize size, GstVC1SeqStructB * structb)
{
GstBitReader br = GST_BIT_READER_INIT (data, size);
g_return_val_if_fail (structb != NULL, GST_VC1_PARSER_ERROR);
ensure_debug_category ();
return parse_sequence_header_struct_b (&br, structb);
}
/**
* gst_vc1_parse_sequence_header_struct_c:
* @data: The data to parse
* @size: the size of @data
* @structc: The #GstVC1SeqStructC to set.
*
* Parses @data, and fills @structc fields.
*
* Returns: a #GstVC1ParserResult
*/
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_c (const guint8 * data, gsize size,
GstVC1SeqStructC * structc)
{
GstBitReader br = GST_BIT_READER_INIT (data, size);
g_return_val_if_fail (structc != NULL, GST_VC1_PARSER_ERROR);
ensure_debug_category ();
return parse_sequence_header_struct_c (&br, structc);
}
/**
* gst_vc1_parse_sequence_header:
* @data: The data to parse
* @size: the size of @data
* @seqhdr: The #GstVC1SeqHdr to set.
* *
* Parses @data, and fills @seqhdr fields. * Parses @data, and fills @seqhdr fields.
* *
@ -1265,92 +1513,25 @@ GstVC1ParserResult
gst_vc1_parse_sequence_header (const guint8 * data, gsize size, gst_vc1_parse_sequence_header (const guint8 * data, gsize size,
GstVC1SeqHdr * seqhdr) GstVC1SeqHdr * seqhdr)
{ {
GstBitReader br; GstBitReader br = GST_BIT_READER_INIT (data, size);
guint8 old_interlaced_mode;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr->profile.simplemain;
g_return_val_if_fail (seqhdr != NULL, GST_VC1_PARSER_ERROR); g_return_val_if_fail (seqhdr != NULL, GST_VC1_PARSER_ERROR);
ensure_debug_category (); ensure_debug_category ();
gst_bit_reader_init (&br, data, size); if (parse_sequence_header_struct_c (&br, &seqhdr->struct_c) ==
GST_VC1_PARSER_ERROR)
goto failed;
READ_UINT8 (&br, seqhdr->profiletype, 2); /* Convenience field */
seqhdr->profile = seqhdr->struct_c.profile;
if (seqhdr->profiletype == GST_VC1_PROFILE_ADVANCED) { if (seqhdr->profile == GST_VC1_PROFILE_ADVANCED)
return parse_sequence_header_advanced (seqhdr, &br); return parse_sequence_header_advanced (seqhdr, &br);
}
GST_DEBUG ("Parsing sequence header in simple or main mode");
if (gst_bit_reader_get_remaining (&br) < 29)
goto failed;
/* Reserved bits */
old_interlaced_mode = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
if (old_interlaced_mode)
GST_WARNING ("Old interlaced mode used");
simplehdr->wmvp = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
if (simplehdr->wmvp)
GST_DEBUG ("WMVP mode");
seqhdr->frmrtq_postproc = gst_bit_reader_get_bits_uint8_unchecked (&br, 3);
seqhdr->bitrtq_postproc = gst_bit_reader_get_bits_uint8_unchecked (&br, 5);
simplehdr->loop_filter = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
calculate_framerate_bitrate (seqhdr);
/* Skipping reserved3 bit */
gst_bit_reader_skip_unchecked (&br, 1);
simplehdr->multires = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
/* Skipping reserved4 bit */
gst_bit_reader_skip_unchecked (&br, 1);
simplehdr->fastuvmc = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
simplehdr->extended_mv = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
simplehdr->dquant = gst_bit_reader_get_bits_uint8_unchecked (&br, 2);
simplehdr->vstransform = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
/* Skipping reserved5 bit */
gst_bit_reader_skip_unchecked (&br, 1);
simplehdr->overlap = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
simplehdr->syncmarker = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
simplehdr->rangered = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
simplehdr->maxbframes = gst_bit_reader_get_bits_uint8_unchecked (&br, 3);
simplehdr->quantizer = gst_bit_reader_get_bits_uint8_unchecked (&br, 2);
seqhdr->finterpflag = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
GST_DEBUG ("frmrtq_postproc %u, bitrtq_postproc %u, loop_filter %u, "
"multires %u, fastuvmc %u, extended_mv %u, dquant %u, vstransform %u, "
"overlap %u, syncmarker %u, rangered %u, maxbframes %u, quantizer %u, "
"finterpflag %u", seqhdr->frmrtq_postproc, seqhdr->bitrtq_postproc,
simplehdr->loop_filter, simplehdr->multires, simplehdr->fastuvmc,
simplehdr->extended_mv, simplehdr->dquant, simplehdr->vstransform,
simplehdr->overlap, simplehdr->syncmarker, simplehdr->rangered,
simplehdr->maxbframes, simplehdr->quantizer, seqhdr->finterpflag);
if (simplehdr->wmvp) {
if (gst_bit_reader_get_remaining (&br) < 29)
goto failed;
simplehdr->coded_width = gst_bit_reader_get_bits_uint16_unchecked (&br, 11);
simplehdr->coded_height =
gst_bit_reader_get_bits_uint16_unchecked (&br, 11);
simplehdr->framerate = gst_bit_reader_get_bits_uint8_unchecked (&br, 5);
gst_bit_reader_skip_unchecked (&br, 1);
simplehdr->slice_code = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
GST_DEBUG ("coded_width %u, coded_height %u, framerate %u slice_code %u",
simplehdr->coded_width, simplehdr->coded_height, simplehdr->framerate,
simplehdr->slice_code);
}
/* compute height and width */ /* compute height and width */
seqhdr->mb_height = (simplehdr->coded_height + 15) >> 4; seqhdr->mb_height = (seqhdr->struct_c.coded_height + 15) >> 4;
seqhdr->mb_width = (simplehdr->coded_width + 15) >> 4; seqhdr->mb_width = (seqhdr->struct_c.coded_width + 15) >> 4;
return GST_VC1_PARSER_OK; return GST_VC1_PARSER_OK;
@ -1377,7 +1558,7 @@ gst_vc1_parse_entry_point_header (const guint8 * data, gsize size,
{ {
GstBitReader br; GstBitReader br;
guint8 i; guint8 i;
GstVC1AdvancedSeqHdr *advanced = &seqhdr->profile.advanced; GstVC1AdvancedSeqHdr *advanced = &seqhdr->advanced;
g_return_val_if_fail (entrypoint != NULL, GST_VC1_PARSER_ERROR); g_return_val_if_fail (entrypoint != NULL, GST_VC1_PARSER_ERROR);
@ -1401,8 +1582,7 @@ gst_vc1_parse_entry_point_header (const guint8 * data, gsize size,
entrypoint->quantizer = gst_bit_reader_get_bits_uint8_unchecked (&br, 2); entrypoint->quantizer = gst_bit_reader_get_bits_uint8_unchecked (&br, 2);
if (advanced->hrd_param_flag) { if (advanced->hrd_param_flag) {
for (i = 0; i < seqhdr->profile.advanced.hrd_param.hrd_num_leaky_buckets; for (i = 0; i < seqhdr->advanced.hrd_param.hrd_num_leaky_buckets; i++)
i++)
READ_UINT8 (&br, entrypoint->hrd_full[MAX_HRD_NUM_LEAKY_BUCKETS], 8); READ_UINT8 (&br, entrypoint->hrd_full[MAX_HRD_NUM_LEAKY_BUCKETS], 8);
} }
@ -1459,7 +1639,7 @@ gst_vc1_parse_frame_header (const guint8 * data, gsize size,
gst_bit_reader_init (&br, data, size); gst_bit_reader_init (&br, data, size);
if (seqhdr->profiletype == GST_VC1_PROFILE_ADVANCED) if (seqhdr->profile == GST_VC1_PROFILE_ADVANCED)
result = parse_frame_header_advanced (&br, framehdr, seqhdr); result = parse_frame_header_advanced (&br, framehdr, seqhdr);
else else
result = parse_frame_header (&br, framehdr, seqhdr); result = parse_frame_header (&br, framehdr, seqhdr);

View file

@ -129,10 +129,15 @@ typedef enum
typedef struct _GstVC1SeqHdr GstVC1SeqHdr; typedef struct _GstVC1SeqHdr GstVC1SeqHdr;
typedef struct _GstVC1AdvancedSeqHdr GstVC1AdvancedSeqHdr; typedef struct _GstVC1AdvancedSeqHdr GstVC1AdvancedSeqHdr;
typedef struct _GstVC1SimpleMainSeqHdr GstVC1SimpleMainSeqHdr;
typedef struct _GstVC1HrdParam GstVC1HrdParam; typedef struct _GstVC1HrdParam GstVC1HrdParam;
typedef struct _GstVC1EntryPointHdr GstVC1EntryPointHdr; typedef struct _GstVC1EntryPointHdr GstVC1EntryPointHdr;
typedef struct _GstVC1SeqLayer GstVC1SeqLayer;
typedef struct _GstVC1SeqStructA GstVC1SeqStructA;
typedef struct _GstVC1SeqStructB GstVC1SeqStructB;
typedef struct _GstVC1SeqStructC GstVC1SeqStructC;
/* Pictures Structures */ /* Pictures Structures */
typedef struct _GstVC1FrameHdr GstVC1FrameHdr; typedef struct _GstVC1FrameHdr GstVC1FrameHdr;
typedef struct _GstVC1PicAdvanced GstVC1PicAdvanced; typedef struct _GstVC1PicAdvanced GstVC1PicAdvanced;
@ -152,37 +157,6 @@ struct _GstVC1HrdParam
guint16 hrd_buffer[MAX_HRD_NUM_LEAKY_BUCKETS]; guint16 hrd_buffer[MAX_HRD_NUM_LEAKY_BUCKETS];
}; };
/**
* GstVC1SimpleMainSeqHdr:
*
* Structure for simple and main profile sequence headers specific parameters.
*/
struct _GstVC1SimpleMainSeqHdr
{
guint8 res_sprite;
guint8 loop_filter;
guint8 multires;
guint8 fastuvmc;
guint8 extended_mv;
guint8 dquant;
guint8 vstransform;
guint8 overlap;
guint8 syncmarker;
guint8 rangered;
guint8 maxbframes;
guint8 quantizer;
/* This should be filled by user if previously known */
guint16 coded_width;
/* This should be filled by user if previously known */
guint16 coded_height;
/* Wmvp specific */
guint8 wmvp; /* Specify if the stream is wmp or not */
guint8 framerate;
guint8 slice_code;
};
/** /**
* GstVC1EntryPointHdr: * GstVC1EntryPointHdr:
* *
@ -221,12 +195,15 @@ struct _GstVC1EntryPointHdr
struct _GstVC1AdvancedSeqHdr struct _GstVC1AdvancedSeqHdr
{ {
guint8 level; guint8 level;
guint8 frmrtq_postproc;
guint8 bitrtq_postproc;
guint8 postprocflag; guint8 postprocflag;
guint16 max_coded_width; guint16 max_coded_width;
guint16 max_coded_height; guint16 max_coded_height;
guint8 pulldown; guint8 pulldown;
guint8 interlace; guint8 interlace;
guint8 tfcntrflag; guint8 tfcntrflag;
guint8 finterpflag;
guint8 psf; guint8 psf;
guint8 display_ext; guint8 display_ext;
guint16 disp_horiz_size; guint16 disp_horiz_size;
@ -245,13 +222,80 @@ struct _GstVC1AdvancedSeqHdr
guint8 transfer_char; guint8 transfer_char;
guint8 matrix_coef; guint8 matrix_coef;
guint8 hrd_param_flag; guint8 hrd_param_flag;
guint8 colordiff_format;
GstVC1HrdParam hrd_param; GstVC1HrdParam hrd_param;
/* computed */
guint framerate; /* Around in fps, 0 if unknown*/
guint bitrate; /* Around in kpbs, 0 if unknown*/
/* The last parsed entry point */ /* The last parsed entry point */
GstVC1EntryPointHdr entrypoint; GstVC1EntryPointHdr entrypoint;
}; };
struct _GstVC1SeqStructA
{
guint32 vert_size;
guint32 horiz_size;
};
struct _GstVC1SeqStructB
{
guint8 level;
guint8 cbr;
guint32 framerate;
/* In simple and main profiles only */
guint32 hrd_buffer;
guint32 hrd_rate;
};
struct _GstVC1SeqStructC
{
GstVC1Profile profile;
/* Only in simple and main profiles */
guint8 frmrtq_postproc;
guint8 bitrtq_postproc;
guint8 res_sprite;
guint8 loop_filter;
guint8 multires;
guint8 fastuvmc;
guint8 extended_mv;
guint8 dquant;
guint8 vstransform;
guint8 overlap;
guint8 syncmarker;
guint8 rangered;
guint8 maxbframes;
guint8 quantizer;
guint8 finterpflag;
/* Computed */
guint framerate; /* Around in fps, 0 if unknown*/
guint bitrate; /* Around in kpbs, 0 if unknown*/
/* This should be filled by user if previously known */
guint16 coded_width;
/* This should be filled by user if previously known */
guint16 coded_height;
/* Wmvp specific */
guint8 wmvp; /* Specify if the stream is wmp or not */
/* In the wmvp case, the framerate is not computed but in the bistream */
guint8 slice_code;
};
struct _GstVC1SeqLayer
{
guint32 numframes;
GstVC1SeqStructA struct_a;
GstVC1SeqStructB struct_b;
GstVC1SeqStructC struct_c;
};
/** /**
* GstVC1SeqHdr: * GstVC1SeqHdr:
* *
@ -259,22 +303,15 @@ struct _GstVC1AdvancedSeqHdr
*/ */
struct _GstVC1SeqHdr struct _GstVC1SeqHdr
{ {
guint8 profiletype; GstVC1Profile profile;
guint8 colordiff_format;
guint8 frmrtq_postproc; GstVC1SeqStructC struct_c;
guint8 bitrtq_postproc;
guint8 finterpflag;
/* calculated */ /* calculated */
guint framerate; /* Around in fps, 0 if unknown*/
guint bitrate; /* Around in kpbs, 0 if unknown*/
guint mb_height; guint mb_height;
guint mb_width; guint mb_width;
union {
GstVC1AdvancedSeqHdr advanced; GstVC1AdvancedSeqHdr advanced;
GstVC1SimpleMainSeqHdr simplemain;
} profile;
}; };
@ -466,6 +503,24 @@ GstVC1ParserResult gst_vc1_parse_entry_point_header (const guint8 *data,
GstVC1EntryPointHdr * entrypoint, GstVC1EntryPointHdr * entrypoint,
GstVC1SeqHdr *seqhdr); GstVC1SeqHdr *seqhdr);
GstVC1ParserResult gst_vc1_parse_sequence_layer (const guint8 *data,
gsize size,
GstVC1SeqLayer * seqlayer);
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_a (const guint8 *data,
gsize size,
GstVC1SeqStructA *structa);
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_b (const guint8 *data,
gsize size,
GstVC1SeqStructB *structb);
GstVC1ParserResult
gst_vc1_parse_sequence_header_struct_c (const guint8 *data,
gsize size,
GstVC1SeqStructC *structc);
GstVC1ParserResult gst_vc1_parse_frame_header (const guint8 *data, GstVC1ParserResult gst_vc1_parse_frame_header (const guint8 *data,
gsize size, gsize size,
GstVC1FrameHdr * framehdr, GstVC1FrameHdr * framehdr,

View file

@ -799,10 +799,10 @@ GST_START_TEST (test_vc1_identify_bdu)
res = gst_vc1_parse_sequence_header (bdu.data + bdu.offset, bdu.size, &hdr); res = gst_vc1_parse_sequence_header (bdu.data + bdu.offset, bdu.size, &hdr);
assert_equals_int (res, GST_VC1_PARSER_OK); assert_equals_int (res, GST_VC1_PARSER_OK);
assert_equals_int (hdr.profiletype, GST_VC1_PROFILE_ADVANCED); assert_equals_int (hdr.profile, GST_VC1_PROFILE_ADVANCED);
assert_equals_int (hdr.profile.advanced.level, GST_VC1_LEVEL_L1); assert_equals_int (hdr.advanced.level, GST_VC1_LEVEL_L1);
assert_equals_int (hdr.colordiff_format, 1); assert_equals_int (hdr.advanced.colordiff_format, 1);
res = gst_vc1_identify_next_bdu (sequence_fullframe + bdu.sc_offset + res = gst_vc1_identify_next_bdu (sequence_fullframe + bdu.sc_offset +
bdu.size, sizeof (sequence_fullframe) - bdu.sc_offset - bdu.size, &bdu); bdu.size, sizeof (sequence_fullframe) - bdu.sc_offset - bdu.size, &bdu);
@ -822,29 +822,29 @@ GST_START_TEST (test_vc1_parse_p_frame_header_main)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; GstVC1SeqStructC *structc = &seqhdr.struct_c;
GstVC1PicSimpleMain *pic = &framehdr.pic.simple; GstVC1PicSimpleMain *pic = &framehdr.pic.simple;
simplehdr->coded_height = 240; structc->coded_height = 240;
simplehdr->coded_width = 320; structc->coded_width = 320;
assert_equals_int (gst_vc1_parse_sequence_header (pframe_header_main, assert_equals_int (gst_vc1_parse_sequence_header (pframe_header_main,
sizeof (pframe_header_main), &seqhdr), GST_VC1_PARSER_OK); sizeof (pframe_header_main), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_MAIN);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (structc->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 2); assert_equals_int (structc->bitrtq_postproc, 2);
assert_equals_int (simplehdr->loop_filter, 1); assert_equals_int (structc->loop_filter, 1);
assert_equals_int (simplehdr->multires, 0); assert_equals_int (structc->multires, 0);
assert_equals_int (simplehdr->extended_mv, 0); assert_equals_int (structc->extended_mv, 0);
assert_equals_int (simplehdr->rangered, 0); assert_equals_int (structc->rangered, 0);
assert_equals_int (simplehdr->vstransform, 1); assert_equals_int (structc->vstransform, 1);
assert_equals_int (simplehdr->overlap, 1); assert_equals_int (structc->overlap, 1);
assert_equals_int (simplehdr->syncmarker, 0); assert_equals_int (structc->syncmarker, 0);
assert_equals_int (simplehdr->dquant, 1); assert_equals_int (structc->dquant, 1);
assert_equals_int (simplehdr->quantizer, 0); assert_equals_int (structc->quantizer, 0);
assert_equals_int (simplehdr->maxbframes, 1); assert_equals_int (structc->maxbframes, 1);
assert_equals_int (gst_vc1_parse_frame_header (pframe_main, assert_equals_int (gst_vc1_parse_frame_header (pframe_main,
sizeof (pframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); sizeof (pframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK);
@ -866,31 +866,31 @@ GST_START_TEST (test_vc1_parse_b_frame_header_main)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; GstVC1SeqStructC *structc = &seqhdr.struct_c;
GstVC1PicSimpleMain *pic = &framehdr.pic.simple; GstVC1PicSimpleMain *pic = &framehdr.pic.simple;
simplehdr->coded_height = 240; structc->coded_height = 240;
simplehdr->coded_width = 320; structc->coded_width = 320;
assert_equals_int (gst_vc1_parse_sequence_header (bframe_header_main, assert_equals_int (gst_vc1_parse_sequence_header (bframe_header_main,
sizeof (bframe_header_main), &seqhdr), GST_VC1_PARSER_OK); sizeof (bframe_header_main), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_MAIN);
assert_equals_int (seqhdr.mb_height, 15); assert_equals_int (seqhdr.mb_height, 15);
assert_equals_int (seqhdr.mb_width, 20); assert_equals_int (seqhdr.mb_width, 20);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (structc->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 3); assert_equals_int (structc->bitrtq_postproc, 3);
assert_equals_int (simplehdr->loop_filter, 1); assert_equals_int (structc->loop_filter, 1);
assert_equals_int (simplehdr->multires, 0); assert_equals_int (structc->multires, 0);
assert_equals_int (simplehdr->extended_mv, 0); assert_equals_int (structc->extended_mv, 0);
assert_equals_int (simplehdr->rangered, 0); assert_equals_int (structc->rangered, 0);
assert_equals_int (simplehdr->vstransform, 1); assert_equals_int (structc->vstransform, 1);
assert_equals_int (simplehdr->overlap, 1); assert_equals_int (structc->overlap, 1);
assert_equals_int (simplehdr->syncmarker, 0); assert_equals_int (structc->syncmarker, 0);
assert_equals_int (simplehdr->dquant, 1); assert_equals_int (structc->dquant, 1);
assert_equals_int (simplehdr->quantizer, 0); assert_equals_int (structc->quantizer, 0);
assert_equals_int (simplehdr->maxbframes, 1); assert_equals_int (structc->maxbframes, 1);
assert_equals_int (gst_vc1_parse_frame_header (bframe_main, assert_equals_int (gst_vc1_parse_frame_header (bframe_main,
sizeof (bframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); sizeof (bframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK);
@ -915,28 +915,28 @@ GST_START_TEST (test_vc1_parse_bi_frame_header_main)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; GstVC1SeqStructC *structc = &seqhdr.struct_c;
GstVC1PicSimpleMain *pic = &framehdr.pic.simple; GstVC1PicSimpleMain *pic = &framehdr.pic.simple;
simplehdr->coded_height = 240; structc->coded_height = 240;
simplehdr->coded_width = 320; structc->coded_width = 320;
assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header, assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header,
sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK); sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_MAIN);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (structc->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 7); assert_equals_int (structc->bitrtq_postproc, 7);
assert_equals_int (simplehdr->loop_filter, 1); assert_equals_int (structc->loop_filter, 1);
assert_equals_int (simplehdr->multires, 0); assert_equals_int (structc->multires, 0);
assert_equals_int (simplehdr->extended_mv, 0); assert_equals_int (structc->extended_mv, 0);
assert_equals_int (simplehdr->rangered, 0); assert_equals_int (structc->rangered, 0);
assert_equals_int (simplehdr->vstransform, 1); assert_equals_int (structc->vstransform, 1);
assert_equals_int (simplehdr->overlap, 1); assert_equals_int (structc->overlap, 1);
assert_equals_int (simplehdr->syncmarker, 0); assert_equals_int (structc->syncmarker, 0);
assert_equals_int (simplehdr->dquant, 1); assert_equals_int (structc->dquant, 1);
assert_equals_int (simplehdr->quantizer, 0); assert_equals_int (structc->quantizer, 0);
assert_equals_int (simplehdr->maxbframes, 1); assert_equals_int (structc->maxbframes, 1);
assert_equals_int (gst_vc1_parse_frame_header (biframe_main, assert_equals_int (gst_vc1_parse_frame_header (biframe_main,
sizeof (biframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); sizeof (biframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK);
@ -958,28 +958,28 @@ GST_START_TEST (test_vc1_parse_i_frame_header_main)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; GstVC1SeqStructC *structc = &seqhdr.struct_c;
GstVC1PicSimpleMain *pic = &framehdr.pic.simple; GstVC1PicSimpleMain *pic = &framehdr.pic.simple;
simplehdr->coded_height = 240; structc->coded_height = 240;
simplehdr->coded_width = 320; structc->coded_width = 320;
assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header, assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header,
sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK); sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_MAIN);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (structc->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 7); assert_equals_int (structc->bitrtq_postproc, 7);
assert_equals_int (simplehdr->loop_filter, 1); assert_equals_int (structc->loop_filter, 1);
assert_equals_int (simplehdr->multires, 0); assert_equals_int (structc->multires, 0);
assert_equals_int (simplehdr->extended_mv, 0); assert_equals_int (structc->extended_mv, 0);
assert_equals_int (simplehdr->rangered, 0); assert_equals_int (structc->rangered, 0);
assert_equals_int (simplehdr->vstransform, 1); assert_equals_int (structc->vstransform, 1);
assert_equals_int (simplehdr->overlap, 1); assert_equals_int (structc->overlap, 1);
assert_equals_int (simplehdr->syncmarker, 0); assert_equals_int (structc->syncmarker, 0);
assert_equals_int (simplehdr->dquant, 1); assert_equals_int (structc->dquant, 1);
assert_equals_int (simplehdr->quantizer, 0); assert_equals_int (structc->quantizer, 0);
assert_equals_int (simplehdr->maxbframes, 1); assert_equals_int (structc->maxbframes, 1);
assert_equals_int (gst_vc1_parse_frame_header (iframe_main, assert_equals_int (gst_vc1_parse_frame_header (iframe_main,
sizeof (iframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); sizeof (iframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK);
@ -1001,23 +1001,23 @@ GST_START_TEST (test_vc1_parse_i_frame_header_adv)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; GstVC1AdvancedSeqHdr *advhdr = &seqhdr.advanced;
GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint;
GstVC1PicAdvanced *pic = &framehdr.pic.advanced; GstVC1PicAdvanced *pic = &framehdr.pic.advanced;
assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr,
sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_ADVANCED);
assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (advhdr->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 31); assert_equals_int (advhdr->bitrtq_postproc, 31);
assert_equals_int (advhdr->postprocflag, 0); assert_equals_int (advhdr->postprocflag, 0);
assert_equals_int (advhdr->max_coded_width, 1920); assert_equals_int (advhdr->max_coded_width, 1920);
assert_equals_int (advhdr->max_coded_height, 1080); assert_equals_int (advhdr->max_coded_height, 1080);
assert_equals_int (advhdr->interlace, 1); assert_equals_int (advhdr->interlace, 1);
assert_equals_int (advhdr->tfcntrflag, 0); assert_equals_int (advhdr->tfcntrflag, 0);
assert_equals_int (seqhdr.finterpflag, 0); assert_equals_int (advhdr->finterpflag, 0);
assert_equals_int (advhdr->display_ext, 1); assert_equals_int (advhdr->display_ext, 1);
assert_equals_int (advhdr->disp_horiz_size, 1920); assert_equals_int (advhdr->disp_horiz_size, 1920);
@ -1062,23 +1062,23 @@ GST_START_TEST (test_vc1_parse_b_frame_header_adv)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; GstVC1AdvancedSeqHdr *advhdr = &seqhdr.advanced;
GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint;
GstVC1PicAdvanced *pic = &framehdr.pic.advanced; GstVC1PicAdvanced *pic = &framehdr.pic.advanced;
assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr,
sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_ADVANCED);
assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (advhdr->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 31); assert_equals_int (advhdr->bitrtq_postproc, 31);
assert_equals_int (advhdr->postprocflag, 0); assert_equals_int (advhdr->postprocflag, 0);
assert_equals_int (advhdr->max_coded_width, 1920); assert_equals_int (advhdr->max_coded_width, 1920);
assert_equals_int (advhdr->max_coded_height, 1080); assert_equals_int (advhdr->max_coded_height, 1080);
assert_equals_int (advhdr->interlace, 1); assert_equals_int (advhdr->interlace, 1);
assert_equals_int (advhdr->tfcntrflag, 0); assert_equals_int (advhdr->tfcntrflag, 0);
assert_equals_int (seqhdr.finterpflag, 0); assert_equals_int (advhdr->finterpflag, 0);
assert_equals_int (advhdr->display_ext, 1); assert_equals_int (advhdr->display_ext, 1);
assert_equals_int (advhdr->disp_horiz_size, 1920); assert_equals_int (advhdr->disp_horiz_size, 1920);
@ -1132,23 +1132,23 @@ GST_START_TEST (test_vc1_parse_p_frame_header_adv)
GstVC1FrameHdr framehdr; GstVC1FrameHdr framehdr;
GstVC1SeqHdr seqhdr; GstVC1SeqHdr seqhdr;
GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; GstVC1AdvancedSeqHdr *advhdr = &seqhdr.advanced;
GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint;
GstVC1PicAdvanced *pic = &framehdr.pic.advanced; GstVC1PicAdvanced *pic = &framehdr.pic.advanced;
assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr,
sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK);
assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); assert_equals_int (seqhdr.profile, GST_VC1_PROFILE_ADVANCED);
assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3);
assert_equals_int (seqhdr.frmrtq_postproc, 7); assert_equals_int (advhdr->frmrtq_postproc, 7);
assert_equals_int (seqhdr.bitrtq_postproc, 31); assert_equals_int (advhdr->bitrtq_postproc, 31);
assert_equals_int (advhdr->postprocflag, 0); assert_equals_int (advhdr->postprocflag, 0);
assert_equals_int (advhdr->max_coded_width, 1920); assert_equals_int (advhdr->max_coded_width, 1920);
assert_equals_int (advhdr->max_coded_height, 1080); assert_equals_int (advhdr->max_coded_height, 1080);
assert_equals_int (advhdr->interlace, 1); assert_equals_int (advhdr->interlace, 1);
assert_equals_int (advhdr->tfcntrflag, 0); assert_equals_int (advhdr->tfcntrflag, 0);
assert_equals_int (seqhdr.finterpflag, 0); assert_equals_int (advhdr->finterpflag, 0);
assert_equals_int (advhdr->display_ext, 1); assert_equals_int (advhdr->display_ext, 1);
assert_equals_int (advhdr->disp_horiz_size, 1920); assert_equals_int (advhdr->disp_horiz_size, 1920);