/*************************************************************************** * Copyright (c) 2002, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: bcmDccTransportMux.c $ * $brcm_Revision: \main\SanJose_MSTV_Devel\1 $ * $brcm_Date: 3/12/02 4:45p $ * * Module Description: * * Revision History: * * $brcm_Log: $ * * \main\SanJose_MSTV_Devel\1 3/12/02 4:45p erikg * Merge from SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38 * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\3 3/12/02 3:58p erikg * removed the winner function * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\2 3/7/02 4:21p erikg * more fleshing out * * \main\SanJose_MSTV_Devel_erikg_mpegccxport2_2002_03_06_1118_38\1 3/6/02 11:29a erikg * new source files * ***************************************************************************/ /*************************************************************************** * Theory of Operation * -------------------- * * This module is used to detect which 608 CC data formats are * present in an MPEG stream. It does this by maintaining an * accumulation count for each type. When each 608 data type * is encountered in the stream, its corresponding count is * incremented. These counts continue to accumulate up to a * maximum. The maximum can be thought of as a clip value. In * a basic sense, those types whose counts are at the maximum * are present. * * To handle the case when a type is disappears from the stream, * we periodically subtract from each count. We chose the increment * value and decrement value such that if a type is present, its * count will increment eventhough its count is also periodically * decremented. For example, the increment may be 3 while the * decrement may be 1. * * Finally, we define some threshhold, which is below the maximum, * above which we consider the type to be present in the stream. * ***************************************************************************/ /********************** * * INCLUDES * **********************/ #include "bcmDccTransportMux.h" #include "bcmDccPriv.h" /********************** * * DEFINES * **********************/ /* * CC608_LEAK_VAL * * Subtract this value from the * accumulated count when 'leaking'. */ #define CC608_LEAK_VAL 1 /* * CC608_ACCUMULATE_VAL * * Add this value to the * accumlated count when a 608 * type is detected. */ #define CC608_ACCUMULATE_VAL 3 /* * CC608_CLIP_VAL * * Don't increment past this * maximum accumulated count value. */ #define CC608_CLIP_VAL 100 /* * CC608_THRESHOLD_VAL * * All types whose count exceed * this threshhold are considered * present in the MPEG stream. */ #define CC608_THRESHOLD_VAL 80 /********************** * * FUNCTIONS * **********************/ /************************************************************************** * * Function: CC608Mux_Init * * Inputs: * pState - state to init * * Outputs: * pState - state is modified * * Returns: * * Description: * * This function initializes the count array to all zeros. * **************************************************************************/ void CC608Mux_Init(DCC_CC608_MUX_STATE * pState) { int cctype ; for ( cctype=0 ; cctype < NUM_CCTYPE ; cctype++ ) { pState->aCCTypeLeakyCount[cctype] = 0 ; } } /************************************************************************** * * Function: CC608Mux_LeakAll * * Inputs: * pState - state, previously init'ed * * Outputs: * pState - state is modified * * Returns: * * Description: * * This function subtracts CC608_LEAK_VAL from all counts, ensuring * that no count falls below zero. * **************************************************************************/ void CC608Mux_LeakAll(DCC_CC608_MUX_STATE * pState) { int cctype ; for ( cctype=0 ; cctype < NUM_CCTYPE ; cctype++ ) { pState->aCCTypeLeakyCount[cctype] = max(0, pState->aCCTypeLeakyCount[cctype] - CC608_LEAK_VAL) ; } } /* CC608Mux_LeakAll */ /************************************************************************** * * Function: CC608Mux_IsDetected * * Inputs: * pState - state, previously init'ed * cct - type * * Outputs: * * * Returns: 1 iff the given type (cct) is detected. * * Description: * * This function compares the accumulated count against the threshhold * value. If greater or equal, this function returns 1, else 0. * **************************************************************************/ int CC608Mux_IsDetected(DCC_CC608_MUX_STATE * pState, CCMUX_TYPES cct) { if ( pState->aCCTypeLeakyCount[cct] >= CC608_THRESHOLD_VAL ) { return(1) ; } else { return(0) ; } } /* CC608Mux_IsDetected */ /************************************************************************** * * Function: CC608Mux_Accumulate * * Inputs: * pState - state, previously init'ed * ccType - type to accumulate * * Outputs: * pState - state is modified * * Returns: void * * Description: * * This function adds CC608_ACCUMULATE_VAL to all counts, ensuring * that no count rises greater than CC608_CLIP_VAL. * **************************************************************************/ void CC608Mux_Accumulate(DCC_CC608_MUX_STATE * pState, CCMUX_TYPES ccType) { pState->aCCTypeLeakyCount[ccType] = min(CC608_CLIP_VAL, pState->aCCTypeLeakyCount[ccType] + CC608_ACCUMULATE_VAL) ; } /* CC608Mux_Accumulate */