2 * Copyright (c) 2004, Yannick Verschueren
3 * Copyright (c) 2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
37 * Read the information contains in VBAS [JPP/JPT stream message header]
38 * Store information (7 bits) in value
41 unsigned int jpt_read_VBAS_info(unsigned int value)
46 while ((elmt >> 7) == 1) {
48 value |= (elmt & 0x7f);
52 value |= (elmt & 0x7f);
58 * Initialize the value of the message header structure
61 void jpt_init_Msg_Header(jpt_msg_header_struct_t * header)
63 header->Id = 0; /* In-class Identifier */
64 header->last_byte = 0; /* Last byte information */
65 header->Class_Id = 0; /* Class Identifier */
66 header->CSn_Id = 0; /* CSn : index identifier */
67 header->Msg_offset = 0; /* Message offset */
68 header->Msg_length = 0; /* Message length */
69 header->Layer_nb = 0; /* Auxiliary for JPP case */
73 * Re-initialize the value of the message header structure
75 * Only parameters always present in message header
78 void jpt_reinit_Msg_Header(jpt_msg_header_struct_t * header)
80 header->Id = 0; /* In-class Identifier */
81 header->last_byte = 0; /* Last byte information */
82 header->Msg_offset = 0; /* Message offset */
83 header->Msg_length = 0; /* Message length */
87 * Read the message header for a JPP/JPT - stream
90 void jpt_read_Msg_Header(jpt_msg_header_struct_t * header)
92 unsigned char elmt, Class = 0, CSn = 0;
93 jpt_reinit_Msg_Header(header);
100 /* See for Class and CSn */
101 switch ((elmt >> 5) & 0x03) {
103 fprintf(stderr, "Forbidden value encounter in message header !!\n");
121 /* see information on bits 'c' [p 10 : A.2.1 general, ISO/IEC FCD 15444-9] */
122 if (((elmt >> 4) & 0x01) == 1)
123 header->last_byte = 1;
125 /* In-class identifier */
126 header->Id |= (elmt & 0x0f);
127 if ((elmt >> 7) == 1)
128 header->Id = jpt_read_VBAS_info(header->Id);
134 header->Class_Id = 0;
135 header->Class_Id = jpt_read_VBAS_info(header->Class_Id);
143 header->CSn_Id = jpt_read_VBAS_info(header->CSn_Id);
146 /* ----------------- */
147 /* VBAS : Msg_offset */
148 /* ----------------- */
149 header->Msg_offset = jpt_read_VBAS_info(header->Msg_offset);
151 /* ----------------- */
152 /* VBAS : Msg_length */
153 /* ----------------- */
154 header->Msg_length = jpt_read_VBAS_info(header->Msg_length);
159 if ((header->Class_Id & 0x01) == 1) {
160 header->Layer_nb = 0;
161 header->Layer_nb = jpt_read_VBAS_info(header->Layer_nb);