source: svn/trunk/newcon3bcm2_21bu/BSEAV/lib/mpeg2_ts_parse/psip_rrt.c

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 4.0 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2007, 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: psip_rrt.c $
11 * $brcm_Revision: 2 $
12 * $brcm_Date: 9/19/07 3:25p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/lib/mpeg2_ts_parse/psip_rrt.c $
19 *
20 * 2   9/19/07 3:25p marcusk
21 * PR34935: Added new fields [3~
22 *
23 * 1   2/7/05 11:26p dlwin
24 * Merge down for release 2005_REFSW_MERGETOMAIN:
25 *
26 * Irvine_BSEAVSW_Devel/2   2/4/04 9:56a erickson
27 * PR9217: converted BDBG_ASSERT calls to CHECK calls. Don't assert on bad
28 * data.
29 *
30 * Irvine_BSEAVSW_Devel/1   8/29/03 5:04p marcusk
31 * Initial Version.
32 *
33 ***************************************************************************/
34#include "bstd.h"
35#include "psip_priv.h"
36#include "psip_rrt.h"
37BDBG_MODULE(psip_rrt);
38
39#define RATING_REGION_OFFSET    (4)
40#define VERSION_NUMBER_OFFSET   (5)
41#define DIMENSION_BYTE_OFFSET   (PSIP_TABLE_DATA_OFFSET+buf[PSIP_TABLE_DATA_OFFSET]+1)
42#define NUM_DIMENSIONS_DEFINED  (buf[DIMENSION_BYTE_OFFSET])
43#define NUM_VALUES( p_dimBfr )  (uint8_t)((p_dimBfr)[(p_dimBfr)[0]+1]&0xF)
44
45
46static int PSIP_RRT_P_getValueByteOffset( const uint8_t *p_dimBfr, int valueNum )
47{
48        int byteOffset;
49        uint8_t i;
50
51        if( valueNum == -1 )
52        {
53                valueNum = NUM_VALUES(p_dimBfr);
54        }
55
56        byteOffset = p_dimBfr[0]+2;
57
58        for( i = 0; i < valueNum; i++ )
59        {
60                byteOffset += 2 + p_dimBfr[byteOffset] + p_dimBfr[1+byteOffset+p_dimBfr[byteOffset]];
61        }
62
63        return byteOffset;
64}
65
66static int PSIP_RRT_P_getDimensionByteOffset( const uint8_t *buf, int dimNum )
67{
68        int byteOffset;
69        uint8_t i;
70
71        if( dimNum == -1 )
72        {
73                dimNum = NUM_DIMENSIONS_DEFINED;
74        }
75
76        byteOffset = DIMENSION_BYTE_OFFSET+1;
77
78        for( i = 0; i < dimNum; i++ )
79        {
80                byteOffset += PSIP_RRT_P_getValueByteOffset(&buf[byteOffset], -1 );
81                CHECK( byteOffset <= TS_PSI_MAX_BYTE_OFFSET(buf) );
82        }
83
84        return byteOffset;
85}
86
87void PSIP_RRT_getHeader( const uint8_t *buf, PSIP_RRT_header *p_header )
88{
89        CHECK( buf[0] == 0xCA );
90
91        p_header->rating_region             = buf[RATING_REGION_OFFSET];
92        p_header->version_number            = ((buf[VERSION_NUMBER_OFFSET] >> 1) & (0 | (0x1F)));
93        p_header->p_rating_region_name_text = &buf[PSIP_TABLE_DATA_OFFSET+1];
94        p_header->dimensions_defined        = NUM_DIMENSIONS_DEFINED;
95}
96
97TS_PSI_descriptor PSIP_RRT_getDescriptor( const uint8_t *buf, int descriptorNum )
98{
99        int byteOffset;
100
101        CHECK( buf[0] == 0xCA );
102
103        byteOffset = PSIP_RRT_P_getDimensionByteOffset( buf, -1 );
104        return TS_P_getDescriptor( &buf[byteOffset+2], (TS_READ_16(&buf[byteOffset]) & 0x3FF), descriptorNum );
105}
106
107BERR_Code PSIP_RRT_getDimension( const uint8_t *buf, int dimensionNum, PSIP_RRT_dimension *p_dimension )
108{
109        int byteOffset;
110
111        CHECK( buf[0] == 0xCA );
112
113        if( dimensionNum >= NUM_DIMENSIONS_DEFINED )
114        {
115                return BERR_INVALID_PARAMETER;
116        }
117
118        byteOffset = PSIP_RRT_P_getDimensionByteOffset( buf, dimensionNum );
119        p_dimension->p_dimension_name_text = &buf[byteOffset+1];
120        p_dimension->graduated_scale = (buf[byteOffset+buf[byteOffset]+1]>>4)&1;
121        p_dimension->values_defined = (uint8_t)(buf[byteOffset+buf[byteOffset]+1]&0xF);
122
123        return BERR_SUCCESS;
124}
125
126BERR_Code PSIP_RRT_getValue( const uint8_t *buf, int dimensionNum, int valueNum, PSIP_RRT_value *p_value )
127{
128        int byteOffset;
129
130        CHECK( buf[0] == 0xCA );
131
132        if( dimensionNum >= NUM_DIMENSIONS_DEFINED )
133        {
134                return BERR_INVALID_PARAMETER;
135        }
136
137        byteOffset = PSIP_RRT_P_getDimensionByteOffset( buf, dimensionNum );
138
139        if( valueNum >= NUM_VALUES( &buf[byteOffset] ) )
140        {
141                return BERR_INVALID_PARAMETER;
142        }
143
144        byteOffset += PSIP_RRT_P_getValueByteOffset( &buf[byteOffset], valueNum );
145
146        p_value->p_abbrev_rating_value_text = &buf[byteOffset+1];
147        p_value->p_rating_value_text = &buf[byteOffset+1+buf[byteOffset]+1];
148
149        return BERR_SUCCESS;
150}
Note: See TracBrowser for help on using the repository browser.