2 * Copyright (C) <2011> Intel
3 * Copyright (C) <2011> Collabora Ltd.
4 * Copyright (C) <2011> Thibault Saunier <thibault.saunier@collabora.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef __PARSER_UTILS__
23 #define __PARSER_UTILS__
26 #include <gst/base/gstbitreader.h>
29 #define GET_BITS(b, num, bits) G_STMT_START { \
30 if (!gst_bit_reader_get_bits_uint32(b, bits, num)) \
32 GST_TRACE ("parsed %d bits: %d", num, *(bits)); \
35 #define CHECK_ALLOWED(val, min, max) G_STMT_START { \
36 if (val < min || val > max) { \
37 GST_WARNING ("value not in allowed range. value: %d, range %d-%d", \
43 #define READ_UINT8(reader, val, nbits) G_STMT_START { \
44 if (!gst_bit_reader_get_bits_uint8 (reader, &val, nbits)) { \
45 GST_WARNING ("failed to read uint8, nbits: %d", nbits); \
50 #define READ_UINT16(reader, val, nbits) G_STMT_START { \
51 if (!gst_bit_reader_get_bits_uint16 (reader, &val, nbits)) { \
52 GST_WARNING ("failed to read uint16, nbits: %d", nbits); \
57 #define READ_UINT32(reader, val, nbits) G_STMT_START { \
58 if (!gst_bit_reader_get_bits_uint32 (reader, &val, nbits)) { \
59 GST_WARNING ("failed to read uint32, nbits: %d", nbits); \
64 #define READ_UINT64(reader, val, nbits) G_STMT_START { \
65 if (!gst_bit_reader_get_bits_uint64 (reader, &val, nbits)) { \
66 GST_WARNING ("failed to read uint64, nbits: %d", nbits); \
72 #define U_READ_UINT8(reader, val, nbits) G_STMT_START { \
73 val = gst_bit_reader_get_bits_uint8_unchecked (reader, nbits); \
76 #define U_READ_UINT16(reader, val, nbits) G_STMT_START { \
77 val = gst_bit_reader_get_bits_uint16_unchecked (reader, nbits); \
80 #define U_READ_UINT32(reader, val, nbits) G_STMT_START { \
81 val = gst_bit_reader_get_bits_uint32_unchecked (reader, nbits); \
84 #define U_READ_UINT64(reader, val, nbits) G_STMT_START { \
85 val = gst_bit_reader_get_bits_uint64_unchecked (reader, nbits); \
88 #define SKIP(reader, nbits) G_STMT_START { \
89 if (!gst_bit_reader_skip (reader, nbits)) { \
90 GST_WARNING ("failed to skip nbits: %d", nbits); \
95 typedef struct _VLCTable VLCTable;
105 decode_vlc (GstBitReader * br, guint * res, const VLCTable * table,
108 #endif /* __PARSER_UTILS__ */