From 705a80d957fe8ebb703c465068b034798b9b0d8c Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 23 Aug 2011 18:25:20 -0300 Subject: [PATCH] codecparser: VC1: Implement a VC1 parsing library --- docs/libs/gst-plugins-bad-libs-docs.sgml | 1 + docs/libs/gst-plugins-bad-libs-sections.txt | 34 + gst-libs/gst/codecparsers/Makefile.am | 20 +- gst-libs/gst/codecparsers/gstvc1parser.c | 1442 +++++++++++++++++++++++++++ gst-libs/gst/codecparsers/gstvc1parser.h | 468 +++++++++ tests/check/Makefile.am | 11 + tests/check/libs/vc1parser.c | 1230 +++++++++++++++++++++++ 7 files changed, 3201 insertions(+), 5 deletions(-) create mode 100644 gst-libs/gst/codecparsers/gstvc1parser.c create mode 100644 gst-libs/gst/codecparsers/gstvc1parser.h create mode 100644 tests/check/libs/vc1parser.c diff --git a/docs/libs/gst-plugins-bad-libs-docs.sgml b/docs/libs/gst-plugins-bad-libs-docs.sgml index f137ca3..bc64884 100644 --- a/docs/libs/gst-plugins-bad-libs-docs.sgml +++ b/docs/libs/gst-plugins-bad-libs-docs.sgml @@ -30,6 +30,7 @@ + diff --git a/docs/libs/gst-plugins-bad-libs-sections.txt b/docs/libs/gst-plugins-bad-libs-sections.txt index 73cc720..cd515e6 100644 --- a/docs/libs/gst-plugins-bad-libs-sections.txt +++ b/docs/libs/gst-plugins-bad-libs-sections.txt @@ -45,6 +45,40 @@ gst_h264_parse_pps
+gstvc1parser +vc1parser +gst/codecparsers/gstvc1parser.h +MAX_HRD_NUM_LEAKY_BUCKETS +GST_VC1_BFRACTION_BASIS +GstVC1StartCode +GstVC1Profile +GstVC1ParseResult +GstVC1PictureType +GstVC1Level +GstVC1QuantizerSpec +GstVC1DQProfile +GstVC1Condover +GstVC1MvMode +GstVC1SeqHdr +GstVC1AdvancedSeqHdr +GstVC1SimpleMainSeqHdr +GstVC1HrdParam +GstVC1EntryPointHdr +GstVC1FrameHdr +GstVC1PicAdvanced +GstVC1PicSimpleMain +GstVC1Picture +GstVC1VopDquant +GstVC1BDU +gst_vc1_identify_next_bdu +gst_vc1_parse_sequence_header +gst_vc1_parse_entry_point_header +gst_vc1_parse_frame_header + + +
+ +
gstmpegvideoparser mpegvideoparser gst/codecparsers/gstmpegvideoparser.h diff --git a/gst-libs/gst/codecparsers/Makefile.am b/gst-libs/gst/codecparsers/Makefile.am index 7fa44f1..c3dfe93 100644 --- a/gst-libs/gst/codecparsers/Makefile.am +++ b/gst-libs/gst/codecparsers/Makefile.am @@ -1,17 +1,27 @@ lib_LTLIBRARIES = libgstcodecparsers-@GST_MAJORMINOR@.la libgstcodecparsers_@GST_MAJORMINOR@_la_SOURCES = \ - gstmpegvideoparser.c gsth264parser.c + gstmpegvideoparser.c gsth264parser.c gstvc1parser.c libgstcodecparsers_@GST_MAJORMINOR@includedir = \ $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/codecparsers libgstcodecparsers_@GST_MAJORMINOR@include_HEADERS = \ - gstmpegvideoparser.h gsth264parser.h + gstmpegvideoparser.h gsth264parser.h gstvc1parser.h -libgstcodecparsers_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) -libgstcodecparsers_@GST_MAJORMINOR@_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) -libgstcodecparsers_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS) +libgstcodecparsers_@GST_MAJORMINOR@_la_CFLAGS = \ + $(GST_PLUGINS_BAD_CFLAGS) \ + -DGST_USE_UNSTABLE_API \ + $(GST_CFLAGS) + +libgstcodecparsers_@GST_MAJORMINOR@_la_LIBADD = \ + $(GST_BASE_LIBS) \ + $(GST_LIBS) + +libgstcodecparsers_@GST_MAJORMINOR@_la_LDFLAGS = \ + $(GST_LIB_LDFLAGS) \ + $(GST_ALL_LDFLAGS) \ + $(GST_LT_LDFLAGS) Android.mk: $(BUILT_SOURCES) Makefile.am androgenizer -:PROJECT libgstcodecparsers -:STATIC libgstcodecparsers-@GST_MAJORMINOR@ \ diff --git a/gst-libs/gst/codecparsers/gstvc1parser.c b/gst-libs/gst/codecparsers/gstvc1parser.c new file mode 100644 index 0000000..8b0b785 --- /dev/null +++ b/gst-libs/gst/codecparsers/gstvc1parser.c @@ -0,0 +1,1442 @@ +/* Gstreamer + * Copyright (C) <2011> Intel + * Copyright (C) <2011> Collabora Ltd. + * Copyright (C) <2011> Thibault Saunier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +/** + * SECTION:gstvc1parser + * @short_description: Convenience library for parsing vc1 video + * bitstream. + * + * For more details about the structures, look at the + * smpte specifications (S421m-2006.pdf). + * + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "gstvc1parser.h" +#include +#include +#include + +#ifndef GST_DISABLE_GST_DEBUG + +#define GST_CAT_DEFAULT ensure_debug_category() + +static GstDebugCategory * +ensure_debug_category (void) +{ + static gsize cat_gonce = 0; + + if (g_once_init_enter (&cat_gonce)) { + gsize cat_done; + + cat_done = (gsize) _gst_debug_category_new ("codecparsers_vc1", 0, + "VC1 codec parsing library"); + + g_once_init_leave (&cat_gonce, cat_done); + } + + return (GstDebugCategory *) cat_gonce; +} + +#else + +#define ensure_debug_category() /* NOOP */ + +#endif /* GST_DISABLE_GST_DEBUG */ + +/* ------------------------------------------------------------------------- */ + +#define GET_BITS(b, num, bits) G_STMT_START { \ + if (!gst_bit_reader_get_bits_uint32(b, bits, num)) \ + goto failed; \ + GST_TRACE ("parsed %d bits: %d", num, *(bits)); \ +} G_STMT_END + +#define READ_UINT8(br, val, nbits) G_STMT_START { \ + if (!gst_bit_reader_get_bits_uint8 (br, &val, nbits)) { \ + GST_WARNING ("failed to read uint8, nbits: %d", nbits); \ + goto failed; \ + } \ +} G_STMT_END + +#define READ_UINT16(br, val, nbits) G_STMT_START { \ + if (!gst_bit_reader_get_bits_uint16 (br, &val, nbits)) { \ + GST_WARNING ("failed to read uint16, nbits: %d", nbits); \ + goto failed; \ + } \ +} G_STMT_END + +#define READ_UINT32(br, val, nbits) G_STMT_START { \ + if (!gst_bit_reader_get_bits_uint32 (br, &val, nbits)) { \ + GST_WARNING ("failed to read uint32, nbits: %d", nbits); \ + goto failed; \ + } \ +} G_STMT_END + +#define SKIP(br, nbits) G_STMT_START { \ + if (!gst_bit_reader_skip (br, nbits)) { \ + GST_WARNING ("Failed to skip nbits: %d", nbits); \ + goto failed; \ + } \ +} G_STMT_END + +const guint8 vc1_pquant_table[3][32] = { + { /* Implicit quantizer */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31}, + { /* Explicit quantizer, pquantizer uniform */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}, + { /* Explicit quantizer, pquantizer non-uniform */ + 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31} +}; + +const guint8 mvmode_table[2][5] = { + { + GST_VC1_MVMODE_1MV_HPEL_BILINEAR, + GST_VC1_MVMODE_1MV, + GST_VC1_MVMODE_1MV_HPEL, + GST_VC1_MVMODE_MIXED_MV, + GST_VC1_MVMODE_INTENSITY_COMP}, + { + GST_VC1_MVMODE_1MV, + GST_VC1_MVMODE_MIXED_MV, + GST_VC1_MVMODE_1MV_HPEL, + GST_VC1_MVMODE_INTENSITY_COMP, + GST_VC1_MVMODE_1MV_HPEL_BILINEAR} +}; + +const guint8 mvmode2_table[2][4] = { + { + GST_VC1_MVMODE_1MV_HPEL_BILINEAR, + GST_VC1_MVMODE_1MV, + GST_VC1_MVMODE_1MV_HPEL, + GST_VC1_MVMODE_MIXED_MV}, + { + GST_VC1_MVMODE_1MV, + GST_VC1_MVMODE_MIXED_MV, + GST_VC1_MVMODE_1MV_HPEL, + GST_VC1_MVMODE_1MV_HPEL_BILINEAR} +}; + +static const guint bfraction_vlc_table[] = { + 0x00, 3, 128, + 0x01, 3, 85, + 0x02, 3, 170, + 0x03, 3, 64, + 0x04, 3, 192, + 0x05, 3, 51, + 0x06, 3, 102, + 0x70, 3, 153, + 0x71, 7, 204, + 0x72, 7, 43, + 0x73, 7, 215, + 0x74, 7, 37, + 0x75, 7, 74, + 0x76, 7, 111, + 0x77, 7, 148, + 0x78, 7, 185, + 0x79, 7, 222, + 0x7a, 7, 32, + 0x7b, 7, 96, + 0x7c, 7, 160, + 0x7d, 7, 224, + 0x7e, 7, 0, /* Indicate sthat it is smtpe reserved */ + 0x7f, 7, GST_VC1_PICTURE_TYPE_BI +}; + +/* Imode types */ +enum +{ + IMODE_RAW, + IMODE_NORM2, + IMODE_DIFF2, + IMODE_NORM6, + IMODE_DIFF6, + IMODE_ROWSKIP, + IMODE_COLSKIP +}; + +static const guint imode_vlc_table[] = { + 0x02, 2, IMODE_NORM2, /* 10 */ + 0x03, 2, IMODE_NORM6, /* 11 */ + 0x02, 3, IMODE_ROWSKIP, /* 010 */ + 0x03, 3, IMODE_COLSKIP, /* 011 */ + 0x01, 3, IMODE_DIFF2, /* 001 */ + 0x01, 4, IMODE_DIFF6, /* 0001 */ + 0x00, 4, IMODE_RAW /* 0000 */ +}; + +const guint vc1_norm2_codes_vlc_table[] = { + 0x00, 1, 1, + 0x03, 2, 3, + 0x04, 3, 3, + 0x05, 3, 2 +}; + +const guint norm6_vlc_table[256] = { + 0x001, 1, 0, + 0x002, 4, 0, + 0x003, 4, 0, + 0x004, 4, 0, + 0x005, 4, 0, + 0x006, 4, 0, + 0x007, 4, 0, + 0x007, 6, 0, + 0x000, 8, 0, + 0x001, 8, 0, + 0x002, 8, 0, + 0x003, 8, 0, + 0x004, 8, 0, + 0x005, 8, 0, + 0x006, 8, 0, + 0x007, 8, 0, + 0x008, 8, 0, + 0x009, 8, 0, + 0x00A, 8, 0, + 0x00B, 8, 0, + 0x00C, 8, 0, + 0x00D, 8, 0, + 0x00E, 8, 0, + 0x037, 9, 0, + 0x036, 9, 0, + 0x035, 9, 0, + 0x034, 9, 0, + 0x033, 9, 0, + 0x032, 9, 0, + 0x047, 10, 0, + 0x04B, 10, 0, + 0x04D, 10, 0, + 0x04E, 10, 0, + 0x30E, 13, 0, + 0x053, 10, 0, + 0x055, 10, 0, + 0x056, 10, 0, + 0x30D, 13, 0, + 0x059, 10, 0, + 0x05A, 10, 0, + 0x30C, 13, 0, + 0x05C, 10, 0, + 0x30B, 13, 0, + 0x30A, 13, 0, + 0x043, 10, 0, + 0x045, 10, 0, + 0x046, 10, 0, + 0x309, 13, 0, + 0x049, 10, 0, + 0x04A, 10, 0, + 0x308, 13, 0, + 0x04C, 10, 0, + 0x307, 13, 0, + 0x306, 13, 0, + 0x051, 10, 0, + 0x052, 10, 0, + 0x305, 13, 0, + 0x054, 10, 0, + 0x304, 13, 0, + 0x303, 13, 0, + 0x058, 10, 0, + 0x302, 13, 0, + 0x301, 13, 0, + 0x300, 13, 0 +}; + +static inline guint8 +decode_colskip (GstBitReader * br, guint width, guint height) +{ + guint i; + guint8 colskip; + + GST_DEBUG ("Colskip rowskip"); + + for (i = 0; i < height; i++) { + READ_UINT8 (br, colskip, 1); + + if (colskip) + SKIP (br, width); + } + + return 1; + +failed: + GST_WARNING ("Failed to parse colskip"); + + return 0; +} + +static inline guint8 +decode_rowskip (GstBitReader * br, guint width, guint height) +{ + guint i; + guint8 rowskip; + + GST_DEBUG ("Parsing rowskip"); + + for (i = 0; i < height; i++) { + READ_UINT8 (br, rowskip, 1); + + if (rowskip) + SKIP (br, width); + } + return 1; + +failed: + GST_WARNING ("Failed to parse rowskip"); + + return 0; +} + +static inline gint8 +decode012 (GstBitReader * br) +{ + guint8 n; + + READ_UINT8 (br, n, 1); + + if (n == 0) + return 0; + + READ_UINT8 (br, n, 1); + + return n + 1; + +failed: + GST_WARNING ("Could not decode 0 1 2 returning -1"); + + return -1; +} + +static inline guint +calculate_nb_pan_scan_win (GstVC1AdvancedSeqHdr * advseqhdr, + GstVC1PicAdvanced * pic) +{ + if (advseqhdr->interlace && !advseqhdr->psf) { + if (advseqhdr->pulldown) + return pic->rff + 2; + + return 2; + + } else { + if (advseqhdr->pulldown) + return pic->rptfrm + 1; + + return 1; + } +} + + +/** + * table should look like: + * {Value, nbBits, Meaning, + * ... + * } nbBits must be increasing + */ +static gboolean +decode_vlc (GstBitReader * br, guint * res, const guint * table, guint length) +{ + guint8 i; + guint cbits = 0; + guint32 value = 0; + + for (i = 0; i < length; i += 3) { + if (cbits != table[i + 1]) { + cbits = table[i + 1]; + if (!gst_bit_reader_peek_bits_uint32 (br, &value, cbits)) { + goto failed; + } + } + + if (value == table[i]) { + SKIP (br, cbits); + if (res) + *res = table[i + 2]; + + return TRUE; + } + } + +failed: + { + GST_DEBUG ("Could not decode VLC returning -1"); + + return FALSE; + } +} + +/*** bitplane decoding ***/ +static gint +bitplane_decoding (GstBitReader * br, guint height, + guint width, guint8 * is_raw) +{ + guint imode; + guint i, j, offset = 0; + + SKIP (br, 1); + if (!decode_vlc (br, &imode, imode_vlc_table, G_N_ELEMENTS (imode_vlc_table))) + goto failed; + + switch (imode) { + case IMODE_RAW: + + GST_DEBUG ("Parsing IMODE_RAW"); + + *is_raw = TRUE; + return TRUE; + + case IMODE_DIFF2: + case IMODE_NORM2: + + GST_DEBUG ("Parsing IMODE_DIFF2 or IMODE_NORM2 biplane"); + + if ((height * width) & 1) { + SKIP (br, 1); + } + + for (i = offset; i < height * width; i += 2) { + /*guint x; */ + if (!decode_vlc (br, NULL, vc1_norm2_codes_vlc_table, + G_N_ELEMENTS (vc1_norm2_codes_vlc_table))) { + goto failed; + } + } + break; + + case IMODE_DIFF6: + case IMODE_NORM6: + + GST_DEBUG ("Parsing IMODE_DIFF6 or IMODE_NORM6 biplane"); + + if (!(height % 3) && (width % 3)) { // use 2x3 decoding + + for (i = 0; i < height; i += 3) { + for (j = width & 1; j < width; j += 2) { + if (!decode_vlc (br, NULL, norm6_vlc_table, + G_N_ELEMENTS (norm6_vlc_table))) { + goto failed; + } + } + } + } else { + for (i = height & 1; i < height; i += 2) { + for (j = width % 3; j < width; j += 3) { + if (!decode_vlc (br, NULL, norm6_vlc_table, + G_N_ELEMENTS (norm6_vlc_table))) { + goto failed; + } + } + } + + j = width % 3; + if (j) + decode_colskip (br, height, width); + + if (height & 1) + decode_rowskip (br, height, width); + } + break; + case IMODE_ROWSKIP: + + GST_DEBUG ("Parsing IMODE_ROWSKIP biplane"); + + if (!decode_rowskip (br, width, height)) + goto failed; + break; + case IMODE_COLSKIP: + + GST_DEBUG ("Parsing IMODE_COLSKIP biplane"); + + if (decode_colskip (br, width, height)) + goto failed; + break; + } + + return TRUE; + +failed: + GST_WARNING ("Failed to decode bitplane"); + + return FALSE; +} + +static gboolean +parse_vopdquant (GstBitReader * br, GstVC1FrameHdr * framehdr, guint8 dquant) +{ + GstVC1VopDquant *vopdquant = &framehdr->vopdquant; + + GST_DEBUG ("Parsing vopdquant"); + + vopdquant->dqbilevel = 0; + + if (dquant == 2) { + READ_UINT8 (br, vopdquant->dquantfrm, 1); + + READ_UINT8 (br, vopdquant->pqdiff, 3); + + if (vopdquant->pqdiff == 7) + READ_UINT8 (br, vopdquant->abspq, 5); + else + vopdquant->abspq = framehdr->pquant + vopdquant->pqdiff + 1; + + } else { + READ_UINT8 (br, vopdquant->dquantfrm, 1); + GST_DEBUG (" %u DquantFrm %u", gst_bit_reader_get_pos (br), + vopdquant->dquantfrm); + + if (vopdquant->dquantfrm) { + READ_UINT8 (br, vopdquant->dqprofile, 1); + + switch (vopdquant->dqprofile) { + case GST_VC1_DQPROFILE_SINGLE_EDGE: + case GST_VC1_DQPROFILE_DOUBLE_EDGES: + READ_UINT8 (br, vopdquant->dqsbedge, 2); + break; + + case GST_VC1_DQPROFILE_ALL_MBS: + READ_UINT8 (br, vopdquant->dqbilevel, 1); + break; + } + + if (vopdquant->dqbilevel + || vopdquant->dqprofile != GST_VC1_DQPROFILE_ALL_MBS) { + { + READ_UINT8 (br, vopdquant->pqdiff, 3); + + if (vopdquant->pqdiff == 7) + READ_UINT8 (br, vopdquant->abspq, 5); + } + } + } + } + + return TRUE; + +failed: + GST_WARNING ("Failed to parse vopdquant"); + + return FALSE; +} + +static inline gint +scan_for_start_codes (const guint8 * data, guint size) +{ + GstByteReader br; + gst_byte_reader_init (&br, data, size); + + /* NALU not empty, so we can at least expect 1 (even 2) bytes following sc */ + return gst_byte_reader_masked_scan_uint32 (&br, 0xffffff00, 0x00000100, + 0, size); +} + +static inline gint +get_unary (GstBitReader * br, gint stop, gint len) +{ + int i; + guint8 current = 0xff; + + for (i = 0; i < len; i++) { + gst_bit_reader_get_bits_uint8 (br, ¤t, 1); + if (current == stop) + return i; + } + + return i; +} + +static GstVC1ParseResult +parse_hrd_param_flag (GstBitReader * br, GstVC1HrdParam * hrd_param) +{ + guint i; + + GST_DEBUG ("Parsing Hrd param flag"); + + + if (gst_bit_reader_get_remaining (br) < 13) + goto failed; + + hrd_param->hrd_num_leaky_buckets = + gst_bit_reader_get_bits_uint8_unchecked (br, 5); + hrd_param->bit_rate_exponent = + gst_bit_reader_get_bits_uint8_unchecked (br, 4); + hrd_param->buffer_size_exponent = + gst_bit_reader_get_bits_uint8_unchecked (br, 4); + + if (gst_bit_reader_get_remaining (br) < + (32 * hrd_param->hrd_num_leaky_buckets)) + goto failed; + + for (i = 0; i < hrd_param->hrd_num_leaky_buckets; i++) { + hrd_param->hrd_rate[i] = gst_bit_reader_get_bits_uint16_unchecked (br, 16); + hrd_param->hrd_buffer[i] = + gst_bit_reader_get_bits_uint16_unchecked (br, 16); + } + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse hrd param flag"); + + return GST_VC1_PARSER_ERROR; +} + +static GstVC1ParseResult +parse_sequence_header_advanced (GstVC1SeqHdr * seqhdr, GstBitReader * br) +{ + GstVC1AdvancedSeqHdr *advanced = &seqhdr->profile.advanced; + + GST_DEBUG ("Parsing sequence header in advanced mode"); + + READ_UINT8 (br, advanced->level, 3); + + READ_UINT8 (br, seqhdr->colordiff_format, 2); + READ_UINT8 (br, seqhdr->frmrtq_postproc, 3); + READ_UINT8 (br, seqhdr->bitrtq_postproc, 5); + + GST_DEBUG ("level %u, colordiff_format %u , frmrtq_postproc %u," + " bitrtq_postproc %u", advanced->level, seqhdr->colordiff_format, + seqhdr->frmrtq_postproc, seqhdr->bitrtq_postproc); + + /* Calulate bitrate and framerate */ + if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 30) { + seqhdr->framerate = 0; + seqhdr->bitrate = 0; + } else if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 30) { + seqhdr->framerate = 2; + seqhdr->bitrate = 1952; + } else if (seqhdr->frmrtq_postproc == 0 && seqhdr->bitrtq_postproc == 31) { + seqhdr->framerate = 6; + seqhdr->bitrate = 2016; + } else { + if (seqhdr->frmrtq_postproc == 7) { + seqhdr->framerate = 30; + } else { + seqhdr->framerate = 2 + (seqhdr->frmrtq_postproc * 4); + } + if (seqhdr->bitrtq_postproc == 31) { + seqhdr->bitrate = 2016; + } else { + seqhdr->bitrate = 32 + (seqhdr->bitrtq_postproc * 64); + } + } + + if (gst_bit_reader_get_remaining (br) < 32) + goto failed; + + advanced->postprocflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1); + advanced->max_coded_width = gst_bit_reader_get_bits_uint16_unchecked (br, 12); + advanced->max_coded_height = + gst_bit_reader_get_bits_uint16_unchecked (br, 12); + advanced->max_coded_width = (advanced->max_coded_width + 1) << 1; + advanced->max_coded_height = (advanced->max_coded_height + 1) << 1; + advanced->pulldown = 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); + seqhdr->finterpflag = gst_bit_reader_get_bits_uint8_unchecked (br, 1); + + GST_DEBUG ("postprocflag %u, max_coded_width %u, max_coded_height %u," + "pulldown %u, interlace %u, tfcntrflag %u, finterpflag %u", + advanced->postprocflag, advanced->max_coded_width, + advanced->max_coded_height, advanced->pulldown, + advanced->interlace, advanced->tfcntrflag, seqhdr->finterpflag); + + /* Skipping reserved bit */ + gst_bit_reader_skip_unchecked (br, 1); + + advanced->psf = gst_bit_reader_get_bits_uint8_unchecked (br, 1); + advanced->display_ext = gst_bit_reader_get_bits_uint8_unchecked (br, 1); + if (advanced->display_ext) { + READ_UINT16 (br, advanced->disp_horiz_size, 14); + READ_UINT16 (br, advanced->disp_vert_size, 14); + + advanced->disp_horiz_size++; + advanced->disp_vert_size++; + + READ_UINT8 (br, advanced->aspect_ratio_flag, 1); + + if (advanced->aspect_ratio_flag) { + READ_UINT8 (br, advanced->aspect_ratio, 4); + + if (advanced->aspect_ratio == 15) { + READ_UINT8 (br, advanced->aspect_horiz_size, 8); + READ_UINT8 (br, advanced->aspect_vert_size, 8); + } + } + READ_UINT8 (br, advanced->framerate_flag, 1); + if (advanced->framerate_flag) { + READ_UINT8 (br, advanced->framerateind, 1); + + if (!advanced->framerateind) { + READ_UINT8 (br, advanced->frameratenr, 8); + READ_UINT8 (br, advanced->frameratedr, 4); + } else { + READ_UINT16 (br, advanced->framerateexp, 16); + } + } + READ_UINT8 (br, advanced->color_format_flag, 1); + + if (advanced->color_format_flag) { + if (gst_bit_reader_get_remaining (br) < 24) + goto failed; + + advanced->color_prim = gst_bit_reader_get_bits_uint8_unchecked (br, 8); + advanced->transfer_char = gst_bit_reader_get_bits_uint8_unchecked (br, 8); + advanced->matrix_coef = gst_bit_reader_get_bits_uint8_unchecked (br, 8); + } + } + READ_UINT8 (br, advanced->hrd_param_flag, 1); + if (advanced->hrd_param_flag) + return parse_hrd_param_flag (br, &advanced->hrd_param); + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse advanced headers"); + + return GST_VC1_PARSER_ERROR; +} + +static GstVC1ParseResult +parse_frame_header_advanced (GstBitReader * br, GstVC1FrameHdr * framehdr, + GstVC1SeqHdr * seqhdr) +{ + GstVC1AdvancedSeqHdr *advhdr = &seqhdr->profile.advanced; + GstVC1PicAdvanced *pic = &framehdr->pic.advanced; + GstVC1EntryPointHdr *entrypthdr = &advhdr->entrypoint; + guint8 mvmodeidx; + guint width = (entrypthdr->coded_width + 15) >> 4; + guint height = (entrypthdr->coded_height + 15) >> 4; + + GST_DEBUG ("Parsing Frame header advanced %u", advhdr->interlace); + + /* Set the conveninence fields */ + framehdr->profile = seqhdr->profiletype; + framehdr->dquant = entrypthdr->dquant; + + if (advhdr->interlace) { + gint8 fcm = decode012 (br); + + if (fcm < 0) + goto failed; + + pic->fcm = (guint8) fcm; + } + + framehdr->ptype = get_unary (br, 0, 4); + + if (framehdr->ptype == GST_VC1_PICTURE_TYPE_SKIPPED) + goto failed; + + if (advhdr->tfcntrflag) { + READ_UINT8 (br, pic->tfcntr, 8); + GST_DEBUG ("tfcntr %u", pic->tfcntr); + } + + if (advhdr->pulldown) { + if (!advhdr->interlace || advhdr->psf) { + + READ_UINT8 (br, pic->rptfrm, 2); + GST_DEBUG ("rptfrm %u", pic->rptfrm); + + } else { + + READ_UINT8 (br, pic->tff, 1); + READ_UINT8 (br, pic->rff, 1); + GST_DEBUG ("tff %u, rff %u", pic->tff, pic->rff); + } + } + + if (entrypthdr->panscan_flag) { + READ_UINT8 (br, pic->ps_present, 1); + + if (pic->ps_present) { + guint i, nb_pan_scan_win = calculate_nb_pan_scan_win (advhdr, pic); + + if (gst_bit_reader_get_remaining (br) < 64 * nb_pan_scan_win) + goto failed; + + for (i = 0; i < nb_pan_scan_win; i++) { + pic->ps_hoffset = gst_bit_reader_get_bits_uint32_unchecked (br, 18); + pic->ps_voffset = gst_bit_reader_get_bits_uint32_unchecked (br, 18); + pic->ps_width = gst_bit_reader_get_bits_uint16_unchecked (br, 14); + pic->ps_height = gst_bit_reader_get_bits_uint16_unchecked (br, 14); + } + } + } + + READ_UINT8 (br, pic->rndctrl, 1); + + if (advhdr->interlace) { + READ_UINT8 (br, pic->uvsamp, 1); + GST_DEBUG ("uvsamp %u", pic->uvsamp); + } + + if (seqhdr->finterpflag) { + READ_UINT8 (br, framehdr->interpfrm, 1); + GST_DEBUG ("interpfrm %u", framehdr->interpfrm); + } + + if (framehdr->ptype == GST_VC1_PICTURE_TYPE_B) { + if (!decode_vlc (br, (guint *) & pic->bfraction, bfraction_vlc_table, + G_N_ELEMENTS (bfraction_vlc_table))) + goto failed; + + GST_DEBUG ("bfraction %u", pic->bfraction); + + if (pic->bfraction == GST_VC1_PICTURE_TYPE_BI) { + framehdr->ptype = GST_VC1_PICTURE_TYPE_BI; + } + + } + + READ_UINT8 (br, framehdr->pqindex, 5); + if (!framehdr->pqindex) + goto failed; + + /* compute pquant */ + if (entrypthdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) + framehdr->pquant = vc1_pquant_table[0][framehdr->pqindex]; + else + framehdr->pquant = vc1_pquant_table[1][framehdr->pqindex]; + + framehdr->pquantizer = 1; + if (entrypthdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) + framehdr->pquantizer = framehdr->pqindex < 9; + if (entrypthdr->quantizer == GST_VC1_QUANTIZER_NON_UNIFORM) + framehdr->pquantizer = 0; + + if (framehdr->pqindex <= 8) + READ_UINT8 (br, framehdr->halfqp, 1); + else + framehdr->halfqp = 0; + + if (entrypthdr->quantizer == GST_VC1_QUANTIZER_EXPLICITLY) { + READ_UINT8 (br, framehdr->pquantizer, 1); + } + + if (advhdr->postprocflag) + READ_UINT8 (br, pic->postproc, 2); + + GST_DEBUG ("Parsing %u picture, pqindex %u, pquant %u pquantizer %u" + "halfqp %u", framehdr->ptype, framehdr->pqindex, framehdr->pquant, + framehdr->pquantizer, framehdr->halfqp); + + switch (framehdr->ptype) { + case GST_VC1_PICTURE_TYPE_I: + case GST_VC1_PICTURE_TYPE_BI: + if (!bitplane_decoding (br, height, width, &pic->acpred)) + goto failed; + + if (entrypthdr->overlap && framehdr->pquant <= 8) { + pic->condover = decode012 (br); + + if (pic->condover == (guint8) - 1) + goto failed; + + else if (pic->condover == GST_VC1_CONDOVER_SELECT) { + + if (!bitplane_decoding (br, height, width, &pic->overflags)) + goto failed; + GST_DEBUG ("overflags %u", pic->overflags); + } + } + + framehdr->transacfrm = get_unary (br, 0, 2); + pic->transacfrm2 = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + if (framehdr->dquant) + parse_vopdquant (br, framehdr, framehdr->dquant); + + GST_DEBUG ("acpred %u, condover %u transacfrm %u transacfrm2 %u,", + pic->acpred, pic->condover, framehdr->transacfrm, pic->transacfrm2); + break; + + case GST_VC1_PICTURE_TYPE_B: + if (entrypthdr->extended_mv) + pic->mvrange = get_unary (br, 0, 3); + else + pic->mvrange = 0; + + READ_UINT8 (br, pic->mvmode, 1); + + if (!bitplane_decoding (br, height, width, &pic->directmb)) + goto failed; + + if (!bitplane_decoding (br, height, width, &pic->skipmb)) + goto failed; + + READ_UINT8 (br, pic->mvtab, 2); + READ_UINT8 (br, pic->cbptab, 2); + + if (framehdr->dquant) { + parse_vopdquant (br, framehdr, framehdr->dquant); + } + + if (entrypthdr->vstransform) { + READ_UINT8 (br, pic->ttmbf, 1); + + if (pic->ttmbf) { + READ_UINT8 (br, pic->ttfrm, 2); + } + } + + framehdr->transacfrm = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + GST_DEBUG ("transacfrm %u transdctab %u mvmode %u mvtab %u," + "cbptab %u directmb %u skipmb %u", framehdr->transacfrm, + framehdr->transdctab, pic->mvmode, pic->mvtab, pic->cbptab, + pic->directmb, pic->skipmb); + + break; + case GST_VC1_PICTURE_TYPE_P: + if (entrypthdr->extended_mv) + pic->mvrange = get_unary (br, 0, 3); + else + pic->mvrange = 0; + + mvmodeidx = framehdr->pquant > 12 ? 0 : 1; + pic->mvmode = mvmode_table[mvmodeidx][get_unary (br, 1, 4)]; + + if (pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP) { + + pic->mvmode2 = mvmode2_table[mvmodeidx][get_unary (br, 1, 4)]; + READ_UINT8 (br, pic->lumscale, 6); + READ_UINT8 (br, pic->lumshift, 6); + + GST_DEBUG ("lumscale %u lumshift %u", pic->lumscale, pic->lumshift); + } + + if (pic->mvmode == GST_VC1_MVMODE_MIXED_MV || + (pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP && + pic->mvmode2 == GST_VC1_MVMODE_MIXED_MV)) { + if (!bitplane_decoding (br, height, width, &pic->mvtypemb)) + goto failed; + GST_DEBUG ("mvtypemb %u", pic->mvtypemb); + } + + if (!bitplane_decoding (br, height, width, &pic->skipmb) || + gst_bit_reader_get_remaining (br) < 4) + goto failed; + + pic->mvtab = gst_bit_reader_get_bits_uint8_unchecked (br, 2); + pic->cbptab = gst_bit_reader_get_bits_uint8_unchecked (br, 2); + + if (framehdr->dquant) { + parse_vopdquant (br, framehdr, framehdr->dquant); + } + + if (entrypthdr->vstransform) { + READ_UINT8 (br, pic->ttmbf, 1); + + if (pic->ttmbf) { + READ_UINT8 (br, pic->ttfrm, 2); + } + } + + framehdr->transacfrm = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + GST_DEBUG ("transacfrm %u transdctab %u mvmode %u mvtab %u," + "cbptab %u skipmb %u", framehdr->transacfrm, framehdr->transdctab, + pic->mvmode, pic->mvtab, pic->cbptab, pic->skipmb); + + break; + } + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse frame header"); + + return GST_VC1_PARSER_ERROR; +} + +static GstVC1ParseResult +parse_frame_header (GstBitReader * br, GstVC1FrameHdr * framehdr, + GstVC1SeqHdr * seqhdr) +{ + guint8 mvmodeidx; + GstVC1PicSimpleMain *pic = &framehdr->pic.simple; + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr->profile.simplemain; + guint width = (simplehdr->coded_width + 15) >> 4; + guint height = (simplehdr->coded_height + 15) >> 4; + + + GST_DEBUG ("Parsing frame header in simple or main mode"); + + /* Set the conveninence fields */ + framehdr->profile = seqhdr->profiletype; + framehdr->dquant = simplehdr->dquant; + + framehdr->interpfrm = 0; + if (seqhdr->finterpflag) + READ_UINT8 (br, framehdr->interpfrm, 1); + + READ_UINT8 (br, pic->frmcnt, 2); + + pic->rangeredfrm = 0; + if (simplehdr->rangered) { + READ_UINT8 (br, pic->rangeredfrm, 2); + } + + /* Figuring out the picture type */ + READ_UINT8 (br, framehdr->ptype, 1); + if (simplehdr->maxbframes) { + if (!framehdr->ptype) { + READ_UINT8 (br, framehdr->ptype, 1); + + if (framehdr->ptype) + framehdr->ptype = GST_VC1_PICTURE_TYPE_I; + else + framehdr->ptype = GST_VC1_PICTURE_TYPE_B; + + } else + framehdr->ptype = GST_VC1_PICTURE_TYPE_P; + + } else { + if (framehdr->ptype) + framehdr->ptype = GST_VC1_PICTURE_TYPE_P; + else + framehdr->ptype = GST_VC1_PICTURE_TYPE_I; + } + + + if (framehdr->ptype == GST_VC1_PICTURE_TYPE_B) { + + if (!decode_vlc (br, (guint *) & pic->bfraction, bfraction_vlc_table, + G_N_ELEMENTS (bfraction_vlc_table))) + goto failed; + + if (pic->bfraction == GST_VC1_PICTURE_TYPE_BI) { + framehdr->ptype = GST_VC1_PICTURE_TYPE_BI; + } + GST_DEBUG ("bfraction= %d", pic->bfraction); + } + + if (framehdr->ptype == GST_VC1_PICTURE_TYPE_I || + framehdr->ptype == GST_VC1_PICTURE_TYPE_BI) + READ_UINT8 (br, pic->bf, 7); + + READ_UINT8 (br, framehdr->pqindex, 5); + if (!framehdr->pqindex) + return GST_VC1_PARSER_ERROR; + + GST_DEBUG ("pqindex %u", framehdr->pqindex); + + /* compute pquant */ + if (simplehdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) + framehdr->pquant = vc1_pquant_table[0][framehdr->pqindex]; + else + framehdr->pquant = vc1_pquant_table[1][framehdr->pqindex]; + + GST_DEBUG ("pquant %u", framehdr->pquant); + + if (framehdr->pqindex <= 8) + READ_UINT8 (br, framehdr->halfqp, 1); + else + framehdr->halfqp = 0; + + /* Set pquantizer */ + framehdr->pquantizer = 1; + if (simplehdr->quantizer == GST_VC1_QUANTIZER_IMPLICITLY) + framehdr->pquantizer = framehdr->pqindex < 9; + else if (simplehdr->quantizer == GST_VC1_QUANTIZER_NON_UNIFORM) + framehdr->pquantizer = 0; + + if (simplehdr->quantizer == GST_VC1_QUANTIZER_EXPLICITLY) + READ_UINT8 (br, framehdr->pquantizer, 1); + + if (simplehdr->extended_mv == 1) { + pic->mvrange = get_unary (br, 0, 3); + GST_DEBUG ("mvrange %u", pic->mvrange); + } + + if (simplehdr->multires && (framehdr->ptype == GST_VC1_PICTURE_TYPE_P || + framehdr->ptype == GST_VC1_PICTURE_TYPE_I)) { + READ_UINT8 (br, pic->respic, 2); + GST_DEBUG ("Respic %u", pic->respic); + } + + GST_DEBUG ("Parsing %u Frame, pquantizer %u, halfqp %u, rangeredfrm %u, " + "interpfrm %u", framehdr->ptype, framehdr->pquantizer, framehdr->halfqp, + pic->rangeredfrm, framehdr->interpfrm); + + switch (framehdr->ptype) { + case GST_VC1_PICTURE_TYPE_I: + case GST_VC1_PICTURE_TYPE_BI: + framehdr->transacfrm = get_unary (br, 0, 2); + pic->transacfrm2 = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + GST_DEBUG ("transacfrm %u, transacfrm2 %u, transdctab %u", + framehdr->transacfrm, pic->transacfrm2, framehdr->transdctab); + break; + + case GST_VC1_PICTURE_TYPE_P: + mvmodeidx = framehdr->pquant > 12; + + pic->mvmode = mvmode_table[mvmodeidx][get_unary (br, 1, 4)]; + + if (pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP) { + pic->mvmode2 = mvmode2_table[mvmodeidx][get_unary (br, 1, 4)]; + READ_UINT8 (br, pic->lumscale, 6); + READ_UINT8 (br, pic->lumshift, 6); + GST_DEBUG ("lumscale %u lumshift %u", pic->lumscale, pic->lumshift); + } + + if (pic->mvmode == GST_VC1_MVMODE_MIXED_MV || + (pic->mvmode == GST_VC1_MVMODE_INTENSITY_COMP && + pic->mvmode2 == GST_VC1_MVMODE_MIXED_MV)) { + if (!bitplane_decoding (br, height, width, &pic->mvtypemb)) + goto failed; + GST_DEBUG ("mvtypemb %u", pic->mvtypemb); + } + if (!bitplane_decoding (br, height, width, &pic->skipmb)) + goto failed; + + READ_UINT8 (br, pic->mvtab, 2); + READ_UINT8 (br, pic->cbptab, 2); + + if (framehdr->dquant) { + parse_vopdquant (br, framehdr, framehdr->dquant); + } + + if (simplehdr->vstransform) { + READ_UINT8 (br, pic->ttmbf, 1); + GST_DEBUG ("ttmbf %u", pic->ttmbf); + + if (pic->ttmbf) { + READ_UINT8 (br, pic->ttfrm, 2); + GST_DEBUG ("ttfrm %u", pic->ttfrm); + } + } + + framehdr->transacfrm = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + GST_DEBUG ("transacfrm %u transdctab %u mvmode %u mvtab %u," + "cbptab %u skipmb %u", framehdr->transacfrm, framehdr->transdctab, + pic->mvmode, pic->mvtab, pic->cbptab, pic->skipmb); + break; + + case GST_VC1_PICTURE_TYPE_B: + READ_UINT8 (br, pic->mvmode, 1); + if (!bitplane_decoding (br, height, width, &pic->directmb)) + goto failed; + if (!bitplane_decoding (br, height, width, &pic->skipmb) == -1) + goto failed; + + READ_UINT8 (br, pic->mvtab, 2); + READ_UINT8 (br, pic->cbptab, 2); + + if (framehdr->dquant) + parse_vopdquant (br, framehdr, framehdr->dquant); + + if (simplehdr->vstransform) { + READ_UINT8 (br, pic->ttmbf, 1); + + if (pic->ttmbf) { + READ_UINT8 (br, pic->ttfrm, 2); + } + } + + framehdr->transacfrm = get_unary (br, 0, 2); + READ_UINT8 (br, framehdr->transdctab, 1); + + GST_DEBUG ("transacfrm %u transdctab %u mvmode %u mvtab %u," + "cbptab %u directmb %u skipmb %u", framehdr->transacfrm, + framehdr->transdctab, pic->mvmode, pic->mvtab, pic->cbptab, + pic->directmb, pic->skipmb); + + break; + } + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse Simple picture header"); + + return GST_VC1_PARSER_ERROR; +} + +/**** API ****/ +/** + * gst_vc1_identify_next_bdu: + * @data: The data to parse + * @size: the size of @data + * @bdu: (out): The #GstVC1BDU where to store parsed bdu headers + * + * Parses @data and fills @bdu fields + * + * Returns: a #GstVC1ParseResult + */ +GstVC1ParseResult +gst_vc1_identify_next_bdu (const guint8 * data, gsize size, GstVC1BDU * bdu) +{ + gint off1, off2; + + g_return_val_if_fail (bdu != NULL, GST_VC1_PARSER_ERROR); + + ensure_debug_category (); + + if (size <= 4) { + GST_DEBUG ("Can't parse, buffer is to small size %" G_GSSIZE_FORMAT, size); + return GST_VC1_PARSER_ERROR; + } + + off1 = scan_for_start_codes (data, size); + + if (off1 < 0) { + GST_DEBUG ("No start code prefix in this buffer"); + return GST_VC1_PARSER_NO_BDU; + } + + bdu->sc_offset = off1; + + bdu->offset = off1 + 4; + bdu->data = (guint8 *) data; + bdu->type = (GstVC1StartCode) (data[bdu->offset - 1]); + + off2 = scan_for_start_codes (data + bdu->offset, size - bdu->offset); + if (off2 < 0) { + GST_DEBUG ("Bdu start %d, No end found", bdu->offset); + + return GST_VC1_PARSER_NO_BDU_END; + } + + if (off2 > 0 && data[bdu->offset + off2 - 1] == 00) + off2--; + + bdu->size = off2; + + GST_DEBUG ("Complete bdu found. Off: %d, Size: %d", bdu->offset, bdu->size); + return GST_VC1_PARSER_OK; +} + +/** + * 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. + * + * Returns: a #GstVC1ParseResult + */ +GstVC1ParseResult +gst_vc1_parse_sequence_header (const guint8 * data, gsize size, + GstVC1SeqHdr * seqhdr) +{ + GstBitReader br; + guint8 old_interlaced_mode; + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr->profile.simplemain; + + g_return_val_if_fail (seqhdr != NULL, GST_VC1_PARSER_ERROR); + + ensure_debug_category (); + + gst_bit_reader_init (&br, data, size); + + READ_UINT8 (&br, seqhdr->profiletype, 2); + + if (seqhdr->profiletype == GST_VC1_PROFILE_ADVANCED) { + 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); + + /* 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); + } + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse sequence header"); + + return GST_VC1_PARSER_ERROR; +} + +/** + * gst_vc1_parse_entry_point_header: + * @data: The data to parse + * @size: the size of @data + * @entrypoint: (out): The #GstVC1EntryPointHdr to set. + * @seqhdr: The #GstVC1SeqHdr currently being parsed + * + * Parses @data, and sets @entrypoint fields. + * + * Returns: a #GstVC1EntryPointHdr + */ +GstVC1ParseResult +gst_vc1_parse_entry_point_header (const guint8 * data, gsize size, + GstVC1EntryPointHdr * entrypoint, GstVC1SeqHdr * seqhdr) +{ + GstBitReader br; + guint8 i; + GstVC1AdvancedSeqHdr *advanced = &seqhdr->profile.advanced; + + g_return_val_if_fail (entrypoint != NULL, GST_VC1_PARSER_ERROR); + + ensure_debug_category (); + + gst_bit_reader_init (&br, data, size); + + if (gst_bit_reader_get_remaining (&br) < 13) + goto failed; + + entrypoint->broken_link = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->closed_entry = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->panscan_flag = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->refdist_flag = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->loopfilter = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->fastuvmc = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->extended_mv = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->dquant = gst_bit_reader_get_bits_uint8_unchecked (&br, 2); + entrypoint->vstransform = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->overlap = gst_bit_reader_get_bits_uint8_unchecked (&br, 1); + entrypoint->quantizer = gst_bit_reader_get_bits_uint8_unchecked (&br, 2); + + if (advanced->hrd_param_flag) { + for (i = 0; i < seqhdr->profile.advanced.hrd_param.hrd_num_leaky_buckets; + i++) + READ_UINT8 (&br, entrypoint->hrd_full[MAX_HRD_NUM_LEAKY_BUCKETS], 8); + } + + READ_UINT8 (&br, entrypoint->coded_size_flag, 1); + if (entrypoint->coded_size_flag) { + READ_UINT16 (&br, entrypoint->coded_width, 12); + READ_UINT16 (&br, entrypoint->coded_height, 12); + entrypoint->coded_height = (entrypoint->coded_height + 1) << 1; + entrypoint->coded_width = (entrypoint->coded_width + 1) << 1; + } + + if (entrypoint->extended_mv) + READ_UINT8 (&br, entrypoint->extended_dmv, 1); + + READ_UINT8 (&br, entrypoint->range_mapy_flag, 1); + if (entrypoint->range_mapy_flag) + READ_UINT8 (&br, entrypoint->range_mapy, 3); + + READ_UINT8 (&br, entrypoint->range_mapuv_flag, 1); + if (entrypoint->range_mapy_flag) + READ_UINT8 (&br, entrypoint->range_mapuv, 3); + + advanced->entrypoint = *entrypoint; + + return GST_VC1_PARSER_OK; + +failed: + GST_WARNING ("Failed to parse entry point header"); + + return GST_VC1_PARSER_ERROR; +} + +/** + * gst_vc1_parse_frame_header: + * @data: The data to parse + * @size: the size of @data + * @entrypoint: The #GstVC1EntryPointHdr to set. + * @seqhdr: The #GstVC1SeqHdr currently being parsed + * + * Parses @data, and fills @entrypoint fields. + * + * Returns: a #GstVC1EntryPointHdr + */ +GstVC1ParseResult +gst_vc1_parse_frame_header (const guint8 * data, gsize size, + GstVC1FrameHdr * framehdr, GstVC1SeqHdr * seqhdr) +{ + GstBitReader br; + + ensure_debug_category (); + + gst_bit_reader_init (&br, data, size); + + if (seqhdr->profiletype == GST_VC1_PROFILE_ADVANCED) + return parse_frame_header_advanced (&br, framehdr, seqhdr); + else + return parse_frame_header (&br, framehdr, seqhdr); + +} diff --git a/gst-libs/gst/codecparsers/gstvc1parser.h b/gst-libs/gst/codecparsers/gstvc1parser.h new file mode 100644 index 0000000..511df64 --- /dev/null +++ b/gst-libs/gst/codecparsers/gstvc1parser.h @@ -0,0 +1,468 @@ +/* Gstreamer + * Copyright (C) <2011> Intel + * Copyright (C) <2011> Collabora Ltd. + * Copyright (C) <2011> Thibault Saunier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_VC1_PARSER_H__ +#define __GST_VC1_PARSER_H__ + +#ifndef GST_USE_UNSTABLE_API +#warning "The VC1 parsing library is unstable API and may change in future." +#warning "You can define GST_USE_UNSTABLE_API to avoid this warning." +#endif + +#include + +G_BEGIN_DECLS + +#define MAX_HRD_NUM_LEAKY_BUCKETS 31 + +/** + * @GST_VC1_BFRACTION_BASIS: The @bfraction variable should be divided + * by this constant to have the actual value. + */ +#define GST_VC1_BFRACTION_BASIS 256 + +typedef enum { + GST_VC1_END_OF_SEQ = 0x0A, + GST_VC1_SLICE = 0x0B, + GST_VC1_FIELD = 0x0C, + GST_VC1_FRAME = 0x0D, + GST_VC1_ENTRYPOINT = 0x0E, + GST_VC1_SEQUENCE = 0x0F, + GST_VC1_SLICE_USER = 0x1B, + GST_VC1_FIELD_USER = 0x1C, + GST_VC1_FRAME_USER = 0x1D, + GST_VC1_ENTRY_POINT_USER = 0x1E, + GST_VC1_SEQUENCE_USER = 0x1F +} GstVC1StartCode; + +typedef enum { + GST_VC1_PROFILE_SIMPLE, + GST_VC1_PROFILE_MAIN, + GST_VC1_PROFILE_RESERVED, + GST_VC1_PROFILE_ADVANCED +} GstVC1Profile; + +typedef enum { + GST_VC1_PARSER_OK, + GST_VC1_PARSER_BROKEN_DATA, + GST_VC1_PARSER_NO_BDU, + GST_VC1_PARSER_NO_BDU_END, + GST_VC1_PARSER_ERROR, +} GstVC1ParseResult; + +typedef enum +{ + GST_VC1_PICTURE_TYPE_P, + GST_VC1_PICTURE_TYPE_B, + GST_VC1_PICTURE_TYPE_I, + GST_VC1_PICTURE_TYPE_BI, + GST_VC1_PICTURE_TYPE_SKIPPED +} GstVC1PictureType; + +typedef enum +{ + GST_VC1_LEVEL_LOW = 0, /* Simple/Main profile low level */ + GST_VC1_LEVELMEDIUM = 1, /* Simple/Main profile medium level */ + GST_VC1_LEVELHIGH = 2, /* Main profile high level */ + + GST_VC1_LEVEL_L0 = 0, /* Advanced profile level 0 */ + GST_VC1_LEVEL_L1 = 1, /* Advanced profile level 1 */ + GST_VC1_LEVEL_L2 = 2, /* Advanced profile level 2 */ + GST_VC1_LEVEL_L3 = 3, /* Advanced profile level 3 */ + GST_VC1_LEVEL_L4 = 4, /* Advanced profile level 4 */ + + /* 5 to 7 reserved */ + GST_VC1_LEVEL_UNKNOWN = 255 /* Unknown profile */ +} GstVC1Level; + +typedef enum +{ + GST_VC1_QUANTIZER_IMPLICITLY, + GST_VC1_QUANTIZER_EXPLICITLY, + GST_VC1_QUANTIZER_NON_UNIFORM, + GST_VC1_QUANTIZER_UNIFORM +} GstVC1QuantizerSpec; + +typedef enum { + GST_VC1_DQPROFILE_FOUR_EDGES, + GST_VC1_DQPROFILE_DOUBLE_EDGES, + GST_VC1_DQPROFILE_SINGLE_EDGE, + GST_VC1_DQPROFILE_ALL_MBS +} GstVC1DQProfile; + +typedef enum { + GST_VC1_CONDOVER_NONE, + GST_VC1_CONDOVER_ALL, + GST_VC1_CONDOVER_SELECT +} GstVC1Condover; + +/** + * GstVC1MvMode: + * + */ +typedef enum +{ + GST_VC1_MVMODE_1MV_HPEL_BILINEAR, + GST_VC1_MVMODE_1MV, + GST_VC1_MVMODE_1MV_HPEL, + GST_VC1_MVMODE_MIXED_MV, + GST_VC1_MVMODE_INTENSITY_COMP +} GstVC1MvMode; + +typedef struct _GstVC1SeqHdr GstVC1SeqHdr; +typedef struct _GstVC1AdvancedSeqHdr GstVC1AdvancedSeqHdr; +typedef struct _GstVC1SimpleMainSeqHdr GstVC1SimpleMainSeqHdr; +typedef struct _GstVC1HrdParam GstVC1HrdParam; +typedef struct _GstVC1EntryPointHdr GstVC1EntryPointHdr; + +/* Pictures Structures */ +typedef struct _GstVC1FrameHdr GstVC1FrameHdr; +typedef struct _GstVC1PicAdvanced GstVC1PicAdvanced; +typedef struct _GstVC1PicSimpleMain GstVC1PicSimpleMain; +typedef struct _GstVC1Picture GstVC1Picture; + +typedef struct _GstVC1VopDquant GstVC1VopDquant; + +typedef struct _GstVC1BDU GstVC1BDU; + +struct _GstVC1HrdParam +{ + guint8 hrd_num_leaky_buckets; + guint8 bit_rate_exponent; + guint8 buffer_size_exponent; + guint16 hrd_rate[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: + * + * Structure for entrypoint header, this will be used only in advanced profiles + */ +struct _GstVC1EntryPointHdr +{ + guint8 broken_link; + guint8 closed_entry; + guint8 panscan_flag; + guint8 refdist_flag; + guint8 loopfilter; + guint8 fastuvmc; + guint8 extended_mv; + guint8 dquant; + guint8 vstransform; + guint8 overlap; + guint8 quantizer; + guint8 coded_size_flag; + guint16 coded_width; + guint16 coded_height; + guint8 extended_dmv; + guint8 range_mapy_flag; + guint8 range_mapy; + guint8 range_mapuv_flag; + guint8 range_mapuv; + + guint8 hrd_full[MAX_HRD_NUM_LEAKY_BUCKETS]; +}; + +/** + * GstVC1AdvancedSeqHdr: + * + * Structure for the advanced profile sequence headers specific parameters. + */ +struct _GstVC1AdvancedSeqHdr +{ + guint8 level; + guint8 postprocflag; + guint16 max_coded_width; + guint16 max_coded_height; + guint8 pulldown; + guint8 interlace; + guint8 tfcntrflag; + guint8 psf; + guint8 display_ext; + guint16 disp_horiz_size; + guint16 disp_vert_size; + guint8 aspect_ratio_flag; + guint8 aspect_ratio; + guint8 aspect_horiz_size; + guint8 aspect_vert_size; + guint8 framerate_flag; + guint8 framerateind; + guint8 frameratenr; + guint8 frameratedr; + guint16 framerateexp; + guint8 color_format_flag; + guint8 color_prim; + guint8 transfer_char; + guint8 matrix_coef; + guint8 hrd_param_flag; + + GstVC1HrdParam hrd_param; + + /* The last parsed entry point */ + GstVC1EntryPointHdr entrypoint; +}; + +/** + * GstVC1SeqHdr: + * + * Structure for sequence headers in any profile. + */ +struct _GstVC1SeqHdr +{ + guint8 profiletype; + guint8 colordiff_format; + guint8 frmrtq_postproc; + guint8 bitrtq_postproc; + guint8 finterpflag; + + /* calculated */ + guint framerate; /* Around in fps, 0 if unknown*/ + guint bitrate; /* Around in kpbs, 0 if unknown*/ + + union { + GstVC1AdvancedSeqHdr advanced; + GstVC1SimpleMainSeqHdr simplemain; + } profile; + +}; + +/** + * GstVC1PicSimpleMain: + * @bfaction: Should be divided by #GST_VC1_BFRACTION_BASIS + * to get the real value. + */ +struct _GstVC1PicSimpleMain +{ + guint8 frmcnt; + guint8 mvrange; + guint8 rangeredfrm; + + /* I and P pic simple and main profiles only */ + guint8 respic; + + /* I and BI pic simple and main profiles only */ + guint8 transacfrm2; + guint8 bf; + + /* B and P pic simple and main profiles only */ + guint8 mvmode; + guint8 mvtab; + guint8 ttmbf; + + /* P pic simple and main profiles only */ + guint8 mvmode2; + guint8 lumscale; + guint8 lumshift; + + guint8 cbptab; + guint8 ttfrm; + + /* B and BI picture only + * Should be divided by #GST_VC1_BFRACTION_BASIS + * to get the real value. */ + guint8 bfraction; + + /* Biplane value, those fields only mention the fact + * that the bitplane is in raw mode or not */ + guint8 mvtypemb; + guint8 skipmb; + guint8 directmb; /* B pic main profile only */ +}; + +/** + * GstVC1PicAdvanced: + * @bfaction: Should be divided by #GST_VC1_BFRACTION_BASIS + * to get the real value. + */ +struct _GstVC1PicAdvanced +{ + guint8 fcm; + guint8 tfcntr; + + guint8 rptfrm; + guint8 tff; + guint8 rff; + guint8 ps_present; + guint32 ps_hoffset; + guint32 ps_voffset; + guint16 ps_width; + guint16 ps_height; + guint8 rndctrl; + guint8 uvsamp; + guint8 postproc; + + /* B and P picture specific */ + guint8 mvrange; + guint8 mvmode; + guint8 mvtab; + guint8 cbptab; + guint8 ttmbf; + guint8 ttfrm; + + /* B and BI picture only + * Should be divided by #GST_VC1_BFRACTION_BASIS + * to get the real value. */ + guint8 bfraction; + + /* ppic */ + guint8 mvmode2; + guint8 lumscale; + guint8 lumshift; + + /* bipic */ + guint8 bf; + guint8 condover; + guint8 transacfrm2; + + /* Biplane value, those fields only mention the fact + * that the bitplane is in raw mode or not */ + guint8 acpred; + guint8 overflags; + guint8 mvtypemb; + guint8 skipmb; + guint8 directmb; +}; + + +struct _GstVC1VopDquant +{ + guint8 pqdiff; + guint8 abspq; + + + /* if dqant != 2*/ + guint8 dquantfrm; + guint8 dqprofile; + + /* if dqprofile == GST_VC1_DQPROFILE_SINGLE_EDGE + * or GST_VC1_DQPROFILE_DOUBLE_EDGE:*/ + guint8 dqsbedge; + + /* if dqprofile == GST_VC1_DQPROFILE_SINGLE_EDGE + * or GST_VC1_DQPROFILE_DOUBLE_EDGE:*/ + guint8 dqbedge; + + /* if dqprofile == GST_VC1_DQPROFILE_ALL_MBS */ + guint8 dqbilevel; + +}; + +/** + * GstVC1FrameHdr: + * + * Structure that represent picture in any profile or mode. + * You should look at @ptype and @profile to know what is currently + * in use. + */ +struct _GstVC1FrameHdr +{ + /* common fields */ + guint8 ptype; + guint8 interpfrm; + guint8 halfqp; + guint8 transacfrm; + guint8 transdctab; + guint8 pqindex; + guint8 pquantizer; + + /* Computed */ + guint8 pquant; + + /* Convenience fields */ + guint8 profile; + guint8 dquant; + + /* If dquant */ + GstVC1VopDquant vopdquant; + + union { + GstVC1PicSimpleMain simple; + GstVC1PicAdvanced advanced; + } pic; +}; + +/** + * GstVC1BDU: + * + * Structure that represents a Bitstream Data Unit. + */ +struct _GstVC1BDU +{ + GstVC1StartCode type; + guint size; + guint sc_offset; + guint offset; + guint8 * data; +}; + +GstVC1ParseResult gst_vc1_identify_next_bdu (const guint8 *data, + gsize size, + GstVC1BDU *bdu); + + +GstVC1ParseResult gst_vc1_parse_sequence_header (const guint8 *data, + gsize size, + GstVC1SeqHdr * seqhdr); + +GstVC1ParseResult gst_vc1_parse_entry_point_header (const guint8 *data, + gsize size, + GstVC1EntryPointHdr * entrypoint, + GstVC1SeqHdr *seqhdr); + +GstVC1ParseResult gst_vc1_parse_frame_header (const guint8 *data, + gsize size, + GstVC1FrameHdr * framehdr, + GstVC1SeqHdr *seqhdr); + +G_END_DECLS +#endif diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index d09991d..75750ea 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -185,6 +185,7 @@ check_PROGRAMS = \ elements/rtpmux \ libs/mpegvideoparser \ libs/h264parser \ + libs/vc1parser \ $(check_schro) \ $(check_vp8) \ elements/viewfinderbin \ @@ -236,6 +237,16 @@ libs_h264parser_LDADD = \ $(GST_PLUGINS_BAD_LIBS) -lgstcodecparsers-@GST_MAJORMINOR@ \ $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) +libs_vc1parser_CFLAGS = \ + $(GST_PLUGINS_BAD_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ + -DGST_USE_UNSTABLE_API \ + $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) + +libs_vc1parser_LDADD = \ + $(top_builddir)/gst-libs/gst/codecparsers/libgstcodecparsers-@GST_MAJORMINOR@.la \ + $(GST_PLUGINS_BAD_LIBS) -lgstcodecparsers-@GST_MAJORMINOR@ \ + $(GST_BASE_LIBS) $(GST_LIBS) $(LDADD) + elements_voaacenc_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(AM_CFLAGS) diff --git a/tests/check/libs/vc1parser.c b/tests/check/libs/vc1parser.c new file mode 100644 index 0000000..5c9ef73 --- /dev/null +++ b/tests/check/libs/vc1parser.c @@ -0,0 +1,1230 @@ +/* Gstreamer + * Copyright (C) <2011> Intel + * Copyright (C) <2011> Collabora Ltd. + * Copyright (C) <2011> Thibault Saunier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ +#include +#include + +static guint8 sequence_fullframe[] = { + 0x00, 0x00, 0x01, 0x0f, 0xca, 0x86, 0x13, 0xf0, 0xef, 0x88, + 0x80, 0x00, 0x00, 0x01, 0x0e, 0x48, 0x3f, 0x4f, 0xc3, 0xbc, + 0x3f, 0x2b, 0x3f, 0x3c, 0x3f, 0x00, 0x00, 0x01, 0x0d, 0x3f, + 0x0c, 0x14, 0x27, 0x3f, 0x68, 0x0c, 0x03, 0x3f, 0x3f, 0x55, + 0x3f, 0x60, 0x71, 0x24, 0x38, 0x28, 0x1b, 0xda, 0xac, 0x01, + 0x3f, 0x3f, 0x3f, 0x33, 0x3f, 0x61, 0x75, 0x70, 0x3f, 0x3f, + 0x3f, 0x0d, 0x3f, 0x03, 0x3f, 0x3f, 0x1b, 0x3f, 0x3f, 0x61, + 0x1a, 0x73, 0x01, 0x26, 0x07, 0x0e, 0x29, 0x3f, 0x1d, 0x68, + 0xe1, 0xa2, 0x98, 0x59, 0x21, 0x3f, 0x1e, 0x7c, 0x3f, 0x3f, + 0x3f, 0x65, 0x49, 0x3f, 0x3f, 0x7e, 0x3f, 0x07, 0x6a, 0x0f, + 0xdb, 0x87, 0x3f, 0x3f, 0x3f, 0x41, 0x3f, 0x3f, 0x77, 0x3f, + 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x44, 0x3f, 0x4a, 0x50, 0x53, + 0x3f, 0x3f, 0x65, 0x3f, 0x2e, 0x3f, 0x3f, 0x3f, 0x08, 0x3f, + 0x3f, 0x04, 0x5e, 0x11, 0x7d, 0x12, 0x3f, 0x4a, 0x6b, 0x50, + 0x42, 0x3f, 0x15, 0x3f, 0x3f, 0x61, 0x3f, 0x3f, 0x75, 0x41, + 0x3f, 0x3f, 0x75, 0x71, 0x3f, 0x3f, 0x3b, 0x3f, 0x0d, 0x3f, + 0x3f, 0x6e, 0x3f, 0x3f, 0x06, 0x3f, 0x30, 0x08, 0x72, 0x3f, + 0x3b, 0x3f, 0x67, 0x6e, 0x3f, 0x50, 0x1b, 0x61, 0x5a, 0x20, + 0x2b, 0x70, 0x3f, 0x2c, 0x22, 0x3f, 0x36, 0x3f, 0x44, 0x40, + 0x00, 0x00, 0x01, 0x05, 0x3f +}; + +static guint8 pframe_header_main[] = { + 0x4e, 0x29, 0x1a, 0x11 +}; + +static guint8 pframe_main[] = { + 0x6a, 0x88, 0xbc, 0x1d, 0x40, 0x16, 0x96, 0x90, 0x05, 0x82, + 0xac, 0x22, 0x88, 0xe0, 0x5d, 0x52, 0xca, 0x85, 0x4c, 0x47, + 0x9d, 0xc9, 0x25, 0x45, 0x56, 0x99, 0x44, 0x15, 0xa5, 0xc5, + 0xe1, 0x35, 0x11, 0x72, 0xc1, 0x27, 0x22, 0x6a, 0x08, 0x9a, + 0x72, 0x4e, 0xe7, 0xa3, 0xf7, 0x23, 0x9d, 0x11, 0x8d, 0xc8, + 0xe6, 0x4f, 0x46, 0x98, 0xe2, 0x03, 0xcc, 0x6c, 0xe8, 0x77, + 0xd4, 0x7c, 0xfc, 0x13, 0x39, 0x20, 0x23, 0x03, 0x24, 0xcd, + 0x15, 0xbf, 0x54, 0x61, 0xf2, 0x25, 0x25, 0xa0, 0x83, 0xa0, +}; + +static guint8 bframe_header_main[] = { + 0x4e, 0x39, 0x1a, 0x11 +}; + +static guint8 bframe_main[] = { + 0x80, 0xae, 0x01, 0x43, 0x47, 0x6a, 0x9f, 0x53, 0x04, 0x55, 0x2a, + 0x8b, 0x42, 0x75, 0x8b, 0x35, 0x50, 0xf5, 0x95, 0x56, 0xf2, 0x00, + 0xe0, 0xa0, 0x60, 0x2c, 0xe8, 0x6b, 0x60, 0x0b, 0x20, 0x00, 0x11, + 0xf1, 0x51, 0xfe, 0x91, 0x60, 0x6a, 0xe6, 0x12, 0x04, 0x2c, 0xe3, + 0x07, 0x0a, 0x09, 0x09, 0x12, 0xcb, 0xe1, 0x42, 0x88, 0x10, 0x67, + 0x80, 0x4c, 0xbf, 0x26, 0x00, 0x82, 0x61, 0x07, 0x21, 0x63, 0x4c, + 0x0c, 0x32, 0x03, 0x53, 0x19, 0x1b, 0x4d, 0xca, 0xc9, 0xe0, 0xc1, + 0x6d, 0x32, 0x48, 0xc9, 0xd7, 0xa6, 0x63, 0x4d, 0xeb, 0xd4, 0x1c, + 0x02, 0x05, 0xfe, 0x57, 0x29, 0x00, 0x58, 0xb0, 0x67, 0x2d, 0x04, + 0xee, 0x1b, 0xaf, 0x53, 0x40, 0x89, 0xbe, 0xf5, 0x76, 0x20, 0x0b, + 0x83, 0xc1, 0x88, 0xee, 0x83, 0x94, 0xab, 0x1c, 0x79, 0xdd, 0x44, + 0xe5, 0x15, 0xae, 0xa5, 0xd3, 0xd5, 0x68, 0x31, 0x3e, 0x5a, 0xa4, + 0x6b, 0x9e, 0xe3, 0xd2, 0x49, 0x00, 0x1d, 0x6d, 0xeb, 0x0d, 0x6b, + 0x54, 0xcd, 0xd2, 0xaf, 0x1f, 0x2b, 0xba, 0xf3, 0xd9, 0x4c, 0x71 +}; + +static guint8 i_bi_frame_header[] = { + 0x4e, 0x79, 0x1a, 0x11 +}; + +static guint8 biframe_main[] = { + 0x0f, 0xe0, 0x4c, 0x56, 0x19, 0xdb, 0x40, 0x68, 0xd9, 0x14, 0x2c, 0x92, + 0x55, 0x1f, 0x59, 0xd5, 0x5b, 0xd8, 0x55, 0x13, 0x19, 0x64, 0x40, 0x2c, + 0x27, 0x38, 0x71, 0x9d, 0x05, 0x52, 0x02, 0x18, 0x7b, 0x9d, 0x22, 0x88, + 0x97, 0xaa, 0x54, 0x95, 0x52, 0x49, 0x23, 0x0b, 0x98, 0xee, 0x6c, 0x26, + 0xe6, 0xff, 0xff, 0x1a, 0x25, 0x15, 0xc3, 0x30, 0x4f, 0x1f, 0xbd, 0xb1, + 0x09, 0x1b, 0x55, 0x33, 0x6c, 0xcd, 0x8c, 0x11, 0x87, 0x1b, 0x86, 0x02, + 0x78, 0xfd, 0x69, 0xc1, 0xa2, 0x3b, 0x27, 0x08, 0xc8, 0x63, 0x5f, 0x52, + 0x10, 0x50, 0xe0, 0xf4, 0x4a, 0xfd, 0x83, 0x30, 0x3f, 0x20, 0x8d, 0x3a, + 0x88, 0xa0, 0x00, 0x23, 0xd8, 0x51, 0xd0, 0xf6, 0x8c, 0xc4, 0xe8, 0x2d, + 0x8c, 0x10, 0x13, 0xae, 0xb2, 0xaa, 0xc0, 0x92, 0x68, 0x33, 0x7b, 0x8f, + 0x63, 0x0e, 0xda, 0x35, 0xc6, 0xa1, 0x11, 0xe6, 0x44, 0xe3, 0xb1, 0x52, + 0xe9, 0x01, 0x05, 0x93, 0x1a, 0x36, 0x41, 0xf6, 0x62, 0x66, 0x05, 0xfb, + 0xd6, 0x99, 0x80, 0x8a, 0x97, 0xad, 0xa4, 0x25, 0xec, 0x1a, 0x04, 0xf3, + 0x0c, 0x9c, 0xe0, 0xea, 0x49, 0xfa, 0x4d, 0x58, 0xc8, 0x1b, 0x63, 0x23, + 0xdc, 0x07, 0x9d, 0xe9, 0x84, 0x93, 0x12, 0xc8, 0xfc, 0x86, 0x98, 0xb0, + 0x3d, 0xc8, 0xb4, 0xed, 0x4c, 0x18, 0xbe, 0xd8, 0x38, 0x1b, 0x6d, 0x39, + 0x90, 0x06, 0x43, 0x75, 0x82, 0x89, 0xc1, 0x6f, 0xf1, 0x12, 0x6d, 0x84, + 0x54, 0x45, 0x62, 0x2d, 0x00, 0x0a, 0x0e, 0x06, 0xf0, 0x04, 0x06, 0x5a +}; + +static guint8 iframe_main[] = { + 0x10, 0x04, 0x88, 0x18, 0x1f, 0xdf, 0xe1, 0xe1, 0xde, 0x17, 0x85, 0xe1, + 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, + 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, + 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, + 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, + 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, + 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, + 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, + 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, + 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, + 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, + 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, + 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, + 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78, 0x5e, 0x17, 0x85, 0xe1, 0x78 +}; + +static guint8 iframe_adv_hdr[] = { + 0xdb, 0xfe, 0x3b, 0xf2, 0x1b, 0xca, 0x3b, 0xf8, 0x86, 0xf1, 0x80, + 0xca, 0x02, 0x02, 0x03, 0x09, 0xa5, 0xb8, 0xd7, 0x07, 0xfc +}; + +static guint8 entrypoint[] = { + 0x5a, 0xc7, 0xfc, 0xef, 0xc8, 0x6c, 0x40 +}; + +static guint8 iframe_adv[] = { + 0x69, 0x1c, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x7f, 0x16, 0x0c, 0x0f, 0x13, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, + 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, + 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, + 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, + 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, + 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, + 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, + 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, + 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, + 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, + 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, + 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, + 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, + 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, + 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, + 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, + 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, + 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, + 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f, 0xc3, 0xf0, 0xfc, 0x3f, 0x0f +}; + +static guint8 bframe_adv[] = { + 0x46, 0x03, 0x1f, 0xf0, 0x8d, 0xd8, 0xbf, 0xc0, 0xcc, 0x14, + 0x24, 0xdc, 0x60, 0xe2, 0xa8, 0x5e, 0x0d, 0xff, 0xfc, 0x3b, + 0x12, 0xfd, 0xe1, 0x2e, 0xd1, 0x84, 0xb0, 0xc2, 0xc4, 0xc1, + 0x60, 0x20, 0x4a, 0x7c, 0x33, 0xff, 0xf2, 0x10, 0xd8, 0x5c, + 0xf6, 0x7f, 0xc4, 0xd5, 0x0e, 0x0e, 0x51, 0xa8, 0x57, 0xff, + 0xfa, 0x43, 0x1f, 0xd0, 0x80, 0xdc, 0x58, 0x02, 0x02, 0xaf, + 0x10, 0xc6, 0x10, 0x12, 0x80, 0xd8, 0x07, 0xff, 0x9d, 0x00, + 0x50, 0x51, 0xa8, 0x0a, 0xd3, 0xef, 0x54, 0x03, 0xcb, 0x3f, + 0xff, 0x2b, 0x8b, 0x21, 0xcb, 0xdb, 0xf1, 0x62, 0x4e, 0x4d, + 0x8b, 0x03, 0x00, 0x16, 0x53, 0xff, 0xa6, 0x65, 0x12, 0x70, + 0xe0, 0x3f, 0xf4, 0x85, 0xb8, 0x4b, 0xc6, 0x04, 0x52, 0xff, + 0xc1, 0xf0, 0x80, 0x39, 0x85, 0x9f, 0xf4, 0xca, 0x91, 0x28, + 0x10, 0x64, 0x2c, 0xe0, 0xff, 0xff, 0x03, 0x2c, 0x3a, 0xfe, + 0x03, 0xc3, 0x2d, 0x0e, 0x60, 0x61, 0x80, 0x09, 0x9f, 0xff, + 0x03, 0x88, 0xc5, 0xd7, 0x9f, 0xfe, 0x1c, 0x14, 0x62, 0xc0, + 0x62, 0xc1, 0x7f, 0xef, 0x87, 0x7d, 0x6c, 0xbf, 0xf7, 0xc2, + 0x00, 0x10, 0x59, 0xd7, 0xfc, 0x33, 0x15, 0xbd, 0x35, 0xec, + 0x17, 0x0b, 0x07, 0x20, 0xd8, 0x42, 0x7e, 0xbf, 0xfc, 0x56, + 0xdd, 0x1f, 0x9c, 0x3a, 0x70, 0x45, 0x93, 0x01, 0x05, 0x37, + 0xb7, 0xff, 0x9f, 0x25, 0x5b, 0xb1, 0xbb, 0x87, 0x35, 0x02, + 0x70, 0x7e, 0x89, 0xb7, 0xf8, 0x5a, 0xb8, 0xb0, 0xb5, 0x04, + 0x4d, 0x2e, 0x11, 0xb9, 0x74, 0xa1, 0x95, 0xf0, 0x7f, 0x7b, + 0x38, 0x58, 0x50, 0x61, 0x9f, 0x3f, 0x80, 0x42, 0x7d, 0x15, + 0x82, 0x00, 0x1d, 0x85, 0x2b, 0x85, 0xf7, 0x14, 0x94, 0x60, + 0x42, 0x38, 0x28, 0xa8, 0x68, 0x2d, 0x28, 0x31, 0xbc, 0x36, + 0x48, 0x64, 0xc0, 0x21, 0x56, 0x30, 0xb9, 0xc0, 0x45, 0x90, + 0xe7, 0x12, 0x83, 0x84, 0xb1, 0x25, 0x86, 0x12, 0x18, 0x2d, + 0x08, 0xe8, 0x2a, 0x98, 0x8e, 0x0d, 0x00, 0xaa, 0x72, 0x75, + 0x61, 0x87, 0x00, 0x44, 0x57, 0xd4, 0x26, 0x02, 0x23, 0x90, + 0xc0, 0x04, 0x90, 0x80, 0x70, 0x46, 0x11, 0xe0, 0x20, 0x26, + 0x8c, 0x04, 0xa2, 0x88, 0x8e, 0x30, 0xc0, 0x30, 0x60, 0xdf, + 0xa2, 0xdf, 0x02, 0xd0, 0x01, 0x40, 0x99, 0x4e, 0xa4, 0x7f, + 0x84, 0x89, 0x63, 0x07, 0x0d, 0x19, 0x1d, 0x6c, 0x88, 0xca, + 0x1c, 0x1d, 0x07, 0x43, 0xc1, 0x02, 0x9c, 0x60, 0xa3, 0x09, + 0x0b, 0xc1, 0xfd, 0xa6, 0xa8, 0x21, 0x83, 0x8c, 0x08, 0x49, + 0x40, 0x56, 0xf9, 0xa6, 0x6a, 0x01, 0x52, 0x0d, 0x0e, 0x12, + 0xe1, 0x4c, 0xbf, 0x88, 0xe5, 0xa8, 0xb8, 0x02, 0x26, 0x0c, + 0x24, 0x74, 0x15, 0x38, 0x70, 0x25, 0x30, 0x24, 0x5e, 0xe0, + 0x22, 0x70, 0x68, 0x96, 0x7f, 0xec, 0x10, 0x23, 0x94, 0x30, + 0x61, 0x62, 0x38, 0xb0, 0x29, 0x2d, 0x78, 0x21, 0xb3, 0xca, + 0x40, 0xee, 0x11, 0xa0, 0x6f, 0xf8, 0x07, 0x71, 0x70, 0x47, + 0xb8, 0x5f, 0x5e, 0x89, 0x6c, 0x31, 0x58, 0x22, 0x0f, 0xff, + 0xf7, 0x17, 0x00, 0x30, 0x85, 0xf3, 0xc2, 0xb0, 0x55, 0xfe, + 0xbf, 0xfe, 0x0a, 0x7c, 0x16, 0x07, 0xf0, 0xdb, 0x81, 0xf9, + 0x40, 0x30, 0x81, 0x84, 0xac, 0x0f, 0xff, 0xe2, 0xb3, 0x4f, + 0xc3, 0x8d, 0x30, 0x76, 0x9a, 0x33, 0xa0, 0x10, 0x50, 0xc8, + 0x60, 0xae, 0x2b, 0x22, 0xff, 0xf8, 0xa9, 0x02, 0xf9, 0xf6, + 0x7a, 0x44, 0x37, 0x69, 0x8b, 0x01, 0x2b, 0x9f, 0xff, 0x81, + 0x60, 0x7a, 0xb9, 0x01, 0x0b, 0x27, 0x70, 0x40, 0xa1, 0x50, + 0x60, 0xa4, 0x61, 0xa1, 0x66, 0x30, 0x91, 0x55, 0x6f, 0xff, + 0xe6, 0x0d, 0x14, 0xae, 0xc8, 0x1a, 0x2c, 0x23, 0x4c, 0xc9, + 0x94, 0x4c, 0x07, 0x61, 0x0d, 0x46, 0x63, 0x89, 0xca, 0xbf, + 0xff, 0xea, 0x27, 0x0c, 0x30, 0x1e, 0x66, 0x1c, 0x13, 0x50, + 0xb0, 0xd8, 0x34, 0x02, 0x14, 0x30, 0x01, 0x54, 0x6a, 0xbf, + 0xff, 0x97, 0xa2, 0x3a, 0x83, 0x85, 0x04, 0x8a, 0xc2, 0x60, + 0xc0, 0x85, 0x57, 0x71, 0x61, 0x45, 0x22, 0x01, 0x07, 0x00, + 0x22, 0xff, 0xfb, 0x5b, 0xf1, 0x80, 0x8b, 0x46, 0x81, 0x68, + 0x02, 0xe2, 0x71, 0x00, 0x11, 0x81, 0x86, 0x2f, 0xff, 0xf7, + 0x5f, 0xdd, 0x42, 0x06, 0x03, 0x38, 0xb4, 0x01, 0xf6, 0xc0, + 0xff, 0xc7, 0xfb, 0xb8, 0x15, 0x0b, 0xfc, 0x1c, 0x09, 0x86, + 0x18, 0x30, 0x34, 0x15, 0x9c, 0x6a, 0x55, 0xff, 0xff, 0xbf, + 0xe2, 0xc0, 0xc3, 0x86, 0xe2, 0x38, 0x18, 0xb3, 0x14, 0x81, + 0xc0, 0x06, 0x04, 0xc2, 0x98, 0xb0, 0x12, 0x7f, 0xff, 0x8c, + 0x06, 0xbf, 0x71, 0x85, 0x0c, 0x08, 0x47, 0x11, 0x87, 0xa0, + 0xa4, 0xe0, 0x63, 0x0a, 0x0c, 0xae, 0x0a, 0xbf, 0xfe, 0xe0, + 0x78, 0xb0, 0x13, 0xb8, 0x20, 0xc3, 0x5d, 0xc5, 0x21, 0x44, + 0x82, 0x48, 0x00, 0x18, 0x24, 0x54, 0x00, 0x03, 0x5c, 0x1b, + 0xff, 0xc3, 0x9a, 0x16, 0x30, 0xb1, 0x85, 0x07, 0x38, 0xc8, + 0x59, 0x20, 0x81, 0x4c, 0x56, 0x75, 0x27, 0x0d, 0x08, 0x71, + 0x58, 0x47, 0x0e, 0x12, 0x85, 0x81, 0x61, 0xbf, 0xfc, 0x5a, + 0x4a, 0x0c, 0x28, 0x56, 0x20, 0x03, 0x14, 0x63, 0x0a, 0x2a, + 0x45, 0x80, 0xd1, 0x38, 0x28, 0x68, 0x32, 0x27, 0xa2, 0x05, + 0xff, 0xf7, 0x03, 0xe2, 0x30, 0x3c, 0x56, 0x61, 0x4e, 0x30, + 0x18, 0xad, 0x80, 0xdc, 0x15, 0x04, 0xa7, 0x0c, 0x18, 0x30, + 0x10, 0x38, 0x62, 0xff, 0xe1, 0x87, 0x3c, 0x20, 0x60, 0x63, + 0x0a, 0x02, 0x29, 0xf0, 0xc2, 0xa4, 0x2c, 0x04, 0x66, 0x2b, + 0x02, 0x72, 0xff, 0xce, 0x07, 0xd0, 0x10, 0x0e, 0x13, 0xc5, + 0x22, 0xc3, 0x02, 0x96, 0x10, 0x33, 0x18, 0x08, 0x1e, 0xe7, + 0xff, 0x9f, 0xd0, 0x61, 0xb9, 0x0a, 0xdf, 0xdc, 0x83, 0x85, + 0x61, 0x38, 0x61, 0x69, 0x24, 0x12, 0x7f, 0xf0, 0x3a, 0x73, + 0x03, 0x09, 0x87, 0x7c, 0x30, 0xb8, 0x58, 0x9c, 0x18, 0x30, + 0x05, 0xd0, 0x4c, 0xff, 0xcb, 0xe3, 0x86, 0x14, 0x5a, 0xc3, + 0x0b, 0x8a, 0xd7, 0x05, 0x15, 0x06, 0x0a, 0x00, 0x50, 0x78, + 0x93, 0xff, 0x7f, 0xc6, 0xc5, 0x97, 0xf0, 0x97, 0x18, 0x70, + 0x71, 0x8c, 0x14, 0x58, 0x03, 0xb4, 0x61, 0xa0, 0x7f, 0xef, + 0xae, 0x18, 0x29, 0x84, 0xee, 0xbf, 0x88, 0xa0, 0x33, 0x0e, + 0x11, 0x41, 0xfc, 0xff, 0xf1, 0xa8, 0xda, 0x1c, 0xa1, 0x81, + 0x05, 0x8a, 0x9f, 0xf1, 0x2c, 0x30, 0x55, 0x18, 0x40, 0xc2, + 0x7d, 0x8b, 0xf7, 0x8a, 0x80, 0x42, 0x58, 0x94, 0x30, 0x51, + 0x1c, 0x00, 0x83, 0x08, 0x4b, 0x3e, 0x1c, 0x1b, 0xe2, 0xb0, + 0x4b, 0x06, 0x03, 0x32, 0xa8, 0xc0, 0xc6, 0x08, 0xb5, 0x6c, + 0x02, 0xa6, 0x00, 0x22, 0xa0, 0xd8, 0x53, 0x1a, 0x0c, 0x0d, + 0x78, 0x97, 0x8c, 0x1c, 0x60, 0xa2, 0x5e, 0xc3, 0x21, 0x86, + 0x8c, 0x0c, 0x55, 0x41, 0x28, 0x46, 0x1b, 0x82, 0x35, 0x85, + 0x4e, 0x03, 0xc1, 0x62, 0x31, 0x8b, 0x83, 0x0b, 0x18, 0x54, + 0x30, 0xbc, 0x1c, 0x38, 0x13, 0x02, 0x08, 0x03, 0x18, 0x08, + 0x86, 0x1a, 0x36, 0x09, 0x33, 0x15, 0x1d, 0x00, 0x0b, 0xf0, + 0xc1, 0x60, 0x2c, 0x0c, 0x58, 0x13, 0x01, 0xc6, 0x0e, 0xa2, + 0xc7, 0x87, 0x0b, 0x3e, 0x16, 0x40, 0x22, 0x88, 0xb8, 0x27, + 0x11, 0x07, 0x07, 0x04, 0xf4, 0xfb, 0x84, 0x30, 0x8e, 0x08, + 0x30, 0xb2, 0x18, 0x08, 0xd8, 0x53, 0xf8, 0x8a, 0x5f, 0x15, + 0x86, 0x10, 0x1b, 0x54, 0x03, 0x11, 0x40, 0x3f, 0xe8, 0x30, + 0x84, 0x15, 0x02, 0xc4, 0x61, 0x44, 0x61, 0x62, 0xe1, 0x7f, + 0xba, 0x84, 0xe1, 0x03, 0x0b, 0x1a, 0x02, 0x2c, 0xcb, 0xfc, + 0x39, 0xc2, 0x4c, 0x26, 0x36, 0x18, 0x68, 0x19, 0x5d, 0x7f, + 0x49, 0x5c, 0x61, 0xc2, 0xd0, 0xa7, 0x42, 0xfe, 0xeb, 0x9a, + 0x01, 0x10, 0x10, 0x9c, 0x2b, 0x46, 0x00, 0x08, 0x91, 0x60, + 0x61, 0x5f, 0x1a, 0x0a, 0xce, 0x2c, 0x0b, 0x30, 0xc2, 0xff, + 0x41, 0x1f, 0xf8, 0xc0, 0x23, 0x03, 0x18, 0x69, 0x62, 0x58, + 0x0f, 0xe0, 0x43, 0x02, 0x11, 0x85, 0x21, 0x84, 0xf7, 0xff, + 0xb7, 0xc6, 0x14, 0x50, 0xc1, 0x0c, 0x66, 0xa1, 0x2e, 0xb0, + 0xc0, 0xa5, 0xd0, 0xcc, 0xc6, 0x15, 0xa8, 0xa5, 0xfc, 0x38, + 0x4b, 0x00, 0xe1, 0xc0, 0x25, 0xc4, 0x54, 0x09, 0x14, 0x50, + 0x4b, 0xd2, 0x25, 0xc5, 0x68, 0xac, 0x2a, 0x04, 0xe2, 0x90, + 0x27, 0xf1, 0x2f, 0xdc, 0x61, 0x67, 0xe2, 0x32, 0x0d, 0xc0, + 0x80, 0xe2, 0xb6, 0x2b, 0x0d, 0x8a, 0x18, 0x30, 0x51, 0x4a, + 0xbb, 0xff, 0xfc, 0x4e, 0xfc, 0x6a, 0xa2, 0xb0, 0x97, 0x0e, + 0x75, 0x0c, 0x21, 0x82, 0x06, 0x8b, 0x11, 0x86, 0x8c, 0x38, + 0x2c, 0x0c, 0x5a, 0x97, 0xff, 0x83, 0x17, 0x87, 0x20, 0x96, + 0x29, 0x05, 0x8a, 0xc6, 0x10, 0x2b, 0x38, 0x20, 0xc0, 0x06, + 0xc0, 0x82, 0xc0, 0xc8, 0x60, 0x4a, 0x1a, 0xd1, 0xaf, 0xff, + 0xb8, 0xc3, 0x38, 0x43, 0x04, 0x8a, 0x31, 0x81, 0x0a, 0x30, + 0x81, 0x86, 0x8c, 0x2c, 0x08, 0x5c, 0x18, 0x00, 0x0b, 0x82, + 0x84, 0x60, 0x0e, 0x07, 0xff, 0xf1, 0x2f, 0x0c, 0x13, 0x40, + 0x84, 0xe5, 0x41, 0x58, 0x1d, 0xf1, 0x90, 0x70, 0x94, 0x30, + 0xa6, 0x02, 0x82, 0x90, 0xb5, 0x81, 0xff, 0xfc, 0xf1, 0xbe, + 0x60, 0x4c, 0x18, 0x30, 0xe1, 0x84, 0x0a, 0x50, 0x21, 0x80, + 0x90, 0xb0, 0x2d, 0x30, 0xb4, 0x34, 0x04, 0x11, 0x6f, 0xff, + 0xf8, 0x5c, 0x61, 0x45, 0xe0, 0x40, 0x22, 0x30, 0xaa, 0x18, + 0x30, 0x41, 0x2c, 0x60, 0xc3, 0x09, 0x11, 0xe8, 0x42, 0x30, + 0x8e, 0x04, 0x0c, 0x2b, 0x7f, 0xfe, 0x80, 0x45, 0xf8, 0x8e, + 0x23, 0x0d, 0xc3, 0x81, 0x04, 0x51, 0x14, 0x0f, 0xe2, 0x1a, 0x10, + 0x07, 0xf2, 0x48, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x29, 0x96, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x92, 0x03, 0x42, 0x1e, 0xc1, + 0x80, 0xba, 0x03, 0x54, 0x13, 0xe6, 0x88, 0xc0, 0xb6, 0x28, + 0x30, 0x39, 0x08, 0x01, 0x48, 0x53, 0x16, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x07, 0x81, 0x00, 0x00, + 0x00, 0x50, 0x2b, 0x0a, 0x42, 0x50, 0x45, 0x85, 0x4e, 0x08, + 0x64, 0x0c, 0x58, 0x86, 0x30, 0x06, 0x06, 0x70, 0x24, 0x00, + 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x44, 0xb6, 0x1f, 0xe4, 0xb6, 0x31, 0x25, 0x43, 0xb1, 0x87, + 0xc1, 0x11, 0x86, 0xa1, 0x10, 0xe4, 0x3d, 0x5e, 0x1c, 0x42, + 0xe9, 0x64, 0xb9, 0x6b, 0x80, 0x29, 0x85, 0xdb, 0xc3, 0x4c, + 0x52, 0xb0, 0x84, 0x86, 0x88, 0x0c, 0x00, 0x02, 0x43, 0xb3, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x83, 0x00, 0x00, + 0x0a, 0x26, 0x8a, 0x1e, 0x82, 0x98, 0x07, 0x01, 0x51, 0x85, + 0x80, 0x42, 0x11, 0x8f, 0xd2, 0x30, 0xbf, 0x0a, 0x09, 0xcb, + 0x45, 0x10, 0x98, 0x78, 0x18, 0xe0, 0xf8, 0xf4, 0x2d, 0x01, + 0x80, 0xc0, 0x60, 0x30, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0xd8, 0x24, 0x00, 0x14, 0x87, 0xe0, 0x11, 0x01, 0xc1, + 0x2a, 0x07, 0x07, 0x01, 0x81, 0xa1, 0x9e, 0x74, 0x38, 0x1c, + 0x0e, 0x04, 0x2c, 0x21, 0x84, 0x02, 0xd4, 0x31, 0x00, 0xa8, + 0x82, 0x36, 0x30, 0xc8, 0xe4, 0x0c, 0x32, 0xbb, 0x8a, 0xb7, + 0x00, 0x98, 0x08, 0x2e, 0x61, 0xec, 0x00, 0x4a, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xbf, 0xf8, 0x04, 0x03, 0x40, 0x00, + 0x45, 0xe9, 0x40, 0x40, 0xd2, 0x0a, 0x84, 0x78, 0xf4, 0x66, + 0xf8, 0x4a, 0x92, 0x82, 0x4c, 0xc9, 0xd0, 0x12, 0xb4, 0x68, + 0x83, 0x27, 0xb0, 0x36, 0x02, 0x80, 0x98, 0x09, 0x84, 0xe1, + 0x60, 0x0c, 0x0d, 0x03, 0x74, 0x0b, 0x86, 0x40, 0x1e, 0x89, + 0xf0, 0x1f, 0x81, 0x4e, 0x00, 0x2b, 0xf0, 0x04, 0x80, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x09, 0x96, 0x24, + 0x09, 0x0d, 0x14, 0x03, 0x87, 0x80, 0xe8, 0x54, 0x09, 0x0f, + 0xf4, 0x09, 0x33, 0x9e, 0xd0, 0x4e, 0x0c, 0x31, 0x80, 0x41, + 0x84, 0x98, 0xe3, 0xc1, 0x88, 0x27, 0xa0, 0xd2, 0x0a, 0x90, + 0x66, 0x4b, 0x0d, 0xc0, 0xac, 0x61, 0x97, 0x9c, 0x12, 0x1b, + 0xec, 0x51, 0x5c, 0x48, 0xa2, 0x9e, 0x1d, 0x03, 0x12, 0x03, + 0x0c, 0xe4, 0x53, 0xb2, 0x80, 0x1c, 0xe2, 0xc2, 0xc0, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x60, 0x01, 0x57, 0x04, 0x86, 0x48, + 0x04, 0xf9, 0x01, 0x20, 0x2e, 0x15, 0x94, 0x01, 0x0e, 0xf2, + 0x9f, 0x40, 0x51, 0x6c, 0x0d, 0x06, 0x24, 0x50, 0x48, 0x00, + 0x83, 0x65, 0x05, 0x67, 0x25, 0x36, 0x7a, 0x26, 0x83, 0xd1, + 0x9e, 0xc2, 0x7f, 0x40, 0xd0, 0x2a, 0x14, 0x26, 0xb8, 0xac, + 0x64, 0x86, 0xd8, 0x47, 0x84, 0x89, 0x4e, 0x79, 0xc8, 0x21, + 0x4c, 0x24, 0x17, 0xa6, 0x6a, 0x51, 0x32, 0x6b, 0x93, 0x20, + 0xa1, 0x72, 0x65, 0x97, 0x77, 0x03, 0x18, 0x88, 0x41, 0xe0, + 0x88, 0x40, 0x21, 0x4e, 0xb6, 0x05, 0x60, 0x02, 0x40, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x8f, 0x03, 0x44, 0xc0, + 0x23, 0x20, 0x06, 0x88, 0x32, 0x16, 0x19, 0xc2, 0xc9, 0x79, + 0xf4, 0xd9, 0x3d, 0x32, 0x22, 0xc9, 0x4e, 0x41, 0x80, 0x4c, + 0x34, 0x0b, 0x31, 0x82, 0x19, 0x80, 0x93, 0x3c, 0xf2, 0x04, + 0xa4, 0x39, 0x21, 0x8c, 0xd6, 0x12, 0x40, 0x80, 0x84, 0x1a, + 0x6e, 0xe3, 0x09, 0xe8, 0x4c, 0x1a, 0x00, 0xe0, 0x49, 0xa8, + 0x02, 0xb2, 0x31, 0x06, 0x60, 0xf8, 0x28, 0x11, 0x68, 0x24, + 0x14, 0x82, 0xfc, 0x82, 0xf9, 0x82, 0x07, 0x48, 0xab, 0x25, + 0xca, 0x0e, 0x44, 0x6a, 0x28, 0x24, 0x28, 0x54, 0x1a, 0x80, + 0x44, 0x46, 0x80, 0xa4, 0x63, 0x2e, 0x02, 0x90, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x21, 0xbf, 0xc1, 0xa0, 0x78, 0x2c, + 0xc5, 0xde, 0x80, 0xc0, 0x4c, 0x22, 0x22, 0x53, 0x01, 0xc8, + 0x38, 0x18, 0x42, 0xbb, 0x05, 0xb3, 0x26, 0xc0, 0xf6, 0x4b, + 0x01, 0xd0, 0x12, 0x01, 0xac, 0x0f, 0x18, 0x73, 0x6d, 0x2c, + 0x8c, 0x85, 0x28, 0x4c, 0x90, 0x80, 0x10, 0x82, 0x5d, 0x50, + 0x13, 0xd6, 0x34, 0xc8, 0x08, 0x4b, 0x09, 0x86, 0x64, 0x06, + 0xb3, 0xdd, 0xa6, 0x4b, 0xd2, 0x6c, 0x97, 0x27, 0xf0, 0x8d, + 0x45, 0xd1, 0x81, 0xc2, 0x0c, 0x2e, 0x44, 0x98, 0xe1, 0x26, + 0xbd, 0xaa, 0x12, 0x6b, 0xfb, 0x80, 0x90, 0xdc, 0x42, 0x16, + 0xdf, 0xd4, 0xd4, 0x08, 0x5c, 0xa3, 0x75, 0xbc, 0x82, 0x09, + 0x83, 0x01, 0x81, 0x70, 0xbb, 0x30, 0xb4, 0x41, 0x4c, 0x68, + 0x30, 0x29, 0x02, 0x82, 0x1f, 0x0c, 0x71, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x07, 0x83, 0x80, 0x18, 0x06, 0x10, 0x47, 0x43, + 0xb0, 0x48, 0x81, 0xa0, 0x13, 0x6d, 0x9c, 0x84, 0xc5, 0xd9, + 0x85, 0x6e, 0x15, 0x79, 0x5c, 0xc5, 0x32, 0xf8, 0x51, 0x31, + 0x96, 0x2e, 0x00, 0x01, 0x05, 0xc0, 0x92, 0x89, 0x08, 0x60, + 0x9b, 0x32, 0x58, 0x25, 0xad, 0xc0, 0x8a, 0x18, 0x66, 0x43, + 0x58, 0x51, 0xb0, 0x11, 0x08, 0x94, 0x01, 0x22, 0x5b, 0xe0, + 0x4c, 0x84, 0x14, 0x80, 0x4a, 0x9c, 0x02, 0x8a, 0x00, 0x38, + 0xe1, 0xf5, 0x3b, 0x20, 0x21, 0x28, 0x1e, 0x0b, 0xd8, 0x80, + 0x81, 0x8a, 0x89, 0x64, 0xb1, 0x2f, 0xe3, 0x30, 0x2d, 0xd4, + 0x20, 0x08, 0x43, 0xf1, 0x19, 0x0a, 0x85, 0x9e, 0xb2, 0xd0, + 0x00, 0x54, 0x56, 0x50, 0x2c, 0x04, 0x80, 0xee, 0x0e, 0x8a, + 0x54, 0x29, 0x10, 0xa5, 0x82, 0xfb, 0x82, 0xc3, 0x80, 0x10, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x01, 0x37, 0xf0, 0x00, 0x01, + 0xeb, 0x59, 0x3d, 0x83, 0x21, 0x41, 0xf6, 0xdd, 0x22, 0xc9, + 0x72, 0x6c, 0x8a, 0xc1, 0x04, 0x9a, 0x5b, 0x94, 0x12, 0x1e, + 0x5a, 0x09, 0x11, 0x2c, 0x0a, 0x2d, 0x05, 0x6b, 0x57, 0x64, + 0xcc, 0x34, 0x47, 0x00, 0x88, 0x2a, 0xa0, 0x7a, 0x41, 0x8b, + 0xb2, 0x88, 0x20, 0x9b, 0xf0, 0x24, 0x40, 0x46, 0x09, 0x54, + 0xe0, 0x68, 0x27, 0xf0, 0x09, 0x68, 0x80, 0xb4, 0x23, 0x53, + 0x38, 0x84, 0x1f, 0x02, 0x6d, 0x62, 0x05, 0x78, 0x49, 0x98, + 0x0e, 0x18, 0xc6, 0x43, 0x20, 0x21, 0x02, 0x0a, 0x44, 0x64, + 0x1c, 0x1d, 0x04, 0xa0, 0xc8, 0x07, 0x07, 0xe1, 0x28, 0xa6, + 0x6c, 0x37, 0xc5, 0x51, 0x86, 0xdd, 0x00, 0xbd, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x2b, 0x80, 0x01, 0xb3, 0x13, 0xe8, 0x76, + 0x09, 0xea, 0x04, 0x23, 0x0b, 0x21, 0x01, 0x02, 0x18, 0x07, + 0x00, 0x8c, 0xd2, 0x0d, 0x64, 0xc8, 0x1b, 0x09, 0x30, 0x48, + 0xa5, 0x97, 0x0d, 0x20, 0xa0, 0x91, 0x27, 0x08, 0x32, 0x41, + 0x56, 0x04, 0x99, 0xcf, 0x20, 0x4a, 0x09, 0xb8, 0x86, 0x49, + 0x19, 0xc0, 0x48, 0xd4, 0xf3, 0x82, 0xae, 0x38, 0x63, 0x04, + 0x26, 0x16, 0x1e, 0x30, 0xd7, 0x4c, 0x80, 0x12, 0x50, 0xfd, + 0x92, 0xe2, 0x03, 0x9f, 0x40, 0x2b, 0x67, 0x38, 0x16, 0x17, + 0x4f, 0xf9, 0x76, 0xaf, 0x09, 0x8b, 0xb9, 0x84, 0x00, 0x02, + 0x8f, 0x2c, 0x00, 0x5d, 0x03, 0x50, 0x00, 0x42, 0x13, 0x06, + 0x60, 0x96, 0xc3, 0xd0, 0x00, 0x3c, 0x10, 0xc0, 0x4e, 0x02, + 0x00, 0x04, 0xe0, 0xf0, 0x23, 0x60, 0x00, 0x00, 0x00, 0x00, + 0x24, 0x1b, 0xe0, 0x00, 0x04, 0x02, 0xe9, 0x4c, 0x97, 0x26, + 0x40, 0x70, 0x24, 0x3b, 0x50, 0xb6, 0x40, 0x54, 0x41, 0x26, + 0x79, 0xa4, 0x94, 0xbc, 0xc5, 0x97, 0x18, 0x61, 0x88, 0x2e, + 0x70, 0x22, 0x62, 0x3c, 0x02, 0x05, 0x80, 0x90, 0xea, 0x06, + 0x68, 0xf4, 0xb2, 0x66, 0x06, 0x09, 0x33, 0x07, 0x54, 0x83, + 0x64, 0xcc, 0x28, 0xc1, 0x60, 0xba, 0x08, 0x8d, 0x1a, 0xf1, + 0xa0, 0x84, 0x85, 0x81, 0x94, 0x23, 0x06, 0x2f, 0x22, 0xb2, +}; + +static guint8 bframe2_adv[] = { + 0x46, 0x88, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0xf8, 0xa1, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, + 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, +}; + +static guint8 pframe_adv[] = { + 0x24, 0x20, 0x04, 0xbf, 0x85, 0x88, 0x65, 0xc1, 0x00, 0xdc, + 0x4c, 0x06, 0xce, 0x05, 0x01, 0x01, 0x41, 0x0c, 0x60, 0x42, + 0x67, 0xff, 0xfb, 0x85, 0x0b, 0x9c, 0x56, 0x0d, 0x0b, 0x1b, + 0x8c, 0x08, 0x08, 0x47, 0x1b, 0xce, 0xc1, 0x83, 0x09, 0x8a, + 0xa1, 0x83, 0x09, 0x16, 0x7f, 0xff, 0x98, 0x94, 0xff, 0x81, + 0x4f, 0xf9, 0x41, 0xe1, 0x83, 0x01, 0xff, 0xff, 0x14, 0x40, + 0xcd, 0x70, 0xd7, 0xf2, 0xf7, 0xc1, 0xf1, 0x18, 0x59, 0xff, + 0xfc, 0x51, 0x18, 0x68, 0x2c, 0xd4, 0x54, 0x16, 0xbf, 0xfe, + 0x0c, 0xf1, 0x81, 0x28, 0x67, 0xff, 0x86, 0x39, 0x05, 0xe6, + 0x5f, 0xff, 0xe0, 0x48, 0xc0, 0xff, 0xfe, 0x61, 0x18, 0x37, + 0xff, 0x97, 0xdc, 0x1c, 0x45, 0x06, 0x06, 0xff, 0xf0, 0x30, + 0x7d, 0x17, 0xff, 0xff, 0x86, 0x07, 0x03, 0xff, 0xf9, 0x01, + 0xf0, 0x7f, 0xff, 0xdf, 0xc1, 0x20, 0x9f, 0xfd, 0x0c, 0x0f, + 0x86, 0x7f, 0xff, 0xee, 0x50, 0xef, 0xfe, 0xc1, 0xa5, 0xc6, + 0x1b, 0xff, 0xff, 0x86, 0x61, 0x9f, 0xfc, 0x1c, 0x1f, 0xa2, + 0xff, 0xff, 0xe0, 0xf8, 0x10, 0x1f, 0xfe, 0x0e, 0x0f, 0x99, + 0x95, 0xff, 0xff, 0xb8, 0x3e, 0xe5, 0xff, 0x81, 0x83, 0xe1, + 0x6b, 0xff, 0xff, 0x40, 0xc0, 0x7c, 0x30, 0xbf, 0xe0, 0xb2, + 0x0e, 0x09, 0x61, 0x53, 0xff, 0xfd, 0x60, 0x20, 0xfc, 0x27, + 0xf0, 0x96, 0x51, 0x26, 0x6c, 0xcf, 0xff, 0xff, 0xe7, 0x60, + 0xe0, 0xb5, 0xee, 0x82, 0xa0, 0xb8, 0x41, 0x32, 0x3f, 0x2f, + 0xcd, 0x3f, 0xa0, 0xa8, 0x96, 0x8e, 0x2a, 0x4c, 0x08, 0x6e, + 0x36, 0x1a, 0x83, 0x2a, 0x8b, 0x02, 0xcb, 0x2f, 0xff, 0xe9, + 0xf8, 0xa4, 0x0e, 0x00, 0x12, 0xc1, 0x88, 0xc3, 0x0c, 0x05, + 0x51, 0x44, 0x61, 0xa3, 0x0b, 0x18, 0x58, 0x38, 0x70, 0x97, + 0xff, 0xff, 0xf8, 0x8c, 0x14, 0x2c, 0x0c, 0x19, 0x86, 0x0c, + 0x27, 0x09, 0xc1, 0x03, 0x08, 0x62, 0xc0, 0xff, 0xff, 0xfe, + 0x94, 0x6d, 0x22, 0x77, 0xc0, 0x44, 0x71, 0x1c, 0x60, 0xe5, + 0xb7, 0xff, 0xfe, 0xbf, 0xba, 0x57, 0x82, 0x0c, 0x24, 0xc8, + 0x5a, 0xbf, 0xff, 0xff, 0xcb, 0x14, 0xc8, 0x30, 0x43, 0x16, + 0x29, 0x51, 0x86, 0x0b, 0x00, 0x51, 0x60, 0x60, 0xc0, 0x17, + 0x75, 0xff, 0xf9, 0x77, 0x0e, 0x18, 0x4b, 0x84, 0xc5, 0x47, + 0x11, 0xc5, 0x10, 0x68, 0x1b, 0x8c, 0x00, 0x6a, 0x71, 0x60, + 0xc0, 0x46, 0xe2, 0xe0, 0x22, 0x65, 0xff, 0xd6, 0x09, 0x0e, + 0x01, 0x15, 0x55, 0x85, 0x48, 0x28, 0x8f, 0xc2, 0x42, 0x06, + 0x1c, 0x23, 0x8b, 0x01, 0x42, 0x74, 0x08, 0x61, 0x9f, 0xff, + 0xc2, 0xca, 0x19, 0x81, 0x02, 0x10, 0x20, 0xc0, 0x1c, 0x5c, + 0x13, 0x84, 0xe6, 0x1a, 0x8b, 0x02, 0x38, 0x98, 0x09, 0x98, + 0xa3, 0xff, 0xfd, 0xc9, 0x05, 0x5e, 0x82, 0x18, 0xc1, 0x40, + 0xc6, 0xf6, 0x04, 0x14, 0x40, 0x60, 0x80, 0xfd, 0x04, 0x6f, + 0xff, 0xf4, 0x58, 0x0a, 0xf8, 0x86, 0x30, 0x02, 0x14, 0x44, + 0xe2, 0xc2, 0x43, 0x3c, 0x1b, 0xff, 0x86, 0xb5, 0x66, 0x16, + 0xf0, 0x7f, 0xa0, 0x9c, 0x5e, 0x84, 0x07, 0xd1, 0x73, 0xff, + 0xee, 0x88, 0xc2, 0xe1, 0x7f, 0xfc, 0xc0, 0xf0, 0x59, 0x65, + 0xfe, 0x9f, 0x70, 0xbf, 0xff, 0xdc, 0x1e, 0x2a, 0x02, 0x57, + 0xff, 0xc0, 0x26, 0x2d, 0x3c, 0x4d, 0x5f, 0xff, 0xc4, 0xc1, + 0x30, 0x11, 0x15, 0xc4, 0xaf, 0xfc, 0x5c, 0x0e, 0x0e, 0x0e, + 0x84, 0x8c, 0x34, 0x34, 0xbf, 0xff, 0x11, 0x81, 0x30, 0x10, + 0x48, 0x87, 0xf9, 0x43, 0x05, 0x25, 0x04, 0x11, 0x43, 0x70, + 0x4f, 0xff, 0xfd, 0x04, 0xe1, 0x0e, 0xfe, 0x6f, 0x83, 0x88, + 0xe1, 0x98, 0x76, 0x0f, 0xfc, 0x89, 0x0e, 0xe7, 0xc2, 0x78, + 0x4c, 0x24, 0xd4, 0x18, 0x8c, 0xbf, 0x27, 0x16, 0xd0, 0xb0, + 0xc9, 0xf4, 0x12, 0x6a, 0x08, 0xe4, 0x5c, 0x24, 0xbf, 0x46, + 0x60, 0xf6, 0x53, 0xf5, 0x6c, 0xff, 0x2e, 0x32, 0x09, 0x1e, + 0xab, 0x09, 0x00, 0x1e, 0x88, 0x56, 0x6e, 0x7a, 0x1c, 0xd0, + 0x30, 0x3c, 0xab, 0xf0, 0x44, 0x5a, 0x90, 0x4f, 0x9a, 0xf0, + 0xe6, 0x7d, 0x62, 0xc1, 0x87, 0x4b, 0xdb, 0xfd, 0x68, 0xd9, + 0x35, 0x3b, 0x01, 0x04, 0x81, 0x2c, 0x24, 0xee, 0xb3, 0x9b, + 0x65, 0x30, 0x49, 0x20, 0xa8, 0x08, 0xf6, 0xaf, 0x33, 0x80, + 0x38, 0x49, 0xa3, 0x94, 0x6e, 0x35, 0x06, 0x4d, 0xc3, 0x30, + 0x92, 0x7c, 0x3c, 0x6b, 0x9e, 0xd5, 0x31, 0x4d, 0x69, 0x87, + 0x2e, 0x04, 0x7e, 0x04, 0x12, 0x5f, 0xa3, 0x0a, 0xe4, 0x5b, + 0x21, 0x6c, 0x45, 0x54, 0x29, 0x11, 0x48, 0x8a, 0xa8, 0x52, + 0x22, 0xa8, 0x33, 0x06, 0xe0, 0xbd, 0xe8, 0x41, 0x00, 0x03, + 0x52, 0xe7, 0x00, 0x7d, 0xf0, 0x42, 0x4d, 0x0f, 0x20, 0x26, + 0x24, 0x09, 0xbb, 0x48, 0x1c, 0xeb, 0xa5, 0xa2, 0x0e, 0xed, + 0x11, 0x66, 0x97, 0x93, 0xb8, 0x4a, 0x70, 0x8a, 0x75, 0x38, + 0x47, 0xc1, 0x26, 0x3e, 0x50, 0x87, 0x33, 0xf2, 0x37, 0xc7, + 0x3b, 0x67, 0x09, 0x33, 0x44, 0xfc, 0xcd, 0xda, 0x19, 0xa6, + 0x3f, 0x27, 0xec, 0x24, 0x12, 0x64, 0x06, 0x13, 0xdd, 0x9e, + 0x81, 0x92, 0x17, 0x5f, 0xb3, 0xd9, 0x37, 0xf2, 0x0f, 0x15, + 0x00, 0x87, 0xb3, 0xe6, 0xc9, 0xc1, 0xbc, 0x24, 0x7f, 0x0f, + 0x7c, 0x76, 0x4c, 0xe0, 0xfb, 0xf7, 0x66, 0x4c, 0x9c, 0x19, + 0x32, 0x6f, 0xb2, 0x64, 0xfa, 0x00, 0x01, 0x26, 0xaa, 0xa4, + 0x16, 0x45, 0x1f, 0x94, 0xee, 0xde, 0x33, 0x09, 0x2e, 0x48, + 0xc2, 0x4b, 0xf4, 0x62, 0x91, 0x16, 0x00, 0x52, 0x20, 0xe2, + 0xba, 0xe2, 0x35, 0x42, 0xa7, 0xa0, 0x9c, 0x9e, 0xcc, 0x39, + 0x9d, 0x31, 0x00, 0xc3, 0xe0, 0x2a, 0x1f, 0x85, 0x61, 0xd3, + 0x63, 0x3f, 0x22, 0xa8, 0xd9, 0xc1, 0x50, 0x50, 0x2f, 0x21, + 0xb1, 0xd8, 0x49, 0x34, 0xa0, 0xb0, 0x0c, 0x7d, 0xe9, 0x53, + 0x27, 0x09, 0xf9, 0x1b, 0x33, 0x5d, 0x93, 0xb8, 0x48, 0x89, + 0xbb, 0x18, 0x4e, 0xf0, 0x44, 0x86, 0x13, 0x7a, 0x16, 0xc4, + 0x36, 0xc7, 0x24, 0xe2, 0x39, 0x20, 0x20, 0x62, 0xb0, 0xf1, + 0xa0, 0x21, 0xc7, 0x2a, 0xdf, 0xd6, 0xd1, 0x5e, 0xcf, 0xba, + 0x09, 0x92, 0xa4, 0xb7, 0xd6, 0x7b, 0x0b, 0xaa, 0x60, 0xe7, + 0x8c, 0xe2, 0xfb, 0xf8, 0xb1, 0x96, 0x70, 0xc5, 0xf7, 0x3d, + 0x7a, 0xce, 0x13, 0x09, 0x0f, 0xd4, 0x2c, 0xfe, 0x30, 0xdd, + 0xdc, 0x11, 0xb1, 0x4e, 0xab, 0x98, 0x0d, 0x45, 0xf0, 0x41, + 0x9d, 0x0c, 0xd6, 0xa1, 0x8e, 0x5c, 0xf4, 0xdf, 0x93, 0x88, + 0x3f, 0x23, 0x61, 0x23, 0x6e, 0xf4, 0x78, 0xac, 0xfa, 0x00, + 0x00, 0x07, 0x1f, 0x94, 0xe9, 0x13, 0xd3, 0x05, 0x61, 0x99, + 0x22, 0x49, 0xf8, 0x6d, 0xb9, 0xb3, 0x83, 0xa6, 0x70, 0x78, + 0xf3, 0x37, 0x54, 0xdf, 0xb6, 0x82, 0x67, 0x07, 0x3d, 0x66, + 0xea, 0x86, 0x72, 0xd3, 0x38, 0x3b, 0x0a, 0xcd, 0xd5, 0x0e, + 0x00, 0x07, 0x19, 0x6d, 0x92, 0x77, 0x3e, 0x0d, 0xba, 0x66, + 0xa6, 0x8c, 0x8d, 0x48, 0xf2, 0xe2, 0x38, 0x31, 0x7f, 0x71, + 0xf9, 0xe8, 0x6c, 0x46, 0xb1, 0x91, 0xc5, 0x6a, 0xbb, 0x16, + 0x36, 0x44, 0xb3, 0x67, 0x64, 0xcf, 0xee, 0xcc, 0x04, 0x61, + 0x7b, 0x91, 0x7e, 0xcd, 0x47, 0x27, 0x16, 0x0f, 0x04, 0x8f, + 0x02, 0x84, 0x8f, 0x85, 0xb5, 0xb3, 0x5a, 0x81, 0x23, 0xa8, +}; + +static guint8 pframe2_adv[] = { + 0x1c, 0x22, 0x1f, 0xdc, 0x9d, 0x3b, 0x81, 0x61, 0x85, 0x2, + 0x57, 0xa0, 0x50, 0xac, 0x03, 0x81, 0x0c, 0x39, 0x4f, 0xff, + 0xc2, 0x20, 0x9f, 0xf4, 0x86, 0x16, 0x8e, 0xe1, 0xda, 0x0c, + 0x24, 0x4b, 0x3f, 0xff, 0x03, 0x77, 0xfe, 0x05, 0x10, 0xc5, + 0x81, 0x3a, 0x50, 0x71, 0x4c, 0x56, 0x10, 0xfa, 0x06, 0x82, + 0xaf, 0xfe, 0x19, 0x49, 0x17, 0xb6, 0x42, 0xad, 0xf0, 0xe8, + 0x6f, 0xc0, 0x97, 0xff, 0x83, 0xd0, 0xce, 0x15, 0x16, 0x85, + 0xa6, 0x77, 0x09, 0xb3, 0xe1, 0x88, 0x30, 0xd0, 0x0f, 0x18, + 0x60, 0x40, 0x5f, 0xfe, 0x07, 0x6f, 0x6c, 0x18, 0x09, 0xdf, + 0xc3, 0x00, 0xee, 0x98, 0x39, 0x8b, 0x40, 0xff, 0xf8, 0x64, + 0xfb, 0xae, 0xae, 0x25, 0xc1, 0x61, 0xa1, 0xa1, 0x63, 0x06, + 0xba, 0xb8, 0x9a, 0x00, 0xe6, 0x40, 0x75, 0xff, 0x08, 0xfc, + 0xa2, 0x88, 0xa2, 0xf7, 0xd4, 0x47, 0xe2, 0x8b, 0x20, 0x11, + 0x02, 0xe0, 0xc1, 0x80, 0xdf, 0xe0, 0xff, 0xe2, 0x18, 0xe0, + 0x40, 0x42, 0xe0, 0xc0, 0x82, 0x59, 0x49, 0x9c, 0x4c, 0x60, + 0x95, 0x86, 0x60, 0xff, 0xf8, 0x22, 0x7d, 0x21, 0xa1, 0x62, + 0x60, 0xc0, 0x06, 0x06, 0x30, 0x90, 0xa0, 0xc1, 0xbb, 0xa0, + 0x10, 0x8e, 0xcf, 0xca, 0x17, 0x4f, 0xf0, 0x34, 0xfb, 0x00, + 0x88, 0xe0, 0xa3, 0x07, 0x04, 0x18, 0x30, 0xe2, 0xc8, 0x50, + 0xb4, 0x14, 0xac, 0x12, 0x9d, 0x30, 0xcf, 0xfb, 0x97, 0xeb, + 0x42, 0x14, 0x83, 0x45, 0x30, 0x31, 0x70, 0x4d, 0x14, 0xc5, + 0x10, 0x51, 0x4c, 0x61, 0x21, 0x4f, 0xf8, 0x1d, 0x7f, 0x0c, + 0xf8, 0x30, 0x1e, 0xa3, 0x00, 0x08, 0x0b, 0x15, 0x46, 0x0a, + 0x0a, 0x26, 0x87, 0x02, 0x06, 0x0a, 0xa3, 0x0a, 0x54, 0x18, + 0x62, 0x80, 0x70, 0x3f, 0xf0, 0xcf, 0xe6, 0x0e, 0x1a, 0x82, + 0x34, 0x30, 0x59, 0x14, 0xc6, 0xa3, 0x04, 0x18, 0x70, 0xc1, + 0x82, 0xc6, 0x05, 0x21, 0x27, 0xe0, 0x7f, 0xe1, 0x8d, 0xae, + 0x91, 0x6a, 0x1c, 0x04, 0x30, 0x00, 0xc1, 0xba, 0x90, 0x59, + 0x89, 0xda, 0xd4, 0x61, 0x8b, 0xc1, 0xfe, 0xda, 0x8c, 0x30, + 0xa0, 0x3d, 0xa3, 0x06, 0x0d, 0x01, 0x85, 0x08, 0x6e, 0x16, + 0x04, 0x30, 0x01, 0x30, 0x51, 0x06, 0x15, 0x1a, 0x03, 0xe2, + 0xd5, 0xeb, 0xa1, 0x98, 0x2d, 0x02, 0x97, 0x77, 0x57, 0x16, + 0x05, 0x61, 0x14, 0x92, 0x32, 0x50, 0x01, 0x4c, 0x46, 0x18, + 0x40, 0x97, 0x9a, 0x0a, 0x97, 0x70, 0xaf, 0x84, 0x84, 0xbd, + 0x7a, 0x45, 0x60, 0xa1, 0x14, 0x47, 0x17, 0x06, 0x00, 0x30, + 0x29, 0x44, 0x51, 0x24, 0x60, 0x62, 0x30, 0x15, 0x08, 0x19, + 0xda, 0xa2, 0x32, 0x06, 0x81, 0xf0, 0x0c, 0x30, 0x43, 0xeb, + 0x00, 0x06, 0x40, 0x60, 0x40, 0xb0, 0xe1, 0x68, 0x34, 0x0c, + 0x04, 0x6e, 0x29, 0x08, 0xc3, 0x01, 0x1b, 0x06, 0xe0, 0x00, + 0x37, 0x55, 0x03, 0xdc, 0x0e, 0xea, 0x04, 0xb2, 0xda, 0x09, + 0x21, 0x54, 0x60, 0xa2, 0x5d, 0x86, 0x02, 0x22, 0x81, 0x80, + 0x0b, 0x44, 0x82, 0x3d, 0x04, 0x71, 0x4a, 0x10, 0x11, 0xfc, + 0x61, 0x04, 0xc0, 0x5b, 0x01, 0x00, 0x46, 0x12, 0x07, 0x11, + 0x83, 0x05, 0x31, 0x24, 0x4a, 0x0c, 0x09, 0x04, 0x15, 0x00, + 0xd0, 0xdc, 0x0f, 0xd3, 0xfd, 0xc5, 0x86, 0x38, 0x5f, 0x85, + 0xc0, 0x42, 0xc2, 0x48, 0x61, 0x20, 0x41, 0x62, 0x48, 0xb0, + 0x0a, 0x49, 0x60, 0xb8, 0x96, 0xef, 0xad, 0xba, 0x60, 0x23, + 0x88, 0xa2, 0x39, 0x60, 0xa8, 0x23, 0x86, 0x8d, 0x02, 0x81, + 0x86, 0x18, 0x30, 0x23, 0x13, 0x42, 0xa3, 0x5b, 0x38, 0x14, + 0x20, 0x5a, 0x18, 0x4a, 0xae, 0x68, 0x8d, 0x4a, 0x8c, 0x00, + 0x51, 0x0e, 0x63, 0x18, 0x10, 0x9a, 0x0c, 0x70, 0x41, 0x38, + 0x46, 0x21, 0x18, 0x25, 0x00, 0x50, 0x95, 0xb8, 0x38, 0x75, + 0xe1, 0xab, 0xe8, 0xa2, 0x3f, 0x18, 0x77, 0xb9, 0xc5, 0x81, + 0x86, 0x0b, 0x2a, 0x21, 0x8c, 0x08, 0x2e, 0x2a, 0x0a, 0xa4, + 0x10, 0xd8, 0x58, 0x3e, 0x80, 0x25, 0x09, 0xcf, 0x47, 0x16, + 0xb9, 0x8a, 0x8e, 0x26, 0x0a, 0x76, 0x51, 0x18, 0x80, 0x19, + 0xa8, 0x0c, 0x9e, 0x5f, 0x6f, 0xd8, 0x59, 0xf7, 0x05, 0x13, + 0x14, 0x53, 0x30, 0x40, 0xa5, 0x04, 0x55, 0xb1, 0x00, 0x55, + 0x74, 0xf9, 0x83, 0xd4, 0xf1, 0x37, 0xee, 0x16, 0x32, 0x12, + 0xf4, 0x14, 0xc8, 0x4b, 0x30, 0xd4, 0x02, 0x92, 0x80, 0x61, + 0x02, 0x88, 0x94, 0xbf, 0xf8, 0x18, 0xc3, 0x97, 0xe5, 0x58, + 0xa8, 0x35, 0x98, 0x1a, 0xc1, 0x41, 0xd4, 0x19, 0xc6, 0x18, + 0x48, 0xb0, 0xbf, 0xfc, 0x1c, 0x56, 0x6e, 0x13, 0xcc, 0x04, + 0x4b, 0x07, 0x27, 0x55, 0x2f, 0x7d, 0x44, 0x61, 0x65, 0x3f, + 0xf0, 0xc0, 0xc0, 0xab, 0x89, 0x83, 0x0d, 0x67, 0x16, 0x00, + 0xc8, 0xa1, 0x84, 0x41, 0x95, 0x33, 0xb8, 0x2e, 0x18, 0x25, + 0xff, 0xf8, 0x18, 0x96, 0xa2, 0xc0, 0x18, 0x58, 0x06, 0x3a, + 0xbf, 0xc1, 0x96, 0xed, 0x10, 0xc4, 0x98, 0xc0, 0x46, 0x13, + 0xff, 0xe1, 0x63, 0x03, 0x17, 0x01, 0x6e, 0x74, 0x06, 0x70, + 0x2a, 0x6a, 0xb3, 0x74, 0x07, 0x61, 0x58, 0x2c, 0x2d, 0xbf, + 0xfd, 0x01, 0x42, 0x30, 0x85, 0xfb, 0xc6, 0x1a, 0x0a, 0x14, + 0x2c, 0x5c, 0x08, 0xbc, 0x43, 0x2f, 0xc2, 0x5f, 0x72, 0x8b, + 0x9c, 0x32, 0x06, 0x0a, 0x27, 0x03, 0x50, 0x61, 0x5f, 0x41, + 0x4e, 0x19, 0x83, 0xff, 0xfb, 0x42, 0x3e, 0x6e, 0x34, 0x12, + 0x7f, 0x75, 0x18, 0x04, 0x1f, 0x06, 0x86, 0x7f, 0xf9, 0x44, + 0x97, 0xee, 0x0d, 0xe9, 0xf2, 0x38, 0x3e, 0xf8, 0x37, 0xfe, + 0x98, 0x1c, 0xd6, 0x30, 0x11, 0x2f, 0xff, 0xe0, 0x76, 0x50, + 0x38, 0x5f, 0xfe, 0x70, 0xc4, 0x29, 0x0b, 0x82, 0x2f, 0xff, + 0xe0, 0x62, 0x48, 0xc3, 0x85, 0x10, 0xa1, 0x69, 0x17, 0xfe, + 0x50, 0xc8, 0x5f, 0x4f, 0xff, 0xfc, 0x30, 0xa0, 0x7f, 0xe9, + 0x0c, 0x00, 0xc2, 0x7f, 0xff, 0xf9, 0x0a, 0x82, 0x56, 0x0d, + 0xfe, 0xd0, 0x8e, 0xff, 0xff, 0xfd, 0x04, 0x64, 0x58, 0x5f, + 0xfe, 0x0f, 0xdc, 0x5a, 0xff, 0xff, 0xe0, 0x9c, 0x33, 0xfd, + 0x60, 0x7c, 0x38, 0x0f, 0xff, 0xff, 0x81, 0xf8, 0x1f, 0xfc, + 0x0f, 0x82, 0x7f, 0xff, 0xe8, 0xe5, 0x3c, 0x0f, 0xf7, 0xc0, + 0xf8, 0xc3, 0x17, 0xff, 0xff, 0x13, 0x37, 0xc1, 0xbf, 0xe0, + 0x70, 0xcc, 0xbf, 0xff, 0xf1, 0x85, 0xfc, 0x1f, 0xfe, 0x07, + 0x83, 0x2f, 0xff, 0xff, 0x1b, 0x7c, 0x1f, 0xfd, 0x42, 0x94, + 0x36, 0x9f, 0xff, 0xfc, 0x1f, 0xe0, 0xfd, 0x99, 0x86, 0x02, + 0x1a, 0x29, 0x81, 0x21, 0x7f, 0xff, 0xfc, 0x83, 0x95, 0x85, + 0x11, 0x60, 0x60, 0x22, 0xc8, 0xd0, 0xc2, 0xc4, 0xb5, 0x83, + 0x95, 0x27, 0xa7, 0xff, 0xfc, 0x85, 0x85, 0xb4, 0x47, 0x24, + 0x18, 0x28, 0xaa, 0x1a, 0x23, 0x2a, 0x84, 0xdb, 0xff, 0xff, + 0xf2, 0x63, 0x92, 0xc4, 0xc0, 0x21, 0xc0, 0xc2, 0xc0, 0x00, + 0x82, 0xc6, 0x00, 0x28, 0x89, 0x72, 0xff, 0xff, 0xef, 0x16, + 0x05, 0x11, 0x1c, 0x61, 0x22, 0x38, 0x50, 0xb8, 0x2a, 0xbb, + 0x9c, 0xe7, 0xcf, 0xff, 0xff, 0xe6, 0x30, 0xce, 0x0f, 0xc0, + 0x04, 0x71, 0x1d, 0xff, 0xff, 0xff, 0xfb, 0xb7, 0x07, 0xe1, + 0x21, 0x82, 0xc0, 0x87, 0x6b, 0xb7, 0xff, 0xff, 0xf7, 0x0c, + 0x10, 0xc5, 0x85, 0x40, 0x96, 0x12, 0x58, 0xe1, 0xc1, 0x5d, + 0xff, 0xff, 0xfb, 0x89, 0xcb, 0x84, 0x30, 0x9c, 0x2a, 0xc5, + 0x41, 0x64, 0x5a, 0xee, 0x0d, 0x8a, 0x61, 0x4b, 0xff, 0xff, + 0x0c, 0xc0, 0x86, 0x10, 0x23, 0x8a, 0x42, 0xe3, 0x0a, 0xc0, + 0x23, 0x07, 0x14, 0x6e, 0x2c, 0x09, 0x4e, 0x2c, 0x05, 0x82, + 0x01, 0x02, 0x2f, 0xff, 0xf4, 0x07, 0xb0, 0x8d, 0x02, 0x09, + 0x14, 0x45, 0x81, 0x86, 0xb8, 0x10, 0xb0, 0x27, 0x00, 0x30, + 0xaa, 0x21, 0x85, 0x80, 0x5c, 0x56, 0x2f, 0xff, 0xf0, 0x7a, + 0x0c, 0x01, 0x68, 0x14, 0x08, 0x1a, 0x82, 0x3d, 0xc2, 0xc4, + 0xe0, 0x60, 0xc0, 0x0e, 0x30, 0x10, 0x6f, 0xff, 0xf4, 0x5b, + 0x8b, 0x3e, 0x30, 0x92, 0x70, 0xc1, 0x86, 0x80, 0x48, 0x33, + 0xc0, 0x82, 0xc5, 0x8f, 0xff, 0xf0, 0xb7, 0x88, 0xed, 0xf1, + 0x85, 0x80, 0x7c, 0x1b, 0xa0, 0x9d, 0xff, 0xfe, 0x51, 0x47, + 0x45, 0xff, 0x94, 0x2f, 0x0c, 0x15, 0x46, 0xff, 0xff, 0xd3, + 0x0c, 0x58, 0x67, 0xfe, 0x74, 0x57, 0x11, 0x80, 0xc6, 0x14, + 0xe2, 0xc0, 0xa9, 0xff, 0x9d, 0xd4, 0x34, 0x61, 0xc2, 0x5a, + 0x09, 0x7f, 0xfa, 0x60, 0xc0, 0x80, 0x8c, 0x6e, 0x62, 0x6a, + 0xff, 0xc4, 0x50, 0x3c, 0x86, 0x1a, 0x70, 0x3f, 0xfe, 0x0d, + 0x8b, 0x90, 0xc7, 0x04, 0x10, 0xd7, 0xfe, 0x10, 0x00, 0x28, + 0x82, 0x0b, 0x01, 0xc3, 0x0a, 0x84, 0x7f, 0xfb, 0xc2, 0x36, + 0x10, 0xf3, 0xf5, 0xe1, 0x64, 0x80, 0x88, 0x0e, 0x29, 0x94, + 0x1f, 0xf2, 0x49, 0xcf, 0xc9, 0xe4, 0xf3, 0xf2, 0x79, 0x3c, + 0xfc, 0x9e, 0x4f, 0x3f, 0x27, 0x93, 0xcf, 0xc9, 0xe4, 0xf3, + 0xf2, 0x79, 0x3c, 0xe2, 0x2f, 0xc9, 0xc9, 0x5c, 0x62, 0x09, + 0x32, 0x51, 0x20, 0x69, 0x21, 0xa1, 0x4e, 0xe0, 0x60, 0x79, + 0xcd, 0x39, 0x96, 0x2a, 0x12, 0x65, 0x1b, 0x59, 0x45, 0x60, + 0x94, 0x98, 0x24, 0xd4, 0x4e, 0xc1, 0xf0, 0x48, 0x73, 0xbd, + 0xf8, 0xce, 0xd1, 0x9d, 0x6f, 0x70, 0xcc, 0x91, 0x08, 0xc2, + 0x4e, 0x77, 0x92, 0x21, 0x18, 0x49, 0xd0, 0xf7, 0x47, 0x21, + 0x08, 0xc2, 0x4e, 0x87, 0x92, 0x21, 0x18, 0x48, 0x90, 0xba, + 0x67, 0x43, 0xf2, 0x44, 0x58, 0x24, 0xe7, 0x79, 0x2b, 0xbe, + 0x78, 0xc2, 0x94, 0xbc, 0x90, 0x94, 0x7a, 0x84, 0xc4, 0x82, + 0x71, 0xeb, 0x25, 0xf2, 0x4e, 0xe6, 0x1f, 0x0f, 0x59, 0x08, + 0xb7, 0x41, 0xf1, 0x55, 0xc2, 0x4c, 0x29, 0x7a, 0x09, 0x33, + 0xd9, 0x81, 0x9e, 0x49, 0x9b, 0x2c, 0xf2, 0x79, 0xf9, 0x3c, + 0x9e, 0x7e, 0x4f, 0x27, 0x9f, 0x93, 0xc9, 0xe7, 0xe4, 0xf2, + 0x79, 0xc6, 0x63, 0x3e, 0x73, 0xc8, 0xf2, 0xe7, 0xe4, 0xf2, + 0x79, 0xf9, 0x3c, 0x9e, 0x7e, 0x4f, 0x27, 0x9f, 0x93, 0xc9, + 0xe7, 0xe4, 0xf2, 0x42, 0x4b, 0x35, 0xa2, 0x8b, 0xd5, 0x18, + 0x71, 0xf4, 0x0f, 0xc8, 0x49, 0x92, 0x6d, 0x61, 0xc1, 0x4a, + 0x94, 0x7d, 0x09, 0x15, 0x4c, 0x00, 0x48, 0xa8, 0x78, 0x12, + 0x29, 0xfb, 0x3f, 0x89, 0x82, 0x4d, 0xc3, 0x3a, 0x09, 0x32, + 0x3d, 0xf7, 0x92, 0x2e, 0x2e, 0x9b, 0xbb, 0x11, 0x8d, 0x9a, + 0x3f, 0x68, 0x01, 0x99, 0x0f, 0x21, 0x0a, 0xe6, 0x75, 0x0d, + 0x92, 0x32, 0xc9, 0xfc, 0x08, 0x25, 0xb2, 0xf7, 0xfd, 0xfc, + 0x01, 0xc9, 0x93, 0xc9, 0x6f, 0x08, 0x49, 0x9c, 0xf2, 0x75, + 0x92, 0x76, 0x09, 0x35, 0x26, 0x6f, 0x24, 0x3c, 0x82, 0x40, + 0x12, 0x19, 0xb6, 0x64, 0x27, 0xbf, 0x2d, 0xbb, 0x59, 0x60, + 0x91, 0x54, 0xe3, 0x6f, 0x64, 0x64, 0x99, 0xe4, 0xb3, 0x71, + 0x4c, 0xf2, 0x79, 0xfe, 0x4f, 0x27, 0x9f, 0x93, 0xc9, 0xe7, + 0xe4, 0xf2, 0x79, 0xf9, 0x3c, 0x9e, 0x7e, 0x4f, 0x27, 0x9f, + 0x93, 0xc9, 0xe7, 0xe4, 0xf2, 0x79, 0xf9, 0x3c, 0x9e, 0x7e, + 0x4f, 0x24, 0x24, 0x42, 0xaa, 0xc2, 0x40, 0x93, 0xc7, 0xe1, + 0xa8, 0xc6, 0xd9, 0x84, 0xa5, 0x02, 0xd6, 0x84, 0x8a, 0x76, + 0x0e, 0xc5, 0xec, 0xc7, 0x70, 0x08, 0xa8, 0x70, 0xf8, 0xa5, + 0x45, 0x2e, 0x09, 0x10, 0xef, 0x82, 0x40, 0x43, 0x08, 0x52, + 0x61, 0x86, 0x47, 0x28, 0xb1, 0xb4, 0x5f, 0x96, 0xb7, 0xec, + 0xd8, 0xe6, 0xec, 0xdf, 0x4d, 0xb9, 0x3c, 0x96, 0x6c, 0x2b, + 0x24, 0x42, 0x3d, 0xfa, 0xbc, 0xad, 0xe3, 0xa2, 0x37, 0x62, + 0x15, 0xf7, 0xed, 0xb0, 0xee, 0x4d, 0x5d, 0xf3, 0x81, 0x19, + 0x23, 0x16, 0x81, 0x9b, 0x25, 0x76, 0x65, 0x1d, 0x92, 0xf9, + 0x39, 0xdf, 0x7e, 0x6a, 0x3b, 0x64, 0x8e, 0x4c, 0xc1, 0x7a, + 0xc9, 0x3d, 0x66, 0x68, 0x4d, 0xd9, 0x27, 0x1c, 0x88, 0x74, + 0x24, 0x46, 0x2a, 0x68, 0xa6, 0x72, 0x70, 0x86, 0xac, 0xd0, + 0x46, 0x99, 0x06, 0xdb, 0x25, 0x32, 0x08, 0x7b, 0x2f, 0x04, + 0x5f, 0xb3, 0x9e, 0x4c, 0xfc, 0x9d, 0x94, 0x23, 0x3c, 0x9e, + 0x7f, 0x93, 0xc9, 0xe7, 0xe4, 0xf2, 0x79, 0xf9, 0x3c, 0x9e, + 0x71, 0x07, 0x10, 0x7e, 0x7e, 0x4f, 0x27, 0x9f, 0x93, 0xc9, + 0xe7, 0xe4, 0xf2, 0x79, 0xf9, 0x3c, 0x9e, 0x7e, 0x4f, 0x24, + 0x24, 0x76, 0xa5, 0xca, 0x61, 0xc4, 0x7a, 0x92, 0x3d, 0x0a, + 0x5c, 0x9f, 0xca, 0x47, 0x09, 0x31, 0xa2, 0x52, 0x18, 0xb5, + 0x65, 0x1f, 0x44, 0x65, 0xf6, 0xc2, 0x44, 0x0f, 0x91, 0xb8, + 0x31, 0x21, 0xc2, 0x44, 0x23, 0x70, 0x90, 0xf6, 0xe1, 0x22, + 0x09, 0xfc, 0x00, 0x20, 0x77, 0x61, 0x20, 0xce, 0x3b, 0x45, + 0x9e, 0xb5, 0xa8, 0x01, 0xb0, 0x4d, 0xe3, 0x0e, 0x7e, 0x24, + 0xc3, 0xbd, 0xf8, 0x64, 0x9d, 0xd9, 0x88, 0x6d, 0x93, 0xc9, + 0x66, 0x8b, 0x39, 0x93, 0x57, 0x59, 0xee, 0x4b, 0xe8, 0x4e, + 0xb2, 0x45, 0x2f, 0xb4, 0xe8, 0x64, 0xaf, 0x2d, 0xc0, 0xdf, + 0xb2, 0x4f, 0x31, 0x32, 0x4f, 0x2e, 0x62, 0x83, 0xf5, 0xd0, + 0xa1, 0xf9, 0x3a, 0x97, 0xdf, 0xdf, 0x3d, 0x53, 0x92, 0x32, + 0x5c, 0xc7, 0xb4, 0xcc, 0xc8, 0x71, 0xbd, 0xd9, 0xf9, 0x2c, + 0xf2, 0x79, 0xfe, 0x4f, 0x27, 0x9f, 0x93, 0xc9, 0xe7, 0xe4, + 0xf2, 0x79, 0xf9, 0x3c, 0x9e, 0x73, 0xc8, 0xf2, 0xe7, 0xe4, + 0xf2, 0x79, 0xf9, 0x3c, 0x9e, 0x7e, 0x4f, 0x27, 0x9f, 0x93, + 0xc9, 0xe7, 0x3c, 0xf9, 0x38, 0xd8, 0x8c, 0x8e, 0x98, 0x62, + 0x16, 0x31, 0x3d, 0xa0, 0x73, 0x1f, 0x8a, 0x46, 0x10, 0x0c, + 0x11, 0xcb, 0x2f, 0x57, 0x1d, 0x82, 0x4f, 0x47, 0x64, 0x58, + 0x01, 0x07, 0x07, 0x2c, 0x50, 0xe1, 0x4a, 0xc9, 0x29, 0xa6, + 0xe6, 0x66, 0x13, 0x7d, 0x84, 0x89, 0x3f, 0x00, 0x48, 0x82, + 0x57, 0x10, 0x8f, 0xe5, 0xe5, 0xf7, 0x3e, 0xd6, 0xf3, 0x0c, + 0xb7, 0xe7, 0xc9, 0x8f, 0x3e, 0x4f, 0x6a, 0xfc, 0xf3, 0xd5, + 0xe9, 0x4a, 0x0a, 0x46, 0x52, 0x52, 0x97, 0x88, 0xe5, 0xb8, + 0x7e, 0x1c, 0xdc, 0x58, 0x72, 0xdb, 0xe1, 0xe4, 0x8b, 0x6f, + 0xea, 0x41, 0xa1, 0x03, 0x6f, 0xd0, 0xe6, 0x5d, 0xd1, 0x90, + 0xeb, 0x7d, 0xb6, 0x7e, 0xe8, 0x0e, 0x8e, 0x53, 0xef, 0xe7, + 0xdc, 0x2c, 0x91, 0x96, 0xec, 0x12, 0x28, 0x9b, 0x93, 0xb9, + 0x74, 0xaf, 0x00, 0xd8, 0x90, 0xd5, 0x99, 0x21, 0xe5, 0x9d, + 0x03, 0x5f, 0x5c, 0x95, 0x22, 0x9b, 0x09, 0x38, 0x1e, 0x48, + 0xcf, 0x24, 0x39, 0x4c, 0xcd, 0x8d, 0x64, 0x8e, 0x82, 0x4d +}; + +GST_START_TEST (test_vc1_identify_bdu) +{ + GstVC1ParseResult res; + GstVC1BDU bdu; + GstVC1SeqHdr hdr; + GstVC1EntryPointHdr entrypt; + + res = gst_vc1_identify_next_bdu (sequence_fullframe, + sizeof (sequence_fullframe), &bdu); + + assert_equals_int (res, GST_VC1_PARSER_OK); + assert_equals_int (bdu.type, GST_VC1_SEQUENCE); + + res = gst_vc1_parse_sequence_header (bdu.data + bdu.offset, bdu.size, &hdr); + assert_equals_int (res, GST_VC1_PARSER_OK); + assert_equals_int (hdr.profiletype, GST_VC1_PROFILE_ADVANCED); + + assert_equals_int (hdr.profile.advanced.level, GST_VC1_LEVEL_L1); + assert_equals_int (hdr.colordiff_format, 1); + + res = gst_vc1_identify_next_bdu (sequence_fullframe + bdu.sc_offset + + bdu.size, sizeof (sequence_fullframe) - bdu.sc_offset - bdu.size, &bdu); + + fail_unless (res == GST_VC1_PARSER_OK); + fail_unless (bdu.type == GST_VC1_ENTRYPOINT); + + res = gst_vc1_parse_entry_point_header (bdu.data + bdu.offset, + bdu.size, &entrypt, &hdr); + fail_unless (res == GST_VC1_PARSER_OK); +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_p_frame_header_main) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; + GstVC1PicSimpleMain *pic = &framehdr.pic.simple; + + assert_equals_int (gst_vc1_parse_sequence_header (pframe_header_main, + sizeof (pframe_header_main), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); + + simplehdr->coded_height = 240; + simplehdr->coded_width = 320; + + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 2); + assert_equals_int (simplehdr->loop_filter, 1); + assert_equals_int (simplehdr->multires, 0); + assert_equals_int (simplehdr->extended_mv, 0); + assert_equals_int (simplehdr->rangered, 0); + assert_equals_int (simplehdr->vstransform, 1); + assert_equals_int (simplehdr->overlap, 1); + assert_equals_int (simplehdr->syncmarker, 0); + assert_equals_int (simplehdr->dquant, 1); + assert_equals_int (simplehdr->quantizer, 0); + assert_equals_int (simplehdr->maxbframes, 1); + + assert_equals_int (gst_vc1_parse_frame_header (pframe_main, + sizeof (pframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_P); + assert_equals_int (framehdr.interpfrm, 0); + assert_equals_int (pic->frmcnt, 1); + assert_equals_int (pic->rangeredfrm, 0); + assert_equals_int (framehdr.pqindex, 10); + assert_equals_int (framehdr.pquant, 7); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 0); + +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_b_frame_header_main) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; + GstVC1PicSimpleMain *pic = &framehdr.pic.simple; + + assert_equals_int (gst_vc1_parse_sequence_header (bframe_header_main, + sizeof (bframe_header_main), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); + + simplehdr->coded_height = 240; + simplehdr->coded_width = 320; + + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 3); + assert_equals_int (simplehdr->loop_filter, 1); + assert_equals_int (simplehdr->multires, 0); + assert_equals_int (simplehdr->extended_mv, 0); + assert_equals_int (simplehdr->rangered, 0); + assert_equals_int (simplehdr->vstransform, 1); + assert_equals_int (simplehdr->overlap, 1); + assert_equals_int (simplehdr->syncmarker, 0); + assert_equals_int (simplehdr->dquant, 1); + assert_equals_int (simplehdr->quantizer, 0); + assert_equals_int (simplehdr->maxbframes, 1); + + assert_equals_int (gst_vc1_parse_frame_header (bframe_main, + sizeof (bframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_B); + assert_equals_int (framehdr.interpfrm, 0); + + assert_equals_int (pic->frmcnt, 2); + assert_equals_int (pic->rangeredfrm, 0); + assert_equals_int (pic->ttmbf, 0); + assert_equals_int (pic->mvtab, 2); + assert_equals_int (pic->cbptab, 1); + assert_equals_int (framehdr.pquant, 7); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 0); +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_bi_frame_header_main) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; + GstVC1PicSimpleMain *pic = &framehdr.pic.simple; + simplehdr->coded_height = 240; + simplehdr->coded_width = 320; + + assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header, + sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 7); + assert_equals_int (simplehdr->loop_filter, 1); + assert_equals_int (simplehdr->multires, 0); + assert_equals_int (simplehdr->extended_mv, 0); + assert_equals_int (simplehdr->rangered, 0); + assert_equals_int (simplehdr->vstransform, 1); + assert_equals_int (simplehdr->overlap, 1); + assert_equals_int (simplehdr->syncmarker, 0); + assert_equals_int (simplehdr->dquant, 1); + assert_equals_int (simplehdr->quantizer, 0); + assert_equals_int (simplehdr->maxbframes, 1); + + assert_equals_int (gst_vc1_parse_frame_header (biframe_main, + sizeof (biframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_BI); + assert_equals_int (framehdr.interpfrm, 0); + + assert_equals_int (pic->frmcnt, 0); + assert_equals_int (pic->rangeredfrm, 0); + assert_equals_int (framehdr.pqindex, 6); + assert_equals_int (framehdr.pquant, 6); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 1); +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_i_frame_header_main) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1SimpleMainSeqHdr *simplehdr = &seqhdr.profile.simplemain; + GstVC1PicSimpleMain *pic = &framehdr.pic.simple; + + simplehdr->coded_height = 240; + simplehdr->coded_width = 320; + + assert_equals_int (gst_vc1_parse_sequence_header (i_bi_frame_header, + sizeof (i_bi_frame_header), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_MAIN); + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 7); + assert_equals_int (simplehdr->loop_filter, 1); + assert_equals_int (simplehdr->multires, 0); + assert_equals_int (simplehdr->extended_mv, 0); + assert_equals_int (simplehdr->rangered, 0); + assert_equals_int (simplehdr->vstransform, 1); + assert_equals_int (simplehdr->overlap, 1); + assert_equals_int (simplehdr->syncmarker, 0); + assert_equals_int (simplehdr->dquant, 1); + assert_equals_int (simplehdr->quantizer, 0); + assert_equals_int (simplehdr->maxbframes, 1); + + assert_equals_int (gst_vc1_parse_frame_header (iframe_main, + sizeof (iframe_main), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_I); + assert_equals_int (framehdr.interpfrm, 0); + + assert_equals_int (pic->frmcnt, 0); + assert_equals_int (pic->rangeredfrm, 0); + assert_equals_int (framehdr.pqindex, 4); + assert_equals_int (framehdr.pquant, 4); + assert_equals_int (framehdr.halfqp, 1); + assert_equals_int (framehdr.pquantizer, 1); +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_i_frame_header_adv) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; + GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; + GstVC1PicAdvanced *pic = &framehdr.pic.advanced; + + assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, + sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); + assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 31); + assert_equals_int (advhdr->postprocflag, 0); + assert_equals_int (advhdr->max_coded_width, 1920); + assert_equals_int (advhdr->max_coded_height, 1080); + assert_equals_int (advhdr->interlace, 1); + assert_equals_int (advhdr->tfcntrflag, 0); + assert_equals_int (seqhdr.finterpflag, 0); + + assert_equals_int (advhdr->display_ext, 1); + assert_equals_int (advhdr->disp_horiz_size, 1920); + assert_equals_int (advhdr->disp_vert_size, 1080); + + assert_equals_int (gst_vc1_parse_entry_point_header (entrypoint, + sizeof (entrypoint), entrypt, &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (entrypt->broken_link, 0); + assert_equals_int (entrypt->closed_entry, 1); + assert_equals_int (entrypt->panscan_flag, 0); + assert_equals_int (entrypt->refdist_flag, 1); + assert_equals_int (entrypt->loopfilter, 1); + assert_equals_int (entrypt->fastuvmc, 0); + assert_equals_int (entrypt->extended_mv, 1); + assert_equals_int (entrypt->dquant, 1); + assert_equals_int (entrypt->vstransform, 1); + assert_equals_int (entrypt->overlap, 0); + assert_equals_int (entrypt->quantizer, 0); + assert_equals_int (entrypt->coded_height, 1080); + assert_equals_int (entrypt->coded_width, 1920); + + assert_equals_int (gst_vc1_parse_frame_header (iframe_adv, + sizeof (iframe_adv), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_I); + assert_equals_int (framehdr.pqindex, 3); + assert_equals_int (framehdr.pquant, 3); + assert_equals_int (framehdr.halfqp, 1); + assert_equals_int (framehdr.pquantizer, 1); + + assert_equals_int (pic->fcm, 0); + assert_equals_int (pic->tff, 1); + assert_equals_int (pic->rff, 0); + assert_equals_int (pic->rndctrl, 0); +} + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_b_frame_header_adv) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; + GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; + GstVC1PicAdvanced *pic = &framehdr.pic.advanced; + + assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, + sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); + assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 31); + assert_equals_int (advhdr->postprocflag, 0); + assert_equals_int (advhdr->max_coded_width, 1920); + assert_equals_int (advhdr->max_coded_height, 1080); + assert_equals_int (advhdr->interlace, 1); + assert_equals_int (advhdr->tfcntrflag, 0); + assert_equals_int (seqhdr.finterpflag, 0); + + assert_equals_int (advhdr->display_ext, 1); + assert_equals_int (advhdr->disp_horiz_size, 1920); + assert_equals_int (advhdr->disp_vert_size, 1080); + + assert_equals_int (gst_vc1_parse_entry_point_header (entrypoint, + sizeof (entrypoint), entrypt, &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (entrypt->broken_link, 0); + assert_equals_int (entrypt->closed_entry, 1); + assert_equals_int (entrypt->panscan_flag, 0); + assert_equals_int (entrypt->refdist_flag, 1); + assert_equals_int (entrypt->loopfilter, 1); + assert_equals_int (entrypt->fastuvmc, 0); + assert_equals_int (entrypt->extended_mv, 1); + assert_equals_int (entrypt->dquant, 1); + assert_equals_int (entrypt->vstransform, 1); + assert_equals_int (entrypt->overlap, 0); + assert_equals_int (entrypt->quantizer, 0); + + assert_equals_int (gst_vc1_parse_frame_header (bframe_adv, + sizeof (bframe_adv), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_B); + assert_equals_int (framehdr.pqindex, 1); + assert_equals_int (framehdr.pquant, 1); + assert_equals_int (framehdr.halfqp, 1); + assert_equals_int (framehdr.pquantizer, 1); + + assert_equals_int (framehdr.vopdquant.dquantfrm, 0); + assert_equals_int (framehdr.transacfrm, 1); + + assert_equals_int (gst_vc1_parse_frame_header (bframe2_adv, + sizeof (bframe2_adv), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_B); + assert_equals_int (framehdr.pqindex, 4); + assert_equals_int (framehdr.pquant, 4); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 1); + assert_equals_int (framehdr.transacfrm, 0); + + assert_equals_int (pic->mvrange, 0); + assert_equals_int (pic->mvmode, 0); +} + + +GST_END_TEST; + +GST_START_TEST (test_vc1_parse_p_frame_header_adv) +{ + GstVC1FrameHdr framehdr; + GstVC1SeqHdr seqhdr; + + GstVC1AdvancedSeqHdr *advhdr = &seqhdr.profile.advanced; + GstVC1EntryPointHdr *entrypt = &advhdr->entrypoint; + GstVC1PicAdvanced *pic = &framehdr.pic.advanced; + + assert_equals_int (gst_vc1_parse_sequence_header (iframe_adv_hdr, + sizeof (iframe_adv_hdr), &seqhdr), GST_VC1_PARSER_OK); + + assert_equals_int (seqhdr.profiletype, GST_VC1_PROFILE_ADVANCED); + assert_equals_int (advhdr->level, GST_VC1_LEVEL_L3); + assert_equals_int (seqhdr.frmrtq_postproc, 7); + assert_equals_int (seqhdr.bitrtq_postproc, 31); + assert_equals_int (advhdr->postprocflag, 0); + assert_equals_int (advhdr->max_coded_width, 1920); + assert_equals_int (advhdr->max_coded_height, 1080); + assert_equals_int (advhdr->interlace, 1); + assert_equals_int (advhdr->tfcntrflag, 0); + assert_equals_int (seqhdr.finterpflag, 0); + + assert_equals_int (advhdr->display_ext, 1); + assert_equals_int (advhdr->disp_horiz_size, 1920); + assert_equals_int (advhdr->disp_vert_size, 1080); + + assert_equals_int (gst_vc1_parse_entry_point_header (entrypoint, + sizeof (entrypoint), entrypt, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (entrypt->broken_link, 0); + assert_equals_int (entrypt->closed_entry, 1); + assert_equals_int (entrypt->panscan_flag, 0); + assert_equals_int (entrypt->refdist_flag, 1); + assert_equals_int (entrypt->loopfilter, 1); + assert_equals_int (entrypt->fastuvmc, 0); + assert_equals_int (entrypt->extended_mv, 1); + assert_equals_int (entrypt->dquant, 1); + assert_equals_int (entrypt->vstransform, 1); + assert_equals_int (entrypt->overlap, 0); + assert_equals_int (entrypt->quantizer, 0); + assert_equals_int (entrypt->coded_height, 1080); + assert_equals_int (entrypt->coded_width, 1920); + + + assert_equals_int (gst_vc1_parse_frame_header (pframe_adv, + sizeof (pframe_adv), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_P); + assert_equals_int (framehdr.pqindex, 1); + assert_equals_int (framehdr.pquant, 1); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 1); + + assert_equals_int (pic->mvmode, 0); + assert_equals_int (pic->mvrange, 0); + + assert_equals_int (gst_vc1_parse_frame_header (pframe2_adv, + sizeof (pframe2_adv), &framehdr, &seqhdr), GST_VC1_PARSER_OK); + assert_equals_int (framehdr.ptype, GST_VC1_PICTURE_TYPE_P); + assert_equals_int (framehdr.pqindex, 1); + assert_equals_int (framehdr.pquant, 1); + assert_equals_int (framehdr.halfqp, 0); + assert_equals_int (framehdr.pquantizer, 1); + + assert_equals_int (pic->mvmode, 3); + assert_equals_int (pic->mvrange, 0); +} + +GST_END_TEST static Suite * +vc1parser_suite (void) +{ + Suite *s = suite_create ("VC1 Parser library"); + + TCase *tc_chain = tcase_create ("general"); + + suite_add_tcase (s, tc_chain); + tcase_add_test (tc_chain, test_vc1_identify_bdu); + tcase_add_test (tc_chain, test_vc1_parse_p_frame_header_main); + tcase_add_test (tc_chain, test_vc1_parse_b_frame_header_main); + tcase_add_test (tc_chain, test_vc1_parse_bi_frame_header_main); + tcase_add_test (tc_chain, test_vc1_parse_i_frame_header_main); + tcase_add_test (tc_chain, test_vc1_parse_i_frame_header_adv); + tcase_add_test (tc_chain, test_vc1_parse_b_frame_header_adv); + tcase_add_test (tc_chain, test_vc1_parse_p_frame_header_adv); + + return s; +} + +int +main (int argc, char **argv) +{ + int nf; + + Suite *s = vc1parser_suite (); + + SRunner *sr = srunner_create (s); + + gst_check_init (&argc, &argv); + + srunner_run_all (sr, CK_NORMAL); + nf = srunner_ntests_failed (sr); + srunner_free (sr); + + return nf; +} -- 2.7.4