MHEG5  18.9.0
MHEG5 Documentation
fpa1_seq.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
27 /*---includes for this file--------------------------------------------------*/
28 #include <stdio.h>
29 #include <stdlib.h>
30 
31 #include "vpa1_sys.h"
32 #include "vpa1_tgs.h"
33 #include "vpa1_rdf.h"
34 
35 #include "fpa1_act.h"
36 #include "fpa1_app.h"
37 #include "fpa1_cho.h"
38 #include "fpa1_grp.h"
39 #include "fpa1_int.h"
40 #include "fpa1_rdf.h"
41 #include "fpa1_seq.h"
42 #include "fpa1_set.h"
43 #include "fpa1_stm.h"
44 #include "fpa1_syn.h"
45 #include "fpa1_tgs.h"
46 #include "fpa1_tok.h"
47 #include "fpa1_typ.h"
48 #include "fpa1_BlockAlloc.h"
49 
50 /*---local typedef structs for this file-------------------------------------*/
51 
52 /*---constant definitions for this file--------------------------------------*/
53 
54 
55 /*---local (static) variable declarations for this file----------------------*/
56 
57 /*---local function definitions----------------------------------------------*/
58 
59 /*---global function definitions---------------------------------------------*/
60 
65 fpa1_syntaxList* fpa1_sequenceParse( unsigned short *itemCnt, int *compSeqArr, vpa1_filePos filePosLimit )
66 {
67  int limit = compSeqArr[0];
68  int count = 1;
69 
70  fpa1_syntaxList *itemPtr = NULL;
71  fpa1_syntaxList *seqTagPtr = NULL;
72 
73  /* file position should be set up correctly */
74  /* before calling fpa1_sequenceParse() */
75 
76  /* get all tags from current file position to limit */
77  fpa1_syntaxList *tagListPtr = fpa1_synGetAllTags( filePosLimit );
78 
79  while ((count < limit) && (tagListPtr != NULL))
80  {
81  if (tagListPtr->tag == compSeqArr[count])
82  {
83  itemPtr = fpa1_synCreateListItem( tagListPtr->tag,
84  tagListPtr->tagPosition,
85  tagListPtr->nextTagPosition );
86 
87  /* looking for a TAG */
88  if (fpa1_tagsParse( itemPtr ) == FALSE)
89  {
90  /* a failure of some sort - delete item */
91  fpa1_delList( itemPtr );
92  itemPtr = NULL;
93  }
94  tagListPtr = fpa1_delFirstItem( tagListPtr );
95  }
96  else if (compSeqArr[count] > MHEG5_TYPE)
97  {
98  /* looking for a TYPE */
100 
101  itemPtr = fpa1_typeParse( compSeqArr[count],
102  filePosLimit );
103 
104  tagListPtr = fpa1_delFirstItem( tagListPtr );
105  }
106 
107  if (itemPtr != NULL)
108  {
109  /* add to list of sequence tags */
110  (*itemCnt)++;
111  itemCnt[1] += itemPtr->childCount[0];
112  itemCnt[2] += itemPtr->childCount[1];
113  seqTagPtr = fpa1_synAddItemToList( seqTagPtr, itemPtr );
114  itemPtr = NULL;
115  }
116  else if ((compSeqArr[count + 1] != SYN_OPTIONAL) &&
117  (compSeqArr[count + 1] != SYN_DEFAULT))
118  {
119  /* found a tag which should not be there - stop */
120 
121  /* free lists */
122  fpa1_delList( seqTagPtr );
123  seqTagPtr = NULL;
124  break;
125  }
126 
127  count += 2;
128  }
129 
130  /* free remaining list */
131  fpa1_delList( tagListPtr );
132 
133  return seqTagPtr;
134 } /* fpa1_sequenceParse() */
135 
140 fpa1_syntaxList* fpa1_sequenceOfParse( unsigned short *itemCnt, int whichType, vpa1_filePos filePosLimit )
141 {
142  fpa1_syntaxList *seqOfItem = NULL;
143  fpa1_syntaxList *returnItem = NULL;
144 
145  /* file position should be set up correctly */
146  /* before calling fpa1_sequenceOfParse() */
147  do
148  {
149  seqOfItem = NULL;
150  switch (whichType)
151  {
152  case SEQ_OF_DEF_ATTRIBS:
153  seqOfItem = fpa1_choiceParse( defAttChoiceCompArr );
154  break;
155  case SEQ_OF_GROUP_ITEM:
156  seqOfItem = fpa1_choiceParse( grpItmChoiceCompArr );
157  break;
158  case SEQ_OF_MOVEMENT:
159  seqOfItem = fpa1_typeParse( SEQ_SIZE_OF_INTEGER, filePosLimit );
160  break;
161  case SEQ_OF_INTEGER:
162  seqOfItem = fpa1_setParse( intSetCompsArr, filePosLimit );
163  break;
165  seqOfItem = fpa1_choiceParse( elemActChoiceCompArr );
166  break;
167  case SEQ_OF_ACTION_SLOT:
168  seqOfItem = fpa1_typeParse( ACTION_SLOT_TYPE, filePosLimit );
169  break;
171  seqOfItem = fpa1_typeParse( TOKEN_GROUP_ITEM_TYPE, filePosLimit );
172  break;
173  case SEQ_OF_PARAMETER:
174  seqOfItem = fpa1_typeParse( PARAMETER_TYPE, filePosLimit );
175  break;
176  case SEQ_OF_POINT:
177  seqOfItem = fpa1_typeParse( POINT_TYPE, filePosLimit );
178  break;
180  seqOfItem = fpa1_typeParse( OBJECT_REFERENCE_TYPE, filePosLimit );
181  break;
182  case SEQ_OF_NEXT_SCENE:
183  seqOfItem = fpa1_typeParse( NEXT_SCENE_TYPE, filePosLimit );
184  break;
185  case SEQ_OF_STREAM_COMP:
186  seqOfItem = fpa1_choiceParse( stmCmpChoiceCompArr );
187  break;
188  case SEQ_OF_XY_POSITION:
189  seqOfItem = fpa1_typeParse( XY_POSITION_TYPE, filePosLimit );
190  break;
191  default:
192  break;
193  }
194 
195  if (seqOfItem != NULL)
196  {
197  /* add to list */
198  (*itemCnt)++;
199  itemCnt[1] += seqOfItem->childCount[0];
200  itemCnt[2] += seqOfItem->childCount[1];
201  returnItem = fpa1_synAddItemToList( returnItem, seqOfItem );
202 
203  /* set up next position */
204  while (seqOfItem->next != NULL)
205  seqOfItem = seqOfItem->next;
206 
207  if (seqOfItem->nextTagPosition < filePosLimit)
208  {
210  }
211  else
212  {
213  break;
214  }
215  }
216  else if (whichType == SEQ_OF_ELEMENTARY_ACTION ||
217  whichType == SEQ_OF_GROUP_ITEM)
218  {
219  /* unknown tag - skip and forget */
220  vpa1_filePos nextTagPosn = fpa1_rdfGetNextTagPosn();
221  if (nextTagPosn < filePosLimit)
222  {
223  fpa1_rdfSetNewFilePosition( nextTagPosn );
224  seqOfItem = (fpa1_syntaxList *)0xdeadbeef;
225  }
226  else
227  {
228  break;
229  }
230  }
231  }
232  while (seqOfItem != NULL);
233 
234  return returnItem;
235 } /* fpa1_sequenceOfParse() */
236 
fpa1_syntaxList * fpa1_setParse(int *, vpa1_filePos)
Definition: fpa1_set.c:178
Contains functions to decode MHEG-5 ASN.1 types.
int grpItmChoiceCompArr[]
Definition: fpa1_grp.c:46
fpa1_syntaxList * fpa1_synCreateListItem(int, vpa1_filePos, vpa1_filePos)
Definition: fpa1_syn.c:161
Contains functions to decode MHEG-5 ASN.1 Token Group and Token Manager class components.
Contains functions/globals used to read MHEG-5 ASN.1 scripts.
fpa1_syntaxList * fpa1_synAddItemToList(fpa1_syntaxList *, fpa1_syntaxList *)
Definition: fpa1_syn.c:134
Contains functions to decode MHEG-5 ASN.1 Integer class component.
fpa1_syntaxList * fpa1_synGetAllTags(vpa1_filePos)
Definition: fpa1_syn.c:56
Contains function to parse MHEG-5 ASN.1 tags.
vpa1_filePos fpa1_rdfGetNextTagPosn(void)
Definition: fpa1_rdf.c:336
fpa1_syntaxList * fpa1_typeParse(int, vpa1_filePos)
Definition: fpa1_typ.c:219
int fpa1_tagsParse(fpa1_syntaxList *)
Definition: fpa1_tgs.c:532
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
Contains functions to decode MHEG-5 ASN.1 Stream, Audio, Video, RTGraphics class components.
fpa1_syntaxList * fpa1_sequenceOfParse(unsigned short *itemCnt, int whichType, vpa1_filePos filePosLimit)
Definition: fpa1_seq.c:140
#define SYN_DEFAULT
Definition: fpa1_syn.h:36
Typedefs for script reading functions.
unsigned short childCount[3]
Definition: fpa1_syn.h:59
Contains functions to decode MHEG-5 ASN.1 Action class components.
Contains macros for MHEG-5 ASN.1 tags and structures.
#define SYN_OPTIONAL
Definition: fpa1_syn.h:35
vpa1_filePos nextTagPosition
Definition: fpa1_syn.h:56
int elemActChoiceCompArr[]
Definition: fpa1_act.c:92
syntax item block manager Contains functions to create a mini memory manager for allocating syntax li...
int stmCmpChoiceCompArr[]
Definition: fpa1_stm.c:99
unsigned short count
fpa1_syntaxList * fpa1_sequenceParse(unsigned short *itemCnt, int *compSeqArr, vpa1_filePos filePosLimit)
Definition: fpa1_seq.c:65
int fpa1_delList(fpa1_syntaxList *firstComp)
vpa1_filePos tagPosition
Definition: fpa1_syn.h:55
int defAttChoiceCompArr[]
Definition: fpa1_app.c:68
Contains functions used to parse MHEG-5 ASN.1 SETs. SETs can have components in any order and as such...
Contains functions to decode MHEG-5 ASN.1 Application class components.
#define FALSE
Definition: techtype.h:68
int intSetCompsArr[]
Definition: fpa1_int.c:49
long vpa1_filePos
Definition: vpa1_sys.h:47
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
Contains functions used to parse MHEG-5 ASN.1 SEQUENCEs. SEQUENCEs have components in order...
fpa1_syntaxList * fpa1_delFirstItem(fpa1_syntaxList *firstComp)
int fpa1_rdfSetNewFilePosition(vpa1_filePos)
Definition: fpa1_rdf.c:375
fpa1_syntaxList * fpa1_choiceParse(int *)
Definition: fpa1_cho.c:67