| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2002, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bcmDccBits.h $ |
|---|
| 11 | * $brcm_Revision: SanJose_MSTV_Devel\2 $ |
|---|
| 12 | * $brcm_Date: 5/13/02 1:14p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * This module contains functions useful for extracting bits |
|---|
| 17 | * from a byte stream. |
|---|
| 18 | * |
|---|
| 19 | * Revision History: |
|---|
| 20 | * |
|---|
| 21 | * $brcm_Log: \SetTop\applications\vbi\Common\bcmDccBits.h $ |
|---|
| 22 | * |
|---|
| 23 | * SanJose_MSTV_Devel\2 5/13/02 1:14p erikg |
|---|
| 24 | * snapshot of dtvcc code Merge from |
|---|
| 25 | * SanJose_MSTV_Devel_erikg_DTVCC_Int_2002_05_02_1128_00 13-May- |
|---|
| 26 | * 02.11:55:52 \SetTop\applications\vbi Added directory element |
|---|
| 27 | * "DTVCCLib". --- 13-May-02.13:08:38 \SetTop\applications\vbi\Common |
|---|
| 28 | * First version of the Dcc 708 Rendering Libraries --- 13-May- |
|---|
| 29 | * 02.13:08:10 \SetTop\applications\vbi\Common\bcmDccBits.h Added ifdef |
|---|
| 30 | * to ensure included only once. |
|---|
| 31 | * Added extern "C" for __cplusplus --- 13-May-02.13:07:04 |
|---|
| 32 | * \SetTop\applications\vbi\MPEGCCTransportLib\source\bcmDccTransportPars |
|---|
| 33 | * e.c NextStartCode() now specifically scans for start codes until it |
|---|
| 34 | * finds |
|---|
| 35 | * 00 00 01 B2. --- 13-May-02.13:08:40 |
|---|
| 36 | * \SetTop\applications\vbi\Common@@\main\SanJose_MSTV_Devel\SanJose_MSTV |
|---|
| 37 | * _Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1\bcmDccCBuf.c First version |
|---|
| 38 | * of the Dcc 708 Rendering Libraries --- 13-May-02.13:08:43 |
|---|
| 39 | * \SetTop\applications\vbi\Common@@\main\SanJose_MSTV_Devel\SanJose_MSTV |
|---|
| 40 | * _Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1\bcmDccCBuf.h First version |
|---|
| 41 | * of the Dcc 708 Rendering Libraries --- 13-May-02.11:55:59 |
|---|
| 42 | * \SetTop\applications\vbi@@\main\SanJose_MSTV_Devel\SanJose_MSTV_Devel_ |
|---|
| 43 | * erikg_DTVCC_Int_2002_05_02_1128_00\1\DTVCCLib Added directory element |
|---|
| 44 | * "source". Added directory element "public_inc". --- |
|---|
| 45 | * |
|---|
| 46 | * SanJose_MSTV_Devel\SanJose_MSTV_Devel_erikg_DTVCC_Int_2002_05_02_1128_00\1 5/13/02 1:8p erikg |
|---|
| 47 | * Added ifdef to ensure included only once. |
|---|
| 48 | * Added extern "C" for __cplusplus |
|---|
| 49 | * |
|---|
| 50 | * \main\SanJose_MSTV_Devel\1 3/12/02 4:46p erikg |
|---|
| 51 | * Merge from SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38 |
|---|
| 52 | * |
|---|
| 53 | * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\1 3/6/02 11:29a erikg |
|---|
| 54 | * new source files |
|---|
| 55 | * |
|---|
| 56 | ***************************************************************************/ |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | /************************************************************************* |
|---|
| 61 | * |
|---|
| 62 | * MODULE DETAILS: |
|---|
| 63 | * |
|---|
| 64 | * The functions in this module operate on bits in a byte buffer (array). |
|---|
| 65 | * Each function is given a pointer to the buffer and a byte offset and a |
|---|
| 66 | * bit offset indicating the current position in the buffer. The byte/bit |
|---|
| 67 | * offsets are either ints or int pointers, depending on whether or not |
|---|
| 68 | * the current position is to be updated. |
|---|
| 69 | * |
|---|
| 70 | * It is assumed that the first bit to be operated on is in the msb position, |
|---|
| 71 | * that is, 0x80. |
|---|
| 72 | * |
|---|
| 73 | *************************************************************************/ |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | #ifndef BCMDCCBITS_H |
|---|
| 77 | #define BCMDCCBITS_H |
|---|
| 78 | |
|---|
| 79 | #ifdef __cplusplus |
|---|
| 80 | extern "C" { |
|---|
| 81 | #endif |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | /************************************************************************* |
|---|
| 85 | * |
|---|
| 86 | * FUNCTION: getnextbit |
|---|
| 87 | * |
|---|
| 88 | * Inputs: |
|---|
| 89 | * pBuf - stream buffer |
|---|
| 90 | * pbyteoff - current byte offset into pBuf |
|---|
| 91 | * pbitoff - bit offset into current byte |
|---|
| 92 | * |
|---|
| 93 | * Outputs: |
|---|
| 94 | * pbyteoff - current byte offset into pBuf |
|---|
| 95 | * pbitoff - bit offset into current byte |
|---|
| 96 | * |
|---|
| 97 | * Returns: the requested bit, 0 or 1 |
|---|
| 98 | * |
|---|
| 99 | * Description: |
|---|
| 100 | * |
|---|
| 101 | * This function returns the next bit and increments the position. |
|---|
| 102 | * |
|---|
| 103 | *************************************************************************/ |
|---|
| 104 | unsigned int |
|---|
| 105 | getnextbit(unsigned char * pBuf, int * pbyteoff, int * pbitoff) ; |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | /************************************************************************* |
|---|
| 109 | * |
|---|
| 110 | * FUNCTION: getnextbits |
|---|
| 111 | * |
|---|
| 112 | * Inputs: |
|---|
| 113 | * pBuf - stream buffer |
|---|
| 114 | * pbyteoff - current byte offset into pBuf |
|---|
| 115 | * pbitoff - bit offset into current byte |
|---|
| 116 | * numbits - number of bits to get (max 32) |
|---|
| 117 | * |
|---|
| 118 | * Outputs: |
|---|
| 119 | * pbyteoff - current byte offset into pBuf |
|---|
| 120 | * pbitoff - bit offset into current byte |
|---|
| 121 | * |
|---|
| 122 | * Returns: the requested bits, lsb justified |
|---|
| 123 | * |
|---|
| 124 | * Description: |
|---|
| 125 | * |
|---|
| 126 | * This function returns the requested number of bits and |
|---|
| 127 | * updates the position. |
|---|
| 128 | * |
|---|
| 129 | *************************************************************************/ |
|---|
| 130 | unsigned int |
|---|
| 131 | getnextbits(unsigned char * pBuf, int * pbyteoff, int * pbitoff, int numbits) ; |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | /************************************************************************* |
|---|
| 135 | * |
|---|
| 136 | * FUNCTION: getnextbits_rev |
|---|
| 137 | * |
|---|
| 138 | * Inputs: |
|---|
| 139 | * pBuf - stream buffer |
|---|
| 140 | * pbyteoff - current byte offset into pBuf |
|---|
| 141 | * pbitoff - bit offset into current byte |
|---|
| 142 | * numbits - number of bits to get (max 32) |
|---|
| 143 | * |
|---|
| 144 | * Outputs: |
|---|
| 145 | * pbyteoff - current byte offset into pBuf |
|---|
| 146 | * pbitoff - bit offset into current byte |
|---|
| 147 | * |
|---|
| 148 | * Returns: the requested bits, bit reversed, lsb justified |
|---|
| 149 | * |
|---|
| 150 | * Description: |
|---|
| 151 | * |
|---|
| 152 | * This function returns the requested number of bits in reverse |
|---|
| 153 | * order and updates the position. |
|---|
| 154 | * |
|---|
| 155 | *************************************************************************/ |
|---|
| 156 | unsigned int |
|---|
| 157 | getnextbits_rev(unsigned char * pBuf, int * pbyteoff, int * pbitoff, int numbits) ; |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | /************************************************************************* |
|---|
| 161 | * |
|---|
| 162 | * FUNCTION: nextbits |
|---|
| 163 | * |
|---|
| 164 | * Inputs: |
|---|
| 165 | * pBuf - stream buffer |
|---|
| 166 | * byteoff - current byte offset into pBuf |
|---|
| 167 | * bitoff - bit offset into current byte |
|---|
| 168 | * numbits - number of bits to get (max 32) |
|---|
| 169 | * |
|---|
| 170 | * Outputs: |
|---|
| 171 | * <none> |
|---|
| 172 | * |
|---|
| 173 | * Returns: the requested bits, lsb justified |
|---|
| 174 | * |
|---|
| 175 | * Description: |
|---|
| 176 | * |
|---|
| 177 | * This function returns the requested number of bits but does |
|---|
| 178 | * not update the position. |
|---|
| 179 | * |
|---|
| 180 | *************************************************************************/ |
|---|
| 181 | unsigned int |
|---|
| 182 | nextbits(unsigned char * pBuf, int byteoff, int bitoff, int numbits) ; |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | /************************************************************************* |
|---|
| 186 | * |
|---|
| 187 | * FUNCTION: next_start_code |
|---|
| 188 | * |
|---|
| 189 | * Inputs: |
|---|
| 190 | * pBuf - stream buffer |
|---|
| 191 | * pbyteoff - current byte offset into pBuf |
|---|
| 192 | * pbitoff - bit offset into current byte |
|---|
| 193 | * numbytes - max bytes to scan forward |
|---|
| 194 | * |
|---|
| 195 | * Outputs: |
|---|
| 196 | * pbyteoff - current byte offset into pBuf |
|---|
| 197 | * pbitoff - bit offset into current byte |
|---|
| 198 | * |
|---|
| 199 | * Returns: 0 for success |
|---|
| 200 | * |
|---|
| 201 | * Description: |
|---|
| 202 | * |
|---|
| 203 | * This function updates the position to the next start code. |
|---|
| 204 | * |
|---|
| 205 | *************************************************************************/ |
|---|
| 206 | int next_start_code(unsigned char * pBuf, int * pbyteoff, int * pbitoff, int numbytes) ; |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | #ifdef __cplusplus |
|---|
| 211 | } |
|---|
| 212 | #endif |
|---|
| 213 | |
|---|
| 214 | #endif /* BCMDCCBITS_H */ |
|---|