uint8_t p_data[CC_MAX_DATA_SIZE];
} cc_data_t;
-static inline int cc_Channel( int i_field, const uint8_t p_data[2] )
-{
- const uint8_t d = p_data[0] & 0x7f;
- if( i_field != 0 && i_field != 1 )
- return -1;
- if( d == 0x14 )
- return 2*i_field + 0;
- else if( d == 0x1c )
- return 2*i_field + 1;
- /* unknown(middle of a command) or not cc channel */
- return -1;
-}
static inline void cc_Init( cc_data_t *c )
{
int i;
{
c->i_data = 0;
}
+
+static inline void cc_AppendData( cc_data_t *c, int i_field, const uint8_t cc[2] )
+{
+ if( i_field == 0 || i_field == 1 )
+ {
+ c->pb_present[2*i_field+0] =
+ c->pb_present[2*i_field+1] = true;
+ }
+
+ c->p_data[c->i_data++] = i_field;
+ c->p_data[c->i_data++] = cc[0];
+ c->p_data[c->i_data++] = cc[1];
+}
+
static inline void cc_Extract( cc_data_t *c, const uint8_t *p_src, int i_src )
{
static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
for( i = 0; i < i_count_cc; i++, cc += 3 )
{
int i_field = cc[0] & 0x03;
- int i_channel;
if( ( cc[0] & 0xfc ) != 0xfc )
continue;
if( i_field != 0 && i_field != 1 )
if( c->i_data + 3 > CC_MAX_DATA_SIZE )
continue;
- i_channel = cc_Channel( i_field, &cc[1] );
- if( i_channel >= 0 && i_channel < 4 )
- c->pb_present[i_channel] = true;
-
- c->p_data[c->i_data++] = i_field;
- c->p_data[c->i_data++] = cc[1];
- c->p_data[c->i_data++] = cc[2];
+ cc_AppendData( c, i_field, &cc[1] );
}
c->b_reorder = true;
}
for( j = 0; j < 2; j++, cc += 3 )
{
const int i_field = j == i_field_first ? 0 : 1;
- int i_channel;
if( b_truncate && i == i_count_cc2 - 1 && j == 1 )
break;
if( c->i_data + 3 > CC_MAX_DATA_SIZE )
continue;
- i_channel = cc_Channel( i_field, &cc[1] );
- if( i_channel >= 0 && i_channel < 4 )
- c->pb_present[i_channel] = true;
- c->p_data[c->i_data++] = i_field;
- c->p_data[c->i_data++] = cc[1];
- c->p_data[c->i_data++] = cc[2];
+ cc_AppendData( c, i_field, &cc[1] );
}
}
c->b_reorder = false;
for( i = 0; i < 2; i++, cc += 4 )
{
const int i_field = i == 0 ? 1 : 0;
- int i_channel = cc_Channel( i_field, &cc[2] );
- if( i_channel >= 0 && i_channel < 4 )
- c->pb_present[i_channel] = true;
- c->p_data[c->i_data++] = i_field;
- c->p_data[c->i_data++] = cc[2];
- c->p_data[c->i_data++] = cc[3];
+
+ cc_AppendData( c, i_field, &cc[2] );
}
c->b_reorder = false;
}
continue;
const int i_field = i_field_idx - 1;
- const int i_channel = cc_Channel( i_field, cc );
- if( i_channel >= 0 && i_channel < 4 )
- c->pb_present[i_channel] = true;
- c->p_data[c->i_data++] = i_field;
- c->p_data[c->i_data++] = cc[0];
- c->p_data[c->i_data++] = cc[1];
+ cc_AppendData( c, i_field, &cc[0] );
}
c->b_reorder = true;
}
typedef struct
{
long l_rec_size;
- uint8_t ex1, ex2;
+ uint8_t ex[2];
uint8_t rec_type;
uint8_t subrec_type;
bool b_ext;
{
demux_sys_t *p_sys = p_demux->p_sys;
int i_field;
- int i_channel;
if( p_block_in )
block_Release(p_block_in);
/* XDS data (extract programs infos) transmitted on field 2 only */
if( i_field == 1 )
- DemuxDecodeXds( p_demux, rec_hdr->ex1, rec_hdr->ex2 );
+ DemuxDecodeXds( p_demux, rec_hdr->ex[0], rec_hdr->ex[1] );
if( p_sys->cc.i_data + 3 > CC_MAX_DATA_SIZE )
return 0;
- p_sys->cc.p_data[p_sys->cc.i_data+0] = i_field;
- p_sys->cc.p_data[p_sys->cc.i_data+1] = rec_hdr->ex1;
- p_sys->cc.p_data[p_sys->cc.i_data+2] = rec_hdr->ex2;
- p_sys->cc.i_data += 3;
-
- i_channel = cc_Channel( i_field, &p_sys->cc.p_data[p_sys->cc.i_data-3 + 1] );
- if( i_channel >= 0 && i_channel < 4 )
- p_sys->cc.pb_present[i_channel] = true;
+ cc_AppendData( &p_sys->cc, i_field, rec_hdr->ex );
return 0;
}
/* marker bit 2 set, so read extended data */
b1 = ( ( ( record_header[ 0 ] & 0x0f ) << 4 ) |
( ( record_header[ 1 ] & 0xf0 ) >> 4 ) );
- b1 &= 0x7f;
b2 = ( ( ( record_header[ 1 ] & 0x0f ) << 4 ) |
( ( record_header[ 2 ] & 0xf0 ) >> 4 ) );
- b2 &= 0x7f;
- p_rec_hdr->ex1 = b1;
- p_rec_hdr->ex2 = b2;
+ p_rec_hdr->ex[0] = b1;
+ p_rec_hdr->ex[1] = b2;
p_rec_hdr->l_rec_size = 0;
p_rec_hdr->l_ty_pts = 0;
p_rec_hdr->b_ext = true;