| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, 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: bvbilib.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/26 $ |
|---|
| 12 | * $brcm_Date: 8/27/10 2:02p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/syslib/vbilib/bvbilib.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/26 8/27/10 2:02p darnstein |
|---|
| 21 | * SW3548-3022: merge to production branch. |
|---|
| 22 | * |
|---|
| 23 | * Hydra_Software_Devel/SW3548-3022/1 7/28/10 4:38p darnstein |
|---|
| 24 | * SW3548-3022: bitstream parsing is relayed to commonutils module BUDP. |
|---|
| 25 | * |
|---|
| 26 | * Hydra_Software_Devel/25 1/8/10 1:12p darnstein |
|---|
| 27 | * SW3556-979: I added an API function that points to the oldest piece of |
|---|
| 28 | * data in the encode queue. |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/24 3/16/09 1:08p darnstein |
|---|
| 31 | * PR53264: New error code for MPEG parsing: BERR_BVBIlib_SOURCE_CHECK. |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/23 4/3/08 5:49p darnstein |
|---|
| 34 | * PR38956,PR40709: New API elements supporting CGMS-B encoding. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/22 9/11/07 5:16p darnstein |
|---|
| 37 | * PR25708: First release of SCTE encoder software. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/21 6/6/07 12:50p darnstein |
|---|
| 40 | * PR30411: multi-line closed caption encoding is ready for test. |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/20 1/19/07 12:05p darnstein |
|---|
| 43 | * PR26464: fix a comment. |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/19 1/18/07 3:13p darnstein |
|---|
| 46 | * PR26464: correctly handle teletext output to multiple VECs |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/18 5/26/06 1:20p darnstein |
|---|
| 49 | * PR21710: A field handle can be dequeued for encoding at any one of |
|---|
| 50 | * three times: top field, bottom field, or FRAME. FRAME is the new |
|---|
| 51 | * choice. The field handles themselves continue to be defined as top |
|---|
| 52 | * field, bottom field, or both. The new logic is when a field handle is |
|---|
| 53 | * dequeued at time FRAME, it is always encoded immediately. The rest of |
|---|
| 54 | * the logic is the same: a "top" field handle is only dequeued and |
|---|
| 55 | * encoded at "top field" time, same for bottoms. When setting up field |
|---|
| 56 | * interrupt callbacks, for progressive video output, the argument |
|---|
| 57 | * BAVC_Polarity_eFrame should be used now. |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/17 4/11/06 7:26p darnstein |
|---|
| 60 | * PR20429: first cut at AMOL encoder software. |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/16 10/21/05 7:46p darnstein |
|---|
| 63 | * PR17732: Gemstar encoder can output a waveform, but I can't make it |
|---|
| 64 | * change yet. |
|---|
| 65 | * |
|---|
| 66 | * Hydra_Software_Devel/15 3/22/05 11:11a darnstein |
|---|
| 67 | * PR 14477: Measure encode queue depth. For diagnostic purposes. |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/14 2/28/05 2:24p darnstein |
|---|
| 70 | * PR 14040: BVBIlib_Encode_Enqueue_isr() simply refuses service if the |
|---|
| 71 | * BVBIlib encoding queue is full. |
|---|
| 72 | * |
|---|
| 73 | * Hydra_Software_Devel/13 7/26/04 5:06p darnstein |
|---|
| 74 | * PR 9080: add some comments to function declarations, at Jason Herrick's |
|---|
| 75 | * suggestion. |
|---|
| 76 | * |
|---|
| 77 | * Hydra_Software_Devel/12 5/11/04 6:54p darnstein |
|---|
| 78 | * PR 9080: add support for user processing of VBI data, simultaneously |
|---|
| 79 | * with hardware encoding of same VBI data. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/11 4/2/04 2:21p darnstein |
|---|
| 82 | * PR 9080: Remove obsolete comments. |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/10 2/23/04 2:29p darnstein |
|---|
| 85 | * PR 9080: no change. |
|---|
| 86 | * |
|---|
| 87 | * Hydra_Software_Devel/9 2/9/04 10:30a darnstein |
|---|
| 88 | * PR 9080: Add function BERR_Code BVBIlib_Encode_NoData_isr() to API. |
|---|
| 89 | * Bug fix: In BVBIlib_encode_data_isr(), if next field handle has the |
|---|
| 90 | * wrong parity, then instruct BVBI module to encode nothing for next |
|---|
| 91 | * field. |
|---|
| 92 | * |
|---|
| 93 | * Hydra_Software_Devel/8 1/27/04 6:24p darnstein |
|---|
| 94 | * PR 9080: Don't check for overrun errors on encoding. It is only |
|---|
| 95 | * possible for closed caption encoding, anyway. |
|---|
| 96 | * |
|---|
| 97 | * Hydra_Software_Devel/7 1/8/04 7:25p darnstein |
|---|
| 98 | * PR 9080: Add capability to query for encoding errors from field |
|---|
| 99 | * handles. Bug fixes. |
|---|
| 100 | * |
|---|
| 101 | * Hydra_Software_Devel/6 12/19/03 5:08p darnstein |
|---|
| 102 | * PR 9080: adapt to changed BAVC enum for field polarity. |
|---|
| 103 | * |
|---|
| 104 | * Hydra_Software_Devel/5 12/3/03 2:54p darnstein |
|---|
| 105 | * Add function BVBIlib_Encode_Flush_isr(). |
|---|
| 106 | * |
|---|
| 107 | * Hydra_Software_Devel/4 10/20/03 4:53p darnstein |
|---|
| 108 | * Add programming example. |
|---|
| 109 | * |
|---|
| 110 | * Hydra_Software_Devel/3 10/14/03 11:31a darnstein |
|---|
| 111 | * Simplify API following comments from Jason. |
|---|
| 112 | * |
|---|
| 113 | * Hydra_Software_Devel/2 10/7/03 10:41a darnstein |
|---|
| 114 | * Fix errors found by compiler. |
|---|
| 115 | * |
|---|
| 116 | * Hydra_Software_Devel/1 10/6/03 1:15p darnstein |
|---|
| 117 | * Initial version |
|---|
| 118 | * |
|---|
| 119 | ***************************************************************************/ |
|---|
| 120 | |
|---|
| 121 | /*= Module Overview ********************************************************* |
|---|
| 122 | <verbatim> |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | Overview |
|---|
| 126 | BVBIlib module manages queues of data to be encoded and/or decoded in the |
|---|
| 127 | vertical blanking interval (VBI) of video material. It is a convenience layer |
|---|
| 128 | for the BVBI module, which it calls into. BVBIlib also calls into BLST for |
|---|
| 129 | queue management functionality, and BKNI for for managing communications |
|---|
| 130 | between ISR software and the main thread of execution. |
|---|
| 131 | |
|---|
| 132 | If the BVBIlib module is used, then several BVBI data structures and |
|---|
| 133 | functions will also have to be called. For example, extracting |
|---|
| 134 | closed caption data in a convenient format will require the use of BVBI |
|---|
| 135 | function BVBI_Field_GetCCData, which in turn requires the use of data structure |
|---|
| 136 | BVBI_Field_Handle. Certain BVBIlib functions return the appropriate reference |
|---|
| 137 | to a BVBI_Field_Handle. |
|---|
| 138 | |
|---|
| 139 | Because the user of BVBIlib must also use BVBI, BVBIlib is not simply a layer |
|---|
| 140 | on top of BVBI. The following hardware/software |
|---|
| 141 | stack illustrates an application that uses BVBIlib. Note that the customer |
|---|
| 142 | application calls into both BVBIlib and BVBI. On the other hand, only the BVBI |
|---|
| 143 | module interfaces with the chip hardware. |
|---|
| 144 | |
|---|
| 145 | +-------------------+ |
|---|
| 146 | | customer | |
|---|
| 147 | | application | |
|---|
| 148 | +---------+---------+ |
|---|
| 149 | | BVBIlib | | |
|---|
| 150 | | module | BVBI | |
|---|
| 151 | +---------+ module | |
|---|
| 152 | | | |
|---|
| 153 | +---------+---------+ |
|---|
| 154 | | | |
|---|
| 155 | | hardware | |
|---|
| 156 | +-------------------+ |
|---|
| 157 | |
|---|
| 158 | Design |
|---|
| 159 | The design for BVBIlib is broken into six parts. |
|---|
| 160 | Part 1 (VBI List sub-API) |
|---|
| 161 | These functions manage a list of BVBI_Field_Handles. The list is used by |
|---|
| 162 | the BVBIlib module as a source of containers for holding VBI data. |
|---|
| 163 | Part 2 (open/close module) |
|---|
| 164 | These functions are used for opening and closing the BVBIlib module. |
|---|
| 165 | These functions need only be called at boot time. (The close function is |
|---|
| 166 | used rarely). |
|---|
| 167 | Part 3 (open/close/configure decoders) |
|---|
| 168 | These functions are used for opening, closing, and configuring VBI |
|---|
| 169 | decoders. Opening one decoder makes it possible to decode all types of VBI |
|---|
| 170 | (closed caption, teletext, etc.). |
|---|
| 171 | Part 4 (open/close/configure encoders) |
|---|
| 172 | Similar to the decoder functions, these functions are used for opening, |
|---|
| 173 | closing, and configuring VBI encoders. |
|---|
| 174 | Part 5 (decoder ISR functions) |
|---|
| 175 | These functions will be called by the customer's ISR that responds to start |
|---|
| 176 | of decoded active video. The ISR is installed using the BINT module. |
|---|
| 177 | There is a BVBIlib function that pulls one field of VBI data out of the |
|---|
| 178 | decoder hardware and makes it available to the rest of the module. This |
|---|
| 179 | function should be called at the beginning of the ISR. Subsequently, the |
|---|
| 180 | user may call BVBIlib functions to manipulate the captured VBI data. There |
|---|
| 181 | is a BVBILIB function to send the VBI data to a VBI encoder queue. |
|---|
| 182 | Part 6 (encoder ISR function) |
|---|
| 183 | This single function will be called by the customer's ISR that responds to |
|---|
| 184 | start of encoded active video. As above, the ISR is installed using the |
|---|
| 185 | BINT module. The function sends one field of VBI data from the encoder's |
|---|
| 186 | queue to the encoder hardware. |
|---|
| 187 | |
|---|
| 188 | Note that the only BVBIlib software to run in non-interrupt context is for |
|---|
| 189 | configuration. The only BVBIlib software to run in the encoder ISRs is a |
|---|
| 190 | single function call to dequeue a field's worth of VBI data and send it to the |
|---|
| 191 | encoder hardware. Therefore, most of the customer programming will take place |
|---|
| 192 | in the decoder ISR. |
|---|
| 193 | |
|---|
| 194 | The BVBIlib module exists primarily to manage lists of VBI field data. The |
|---|
| 195 | contents of these lists are thus BVBI_Field_Handle's. There are two types of |
|---|
| 196 | lists in the design: Encoder queues, and the BVBIlib_List sub-API free list. |
|---|
| 197 | Encoder queues |
|---|
| 198 | When the user creates a BVBIlib encoder, BVBIlib creates an encoder queue. |
|---|
| 199 | For every field of video the encoder hardware processes, it will remove one |
|---|
| 200 | BVBI_Field_Handle from this queue and encode the VBI data it contains (if |
|---|
| 201 | any) in the video. The user's only interaction with this queue is to |
|---|
| 202 | insert BVBI_Field_Handle's into it. Typically, these BVBI_Field_Handles |
|---|
| 203 | will originate from a decoder queue, although the user may do some |
|---|
| 204 | processing of his own. |
|---|
| 205 | The BVBIlib_List sub-API free list |
|---|
| 206 | The user must create one or more BVBIlib_List objects to hold |
|---|
| 207 | BVBI_Field_Handle's. Subsequently, these handles may be allocated by |
|---|
| 208 | a BVBIlib decoder to decode VBI data into. The user may also allocate |
|---|
| 209 | a handle for his own use. A handle may also be passed to a BVBIlib |
|---|
| 210 | encoder queue, where it will eventually be used as a source of data |
|---|
| 211 | for VBI encoding. Afterwards, the BVBIlib encoder will "return" the |
|---|
| 212 | handle to the free list, unless there is another entity (the user, |
|---|
| 213 | or another BVBIlib encoder) that is still using the handle. See the |
|---|
| 214 | next section for a discussion on managing the BVBI_Field_Handle's. |
|---|
| 215 | |
|---|
| 216 | Managing The Collection of BVBI_Field_Handles |
|---|
| 217 | The BVBIlib module manages lists of BVBI_Field_Handles for use in encoding |
|---|
| 218 | and decoding VBI. This was discussed in the previous section. The management |
|---|
| 219 | of these handles has the following features: |
|---|
| 220 | |
|---|
| 221 | o All memory allocation and deallocation is performed by the BVBIlib_List |
|---|
| 222 | sub-API. Memory leaks are avoided. |
|---|
| 223 | o The user may reserve a BVBI_Field_Handle for his own use, and then return it |
|---|
| 224 | to the BVBIlib_List sub-API after he is done with it. |
|---|
| 225 | o Each BVBI_Field_Handle allocated by BVBIlib has a usage count associated |
|---|
| 226 | with it. This allows a handle to be used by several "clients" at once. The |
|---|
| 227 | most extreme case of this is that a handle can be enqueued for encoding on |
|---|
| 228 | both VEC cores, and also retained for reading by user software. BVBIlib |
|---|
| 229 | recycles a handle when its usage count drops to zero. |
|---|
| 230 | |
|---|
| 231 | The following diagram indicates buffer usage in the BVBIlib module. |
|---|
| 232 | |
|---|
| 233 | +-+ |
|---|
| 234 | | | indicates a logically empty BVBI_Field_Handle |
|---|
| 235 | +-+ |
|---|
| 236 | |
|---|
| 237 | +-+ |
|---|
| 238 | |x| indicates a BVBI_Field_Handle that contains useful data |
|---|
| 239 | +-+ |
|---|
| 240 | |
|---|
| 241 | BVBIlib_List sub-API free list |
|---|
| 242 | +-+-+-+-+-+-+-+-+-+-+ |
|---|
| 243 | +-------------------< | | | | | | | | | | | <--------------------+ |
|---|
| 244 | | +-+-+-+-+-+-+-+-+-+-+ | |
|---|
| 245 | | | |
|---|
| 246 | | | |
|---|
| 247 | | | |
|---|
| 248 | | | |
|---|
| 249 | | +-+ +-+ | |
|---|
| 250 | +--->((O))--->| |---->(user s/w)---+----------->| | --->((O))----+ |
|---|
| 251 | | BVBIlib +-+ | +-+ BVBIlib | |
|---|
| 252 | | software | software | |
|---|
| 253 | | (reserve) | (return) | |
|---|
| 254 | | | | |
|---|
| 255 | | ___ +-+ | +-+-+-+-+-+ ___ | |
|---|
| 256 | +--->((O))--->|x|---->(user s/w)---+--->|x|x|x|x|x| --->((O))----+ |
|---|
| 257 | Decoder +-+ | +-+-+-+-+-+ Encoder | |
|---|
| 258 | hardware Decoder | Encoder hardware | |
|---|
| 259 | output | queue | |
|---|
| 260 | | | |
|---|
| 261 | | | |
|---|
| 262 | | | |
|---|
| 263 | | +-+-+-+-+-+ ___ | |
|---|
| 264 | +--->|x|x|x|x|x| --->((O))----+ |
|---|
| 265 | +-+-+-+-+-+ Encoder |
|---|
| 266 | Encoder hardware |
|---|
| 267 | queue |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | Working with BVBI_Field_Handles and Usage Counts |
|---|
| 271 | |
|---|
| 272 | The BVBIlib will take care of managing its collection of BVBI_Field_Handles and |
|---|
| 273 | prevent memory leaks related to these handles. The concept of usage count is |
|---|
| 274 | central to the management scheme, and the user of BVBIlib must follow certain |
|---|
| 275 | rules for this scheme to succeed. |
|---|
| 276 | |
|---|
| 277 | Certain functions cause a BVBI_Field_Handle to be given out to the user. |
|---|
| 278 | These functions are |
|---|
| 279 | o BVBIlib_Decode_Data_isr() |
|---|
| 280 | o BVBIlib_List_Obtain_isr() |
|---|
| 281 | These functions produce a BVBI_Field_Handle for the user to manipulate as he |
|---|
| 282 | wishes. The usage count of a BVBI_Field_Handle obtained in this manner is |
|---|
| 283 | zero. |
|---|
| 284 | |
|---|
| 285 | A function is provided so that the user can return a |
|---|
| 286 | BVBI_Field_Handle and enqueue it for encoding: |
|---|
| 287 | o BVBIlib_Encode_Enqueue_isr() |
|---|
| 288 | This function accepts a BVBI_Field_Handle from the user. In most cases, the |
|---|
| 289 | user should no longer access the BVBI_Field_Handle after calling this |
|---|
| 290 | function. There are exceptions, described below. In all cases, the BVBIlib |
|---|
| 291 | increments the usage count of the BVBI_Field_Handle as it is enqueued. |
|---|
| 292 | |
|---|
| 293 | A function is provided that encodes the VBI data in the oldest |
|---|
| 294 | BVBI_Field_Handle in an encoder's queue: |
|---|
| 295 | o BVBIlib_Encode_Data_isr() |
|---|
| 296 | After this function encodes the VBI data, it decrements the use count of the |
|---|
| 297 | BVBI_Field_handle. If the usage count is then zero, BVBIlib recycles the |
|---|
| 298 | BVBI_Field_Handle for other use. This is the purpose of the usage count. |
|---|
| 299 | |
|---|
| 300 | Another function is provided so that the user can return a BVBI_Field_Handle |
|---|
| 301 | without encoding it: |
|---|
| 302 | o BVBIlib_List_Return_isr() |
|---|
| 303 | This function puts a BVBI_Field_Handle onto a BVBIlib_List free list. The |
|---|
| 304 | BVBI_Field_Handle is thus "recycled," and available for use again. |
|---|
| 305 | |
|---|
| 306 | The simplest use case of the BVBIlib is to simply decode a field of VBI data |
|---|
| 307 | and immediately encode it. From the point of view of memory (leak) management, |
|---|
| 308 | the usage is |
|---|
| 309 | |
|---|
| 310 | BVBIlib_Decode_Data_isr() // Returns a BVBI_Field_Handle, usage count 0. |
|---|
| 311 | BVBIlib_Encode_Enqueue_isr() // Enqueues the above BVBI_Field_Handle, usage |
|---|
| 312 | // count will increment to 1. |
|---|
| 313 | BVBIlib_Encode_Data_isr() // Dequeues the BVBI_field_Handle and encodes |
|---|
| 314 | // its VBI data. The usage count drops to |
|---|
| 315 | // zero, so the BVBI_Field_Handle is recycled |
|---|
| 316 | // to a BVBIlib_List free list. |
|---|
| 317 | |
|---|
| 318 | In the above example, the user must NOT access the BVBI_Field_Handle after |
|---|
| 319 | BVBIlib_Encode_Enqueue_isr() is called, because the BVBI_Field_Handle is |
|---|
| 320 | subject to reuse by BVBIlib. The above programming example is a simple obtain, |
|---|
| 321 | return sequence. |
|---|
| 322 | |
|---|
| 323 | Another use case is the situation where the user decodes VBI data, but does not |
|---|
| 324 | re-encode it into an outgoing video destination. From the point of view of |
|---|
| 325 | memory (leak) management, the usage is |
|---|
| 326 | |
|---|
| 327 | BVBIlib_Decode_Data_isr() // Returns a BVBI_Field_Handle, usage count 0. |
|---|
| 328 | ... // User processes BVBI_Field_Handle as he |
|---|
| 329 | // wishes. |
|---|
| 330 | BVBIlib_List_Return_isr() // User returns the above BVBI_Field_Handle to |
|---|
| 331 | // BVBIlib for recycling to BVBIlib_list free |
|---|
| 332 | // list. |
|---|
| 333 | |
|---|
| 334 | Once again, the user must NOT access the BVBI_Field_Handle after |
|---|
| 335 | BVBIlib_List_Return_isr() is called. The above example is once again a simple |
|---|
| 336 | obtain, return sequence. |
|---|
| 337 | |
|---|
| 338 | A similar use case is the situation where the user does not decode any VBI |
|---|
| 339 | data, but synthesizes it to be encoded into outgoing video. From the point of |
|---|
| 340 | view of memory (leak) management, the usage is |
|---|
| 341 | |
|---|
| 342 | BVBIlib_List_Obtain_isr() // Gives a BVBI_Field_Handle to the user. |
|---|
| 343 | // Usage count is 0. |
|---|
| 344 | ... // User fills the BVBI_Field_Handle with data |
|---|
| 345 | // of his own creation. |
|---|
| 346 | BVBIlib_Encode_Enqueue_isr() // Enqueues the above BVBI_Field_Handle, usage |
|---|
| 347 | // count will increment to 1. |
|---|
| 348 | BVBIlib_Encode_Data_isr() // Dequeues the BVBI_field_Handle and encodes |
|---|
| 349 | // its VBI data. The usage count drops to |
|---|
| 350 | // zero, so the BVBI_Field_Handle is recycled |
|---|
| 351 | // to a BVBIlib_List free list. |
|---|
| 352 | |
|---|
| 353 | Once again, the user must NOT access the BVBI_Field_Handle after |
|---|
| 354 | BVBIlib_Encode_Enqueue_isr() is called. Again, the example |
|---|
| 355 | illustrates a simple obtain, return. |
|---|
| 356 | |
|---|
| 357 | Here is a slight complication. Suppose that an application is to |
|---|
| 358 | decode VBI from the incoming video source, and re-encode it into |
|---|
| 359 | TWO video destinations. The use count prevents BVBI_Field_Handles |
|---|
| 360 | from being recycled too soon: |
|---|
| 361 | |
|---|
| 362 | BVBIlib_Decode_Data_isr() // Returns a BVBI_Field_Handle, usage count 0. |
|---|
| 363 | BVBIlib_Encode_Enqueue_isr() // Usage count increments to 1. |
|---|
| 364 | BVBIlib_Encode_Enqueue_isr() // Usage count increments to 2. |
|---|
| 365 | BVBIlib_Encode_Data_isr() // Usage count decrements to 1. |
|---|
| 366 | BVBIlib_Encode_Data_isr() // Usage count decrements to 0. |
|---|
| 367 | |
|---|
| 368 | The last two calls to BVBIlib_Encode_Data_isr() apply to two |
|---|
| 369 | different encoder queues. Thus, the order in which the two calls |
|---|
| 370 | occur cannot be predicted. Nevertheless, when the BVBI_Field_Handle |
|---|
| 371 | passes through both queues and its data is encoded (twice), the |
|---|
| 372 | usage count will drop to zero and the BVBIlib software will recycle |
|---|
| 373 | the BVBI_Field_Handle. |
|---|
| 374 | |
|---|
| 375 | Here is a final, maximally complicated usage case. Please note |
|---|
| 376 | that a typical user will not have to bother with the following |
|---|
| 377 | method. Suppose that the user develops his own software to |
|---|
| 378 | process VBI data. Suppose also that this customer wishes to |
|---|
| 379 | use VEC hardware to encode the same VBI data in the usual way. |
|---|
| 380 | This syslib provides functions BVBIlib_List_IncrementUsage_isr() |
|---|
| 381 | and BVBIlib_List_DecrementUsage_isr() to support this usage. |
|---|
| 382 | These two functions provide a backdoor into the memory management |
|---|
| 383 | scheme of this syslib. Therefore, they should not normally be used. |
|---|
| 384 | Here is the previous example of decoding and (dual) encoding, |
|---|
| 385 | with added VBI processing by the customer: |
|---|
| 386 | |
|---|
| 387 | BVBIlib_Decode_Data_isr() // Returns a BVBI_Field_Handle, usage count 0. |
|---|
| 388 | BVBIlib_List_IncrementUsage_isr() |
|---|
| 389 | // Usage count increments to 1 |
|---|
| 390 | BVBIlib_Encode_Enqueue_isr() // Usage count increments to 2. |
|---|
| 391 | BVBIlib_Encode_Enqueue_isr() // Usage count increments to 3. |
|---|
| 392 | BVBIlib_Encode_Data_isr() // Usage count decrements to 2. |
|---|
| 393 | BVBIlib_List_DecrementUsage_isr() |
|---|
| 394 | // Usage count decrements to 1 |
|---|
| 395 | BVBIlib_Encode_Data_isr() // Usage count decrements to 0. |
|---|
| 396 | |
|---|
| 397 | The last three function calls all decrement the usage count, and |
|---|
| 398 | may occur in any order. As in the previous example, when the usage |
|---|
| 399 | count decrements to zero, one of the BVBIlib functions will recycle |
|---|
| 400 | the BVBI_Field_Handle. |
|---|
| 401 | |
|---|
| 402 | Usage |
|---|
| 403 | The usage of BVBIlib involves the following. This programming takes place in |
|---|
| 404 | the main thread of execution, not in interrupt context. |
|---|
| 405 | * Open and Configure BVBIlib |
|---|
| 406 | * Open the BVBI module |
|---|
| 407 | * Create BVBI encoder handles and BVBI decoder handles |
|---|
| 408 | * Configure the BVBI encoder handles and BVBI decoder handles |
|---|
| 409 | * Open the BVBIlib module |
|---|
| 410 | * Create one or more BVBIlib_List free lists for use by encoders and |
|---|
| 411 | decoders. |
|---|
| 412 | * Create BVBIlib encoders and decoders, selecting types of VBI data to |
|---|
| 413 | be encoded and/or decoded (closed caption, teletext, etc.). |
|---|
| 414 | * Install the two BVBIlib ISR functions, usually using the BINT module. |
|---|
| 415 | * Apply changes to the BVBI encoder handles and BVBI decoder handles. |
|---|
| 416 | This causes VBI data extraction and/or insertion to begin. |
|---|
| 417 | * Repeatedly decode and process a field of VBI data (in decode ISR) |
|---|
| 418 | * Obtain a field of decoded VBI data, using a BVBIlib function. |
|---|
| 419 | * Reformat (extract) VBI data, using BVBI functions. |
|---|
| 420 | * Process VBI data, using customer software. |
|---|
| 421 | * Reformat (insert) VBI data, using BVBI functions. |
|---|
| 422 | * Enqueue a field of VBI data for encoding, using a BVBIlib function. |
|---|
| 423 | * Repeatedly encode a field of VBI data (in encode ISR) |
|---|
| 424 | * Dequeue and encode a field of VBI data, using a BVBIlib function. |
|---|
| 425 | * - or - instruct the encoder hardware to send no data for one field. |
|---|
| 426 | * Close and deallocate |
|---|
| 427 | * Turn off VBI encoding and decoding by calling BVBI functions. |
|---|
| 428 | * Return any outstanding BVBI_Field_Handles to BVBIlib_List. |
|---|
| 429 | * Destroy BVBIlib encoders and decoders. |
|---|
| 430 | * Destroy BVBIlib_List free list(s). |
|---|
| 431 | * Close the BVBIlib module. |
|---|
| 432 | * Destroy BVBI encoders and decoders. |
|---|
| 433 | * Close the BVBI module. |
|---|
| 434 | |
|---|
| 435 | Some observations |
|---|
| 436 | o The encoder queues will have a fixed length chosen by the user. If the queue |
|---|
| 437 | fills up, BVBIlib will discard the oldest VBI field data. |
|---|
| 438 | o The design allows the user to instantly pass a field of captured (decoded) |
|---|
| 439 | VBI data to one or more VBI encoders. The user can also "reserve" fields of |
|---|
| 440 | data for his use, so that BVBIlib will NOT recycle these fields after they |
|---|
| 441 | are encoded. However, these fields do not live in any queue or list that is |
|---|
| 442 | accessable to the user. The user must construct his own queue or list if he |
|---|
| 443 | wishes to keep several fields of VBI data hanging around his application |
|---|
| 444 | software. |
|---|
| 445 | o When BVBIlib_List is created, a number of empty BVBI_Field_Handles are |
|---|
| 446 | created. The user chooses how many. The user also has to choose whether or |
|---|
| 447 | not these handles will be capable of holding teletext data. The user also |
|---|
| 448 | has to choose whether or not these handles will be capable of holding VPS |
|---|
| 449 | data. For each of these two decisions, it's "all or nothing." All handles |
|---|
| 450 | will be sized to hold teletext, or none of them. Similarly for VPS. |
|---|
| 451 | o The implementation will depend on the fact that the interrupts that mark the |
|---|
| 452 | beginning of active video (encoded and decoded) for each VEC and VDEC will |
|---|
| 453 | not override each other. In other words, each associated ISR will run to |
|---|
| 454 | completion before any other BVBIlib-hosting ISR starts to run. |
|---|
| 455 | |
|---|
| 456 | Sample Code |
|---|
| 457 | |
|---|
| 458 | /////////////////////////////////////////////////////////////// |
|---|
| 459 | // Begin initialization code: runs in non-interrupt context. // |
|---|
| 460 | /////////////////////////////////////////////////////////////// |
|---|
| 461 | |
|---|
| 462 | BMEM_Handle memHandle; |
|---|
| 463 | BVBI_Handle vbiHandle; |
|---|
| 464 | BVBI_Decode_Handle decHdl; |
|---|
| 465 | BVBI_Encode_Handle encHdl; |
|---|
| 466 | BVBIlib_Handle vbilHandle; |
|---|
| 467 | BVBIlib_list_Handle listHandle; |
|---|
| 468 | BVBIlib_Decode_Handle declHdl; |
|---|
| 469 | BVBIlib_Encode_Handle EnclHdl; |
|---|
| 470 | |
|---|
| 471 | // Initialize BMEM module. |
|---|
| 472 | // This results in a valid memHandle. |
|---|
| 473 | // See programmers guide to BMEM base module for info. |
|---|
| 474 | |
|---|
| 475 | // Initialize BVBI porting interface module. |
|---|
| 476 | // This results in valid vbiHandle, decHdl, and encHdl. |
|---|
| 477 | // See programmers guide to BVBI porting interface for example code. |
|---|
| 478 | |
|---|
| 479 | // Open the BVBIlib module |
|---|
| 480 | BVBIlib_Open (&vbilHandle, vbiHandle); |
|---|
| 481 | |
|---|
| 482 | // Create a BVBIlib free list to manage 16 BVBI field handles |
|---|
| 483 | BVBIlib_List_Create (&listHandle, vbiHandle, 16, NULL); |
|---|
| 484 | |
|---|
| 485 | // Create a BVBIlib decoder and encoder |
|---|
| 486 | BVBIlib_Decode_Create (vbilHandle, listHandle, decHdl, &declHdl); |
|---|
| 487 | BVBIlib_Encode_Create (vbilHandle, listHandle, encHdl, 4, &enclHdl); |
|---|
| 488 | |
|---|
| 489 | ///////////////////////////// |
|---|
| 490 | // End initialization code // |
|---|
| 491 | ///////////////////////////// |
|---|
| 492 | |
|---|
| 493 | //////////////////////////// |
|---|
| 494 | // Begin Encoder ISR code // |
|---|
| 495 | //////////////////////////// |
|---|
| 496 | |
|---|
| 497 | // This bit of code should be installed into the ISR that is associated with |
|---|
| 498 | // the interrupt that marks the beginning of active video for the VEC that is |
|---|
| 499 | // associated with handle encHdl above. |
|---|
| 500 | |
|---|
| 501 | BAVC_Polarity polarity; |
|---|
| 502 | BVBIlib_Encode_Handle enclHdl; |
|---|
| 503 | |
|---|
| 504 | // In the following, enclHdl is the same variable that was initialized above. |
|---|
| 505 | // The BINT module provides a method for passing a variable to an ISR. |
|---|
| 506 | // Setting the polarity argument is tricky. See the programmers guide to the |
|---|
| 507 | // BVBI porting interface for details. |
|---|
| 508 | BVBIlib_Encode_Data_isr (enclHdl, polarity); |
|---|
| 509 | |
|---|
| 510 | ////////////////////////// |
|---|
| 511 | // End Encoder ISR code // |
|---|
| 512 | ////////////////////////// |
|---|
| 513 | |
|---|
| 514 | //////////////////////////// |
|---|
| 515 | // Begin Decoder ISR code // |
|---|
| 516 | //////////////////////////// |
|---|
| 517 | |
|---|
| 518 | // This code should be installed into the ISR that is associated with the |
|---|
| 519 | // interrupt that marks the beginning of active video for the VDEC that is |
|---|
| 520 | // associated with handle decHdl above. |
|---|
| 521 | |
|---|
| 522 | uint16_t ccData; |
|---|
| 523 | BAVC_Polarity polarity; |
|---|
| 524 | BVBI_Field_Handle fieldHandle; |
|---|
| 525 | BVBIlib_Decode_Handle declHdl; |
|---|
| 526 | BVBIlib_Encode_Handle enclHdl; |
|---|
| 527 | |
|---|
| 528 | // In the following, declHdl is the same variable that was initialized above. |
|---|
| 529 | // The BINT module provides a method for passing a variable to an ISR. |
|---|
| 530 | // Setting the polarity argument is tricky. See the programmers guide to the |
|---|
| 531 | // BVBI porting interface for details. |
|---|
| 532 | // |
|---|
| 533 | // This function call obtains decoded VBI data for the previous field. |
|---|
| 534 | BVBIlib_Decode_Data_isr (declHdl, &fieldHandle, polarity); |
|---|
| 535 | |
|---|
| 536 | // Modify the decoded VBI data (a silly example) |
|---|
| 537 | BVBI_Field_GetCCData_isr (fieldHandke, &ccData); |
|---|
| 538 | ccData = ccData + 1; |
|---|
| 539 | ccData = BVBI_SecCCParityBits (ccData); |
|---|
| 540 | BVBI_Field_SetCCData_isr (fieldHandke, ccData); |
|---|
| 541 | |
|---|
| 542 | // In the following, enclHdl is the same variable that was initialized above. |
|---|
| 543 | // This function call sends the modified VBI data to the VEC for encoding. |
|---|
| 544 | BVBIlib_Encode_Enqueue_isr (enclHdl, fieldHandle); |
|---|
| 545 | |
|---|
| 546 | ////////////////////////// |
|---|
| 547 | // End Decoder ISR code // |
|---|
| 548 | ////////////////////////// |
|---|
| 549 | |
|---|
| 550 | </verbatim> |
|---|
| 551 | ***************************************************************************/ |
|---|
| 552 | |
|---|
| 553 | #ifndef BVBILIB_H__ |
|---|
| 554 | #define BVBILIB_H__ |
|---|
| 555 | |
|---|
| 556 | #include "berr.h" |
|---|
| 557 | #include "bvbi.h" |
|---|
| 558 | /* Only for backwards compatibility */ |
|---|
| 559 | #include "budp.h" |
|---|
| 560 | |
|---|
| 561 | #ifdef __cplusplus |
|---|
| 562 | extern "C" { |
|---|
| 563 | #endif |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | /***************************************************************************** |
|---|
| 567 | Module specific standard BERR codes |
|---|
| 568 | *****************************************************************************/ |
|---|
| 569 | /* This error indicates that a handle has been closed, but the user has failed |
|---|
| 570 | to return all its resources first. */ |
|---|
| 571 | #define BVBIlib_USER_LEAK BERR_MAKE_CODE(BERR_VBIlib_ID, 0x0000) |
|---|
| 572 | #define BVBIlib_NO_HANDLES BERR_MAKE_CODE(BERR_VBIlib_ID, 0x0001) |
|---|
| 573 | #define BVBIlib_QUEUE_FULL BERR_MAKE_CODE(BERR_VBIlib_ID, 0x0002) |
|---|
| 574 | |
|---|
| 575 | /* The following codes are used by the bitstream parsers */ |
|---|
| 576 | #define BERR_BVBIlib_NO_DATA BERR_BUDP_NO_DATA |
|---|
| 577 | #define BERR_BVBIlib_PARSE_ERROR BERR_BUDP_PARSE_ERROR |
|---|
| 578 | #define BERR_BVBIlib_SOURCE_CHECK BERR_BUDP_SOURCE_CHECK |
|---|
| 579 | |
|---|
| 580 | /* Programming note: |
|---|
| 581 | * ---------------- |
|---|
| 582 | * The above error code BERR_BVBIlib_SOURCE_CHECK indicates that parsing is |
|---|
| 583 | * successful. However, because the data was encoded into an MPEG sequence |
|---|
| 584 | * header or GOP header, this data is not suitable for text output. |
|---|
| 585 | */ |
|---|
| 586 | |
|---|
| 587 | /***************************************************************************** |
|---|
| 588 | * Structures |
|---|
| 589 | *****************************************************************************/ |
|---|
| 590 | |
|---|
| 591 | /***************************************************************************** |
|---|
| 592 | Summary: |
|---|
| 593 | Handle for BVBIlib module |
|---|
| 594 | |
|---|
| 595 | Description: |
|---|
| 596 | The BVBIlib_Handle, once opened, represents the state of the BVBIlib |
|---|
| 597 | module. |
|---|
| 598 | |
|---|
| 599 | See Also: |
|---|
| 600 | BVBIlib_Open |
|---|
| 601 | *****************************************************************************/ |
|---|
| 602 | typedef struct BVBIlib_P_Handle *BVBIlib_Handle; /* Opaque */ |
|---|
| 603 | |
|---|
| 604 | /***************************************************************************** |
|---|
| 605 | Summary: |
|---|
| 606 | Settings for BVBIlib_List module |
|---|
| 607 | |
|---|
| 608 | Description: |
|---|
| 609 | The BVBIlib_List_Settings struct contains various settings for the |
|---|
| 610 | BVBIlib_List free list. |
|---|
| 611 | |
|---|
| 612 | See Also: |
|---|
| 613 | BVBIlib_List_Create, BVBIlib_List_GetDefaultSettings |
|---|
| 614 | *****************************************************************************/ |
|---|
| 615 | typedef struct BVBIlib_List_Settings |
|---|
| 616 | { |
|---|
| 617 | bool bAllowTeletext; /* Whether or not it will be possible to |
|---|
| 618 | encode/decode teletext. */ |
|---|
| 619 | bool bAllowVPS; /* Whether or not it will be possible to |
|---|
| 620 | encode/decode VPS. */ |
|---|
| 621 | bool bAllowGemstar; /* Whether or not it will be possible to |
|---|
| 622 | encode/decode Gemstar. */ |
|---|
| 623 | bool bAllowAmol; /* Whether or not it will be possible to |
|---|
| 624 | encode/decode AMOL. */ |
|---|
| 625 | bool bAllowMcc; /* Whether or not it will be possible to |
|---|
| 626 | encode/decode multi-line closed caption. */ |
|---|
| 627 | bool bAllowCgmsB; /* Whether or not it will be possible to |
|---|
| 628 | encode/decode CGMS-B. */ |
|---|
| 629 | size_t scteCcSize; /* Maximum number of SCTE closed caption entries |
|---|
| 630 | to reserve space for in each field handle. |
|---|
| 631 | May be zero. */ |
|---|
| 632 | size_t scteNrtvSize; /* Maximum number of SCTE NRTV entries to reserve |
|---|
| 633 | space for in each field handle. May be zero. */ |
|---|
| 634 | size_t sctePamSize; /* Maximum number of SCTE luma_PAM_data bytes to |
|---|
| 635 | reserve space for in each field handle. May |
|---|
| 636 | be zero. */ |
|---|
| 637 | size_t scteMonoSize; /* Maximum number of SCTE monochrome bytes to |
|---|
| 638 | reserve space for in each each of two line |
|---|
| 639 | stores, in each field handle. May be zero. */ |
|---|
| 640 | } |
|---|
| 641 | BVBIlib_List_Settings; |
|---|
| 642 | |
|---|
| 643 | /***************************************************************************** |
|---|
| 644 | Summary: |
|---|
| 645 | Handle for BVBIlib_List module |
|---|
| 646 | |
|---|
| 647 | Description: |
|---|
| 648 | The BVBIlib_List_Handle, once opened, represents the state of a |
|---|
| 649 | BVBIlib_List free list (of BVBI_Field_Handles). |
|---|
| 650 | |
|---|
| 651 | See Also: |
|---|
| 652 | BVBIlib_LIst_Create |
|---|
| 653 | *****************************************************************************/ |
|---|
| 654 | typedef struct BVBIlib_P_List_Handle *BVBIlib_List_Handle; /* Opaque */ |
|---|
| 655 | |
|---|
| 656 | |
|---|
| 657 | /***************************************************************************** |
|---|
| 658 | Summary: |
|---|
| 659 | Handle for VBI encoding functionality |
|---|
| 660 | |
|---|
| 661 | Description: |
|---|
| 662 | The BVBIlib_Encode_Handle is used to control how VBI encoding is done. |
|---|
| 663 | It is used by a number of encoding-related functions. It is allocated |
|---|
| 664 | by BVBIlib_Encode_Create. |
|---|
| 665 | |
|---|
| 666 | See Also: |
|---|
| 667 | BVBIlib_Encode_Create, BVBIlib_Encode_Destroy |
|---|
| 668 | *****************************************************************************/ |
|---|
| 669 | typedef struct BVBIlib_P_Encode_Handle *BVBIlib_Encode_Handle; /* Opaque */ |
|---|
| 670 | |
|---|
| 671 | |
|---|
| 672 | /***************************************************************************** |
|---|
| 673 | Summary: |
|---|
| 674 | Handle for VBI decoding functionality |
|---|
| 675 | |
|---|
| 676 | Description: |
|---|
| 677 | The BVBIlib_Decode_Handle is used to control how VBI decoding is done. |
|---|
| 678 | It is used by a number of decoding-related functions. It is allocated |
|---|
| 679 | by BVBIlib_Decode_Create. |
|---|
| 680 | |
|---|
| 681 | See Also: |
|---|
| 682 | BVBIlib_Encode_Create, BVBIilb_Encode_Destroy |
|---|
| 683 | *****************************************************************************/ |
|---|
| 684 | typedef struct BVBIlib_P_Decode_Handle *BVBIlib_Decode_Handle; /* Opaque */ |
|---|
| 685 | |
|---|
| 686 | |
|---|
| 687 | /***************************************************************************** |
|---|
| 688 | * Public API |
|---|
| 689 | *****************************************************************************/ |
|---|
| 690 | |
|---|
| 691 | |
|---|
| 692 | /***************************************************************************** |
|---|
| 693 | Summary: |
|---|
| 694 | Initialize the BVBIlib module |
|---|
| 695 | |
|---|
| 696 | Description: |
|---|
| 697 | This module intializes the BVBIlib module. |
|---|
| 698 | |
|---|
| 699 | Returns: |
|---|
| 700 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 701 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 702 | possibly NULL. |
|---|
| 703 | BERR_OUT_OF_SYSTEM_MEMORY - Memory allocation failed. |
|---|
| 704 | |
|---|
| 705 | See Also: |
|---|
| 706 | BVBIlib_Close |
|---|
| 707 | *****************************************************************************/ |
|---|
| 708 | BERR_Code BVBIlib_Open( |
|---|
| 709 | BVBIlib_Handle *pVbilHandle, /* [out] A pointer to an allocated |
|---|
| 710 | BVBIlib_Handle */ |
|---|
| 711 | BVBI_Handle vbiHandle /* [in] An initialized BVBI module |
|---|
| 712 | handle. */ |
|---|
| 713 | ); |
|---|
| 714 | |
|---|
| 715 | |
|---|
| 716 | /***************************************************************************** |
|---|
| 717 | Summary: |
|---|
| 718 | Close a BVBIlib_Handle. |
|---|
| 719 | |
|---|
| 720 | Description: |
|---|
| 721 | This function frees the BVBIlib_Handle structure and all associated data. |
|---|
| 722 | It does NOT shutown any BVBI handles. |
|---|
| 723 | |
|---|
| 724 | *****************************************************************************/ |
|---|
| 725 | void BVBIlib_Close( |
|---|
| 726 | BVBIlib_Handle vbilHandle /* [in] A valid BVBIlib_Handle object */ |
|---|
| 727 | ); |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | /***************************************************************************** |
|---|
| 731 | Summary: |
|---|
| 732 | Get the default settings for the BVBIlib_List free list |
|---|
| 733 | |
|---|
| 734 | Description: |
|---|
| 735 | This module fills in a settings data structure for the BVBIlib_List module |
|---|
| 736 | with default values. |
|---|
| 737 | |
|---|
| 738 | Returns: |
|---|
| 739 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 740 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 741 | possibly NULL. |
|---|
| 742 | |
|---|
| 743 | See Also: |
|---|
| 744 | BVBIlib_List_Create |
|---|
| 745 | *****************************************************************************/ |
|---|
| 746 | BERR_Code BVBIlib_List_GetDefaultSettings ( |
|---|
| 747 | BVBIlib_List_Settings* pSettings /* [out] Pointer to an allocated |
|---|
| 748 | BVBIlib_List_Settings |
|---|
| 749 | object. */ |
|---|
| 750 | ); |
|---|
| 751 | |
|---|
| 752 | |
|---|
| 753 | /***************************************************************************** |
|---|
| 754 | Summary: |
|---|
| 755 | Create a BVBIlib_List free list |
|---|
| 756 | |
|---|
| 757 | Description: |
|---|
| 758 | This module creates a BVBIlib_List free list (of BVBI_Field_Handles). |
|---|
| 759 | |
|---|
| 760 | Returns: |
|---|
| 761 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 762 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 763 | possibly NULL. |
|---|
| 764 | BERR_OUT_OF_SYSTEM_MEMORY - Memory allocation failed. |
|---|
| 765 | |
|---|
| 766 | See Also: |
|---|
| 767 | BVBIlib_List_Destroy |
|---|
| 768 | *****************************************************************************/ |
|---|
| 769 | BERR_Code BVBIlib_List_Create( |
|---|
| 770 | BVBIlib_List_Handle * listHandle, /* [out] A pointer to an allocated |
|---|
| 771 | BVBIlib_List_Handle. */ |
|---|
| 772 | BVBI_Handle vbiHandle, /* [in] The main BVBI context |
|---|
| 773 | handle. */ |
|---|
| 774 | int nHandles, /* [in] How many BVBI_Field_Handles |
|---|
| 775 | to create in the list. */ |
|---|
| 776 | const BVBIlib_List_Settings* |
|---|
| 777 | pSettings /* [in] Various settings for the |
|---|
| 778 | list. Use NULL to get the |
|---|
| 779 | default settings. */ |
|---|
| 780 | ); |
|---|
| 781 | |
|---|
| 782 | |
|---|
| 783 | /***************************************************************************** |
|---|
| 784 | Summary: |
|---|
| 785 | Destroy a BVBIlib_List_Handle. |
|---|
| 786 | |
|---|
| 787 | Description: |
|---|
| 788 | This function destroys a valid BVBIlib_List_Handle created by |
|---|
| 789 | BVBIlib_List_Create. Any BVBI_Field_Handles contained in the list are |
|---|
| 790 | destroyed as well. |
|---|
| 791 | |
|---|
| 792 | Returns: |
|---|
| 793 | BERR_SUCCESS - The handle was successfully destroyed. |
|---|
| 794 | BERR_INVALID_PARAMETER - The supplied parameter was invalid, |
|---|
| 795 | possibly NULL. |
|---|
| 796 | BERR_VBIlib_USER_LEAK - Some of the BVBI_Field_Handles were not |
|---|
| 797 | returned to the free list. |
|---|
| 798 | |
|---|
| 799 | *****************************************************************************/ |
|---|
| 800 | BERR_Code BVBIlib_List_Destroy( |
|---|
| 801 | BVBIlib_List_Handle listHandle /* [in] A BVBIlib_List_Handle to be |
|---|
| 802 | destroyed */ |
|---|
| 803 | ); |
|---|
| 804 | |
|---|
| 805 | |
|---|
| 806 | /***************************************************************************** |
|---|
| 807 | Summary: |
|---|
| 808 | Create a BVBIlib_Decode_Handle. |
|---|
| 809 | |
|---|
| 810 | Description: |
|---|
| 811 | This function creates a BVBIlib_Decode_Handle for the specified |
|---|
| 812 | BVBI_Decode_Handle. The state of the BVBI_Decode_Handle determines |
|---|
| 813 | what VBI data is decoded. |
|---|
| 814 | |
|---|
| 815 | Returns: |
|---|
| 816 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 817 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 818 | possibly NULL. |
|---|
| 819 | BERR_OUT_OF_SYSTEM_MEMORY - Memory allocation failed. |
|---|
| 820 | |
|---|
| 821 | *****************************************************************************/ |
|---|
| 822 | BERR_Code BVBIlib_Decode_Create( |
|---|
| 823 | BVBIlib_Handle vbilHandle, /* [in] A valid BVBIlib_Handle |
|---|
| 824 | object */ |
|---|
| 825 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 826 | to use as a source of |
|---|
| 827 | BVBI_Field_Handles */ |
|---|
| 828 | BVBI_Decode_Handle decHdl, /* [in] A valid BVBI_Decode_Handle */ |
|---|
| 829 | BVBIlib_Decode_Handle * pDeclHdl /* [out] A pointer to a |
|---|
| 830 | BVBIlib_Decode_Handle to |
|---|
| 831 | be initialized */ |
|---|
| 832 | ); |
|---|
| 833 | |
|---|
| 834 | |
|---|
| 835 | /***************************************************************************** |
|---|
| 836 | Summary: |
|---|
| 837 | Create a BVBIlib_Encode_Handle. |
|---|
| 838 | |
|---|
| 839 | Description: |
|---|
| 840 | This function creates a BVBIlib_Encode_Handle for the specified |
|---|
| 841 | BVBI_Encode_Handle. The state of the BVBI_Encode_Handle determines |
|---|
| 842 | what VBI data is encoded. |
|---|
| 843 | |
|---|
| 844 | Returns: |
|---|
| 845 | BERR_SUCCESS - The handle was successfully created. |
|---|
| 846 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 847 | possibly NULL. |
|---|
| 848 | BERR_OUT_OF_SYSTEM_MEMORY - Memory allocation failed. |
|---|
| 849 | |
|---|
| 850 | *****************************************************************************/ |
|---|
| 851 | BERR_Code BVBIlib_Encode_Create( |
|---|
| 852 | BVBIlib_Handle vbilHandle, /* [in] A valid BVBIlib_Handle |
|---|
| 853 | object */ |
|---|
| 854 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 855 | to recycle |
|---|
| 856 | BVBI_Field_Handless to |
|---|
| 857 | after encoding */ |
|---|
| 858 | BVBI_Encode_Handle encHdl, /* [in] A valid BVBI_Encode_Handle */ |
|---|
| 859 | int nMaxQueue, /* [in] The maximum number of |
|---|
| 860 | fields of VBI data that may |
|---|
| 861 | be enqueued for future |
|---|
| 862 | encoding. If this limit is |
|---|
| 863 | exceeded, the oldest |
|---|
| 864 | enqueued VBI data will be |
|---|
| 865 | discarded. */ |
|---|
| 866 | BVBIlib_Encode_Handle * pEnclHdl /* [out] A pointer to a |
|---|
| 867 | BVBIlib_Encode_Handle to |
|---|
| 868 | be initialized */ |
|---|
| 869 | ); |
|---|
| 870 | |
|---|
| 871 | |
|---|
| 872 | |
|---|
| 873 | /***************************************************************************** |
|---|
| 874 | Summary: |
|---|
| 875 | Destroy a BVBIlib_Decode_Handle. |
|---|
| 876 | |
|---|
| 877 | Description: |
|---|
| 878 | This function destroys a valid BVBIlib_Decode_Handle created by |
|---|
| 879 | BVBIlib_Decode_Create. It does NOT destroy any BVBI_Decode_Handles. |
|---|
| 880 | |
|---|
| 881 | Returns: |
|---|
| 882 | BERR_SUCCESS - The handle was successfully destroyed. |
|---|
| 883 | BERR_INVALID_PARAMETER - The supplied parameter was invalid, |
|---|
| 884 | possibly NULL. |
|---|
| 885 | |
|---|
| 886 | *****************************************************************************/ |
|---|
| 887 | BERR_Code BVBIlib_Decode_Destroy( |
|---|
| 888 | BVBIlib_Decode_Handle declHdl /* [in] A BVBIlib_Decode_Handle to be |
|---|
| 889 | destroyed */ |
|---|
| 890 | ); |
|---|
| 891 | |
|---|
| 892 | |
|---|
| 893 | |
|---|
| 894 | /***************************************************************************** |
|---|
| 895 | Summary: |
|---|
| 896 | Destroy a BVBIlib_Encode_Handle. |
|---|
| 897 | |
|---|
| 898 | Description: |
|---|
| 899 | This function destroys a valid BVBIlib_Encode_Handle created by |
|---|
| 900 | BVBIlib_Encode_Create. It does NOT destroy any BVBI_Encode_Handles. |
|---|
| 901 | |
|---|
| 902 | Returns: |
|---|
| 903 | BERR_SUCCESS - The handle was successfully destroyed. |
|---|
| 904 | BERR_INVALID_PARAMETER - The supplied parameter was invalid, |
|---|
| 905 | possibly NULL. |
|---|
| 906 | |
|---|
| 907 | *****************************************************************************/ |
|---|
| 908 | BERR_Code BVBIlib_Encode_Destroy( |
|---|
| 909 | BVBIlib_Encode_Handle enclHdl /* [in] A BVBIlib_Encode_Handle to be |
|---|
| 910 | destroyed */ |
|---|
| 911 | ); |
|---|
| 912 | |
|---|
| 913 | |
|---|
| 914 | /***************************************************************************** |
|---|
| 915 | Summary: |
|---|
| 916 | Decodes a field of VBI data and provides it to the caller. |
|---|
| 917 | |
|---|
| 918 | Description: |
|---|
| 919 | This function takes an active BVBIlib_Decode_Handle and decodes |
|---|
| 920 | VBI data into it. The data structure (handle) required to hold |
|---|
| 921 | this data is allocated by this function, not by the user. |
|---|
| 922 | |
|---|
| 923 | This function is intended to be called from the interrupt |
|---|
| 924 | that marks the beginning of a field of decoded active |
|---|
| 925 | video. For most applications, the ISR corresponding to |
|---|
| 926 | this interrupt calls this function before any other VBI |
|---|
| 927 | related processing. |
|---|
| 928 | |
|---|
| 929 | The programmer's guide includes a section _Working with |
|---|
| 930 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 931 | function. The user should understand this material in |
|---|
| 932 | order to avoid memory management problems. |
|---|
| 933 | |
|---|
| 934 | Setting the polarity parameter is a bit tricky. See the |
|---|
| 935 | documentation for function BVBI_Decode_Data_isr in the |
|---|
| 936 | BVBI module. |
|---|
| 937 | |
|---|
| 938 | Returns: |
|---|
| 939 | BERR_SUCCESS - The function call succeeded. |
|---|
| 940 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 941 | possibly NULL. |
|---|
| 942 | BVBI_ERR_FLDH_CONFLICT - The encode handle is configured to encode a |
|---|
| 943 | bulky data format such as teletext, but the |
|---|
| 944 | field handle is not properly sized for this. |
|---|
| 945 | |
|---|
| 946 | *****************************************************************************/ |
|---|
| 947 | BERR_Code BVBIlib_Decode_Data_isr( |
|---|
| 948 | BVBIlib_Decode_Handle declHdl, /* [in] A valid |
|---|
| 949 | BVBIlib_Decode_Handle object */ |
|---|
| 950 | BVBI_Field_Handle * pFieldHandle, /* [out] A pointer to a |
|---|
| 951 | BVBI_Field_Handle |
|---|
| 952 | object. Upon return, this |
|---|
| 953 | will point to the decoded |
|---|
| 954 | VBI data. */ |
|---|
| 955 | BAVC_Polarity polarity /* [in] Which field (even, odd, or |
|---|
| 956 | frame) to decode data from. */ |
|---|
| 957 | ); |
|---|
| 958 | |
|---|
| 959 | |
|---|
| 960 | /***************************************************************************** |
|---|
| 961 | Summary: |
|---|
| 962 | Enqueues a field of VBI data for encoding |
|---|
| 963 | |
|---|
| 964 | Description: |
|---|
| 965 | This function takes an active BVBIlib_Encode_Handle and valid |
|---|
| 966 | BVBI_Field_Handle and enqueues the VBI data appropriately for |
|---|
| 967 | future encoding. |
|---|
| 968 | |
|---|
| 969 | This function is intended to be called from the interrupt |
|---|
| 970 | that marks the beginning of a field of DECODED active |
|---|
| 971 | video. However, it requires a handle for an ENCODER. |
|---|
| 972 | |
|---|
| 973 | After working its way through the queue, the BVBI_Field_Handle will |
|---|
| 974 | eventually be encoded during a future call to BVBIlib_Encode_Data_isr(). |
|---|
| 975 | |
|---|
| 976 | The programmer's guide includes a section _Working with |
|---|
| 977 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 978 | function. The user should understand this material in |
|---|
| 979 | order to avoid memory management problems. |
|---|
| 980 | |
|---|
| 981 | Returns: |
|---|
| 982 | BERR_SUCCESS - The function call succeeded. |
|---|
| 983 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 984 | possibly NULL. |
|---|
| 985 | BVBIlib_QUEUE_FULL - The queue is full. The user's field handle |
|---|
| 986 | was not enqueued. |
|---|
| 987 | |
|---|
| 988 | *****************************************************************************/ |
|---|
| 989 | BERR_Code BVBIlib_Encode_Enqueue_isr( |
|---|
| 990 | BVBIlib_Encode_Handle enclHdl, /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 991 | object */ |
|---|
| 992 | BVBI_Field_Handle fieldHandle /* [in] A valid BVBI_Field_Handle |
|---|
| 993 | object. The handle will be |
|---|
| 994 | reused if its usage count is |
|---|
| 995 | zero, after encoding is |
|---|
| 996 | complete. */ |
|---|
| 997 | ); |
|---|
| 998 | |
|---|
| 999 | |
|---|
| 1000 | /***************************************************************************** |
|---|
| 1001 | Summary: |
|---|
| 1002 | Dequeues oldest field of VBI data and encodes it. |
|---|
| 1003 | |
|---|
| 1004 | Description: |
|---|
| 1005 | This function takes an active BVBIlib_Encode_Handle and |
|---|
| 1006 | possibly encodes the oldest queued field of VBI data. |
|---|
| 1007 | If the parity setting of the VBI data agrees with the |
|---|
| 1008 | current field, then the encoding takes place. Otherwise, |
|---|
| 1009 | the data remains queued until the next field. |
|---|
| 1010 | |
|---|
| 1011 | This function is intended to be called from the interrupt |
|---|
| 1012 | that marks the beginning of a field of encoded active |
|---|
| 1013 | video. For most applications, the ISR corresponding to |
|---|
| 1014 | this interrupt will do no other VBI related work except to |
|---|
| 1015 | call this function. |
|---|
| 1016 | |
|---|
| 1017 | In most applications, either this function or BVBIlib_Encode_NoData_isr |
|---|
| 1018 | should be called once per output video field. |
|---|
| 1019 | |
|---|
| 1020 | Setting the polarity parameter is a bit tricky. See the |
|---|
| 1021 | documentation for function BVBI_Encode_Data_isr in the |
|---|
| 1022 | BVBI module. |
|---|
| 1023 | |
|---|
| 1024 | Returns: |
|---|
| 1025 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1026 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1027 | possibly NULL. |
|---|
| 1028 | BVBI_ERR_FLDH_CONFLICT - The encode handle is configured to encode a |
|---|
| 1029 | bulky data format such as teletext, but the |
|---|
| 1030 | field handle is not properly sized for this. |
|---|
| 1031 | |
|---|
| 1032 | *****************************************************************************/ |
|---|
| 1033 | BERR_Code BVBIlib_Encode_Data_isr( |
|---|
| 1034 | BVBIlib_Encode_Handle enclHdl, /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 1035 | object */ |
|---|
| 1036 | BAVC_Polarity polarity /* [in] Which field (even, odd, or |
|---|
| 1037 | frame) to encode data into */ |
|---|
| 1038 | ); |
|---|
| 1039 | |
|---|
| 1040 | |
|---|
| 1041 | /***************************************************************************** |
|---|
| 1042 | Summary: |
|---|
| 1043 | Returns pointer to oldest piece of data in encoder queue. |
|---|
| 1044 | |
|---|
| 1045 | Description: |
|---|
| 1046 | This function takes an active BVBIlib_Encode_Handle and |
|---|
| 1047 | returns a pointer to the oldest piece of VBI data in the encode |
|---|
| 1048 | queue. Neither the state of the queue, nor the state of the VBI |
|---|
| 1049 | data is changed. |
|---|
| 1050 | |
|---|
| 1051 | This function is provided for the convenience of applications that |
|---|
| 1052 | must occasionally "mix in" a piece of VBI data at random times. In |
|---|
| 1053 | this situation, the application can add this data to the head of |
|---|
| 1054 | the encode queue, with the help of this function. If the queue is |
|---|
| 1055 | empty, the application can create a new BVBI field handle put his |
|---|
| 1056 | data into it, and finally put the field handle into the queue in |
|---|
| 1057 | the normal fashion. |
|---|
| 1058 | |
|---|
| 1059 | Returns: |
|---|
| 1060 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1061 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1062 | possibly NULL. |
|---|
| 1063 | |
|---|
| 1064 | *****************************************************************************/ |
|---|
| 1065 | BERR_Code BVBIlib_Encode_GetOldestDatum_isr( |
|---|
| 1066 | BVBIlib_Encode_Handle enclHdl, /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 1067 | object */ |
|---|
| 1068 | BVBI_Field_Handle* pFieldHandle /* [out] The oldest piece of data in |
|---|
| 1069 | the encode queue. NULL if the |
|---|
| 1070 | queue is empty. */ |
|---|
| 1071 | ); |
|---|
| 1072 | |
|---|
| 1073 | |
|---|
| 1074 | /***************************************************************************** |
|---|
| 1075 | Summary: |
|---|
| 1076 | Causes the VBI encoder hardware to output no VBI data for current field. |
|---|
| 1077 | |
|---|
| 1078 | Description: |
|---|
| 1079 | This function takes an active BVBIlib_Encode_Handle and |
|---|
| 1080 | causes the hardware to output NO VBI data |
|---|
| 1081 | for the next video field. This function is called |
|---|
| 1082 | in place of BVBIlib_Encode_Data_isr. |
|---|
| 1083 | |
|---|
| 1084 | This function is intended to be called from the interrupt |
|---|
| 1085 | that marks the beginning of a field of encoded active |
|---|
| 1086 | video. |
|---|
| 1087 | |
|---|
| 1088 | In most applications, either this function or BVBIlib_Encode_Data_isr |
|---|
| 1089 | should be called once per output video field. |
|---|
| 1090 | |
|---|
| 1091 | Setting the polarity parameter is a bit tricky. It is the |
|---|
| 1092 | polarity of the field to be affected, which is probably |
|---|
| 1093 | the opposite of the polarity in force then this function |
|---|
| 1094 | is called. |
|---|
| 1095 | |
|---|
| 1096 | Returns: |
|---|
| 1097 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1098 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1099 | possibly NULL. |
|---|
| 1100 | |
|---|
| 1101 | *****************************************************************************/ |
|---|
| 1102 | BERR_Code BVBIlib_Encode_NoData_isr( |
|---|
| 1103 | BVBIlib_Encode_Handle enclHdl, /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 1104 | object. */ |
|---|
| 1105 | BAVC_Polarity polarity /* [in] Which field (even, odd, or |
|---|
| 1106 | frame) to modify. */ |
|---|
| 1107 | ); |
|---|
| 1108 | |
|---|
| 1109 | |
|---|
| 1110 | /***************************************************************************** |
|---|
| 1111 | Summary: |
|---|
| 1112 | Remove all pending VBI data from the queue to the encoder hardware. |
|---|
| 1113 | |
|---|
| 1114 | Description: |
|---|
| 1115 | This function takes an active BVBIlib_Encode_Handle and |
|---|
| 1116 | recycles any and all pending VBI data enqueued for encoding. |
|---|
| 1117 | |
|---|
| 1118 | This function may be called from an ISR. It can be used to stop encoding |
|---|
| 1119 | without actually shutting down the VBI syslib, or the chip VBI cores. |
|---|
| 1120 | |
|---|
| 1121 | Returns: |
|---|
| 1122 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1123 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1124 | possibly NULL. |
|---|
| 1125 | |
|---|
| 1126 | *****************************************************************************/ |
|---|
| 1127 | BERR_Code BVBIlib_Encode_Flush_isr( |
|---|
| 1128 | BVBIlib_Encode_Handle enclHdl /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 1129 | object */ |
|---|
| 1130 | ); |
|---|
| 1131 | |
|---|
| 1132 | |
|---|
| 1133 | /***************************************************************************** |
|---|
| 1134 | Summary: |
|---|
| 1135 | Obtain number of field handles in encoding queue. For diagnostic use. |
|---|
| 1136 | |
|---|
| 1137 | Description: |
|---|
| 1138 | This function takes an active BVBIlib_Encode_Handle and |
|---|
| 1139 | discloses how many field handles are contained within, waiting to be |
|---|
| 1140 | encoded. This function is intended for use in bring-up and |
|---|
| 1141 | trouble-shooting. |
|---|
| 1142 | |
|---|
| 1143 | This function may be called from an ISR. |
|---|
| 1144 | |
|---|
| 1145 | Returns: |
|---|
| 1146 | Number of items in queue. |
|---|
| 1147 | |
|---|
| 1148 | *****************************************************************************/ |
|---|
| 1149 | int BVBIlib_GetQueueLength( |
|---|
| 1150 | BVBIlib_Encode_Handle enclHdl /* [in] A valid BVBIlib_Encode_Handle |
|---|
| 1151 | object */ |
|---|
| 1152 | ); |
|---|
| 1153 | |
|---|
| 1154 | |
|---|
| 1155 | /***************************************************************************** |
|---|
| 1156 | Summary: |
|---|
| 1157 | Obtains a BVBI_Field_Handle for the user. |
|---|
| 1158 | |
|---|
| 1159 | Description: |
|---|
| 1160 | This function takes an active BVBIlib_Handle and selects an unused |
|---|
| 1161 | BVBI_Field_Handle for the caller to use. The caller should |
|---|
| 1162 | eventually return the BVBI_Field_Handle to the BVBIlib module by |
|---|
| 1163 | calling BVBIlib_List_Return_isr. |
|---|
| 1164 | |
|---|
| 1165 | This function is intended to be called from the interrupt |
|---|
| 1166 | that marks the beginning of a field of decoded active |
|---|
| 1167 | video. |
|---|
| 1168 | |
|---|
| 1169 | The programmer's guide includes a section _Working with |
|---|
| 1170 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 1171 | function. The user should understand this material in |
|---|
| 1172 | order to avoid memory management problems. |
|---|
| 1173 | |
|---|
| 1174 | |
|---|
| 1175 | Returns: |
|---|
| 1176 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1177 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1178 | possibly NULL. |
|---|
| 1179 | BVBIlib_NO_HANDLES - There are no unused BVBI_Field_Handles |
|---|
| 1180 | available. |
|---|
| 1181 | |
|---|
| 1182 | See Also: |
|---|
| 1183 | BVBIlib_List_Return_isr |
|---|
| 1184 | |
|---|
| 1185 | *****************************************************************************/ |
|---|
| 1186 | BERR_Code BVBIlib_List_Obtain_isr( |
|---|
| 1187 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 1188 | object */ |
|---|
| 1189 | BVBI_Field_Handle * pFieldHandle /* [out] A BVBI_Field_Handle object. |
|---|
| 1190 | The user may use this as he |
|---|
| 1191 | wishes. */ |
|---|
| 1192 | ); |
|---|
| 1193 | |
|---|
| 1194 | |
|---|
| 1195 | /***************************************************************************** |
|---|
| 1196 | Summary: |
|---|
| 1197 | Returns a BVBI_Field_Handle after use. |
|---|
| 1198 | |
|---|
| 1199 | Description: |
|---|
| 1200 | This function takes an active BVBIlib_Handle and a BVBI_Field_Handle |
|---|
| 1201 | and tells the BVBIlib module that the BVBI_Field_Handle is no longer |
|---|
| 1202 | in use. |
|---|
| 1203 | |
|---|
| 1204 | This function is intended to be called from the interrupt |
|---|
| 1205 | that marks the beginning of a field of decoded active |
|---|
| 1206 | video. |
|---|
| 1207 | |
|---|
| 1208 | The programmer's guide includes a section _Working with |
|---|
| 1209 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 1210 | function. The user should understand this material in |
|---|
| 1211 | order to avoid memory management problems. |
|---|
| 1212 | |
|---|
| 1213 | Returns: |
|---|
| 1214 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1215 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1216 | possibly NULL. |
|---|
| 1217 | |
|---|
| 1218 | See Also: |
|---|
| 1219 | BVBIlib_List_Obtain_isr |
|---|
| 1220 | |
|---|
| 1221 | *****************************************************************************/ |
|---|
| 1222 | BERR_Code BVBIlib_List_Return_isr( |
|---|
| 1223 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 1224 | object */ |
|---|
| 1225 | BVBI_Field_Handle fieldHandle /* [in] A BVBI_Field_Handle object. |
|---|
| 1226 | The user indicates that it |
|---|
| 1227 | is no longer in use. */ |
|---|
| 1228 | ); |
|---|
| 1229 | |
|---|
| 1230 | |
|---|
| 1231 | /***************************************************************************** |
|---|
| 1232 | Summary: |
|---|
| 1233 | Reserves a BVBI_Field_Handle for use in a customer supplied |
|---|
| 1234 | VBI processor. |
|---|
| 1235 | |
|---|
| 1236 | Description: |
|---|
| 1237 | This function takes an active a BVBI_Field_Handle and increments |
|---|
| 1238 | its internal usage count. This prevents the BVBIlib system |
|---|
| 1239 | library from recycling the field handle after VBI encoding |
|---|
| 1240 | on the field handle is complete. |
|---|
| 1241 | |
|---|
| 1242 | This function is not needed under "normal" circumstances. |
|---|
| 1243 | In this context, "normal" refers to a scenario where VBI data |
|---|
| 1244 | is simply sent to one or more VECs for hardware encoding, |
|---|
| 1245 | via calls to BVBIlib_Encode_Enqueue_isr(). This function |
|---|
| 1246 | should only be used when a field handle is to be accessed by |
|---|
| 1247 | a customer's application code AFTER it is sent to hardware |
|---|
| 1248 | for encoding via calls to BVBIlib_Encode_Data_isr(). |
|---|
| 1249 | |
|---|
| 1250 | A specific example of when to use this function is when the |
|---|
| 1251 | customer develops a software VBI encoder, but the customer |
|---|
| 1252 | also wishes to use one ore more VECs to encode VBI data |
|---|
| 1253 | in hardware. |
|---|
| 1254 | |
|---|
| 1255 | Eventually, the user must call BVBIlib_List_DecrementUsage() |
|---|
| 1256 | or BVBIlib_List_DecrementUsage_isr() in order to prevent |
|---|
| 1257 | a memory leak. |
|---|
| 1258 | |
|---|
| 1259 | The programmer's guide includes a section _Working with |
|---|
| 1260 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 1261 | function. The user should understand this material in |
|---|
| 1262 | order to avoid memory management problems. |
|---|
| 1263 | |
|---|
| 1264 | See Also: |
|---|
| 1265 | BVBIlib_List_DecrementUsage() |
|---|
| 1266 | BVBIlib_List_DecrementUsage_isr() |
|---|
| 1267 | |
|---|
| 1268 | *****************************************************************************/ |
|---|
| 1269 | void BVBIlib_List_IncrementUsage_isr( |
|---|
| 1270 | BVBI_Field_Handle fieldHandle /* [in] A BVBI_Field_Handle object. |
|---|
| 1271 | The user indicates that it |
|---|
| 1272 | is is reserved for use by |
|---|
| 1273 | the caller. */ |
|---|
| 1274 | ); |
|---|
| 1275 | |
|---|
| 1276 | |
|---|
| 1277 | /***************************************************************************** |
|---|
| 1278 | Summary: |
|---|
| 1279 | Releases a BVBI_Field_Handle after use in a customer supplied |
|---|
| 1280 | VBI processor. |
|---|
| 1281 | |
|---|
| 1282 | Description: |
|---|
| 1283 | This function takes an active a BVBI_Field_Handle and decrements |
|---|
| 1284 | its internal usage count. If the usage count is zero, then |
|---|
| 1285 | the field handle is "recycled" for reuse by the BVBIlib syslib. |
|---|
| 1286 | |
|---|
| 1287 | This function is not needed under "normal" circumstances. |
|---|
| 1288 | In this context, "normal" refers to a scenario where VBI data |
|---|
| 1289 | is simply sent to one or more VECs for hardware encoding, |
|---|
| 1290 | via calls to BVBIlib_Encode_Enqueue_isr(). This function |
|---|
| 1291 | should only be used when a field handle is to be accessed by |
|---|
| 1292 | a customer's application code AFTER it is sent to hardware |
|---|
| 1293 | for encoding via calls to BVBIlib_Encode_Data_isr(). |
|---|
| 1294 | |
|---|
| 1295 | A specific example of when to use this function is when the |
|---|
| 1296 | customer develops a software VBI encoder, but the customer |
|---|
| 1297 | also wishes to use one ore more VECs to encode VBI data |
|---|
| 1298 | in hardware. |
|---|
| 1299 | |
|---|
| 1300 | Calls to this function must be exactly balanced by calls |
|---|
| 1301 | to BVBIlib_List_IncrementUsage_isr() in order to avoid |
|---|
| 1302 | memory leaks. |
|---|
| 1303 | |
|---|
| 1304 | The programmer's guide includes a section _Working with |
|---|
| 1305 | BVBI_Field_Handles and Usage Counts_ that elaborates this |
|---|
| 1306 | function. The user should understand this material in |
|---|
| 1307 | order to avoid memory management problems. |
|---|
| 1308 | |
|---|
| 1309 | Returns: |
|---|
| 1310 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1311 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1312 | possibly NULL. |
|---|
| 1313 | |
|---|
| 1314 | See Also: |
|---|
| 1315 | BVBIlib_List_IncrementUsage_isr() |
|---|
| 1316 | BVBIlib_List_DecrementUsage() |
|---|
| 1317 | |
|---|
| 1318 | *****************************************************************************/ |
|---|
| 1319 | BERR_Code BVBIlib_List_DecrementUsage_isr( |
|---|
| 1320 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 1321 | object */ |
|---|
| 1322 | BVBI_Field_Handle fieldHandle /* [in] A BVBI_Field_Handle object. |
|---|
| 1323 | The user indicates that he |
|---|
| 1324 | will not access this field |
|---|
| 1325 | handle again. */ |
|---|
| 1326 | ); |
|---|
| 1327 | |
|---|
| 1328 | |
|---|
| 1329 | /***************************************************************************** |
|---|
| 1330 | Summary: |
|---|
| 1331 | Releases a BVBI_Field_Handle after use in a customer supplied |
|---|
| 1332 | VBI processor. |
|---|
| 1333 | |
|---|
| 1334 | Description: |
|---|
| 1335 | This function does the same task as |
|---|
| 1336 | BVBIlib_List_DecrementUsage_isr(), but |
|---|
| 1337 | it includes a critical section. Therefore, it can (and must) |
|---|
| 1338 | be called outside of interrupt context. |
|---|
| 1339 | |
|---|
| 1340 | Returns: |
|---|
| 1341 | BERR_SUCCESS - The function call succeeded. |
|---|
| 1342 | BERR_INVALID_PARAMETER - One of the supplied parameters was invalid, |
|---|
| 1343 | possibly NULL. |
|---|
| 1344 | |
|---|
| 1345 | See Also: |
|---|
| 1346 | BVBIlib_List_IncrementUsage_isr() |
|---|
| 1347 | BVBIlib_List_DecrementUsage_isr() |
|---|
| 1348 | |
|---|
| 1349 | *****************************************************************************/ |
|---|
| 1350 | BERR_Code BVBIlib_List_DecrementUsage( |
|---|
| 1351 | BVBIlib_List_Handle vbillHandle, /* [in] A valid BVBIlib_List_Handle |
|---|
| 1352 | object */ |
|---|
| 1353 | BVBI_Field_Handle fieldHandle /* [in] A BVBI_Field_Handle object. |
|---|
| 1354 | The user indicates that he |
|---|
| 1355 | will not access this field |
|---|
| 1356 | handle again. */ |
|---|
| 1357 | ); |
|---|
| 1358 | |
|---|
| 1359 | #ifdef __cplusplus |
|---|
| 1360 | } |
|---|
| 1361 | #endif |
|---|
| 1362 | |
|---|
| 1363 | #endif /* BVBILIB_H__ */ |
|---|