- int i_channel = cc_Channel( i_field, &cc[2] );
- if( i_channel >= 0 && i_channel < 4 )
- c->pb_present[i_channel] = VLC_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;
+ }
+ else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
+ !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
+ {
+ /* SCTE-20 CC */
+ bs_t s;
+ bs_init( &s, &p_src[2], i_src - 2 );
+ const int i_cc_count = bs_read( &s, 5 );
+ for( int i = 0; i < i_cc_count; i++ )
+ {
+ bs_skip( &s, 2 );
+ const int i_field_idx = bs_read( &s, 2 );
+ bs_skip( &s, 5 );
+ uint8_t cc[2];
+ for( int j = 0; j < 2; j++ )
+ {
+ cc[j] = 0;
+ for( int k = 0; k < 8; k++ )
+ cc[j] |= bs_read( &s, 1 ) << k;
+ }
+ bs_skip( &s, 1 );
+
+ if( i_field_idx == 0 )
+ continue;
+ if( c->i_data + 2*3 > CC_MAX_DATA_SIZE )
+ continue;
+
+ /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
+ int i_field = ((i_field_idx - 1) & 1);
+ if (!b_top_field_first)
+ i_field ^= 1;
+
+ cc_AppendData( c, i_field, &cc[0] );