source: svn/trunk/newcon3bcm2_21bu/dta/src/dcc/bcmDccTransportMux.c

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 5.9 KB
Line 
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: bcmDccTransportMux.c $
11 * $brcm_Revision: \main\SanJose_MSTV_Devel\1 $
12 * $brcm_Date: 3/12/02 4:45p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: $
19 *
20 * \main\SanJose_MSTV_Devel\1   3/12/02 4:45p erikg
21 * Merge from SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38
22 *
23 * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\3   3/12/02 3:58p erikg
24 * removed the winner function
25 *
26 * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\2   3/7/02 4:21p erikg
27 * more fleshing out
28 *
29 * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\1   3/6/02 11:29a erikg
30 * new source files
31 *
32 ***************************************************************************/
33
34/***************************************************************************
35 * Theory of Operation
36 * --------------------
37 *
38 * This module is used to detect which 608 CC data formats are
39 * present in an MPEG stream.  It does this by maintaining an
40 * accumulation count for each type.  When each 608 data type
41 * is encountered in the stream, its corresponding count is
42 * incremented.  These counts continue to accumulate up to a
43 * maximum.  The maximum can be thought of as a clip value.  In
44 * a basic sense, those types whose counts are at the maximum
45 * are present.
46 *
47 * To handle the case when a type is disappears from the stream,
48 * we periodically subtract from each count.  We chose the increment
49 * value and decrement value such that if a type is present, its
50 * count will increment eventhough its count is also periodically
51 * decremented.  For example, the increment may be 3 while the
52 * decrement may be 1.
53 *
54 * Finally, we define some threshhold, which is below the maximum,
55 * above which we consider the type to be present in the stream.
56 *
57 ***************************************************************************/
58
59
60
61
62
63                                                        /**********************
64                                                         *
65                                                         * INCLUDES
66                                                         *
67                                                         **********************/
68
69#include "bcmDccTransportMux.h"
70#include "bcmDccPriv.h"
71
72
73
74                                                        /**********************
75                                                         *
76                                                         * DEFINES
77                                                         *
78                                                         **********************/
79
80/*
81 * CC608_LEAK_VAL
82 *
83 * Subtract this value from the
84 * accumulated count when 'leaking'.
85 */
86#define CC608_LEAK_VAL                  1
87
88/*
89 * CC608_ACCUMULATE_VAL
90 *
91 * Add this value to the
92 * accumlated count when a 608
93 * type is detected.
94 */
95#define CC608_ACCUMULATE_VAL    3
96
97/*
98 * CC608_CLIP_VAL
99 *
100 * Don't increment past this
101 * maximum accumulated count value.
102 */
103#define CC608_CLIP_VAL                  100
104
105/*
106 * CC608_THRESHOLD_VAL
107 *
108 * All types whose count exceed
109 * this threshhold are considered
110 * present in the MPEG stream.
111 */
112#define CC608_THRESHOLD_VAL             80
113
114
115
116
117                                                        /**********************
118                                                         *
119                                                         * FUNCTIONS
120                                                         *
121                                                         **********************/
122                                                         
123/**************************************************************************
124 *
125 * Function:            CC608Mux_Init
126 *
127 * Inputs:                     
128 *                                      pState                          - state to init
129 *
130 * Outputs:             
131 *                                      pState                          - state is modified
132 *
133 * Returns:                     <void>
134 *
135 * Description:
136 *
137 * This function initializes the count array to all zeros.
138 *
139 **************************************************************************/
140void CC608Mux_Init(DCC_CC608_MUX_STATE * pState)
141{
142        int cctype ;
143
144        for ( cctype=0 ; cctype < NUM_CCTYPE ; cctype++ )
145        {
146                pState->aCCTypeLeakyCount[cctype] = 0 ;
147        }
148}
149
150/**************************************************************************
151 *
152 * Function:            CC608Mux_LeakAll
153 *
154 * Inputs:                     
155 *                                      pState                          - state, previously init'ed
156 *
157 * Outputs:             
158 *                                      pState                          - state is modified
159 *
160 * Returns:                     <void>
161 *
162 * Description:
163 *
164 * This function subtracts CC608_LEAK_VAL from all counts, ensuring
165 * that no count falls below zero.
166 *
167 **************************************************************************/
168void CC608Mux_LeakAll(DCC_CC608_MUX_STATE * pState)
169{
170        int cctype ;
171
172        for ( cctype=0 ; cctype < NUM_CCTYPE ; cctype++ )
173        {
174                pState->aCCTypeLeakyCount[cctype] = 
175                        max(0, pState->aCCTypeLeakyCount[cctype] - CC608_LEAK_VAL) ;
176        }
177       
178} /* CC608Mux_LeakAll */
179
180
181/**************************************************************************
182 *
183 * Function:            CC608Mux_IsDetected
184 *
185 * Inputs:                     
186 *                                      pState                          - state, previously init'ed
187 *                                      cct                                     - type
188 *
189 * Outputs:             
190 *                                      <none>
191 *
192 * Returns:                     1 iff the given type (cct) is detected.
193 *
194 * Description:
195 *
196 * This function compares the accumulated count against the threshhold
197 * value.  If greater or equal, this function returns 1, else 0.
198 *
199 **************************************************************************/
200int CC608Mux_IsDetected(DCC_CC608_MUX_STATE * pState, CCMUX_TYPES cct)
201{
202        if ( pState->aCCTypeLeakyCount[cct] >= CC608_THRESHOLD_VAL )
203        {
204                return(1) ;
205        }
206        else
207        {
208                return(0) ;
209        }
210       
211} /* CC608Mux_IsDetected */
212
213
214/**************************************************************************
215 *
216 * Function:            CC608Mux_Accumulate
217 *
218 * Inputs:                     
219 *                                      pState                          - state, previously init'ed
220 *                                      ccType                          - type to accumulate
221 *
222 * Outputs:             
223 *                                      pState                          - state is modified
224 *
225 * Returns:                     void
226 *
227 * Description:
228 *
229 * This function adds CC608_ACCUMULATE_VAL to all counts, ensuring
230 * that no count rises greater than CC608_CLIP_VAL.
231 *
232 **************************************************************************/
233void CC608Mux_Accumulate(DCC_CC608_MUX_STATE * pState, CCMUX_TYPES ccType)
234{
235        pState->aCCTypeLeakyCount[ccType] = 
236                min(CC608_CLIP_VAL, pState->aCCTypeLeakyCount[ccType] + CC608_ACCUMULATE_VAL) ;
237
238} /* CC608Mux_Accumulate */
239
240
241
Note: See TracBrowser for help on using the repository browser.