Coverage Report

Created: 2026-05-30 08:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/modules/codec/cc.h
Line
Count
Source
1
/*****************************************************************************
2
 * cc.h
3
 *****************************************************************************
4
 * Copyright (C) 2007 Laurent Aimar
5
 *
6
 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7
 *
8
 * This program is free software; you can redistribute it and/or modify it
9
 * under the terms of the GNU Lesser General Public License as published by
10
 * the Free Software Foundation; either version 2.1 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public License
19
 * along with this program; if not, write to the Free Software Foundation,
20
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21
 *****************************************************************************/
22
23
#ifndef VLC_CC_H_
24
#define VLC_CC_H_
25
26
#include <vlc_bits.h>
27
28
247k
#define CC_PKT_BYTE0(field) (0xFC | (0x03 & field))
29
30
/* CC have a maximum rate of 9600 bit/s (per field?) */
31
#define CC_MAX_DATA_SIZE (2 * 3*600)
32
enum cc_payload_type_e
33
{
34
    CC_PAYLOAD_NONE,
35
    CC_PAYLOAD_RAW,
36
    CC_PAYLOAD_GA94,
37
    CC_PAYLOAD_DVD,
38
    CC_PAYLOAD_REPLAYTV,
39
    CC_PAYLOAD_SCTE20,
40
    CC_PAYLOAD_CDP,
41
};
42
typedef struct
43
{
44
    /* Which channel are present */
45
    uint64_t i_708channels;
46
    uint8_t  i_608channels;
47
48
    /* */
49
    bool b_reorder;
50
    struct
51
    {
52
        uint8_t pktsize;
53
        uint8_t seq;
54
        uint8_t sid_bs;
55
        enum
56
        {
57
            CEA708_PKT_END,
58
            CEA708_PKT_WAIT_BLOCK_HEADER,
59
            CEA708_PKT_WAIT_EXT_BLOCK_HEADER,
60
            CEA708_PKT_IN_BLOCK,
61
        } state;
62
    } cea708;
63
64
    /* */
65
    enum cc_payload_type_e i_payload_type;
66
    int i_payload_other_count;
67
68
    /* CC data per field
69
     *  byte[x+0]: field (0/1)
70
     *  byte[x+1]: cc data 1
71
     *  byte[x+2]: cc data 2
72
     */
73
    size_t  i_data;
74
    uint8_t p_data[CC_MAX_DATA_SIZE];
75
} cc_data_t;
76
77
static inline void cc_Init( cc_data_t *c )
78
436k
{
79
436k
    c->i_608channels = 0;
80
436k
    c->i_708channels = 0;
81
436k
    c->i_data = 0;
82
436k
    c->b_reorder = false;
83
436k
    c->cea708.pktsize = 0;
84
436k
    c->cea708.seq = 0;
85
436k
    c->cea708.sid_bs = 0;
86
436k
    c->cea708.state = CEA708_PKT_END;
87
436k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
436k
    c->i_payload_other_count = 0;
89
436k
}
Unexecuted instantiation: mp4.c:cc_Init
ty.c:cc_Init
Line
Count
Source
78
1.21k
{
79
1.21k
    c->i_608channels = 0;
80
1.21k
    c->i_708channels = 0;
81
1.21k
    c->i_data = 0;
82
    c->b_reorder = false;
83
1.21k
    c->cea708.pktsize = 0;
84
1.21k
    c->cea708.seq = 0;
85
1.21k
    c->cea708.sid_bs = 0;
86
1.21k
    c->cea708.state = CEA708_PKT_END;
87
1.21k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
1.21k
    c->i_payload_other_count = 0;
89
1.21k
}
hxxx_common.c:cc_Init
Line
Count
Source
78
178k
{
79
178k
    c->i_608channels = 0;
80
178k
    c->i_708channels = 0;
81
178k
    c->i_data = 0;
82
    c->b_reorder = false;
83
178k
    c->cea708.pktsize = 0;
84
178k
    c->cea708.seq = 0;
85
178k
    c->cea708.sid_bs = 0;
86
178k
    c->cea708.state = CEA708_PKT_END;
87
178k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
178k
    c->i_payload_other_count = 0;
89
178k
}
mpegvideo.c:cc_Init
Line
Count
Source
78
47.7k
{
79
47.7k
    c->i_608channels = 0;
80
47.7k
    c->i_708channels = 0;
81
47.7k
    c->i_data = 0;
82
    c->b_reorder = false;
83
47.7k
    c->cea708.pktsize = 0;
84
47.7k
    c->cea708.seq = 0;
85
47.7k
    c->cea708.sid_bs = 0;
86
47.7k
    c->cea708.state = CEA708_PKT_END;
87
47.7k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
47.7k
    c->i_payload_other_count = 0;
89
47.7k
}
vc1.c:cc_Init
Line
Count
Source
78
198
{
79
198
    c->i_608channels = 0;
80
198
    c->i_708channels = 0;
81
198
    c->i_data = 0;
82
    c->b_reorder = false;
83
198
    c->cea708.pktsize = 0;
84
198
    c->cea708.seq = 0;
85
198
    c->cea708.sid_bs = 0;
86
198
    c->cea708.state = CEA708_PKT_END;
87
198
    c->i_payload_type = CC_PAYLOAD_NONE;
88
198
    c->i_payload_other_count = 0;
89
198
}
dav1d.c:cc_Init
Line
Count
Source
78
3.95k
{
79
3.95k
    c->i_608channels = 0;
80
3.95k
    c->i_708channels = 0;
81
3.95k
    c->i_data = 0;
82
    c->b_reorder = false;
83
3.95k
    c->cea708.pktsize = 0;
84
3.95k
    c->cea708.seq = 0;
85
3.95k
    c->cea708.sid_bs = 0;
86
3.95k
    c->cea708.state = CEA708_PKT_END;
87
3.95k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
3.95k
    c->i_payload_other_count = 0;
89
3.95k
}
video.c:cc_Init
Line
Count
Source
78
205k
{
79
205k
    c->i_608channels = 0;
80
205k
    c->i_708channels = 0;
81
205k
    c->i_data = 0;
82
    c->b_reorder = false;
83
205k
    c->cea708.pktsize = 0;
84
205k
    c->cea708.seq = 0;
85
205k
    c->cea708.sid_bs = 0;
86
205k
    c->cea708.state = CEA708_PKT_END;
87
205k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
205k
    c->i_payload_other_count = 0;
89
205k
}
90
static inline void cc_Exit( cc_data_t *c )
91
179k
{
92
179k
    VLC_UNUSED(c);
93
179k
    return;
94
179k
}
Unexecuted instantiation: mp4.c:cc_Exit
ty.c:cc_Exit
Line
Count
Source
91
1.21k
{
92
1.21k
    VLC_UNUSED(c);
93
1.21k
    return;
94
1.21k
}
hxxx_common.c:cc_Exit
Line
Count
Source
91
178k
{
92
178k
    VLC_UNUSED(c);
93
178k
    return;
94
178k
}
Unexecuted instantiation: mpegvideo.c:cc_Exit
vc1.c:cc_Exit
Line
Count
Source
91
198
{
92
198
    VLC_UNUSED(c);
93
198
    return;
94
198
}
Unexecuted instantiation: dav1d.c:cc_Exit
Unexecuted instantiation: video.c:cc_Exit
95
static inline void cc_Flush( cc_data_t *c )
96
3.77M
{
97
3.77M
    c->i_data = 0;
98
3.77M
    c->cea708.state = CEA708_PKT_END;
99
3.77M
}
Unexecuted instantiation: mp4.c:cc_Flush
ty.c:cc_Flush
Line
Count
Source
96
2.50k
{
97
2.50k
    c->i_data = 0;
98
2.50k
    c->cea708.state = CEA708_PKT_END;
99
2.50k
}
hxxx_common.c:cc_Flush
Line
Count
Source
96
3.32M
{
97
3.32M
    c->i_data = 0;
98
3.32M
    c->cea708.state = CEA708_PKT_END;
99
3.32M
}
mpegvideo.c:cc_Flush
Line
Count
Source
96
150k
{
97
150k
    c->i_data = 0;
98
150k
    c->cea708.state = CEA708_PKT_END;
99
150k
}
vc1.c:cc_Flush
Line
Count
Source
96
33.4k
{
97
33.4k
    c->i_data = 0;
98
33.4k
    c->cea708.state = CEA708_PKT_END;
99
33.4k
}
dav1d.c:cc_Flush
Line
Count
Source
96
3.95k
{
97
3.95k
    c->i_data = 0;
98
3.95k
    c->cea708.state = CEA708_PKT_END;
99
3.95k
}
video.c:cc_Flush
Line
Count
Source
96
258k
{
97
258k
    c->i_data = 0;
98
258k
    c->cea708.state = CEA708_PKT_END;
99
258k
}
100
101
static inline void cc_ProbeCEA708OneByte( cc_data_t *c, bool b_start, const uint8_t cc )
102
523k
{
103
523k
    if( b_start )
104
117k
    {
105
117k
        const uint8_t i_pkt_sequence = cc >> 6;
106
117k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
45.9k
        {
108
45.9k
            c->cea708.pktsize = 0;
109
45.9k
            c->cea708.seq = i_pkt_sequence;
110
45.9k
            c->cea708.state = CEA708_PKT_END;
111
45.9k
        }
112
71.3k
        else
113
71.3k
        {
114
71.3k
            c->cea708.seq = i_pkt_sequence;
115
71.3k
            c->cea708.pktsize = cc & 63;
116
71.3k
            if( c->cea708.pktsize == 0 )
117
13.5k
                c->cea708.pktsize = 127;
118
57.7k
            else
119
57.7k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
71.3k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
71.3k
        }
122
117k
    }
123
406k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
82.2k
    {
125
82.2k
        c->cea708.state = CEA708_PKT_END;
126
82.2k
    }
127
323k
    else if( c->cea708.state != CEA708_PKT_END )
128
271k
    {
129
271k
        switch( c->cea708.state )
130
271k
        {
131
109k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
109k
            {
133
109k
                uint8_t i_sid = cc >> 5;
134
109k
                c->cea708.sid_bs = cc & 0x1F;
135
109k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
79.8k
                {
137
79.8k
                    if( i_sid != 0x07 )
138
63.8k
                    {
139
63.8k
                        const uint8_t mask = (1 << --i_sid);
140
63.8k
                        c->i_708channels |= (mask + (mask - 1));
141
63.8k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
63.8k
                    }
143
16.0k
                    else if( c->cea708.sid_bs < 2 )
144
2.42k
                    {
145
2.42k
                        c->cea708.state = CEA708_PKT_END;
146
2.42k
                    }
147
13.5k
                    else
148
13.5k
                    {
149
                        /* need to look up next byte in next pkt */
150
13.5k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
13.5k
                    }
152
79.8k
                }
153
29.2k
                else c->cea708.state = CEA708_PKT_END;
154
109k
            } break;
155
156
9.19k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
9.19k
            {
158
9.19k
                uint8_t i_extsid = cc & 0x3F;
159
9.19k
                if( i_extsid >= 0x07 )
160
4.77k
                {
161
4.77k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
4.77k
                    c->i_708channels |= (mask + (mask - 1));
163
4.77k
                }
164
9.19k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
9.19k
                else
167
9.19k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
9.19k
            } break;
169
170
153k
            case CEA708_PKT_IN_BLOCK:
171
153k
            {
172
153k
                c->cea708.sid_bs--;
173
153k
                if( c->cea708.sid_bs == 0 )
174
41.2k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
153k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
271k
        }
181
271k
        c->cea708.pktsize--;
182
183
271k
        if(c->cea708.pktsize == 0)
184
6.97k
            c->cea708.state = CEA708_PKT_END;
185
271k
    }
186
523k
}
Unexecuted instantiation: mp4.c:cc_ProbeCEA708OneByte
Unexecuted instantiation: ty.c:cc_ProbeCEA708OneByte
hxxx_common.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
199k
{
103
199k
    if( b_start )
104
50.4k
    {
105
50.4k
        const uint8_t i_pkt_sequence = cc >> 6;
106
50.4k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
17.8k
        {
108
17.8k
            c->cea708.pktsize = 0;
109
17.8k
            c->cea708.seq = i_pkt_sequence;
110
17.8k
            c->cea708.state = CEA708_PKT_END;
111
17.8k
        }
112
32.5k
        else
113
32.5k
        {
114
32.5k
            c->cea708.seq = i_pkt_sequence;
115
32.5k
            c->cea708.pktsize = cc & 63;
116
32.5k
            if( c->cea708.pktsize == 0 )
117
4.92k
                c->cea708.pktsize = 127;
118
27.6k
            else
119
27.6k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
32.5k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
32.5k
        }
122
50.4k
    }
123
148k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
30.7k
    {
125
30.7k
        c->cea708.state = CEA708_PKT_END;
126
30.7k
    }
127
117k
    else if( c->cea708.state != CEA708_PKT_END )
128
98.3k
    {
129
98.3k
        switch( c->cea708.state )
130
98.3k
        {
131
42.7k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
42.7k
            {
133
42.7k
                uint8_t i_sid = cc >> 5;
134
42.7k
                c->cea708.sid_bs = cc & 0x1F;
135
42.7k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
31.3k
                {
137
31.3k
                    if( i_sid != 0x07 )
138
24.7k
                    {
139
24.7k
                        const uint8_t mask = (1 << --i_sid);
140
24.7k
                        c->i_708channels |= (mask + (mask - 1));
141
24.7k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
24.7k
                    }
143
6.60k
                    else if( c->cea708.sid_bs < 2 )
144
907
                    {
145
907
                        c->cea708.state = CEA708_PKT_END;
146
907
                    }
147
5.69k
                    else
148
5.69k
                    {
149
                        /* need to look up next byte in next pkt */
150
5.69k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
5.69k
                    }
152
31.3k
                }
153
11.4k
                else c->cea708.state = CEA708_PKT_END;
154
42.7k
            } break;
155
156
3.06k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
3.06k
            {
158
3.06k
                uint8_t i_extsid = cc & 0x3F;
159
3.06k
                if( i_extsid >= 0x07 )
160
1.34k
                {
161
1.34k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
1.34k
                    c->i_708channels |= (mask + (mask - 1));
163
1.34k
                }
164
3.06k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
3.06k
                else
167
3.06k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
3.06k
            } break;
169
170
52.5k
            case CEA708_PKT_IN_BLOCK:
171
52.5k
            {
172
52.5k
                c->cea708.sid_bs--;
173
52.5k
                if( c->cea708.sid_bs == 0 )
174
12.3k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
52.5k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
98.3k
        }
181
98.3k
        c->cea708.pktsize--;
182
183
98.3k
        if(c->cea708.pktsize == 0)
184
1.59k
            c->cea708.state = CEA708_PKT_END;
185
98.3k
    }
186
199k
}
mpegvideo.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
198k
{
103
198k
    if( b_start )
104
44.6k
    {
105
44.6k
        const uint8_t i_pkt_sequence = cc >> 6;
106
44.6k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
23.3k
        {
108
23.3k
            c->cea708.pktsize = 0;
109
23.3k
            c->cea708.seq = i_pkt_sequence;
110
23.3k
            c->cea708.state = CEA708_PKT_END;
111
23.3k
        }
112
21.3k
        else
113
21.3k
        {
114
21.3k
            c->cea708.seq = i_pkt_sequence;
115
21.3k
            c->cea708.pktsize = cc & 63;
116
21.3k
            if( c->cea708.pktsize == 0 )
117
4.74k
                c->cea708.pktsize = 127;
118
16.5k
            else
119
16.5k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
21.3k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
21.3k
        }
122
44.6k
    }
123
153k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
37.7k
    {
125
37.7k
        c->cea708.state = CEA708_PKT_END;
126
37.7k
    }
127
115k
    else if( c->cea708.state != CEA708_PKT_END )
128
97.9k
    {
129
97.9k
        switch( c->cea708.state )
130
97.9k
        {
131
36.3k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
36.3k
            {
133
36.3k
                uint8_t i_sid = cc >> 5;
134
36.3k
                c->cea708.sid_bs = cc & 0x1F;
135
36.3k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
26.3k
                {
137
26.3k
                    if( i_sid != 0x07 )
138
20.6k
                    {
139
20.6k
                        const uint8_t mask = (1 << --i_sid);
140
20.6k
                        c->i_708channels |= (mask + (mask - 1));
141
20.6k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
20.6k
                    }
143
5.67k
                    else if( c->cea708.sid_bs < 2 )
144
964
                    {
145
964
                        c->cea708.state = CEA708_PKT_END;
146
964
                    }
147
4.71k
                    else
148
4.71k
                    {
149
                        /* need to look up next byte in next pkt */
150
4.71k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
4.71k
                    }
152
26.3k
                }
153
9.98k
                else c->cea708.state = CEA708_PKT_END;
154
36.3k
            } break;
155
156
3.56k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
3.56k
            {
158
3.56k
                uint8_t i_extsid = cc & 0x3F;
159
3.56k
                if( i_extsid >= 0x07 )
160
2.18k
                {
161
2.18k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
2.18k
                    c->i_708channels |= (mask + (mask - 1));
163
2.18k
                }
164
3.56k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
3.56k
                else
167
3.56k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
3.56k
            } break;
169
170
58.0k
            case CEA708_PKT_IN_BLOCK:
171
58.0k
            {
172
58.0k
                c->cea708.sid_bs--;
173
58.0k
                if( c->cea708.sid_bs == 0 )
174
15.2k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
58.0k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
97.9k
        }
181
97.9k
        c->cea708.pktsize--;
182
183
97.9k
        if(c->cea708.pktsize == 0)
184
3.22k
            c->cea708.state = CEA708_PKT_END;
185
97.9k
    }
186
198k
}
vc1.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
5.69k
{
103
5.69k
    if( b_start )
104
1.38k
    {
105
1.38k
        const uint8_t i_pkt_sequence = cc >> 6;
106
1.38k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
569
        {
108
569
            c->cea708.pktsize = 0;
109
569
            c->cea708.seq = i_pkt_sequence;
110
569
            c->cea708.state = CEA708_PKT_END;
111
569
        }
112
812
        else
113
812
        {
114
812
            c->cea708.seq = i_pkt_sequence;
115
812
            c->cea708.pktsize = cc & 63;
116
812
            if( c->cea708.pktsize == 0 )
117
207
                c->cea708.pktsize = 127;
118
605
            else
119
605
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
812
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
812
        }
122
1.38k
    }
123
4.31k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
977
    {
125
977
        c->cea708.state = CEA708_PKT_END;
126
977
    }
127
3.33k
    else if( c->cea708.state != CEA708_PKT_END )
128
2.95k
    {
129
2.95k
        switch( c->cea708.state )
130
2.95k
        {
131
1.26k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
1.26k
            {
133
1.26k
                uint8_t i_sid = cc >> 5;
134
1.26k
                c->cea708.sid_bs = cc & 0x1F;
135
1.26k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
897
                {
137
897
                    if( i_sid != 0x07 )
138
639
                    {
139
639
                        const uint8_t mask = (1 << --i_sid);
140
639
                        c->i_708channels |= (mask + (mask - 1));
141
639
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
639
                    }
143
258
                    else if( c->cea708.sid_bs < 2 )
144
37
                    {
145
37
                        c->cea708.state = CEA708_PKT_END;
146
37
                    }
147
221
                    else
148
221
                    {
149
                        /* need to look up next byte in next pkt */
150
221
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
221
                    }
152
897
                }
153
365
                else c->cea708.state = CEA708_PKT_END;
154
1.26k
            } break;
155
156
163
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
163
            {
158
163
                uint8_t i_extsid = cc & 0x3F;
159
163
                if( i_extsid >= 0x07 )
160
62
                {
161
62
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
62
                    c->i_708channels |= (mask + (mask - 1));
163
62
                }
164
163
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
163
                else
167
163
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
163
            } break;
169
170
1.53k
            case CEA708_PKT_IN_BLOCK:
171
1.53k
            {
172
1.53k
                c->cea708.sid_bs--;
173
1.53k
                if( c->cea708.sid_bs == 0 )
174
450
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
1.53k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
2.95k
        }
181
2.95k
        c->cea708.pktsize--;
182
183
2.95k
        if(c->cea708.pktsize == 0)
184
50
            c->cea708.state = CEA708_PKT_END;
185
2.95k
    }
186
5.69k
}
Unexecuted instantiation: dav1d.c:cc_ProbeCEA708OneByte
video.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
120k
{
103
120k
    if( b_start )
104
20.9k
    {
105
20.9k
        const uint8_t i_pkt_sequence = cc >> 6;
106
20.9k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
4.26k
        {
108
4.26k
            c->cea708.pktsize = 0;
109
4.26k
            c->cea708.seq = i_pkt_sequence;
110
4.26k
            c->cea708.state = CEA708_PKT_END;
111
4.26k
        }
112
16.6k
        else
113
16.6k
        {
114
16.6k
            c->cea708.seq = i_pkt_sequence;
115
16.6k
            c->cea708.pktsize = cc & 63;
116
16.6k
            if( c->cea708.pktsize == 0 )
117
3.72k
                c->cea708.pktsize = 127;
118
12.9k
            else
119
12.9k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
16.6k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
16.6k
        }
122
20.9k
    }
123
99.4k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
12.7k
    {
125
12.7k
        c->cea708.state = CEA708_PKT_END;
126
12.7k
    }
127
86.7k
    else if( c->cea708.state != CEA708_PKT_END )
128
72.6k
    {
129
72.6k
        switch( c->cea708.state )
130
72.6k
        {
131
28.7k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
28.7k
            {
133
28.7k
                uint8_t i_sid = cc >> 5;
134
28.7k
                c->cea708.sid_bs = cc & 0x1F;
135
28.7k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
21.2k
                {
137
21.2k
                    if( i_sid != 0x07 )
138
17.8k
                    {
139
17.8k
                        const uint8_t mask = (1 << --i_sid);
140
17.8k
                        c->i_708channels |= (mask + (mask - 1));
141
17.8k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
17.8k
                    }
143
3.48k
                    else if( c->cea708.sid_bs < 2 )
144
514
                    {
145
514
                        c->cea708.state = CEA708_PKT_END;
146
514
                    }
147
2.96k
                    else
148
2.96k
                    {
149
                        /* need to look up next byte in next pkt */
150
2.96k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
2.96k
                    }
152
21.2k
                }
153
7.47k
                else c->cea708.state = CEA708_PKT_END;
154
28.7k
            } break;
155
156
2.41k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
2.41k
            {
158
2.41k
                uint8_t i_extsid = cc & 0x3F;
159
2.41k
                if( i_extsid >= 0x07 )
160
1.18k
                {
161
1.18k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
1.18k
                    c->i_708channels |= (mask + (mask - 1));
163
1.18k
                }
164
2.41k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
2.41k
                else
167
2.41k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
2.41k
            } break;
169
170
41.5k
            case CEA708_PKT_IN_BLOCK:
171
41.5k
            {
172
41.5k
                c->cea708.sid_bs--;
173
41.5k
                if( c->cea708.sid_bs == 0 )
174
13.1k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
41.5k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
72.6k
        }
181
72.6k
        c->cea708.pktsize--;
182
183
72.6k
        if(c->cea708.pktsize == 0)
184
2.10k
            c->cea708.state = CEA708_PKT_END;
185
72.6k
    }
186
120k
}
187
188
static inline void cc_ProbeCEA708( cc_data_t *c, uint8_t i_field, const uint8_t cc[2] )
189
261k
{
190
261k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
117k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
144k
    else /* DTVCC_PACKET_DATA */
193
144k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
261k
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
261k
}
Unexecuted instantiation: mp4.c:cc_ProbeCEA708
Unexecuted instantiation: ty.c:cc_ProbeCEA708
hxxx_common.c:cc_ProbeCEA708
Line
Count
Source
189
99.5k
{
190
99.5k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
50.4k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
49.1k
    else /* DTVCC_PACKET_DATA */
193
49.1k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
99.5k
}
mpegvideo.c:cc_ProbeCEA708
Line
Count
Source
189
99.1k
{
190
99.1k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
44.6k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
54.5k
    else /* DTVCC_PACKET_DATA */
193
54.5k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
99.1k
}
vc1.c:cc_ProbeCEA708
Line
Count
Source
189
2.84k
{
190
2.84k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
1.38k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
1.46k
    else /* DTVCC_PACKET_DATA */
193
1.46k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
2.84k
}
Unexecuted instantiation: dav1d.c:cc_ProbeCEA708
video.c:cc_ProbeCEA708
Line
Count
Source
189
60.2k
{
190
60.2k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
20.9k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
39.2k
    else /* DTVCC_PACKET_DATA */
193
39.2k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
60.2k
}
196
197
static inline bool cc_AppendData( cc_data_t *c, uint8_t cc_preamble, const uint8_t cc[2] )
198
863k
{
199
863k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
12.6k
        return false;
201
202
850k
    const uint8_t i_field = cc_preamble & 0x03;
203
850k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
588k
    {
205
588k
        c->i_608channels |= (3 << (2 * i_field));
206
588k
    }
207
261k
    else
208
261k
    {
209
261k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
261k
        c->i_708channels |= 1;
212
261k
    }
213
214
850k
    c->p_data[c->i_data++] = cc_preamble;
215
850k
    c->p_data[c->i_data++] = cc[0];
216
850k
    c->p_data[c->i_data++] = cc[1];
217
850k
    return true;
218
863k
}
Unexecuted instantiation: mp4.c:cc_AppendData
ty.c:cc_AppendData
Line
Count
Source
198
43.2k
{
199
43.2k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
0
        return false;
201
202
43.2k
    const uint8_t i_field = cc_preamble & 0x03;
203
43.2k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
43.2k
    {
205
43.2k
        c->i_608channels |= (3 << (2 * i_field));
206
43.2k
    }
207
0
    else
208
0
    {
209
0
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
0
        c->i_708channels |= 1;
212
0
    }
213
214
43.2k
    c->p_data[c->i_data++] = cc_preamble;
215
43.2k
    c->p_data[c->i_data++] = cc[0];
216
43.2k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
43.2k
}
hxxx_common.c:cc_AppendData
Line
Count
Source
198
109k
{
199
109k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
442
        return false;
201
202
108k
    const uint8_t i_field = cc_preamble & 0x03;
203
108k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
9.33k
    {
205
9.33k
        c->i_608channels |= (3 << (2 * i_field));
206
9.33k
    }
207
99.5k
    else
208
99.5k
    {
209
99.5k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
99.5k
        c->i_708channels |= 1;
212
99.5k
    }
213
214
108k
    c->p_data[c->i_data++] = cc_preamble;
215
108k
    c->p_data[c->i_data++] = cc[0];
216
108k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
109k
}
mpegvideo.c:cc_AppendData
Line
Count
Source
198
358k
{
199
358k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
11.9k
        return false;
201
202
346k
    const uint8_t i_field = cc_preamble & 0x03;
203
346k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
247k
    {
205
247k
        c->i_608channels |= (3 << (2 * i_field));
206
247k
    }
207
99.1k
    else
208
99.1k
    {
209
99.1k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
99.1k
        c->i_708channels |= 1;
212
99.1k
    }
213
214
346k
    c->p_data[c->i_data++] = cc_preamble;
215
346k
    c->p_data[c->i_data++] = cc[0];
216
346k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
358k
}
vc1.c:cc_AppendData
Line
Count
Source
198
6.97k
{
199
6.97k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
161
        return false;
201
202
6.81k
    const uint8_t i_field = cc_preamble & 0x03;
203
6.81k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
3.96k
    {
205
3.96k
        c->i_608channels |= (3 << (2 * i_field));
206
3.96k
    }
207
2.84k
    else
208
2.84k
    {
209
2.84k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
2.84k
        c->i_708channels |= 1;
212
2.84k
    }
213
214
6.81k
    c->p_data[c->i_data++] = cc_preamble;
215
6.81k
    c->p_data[c->i_data++] = cc[0];
216
6.81k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
6.97k
}
Unexecuted instantiation: dav1d.c:cc_AppendData
video.c:cc_AppendData
Line
Count
Source
198
345k
{
199
345k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
109
        return false;
201
202
345k
    const uint8_t i_field = cc_preamble & 0x03;
203
345k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
285k
    {
205
285k
        c->i_608channels |= (3 << (2 * i_field));
206
285k
    }
207
60.2k
    else
208
60.2k
    {
209
60.2k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
60.2k
        c->i_708channels |= 1;
212
60.2k
    }
213
214
345k
    c->p_data[c->i_data++] = cc_preamble;
215
345k
    c->p_data[c->i_data++] = cc[0];
216
345k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
345k
}
219
220
static inline void cc_Extract( cc_data_t *c, enum cc_payload_type_e i_payload_type,
221
                               bool b_top_field_first, const uint8_t *p_src, int i_src )
222
129k
{
223
129k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
13.0k
    {
225
13.0k
        c->i_payload_other_count++;
226
13.0k
        if( c->i_payload_other_count < 50 )
227
12.9k
            return;
228
13.0k
    }
229
116k
    c->i_payload_type        = i_payload_type;
230
116k
    c->i_payload_other_count = 0;
231
232
116k
    if( i_payload_type == CC_PAYLOAD_RAW )
233
4.83k
    {
234
350k
        for( int i = 0; i + 2 < i_src; i += 3 )
235
345k
        {
236
345k
            const uint8_t *cc = &p_src[i];
237
345k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
109
                break;
239
345k
        }
240
4.83k
        c->b_reorder = true;
241
4.83k
    }
242
112k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
61.5k
    {
244
        /* cc_data()
245
         *          u1 reserved(1)
246
         *          u1 process_cc_data_flag
247
         *          u1 additional_data_flag
248
         *          u5 cc_count
249
         *          u8 reserved(1111 1111)
250
         *          for cc_count
251
         *              u5 marker bit(1111 1)
252
         *              u1 cc_valid
253
         *              u2 cc_type
254
         *              u8 cc_data_1
255
         *              u8 cc_data_2
256
         *          u8 marker bit(1111 1111)
257
         *          if additional_data_flag
258
         *              unknown
259
         */
260
        /* cc_type:
261
         *  0x00: field 1
262
         *  0x01: field 2
263
         */
264
61.5k
        if(i_src < 1)
265
314
            return;
266
61.2k
        const uint8_t *cc = &p_src[0];
267
61.2k
        const int i_count_cc = cc[0]&0x1f;
268
61.2k
        int i;
269
270
61.2k
        if( !(cc[0]&0x40) ) // process flag
271
2.31k
            return;
272
58.8k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
4.83k
            return;
274
54.0k
        if( i_count_cc <= 0 )   // no cc present
275
712
            return;
276
53.3k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
8.34k
            return;
278
45.0k
        cc += 2;
279
280
248k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
204k
        {
282
204k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
860
                break;
284
204k
        }
285
45.0k
        c->b_reorder = true;
286
45.0k
    }
287
50.4k
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
4.05k
    {
289
        /* user_data
290
         *          (u32 stripped earlier)
291
         *          u32 (0x43 0x43 0x01 0xf8)
292
         *          u1 caption_odd_field_first (CC1/CC2)
293
         *          u1 caption_filler
294
         *          u5 cc_block_count  (== cc_count / 2)
295
         *          u1 caption_extra_field_added (because odd cc_count)
296
         *          for cc_block_count * 2 + caption_extra_field_added
297
         *              u7 cc_filler_1
298
         *              u1 cc_field_is_odd
299
         *              u8 cc_data_1
300
         *              u8 cc_data_2
301
         */
302
4.05k
        if(i_src < 6)
303
0
            return;
304
4.05k
        const int b_truncate = p_src[4] & 0x01;
305
4.05k
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
4.05k
        const uint8_t *cc = &p_src[5];
307
4.05k
        i_src -= 5;
308
4.05k
        int i;
309
310
50.4k
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
54.2k
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
50.4k
        {
314
50.4k
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
18.6k
            {
316
18.6k
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
18.6k
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
208
                    break;
319
18.6k
            }
320
50.2k
            i_src -= 3;
321
50.2k
        }
322
4.05k
        c->b_reorder = false;
323
4.05k
    }
324
46.4k
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
1.36k
    {
326
1.36k
        if(i_src < 1)
327
0
            return;
328
1.36k
        const uint8_t *cc = &p_src[0];
329
18.2k
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
16.8k
             i_cc_count--, cc += 4 )
331
17.0k
        {
332
17.0k
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
17.0k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
247
                return;
335
17.0k
        }
336
1.11k
        c->b_reorder = false;
337
1.11k
    }
338
45.0k
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
30.7k
    {
340
        /* user_data(2)
341
         *          (u32 stripped earlier)
342
         *          u16 p_cc_scte20
343
         *          u5 cc_count
344
         *          for cc_count
345
         *              u2 cc_priority
346
         *              u2 cc_field_num
347
         *              u5 cc_line_offset
348
         *              u8 cc_data_1[1:8]
349
         *              u8 cc_data_2[1:8]
350
         *              u1 marker bit
351
         *          un additional_realtimevideodata
352
         *          un reserved
353
         */
354
30.7k
        if(i_src < 2)
355
0
            return;
356
30.7k
        bs_t s;
357
30.7k
        bs_init( &s, &p_src[2], i_src - 2 );
358
30.7k
        const int i_cc_count = bs_read( &s, 5 );
359
738k
        for( int i = 0; i < i_cc_count; i++ )
360
707k
        {
361
707k
            bs_skip( &s, 2 );
362
707k
            const int i_field_idx = bs_read( &s, 2 );
363
707k
            bs_skip( &s, 5 );
364
707k
            uint8_t cc[2];
365
2.12M
            for( int j = 0; j < 2; j++ )
366
1.41M
            {
367
1.41M
                cc[j] = 0;
368
12.7M
                for( int k = 0; k < 8; k++ )
369
11.3M
                    cc[j] |= bs_read( &s, 1 ) << k;
370
1.41M
            }
371
707k
            bs_skip( &s, 1 );
372
373
707k
            if( i_field_idx == 0 )
374
539k
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
168k
            int i_field = ((i_field_idx - 1) & 1);
378
168k
            if (!b_top_field_first)
379
155k
                i_field ^= 1;
380
381
168k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
10.0k
                continue;
383
168k
        }
384
30.7k
        c->b_reorder = true;
385
30.7k
    }
386
14.3k
    else // CC_PAYLOAD_CDP
387
14.3k
    {
388
14.3k
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
14.3k
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
14.3k
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
14.3k
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
14.3k
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
14.3k
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
14.3k
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
14.3k
        if(i_src < 7)
397
628
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
13.6k
        uint8_t cdp_length = p_src[2];
401
13.6k
        if(cdp_length < 8 || cdp_length > i_src)
402
827
            return;
403
12.8k
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
12.8k
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
12.8k
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
5.30k
        {
411
5.30k
            if( i_src < 5 ) // Shall be 5 bytes
412
251
                return;
413
5.05k
            p_src += 5; i_src -= 5;
414
5.05k
        }
415
        /* 5.4 ccdata_section */
416
12.6k
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
10.4k
        {
418
            /* ccdata_section()
419
             *      u8 0x72
420
             *      u3 marker bits(111)
421
             *      u5 cc_count
422
             *      for cc_count
423
             *          u5 marker bits(1111 1)
424
             *          u1 cc_valid
425
             *          u2 cc_type
426
             *          u8 cc_data_1
427
             *          u8 cc_data_2
428
             */
429
10.4k
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
4.37k
                return;
431
432
6.05k
            const uint8_t *cc = &p_src[1];
433
6.05k
            const int i_count_cc = cc[0]&0x1f;
434
435
6.05k
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
714
                return;
437
5.34k
            cc += 1;
438
70.1k
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
65.9k
            {
440
65.9k
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
1.18k
                    break;
442
65.9k
            }
443
5.34k
        }
444
        /* remaining data */
445
7.51k
        c->b_reorder = false;
446
7.51k
    }
447
116k
}
Unexecuted instantiation: mp4.c:cc_Extract
Unexecuted instantiation: ty.c:cc_Extract
hxxx_common.c:cc_Extract
Line
Count
Source
222
51.5k
{
223
51.5k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
0
    {
225
0
        c->i_payload_other_count++;
226
0
        if( c->i_payload_other_count < 50 )
227
0
            return;
228
0
    }
229
51.5k
    c->i_payload_type        = i_payload_type;
230
51.5k
    c->i_payload_other_count = 0;
231
232
51.5k
    if( i_payload_type == CC_PAYLOAD_RAW )
233
0
    {
234
0
        for( int i = 0; i + 2 < i_src; i += 3 )
235
0
        {
236
0
            const uint8_t *cc = &p_src[i];
237
0
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
0
                break;
239
0
        }
240
0
        c->b_reorder = true;
241
0
    }
242
51.5k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
51.5k
    {
244
        /* cc_data()
245
         *          u1 reserved(1)
246
         *          u1 process_cc_data_flag
247
         *          u1 additional_data_flag
248
         *          u5 cc_count
249
         *          u8 reserved(1111 1111)
250
         *          for cc_count
251
         *              u5 marker bit(1111 1)
252
         *              u1 cc_valid
253
         *              u2 cc_type
254
         *              u8 cc_data_1
255
         *              u8 cc_data_2
256
         *          u8 marker bit(1111 1111)
257
         *          if additional_data_flag
258
         *              unknown
259
         */
260
        /* cc_type:
261
         *  0x00: field 1
262
         *  0x01: field 2
263
         */
264
51.5k
        if(i_src < 1)
265
314
            return;
266
51.2k
        const uint8_t *cc = &p_src[0];
267
51.2k
        const int i_count_cc = cc[0]&0x1f;
268
51.2k
        int i;
269
270
51.2k
        if( !(cc[0]&0x40) ) // process flag
271
1.06k
            return;
272
50.1k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
2.20k
            return;
274
47.9k
        if( i_count_cc <= 0 )   // no cc present
275
504
            return;
276
47.4k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
6.75k
            return;
278
40.6k
        cc += 2;
279
280
149k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
109k
        {
282
109k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
442
                break;
284
109k
        }
285
40.6k
        c->b_reorder = true;
286
40.6k
    }
287
0
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
0
    {
289
        /* user_data
290
         *          (u32 stripped earlier)
291
         *          u32 (0x43 0x43 0x01 0xf8)
292
         *          u1 caption_odd_field_first (CC1/CC2)
293
         *          u1 caption_filler
294
         *          u5 cc_block_count  (== cc_count / 2)
295
         *          u1 caption_extra_field_added (because odd cc_count)
296
         *          for cc_block_count * 2 + caption_extra_field_added
297
         *              u7 cc_filler_1
298
         *              u1 cc_field_is_odd
299
         *              u8 cc_data_1
300
         *              u8 cc_data_2
301
         */
302
0
        if(i_src < 6)
303
0
            return;
304
0
        const int b_truncate = p_src[4] & 0x01;
305
0
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
0
        const uint8_t *cc = &p_src[5];
307
0
        i_src -= 5;
308
0
        int i;
309
310
0
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
0
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
0
        {
314
0
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
0
            {
316
0
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
0
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
0
                    break;
319
0
            }
320
0
            i_src -= 3;
321
0
        }
322
0
        c->b_reorder = false;
323
0
    }
324
0
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
0
    {
326
0
        if(i_src < 1)
327
0
            return;
328
0
        const uint8_t *cc = &p_src[0];
329
0
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
0
             i_cc_count--, cc += 4 )
331
0
        {
332
0
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
0
                return;
335
0
        }
336
0
        c->b_reorder = false;
337
0
    }
338
0
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
0
    {
340
        /* user_data(2)
341
         *          (u32 stripped earlier)
342
         *          u16 p_cc_scte20
343
         *          u5 cc_count
344
         *          for cc_count
345
         *              u2 cc_priority
346
         *              u2 cc_field_num
347
         *              u5 cc_line_offset
348
         *              u8 cc_data_1[1:8]
349
         *              u8 cc_data_2[1:8]
350
         *              u1 marker bit
351
         *          un additional_realtimevideodata
352
         *          un reserved
353
         */
354
0
        if(i_src < 2)
355
0
            return;
356
0
        bs_t s;
357
0
        bs_init( &s, &p_src[2], i_src - 2 );
358
0
        const int i_cc_count = bs_read( &s, 5 );
359
0
        for( int i = 0; i < i_cc_count; i++ )
360
0
        {
361
0
            bs_skip( &s, 2 );
362
0
            const int i_field_idx = bs_read( &s, 2 );
363
0
            bs_skip( &s, 5 );
364
0
            uint8_t cc[2];
365
0
            for( int j = 0; j < 2; j++ )
366
0
            {
367
0
                cc[j] = 0;
368
0
                for( int k = 0; k < 8; k++ )
369
0
                    cc[j] |= bs_read( &s, 1 ) << k;
370
0
            }
371
0
            bs_skip( &s, 1 );
372
373
0
            if( i_field_idx == 0 )
374
0
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
0
            int i_field = ((i_field_idx - 1) & 1);
378
0
            if (!b_top_field_first)
379
0
                i_field ^= 1;
380
381
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
0
                continue;
383
0
        }
384
0
        c->b_reorder = true;
385
0
    }
386
0
    else // CC_PAYLOAD_CDP
387
0
    {
388
0
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
0
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
0
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
0
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
0
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
0
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
0
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
0
        if(i_src < 7)
397
0
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
0
        uint8_t cdp_length = p_src[2];
401
0
        if(cdp_length < 8 || cdp_length > i_src)
402
0
            return;
403
0
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
0
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
0
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
0
        {
411
0
            if( i_src < 5 ) // Shall be 5 bytes
412
0
                return;
413
0
            p_src += 5; i_src -= 5;
414
0
        }
415
        /* 5.4 ccdata_section */
416
0
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
0
        {
418
            /* ccdata_section()
419
             *      u8 0x72
420
             *      u3 marker bits(111)
421
             *      u5 cc_count
422
             *      for cc_count
423
             *          u5 marker bits(1111 1)
424
             *          u1 cc_valid
425
             *          u2 cc_type
426
             *          u8 cc_data_1
427
             *          u8 cc_data_2
428
             */
429
0
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
0
                return;
431
432
0
            const uint8_t *cc = &p_src[1];
433
0
            const int i_count_cc = cc[0]&0x1f;
434
435
0
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
0
                return;
437
0
            cc += 1;
438
0
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
0
            {
440
0
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
0
                    break;
442
0
            }
443
0
        }
444
        /* remaining data */
445
0
        c->b_reorder = false;
446
0
    }
447
51.5k
}
mpegvideo.c:cc_Extract
Line
Count
Source
222
72.6k
{
223
72.6k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
13.0k
    {
225
13.0k
        c->i_payload_other_count++;
226
13.0k
        if( c->i_payload_other_count < 50 )
227
12.9k
            return;
228
13.0k
    }
229
59.6k
    c->i_payload_type        = i_payload_type;
230
59.6k
    c->i_payload_other_count = 0;
231
232
59.6k
    if( i_payload_type == CC_PAYLOAD_RAW )
233
0
    {
234
0
        for( int i = 0; i + 2 < i_src; i += 3 )
235
0
        {
236
0
            const uint8_t *cc = &p_src[i];
237
0
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
0
                break;
239
0
        }
240
0
        c->b_reorder = true;
241
0
    }
242
59.6k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
9.20k
    {
244
        /* cc_data()
245
         *          u1 reserved(1)
246
         *          u1 process_cc_data_flag
247
         *          u1 additional_data_flag
248
         *          u5 cc_count
249
         *          u8 reserved(1111 1111)
250
         *          for cc_count
251
         *              u5 marker bit(1111 1)
252
         *              u1 cc_valid
253
         *              u2 cc_type
254
         *              u8 cc_data_1
255
         *              u8 cc_data_2
256
         *          u8 marker bit(1111 1111)
257
         *          if additional_data_flag
258
         *              unknown
259
         */
260
        /* cc_type:
261
         *  0x00: field 1
262
         *  0x01: field 2
263
         */
264
9.20k
        if(i_src < 1)
265
0
            return;
266
9.20k
        const uint8_t *cc = &p_src[0];
267
9.20k
        const int i_count_cc = cc[0]&0x1f;
268
9.20k
        int i;
269
270
9.20k
        if( !(cc[0]&0x40) ) // process flag
271
1.21k
            return;
272
7.98k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
2.42k
            return;
274
5.55k
        if( i_count_cc <= 0 )   // no cc present
275
208
            return;
276
5.34k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
1.45k
            return;
278
3.89k
        cc += 2;
279
280
92.0k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
88.4k
        {
282
88.4k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
257
                break;
284
88.4k
        }
285
3.89k
        c->b_reorder = true;
286
3.89k
    }
287
50.4k
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
4.05k
    {
289
        /* user_data
290
         *          (u32 stripped earlier)
291
         *          u32 (0x43 0x43 0x01 0xf8)
292
         *          u1 caption_odd_field_first (CC1/CC2)
293
         *          u1 caption_filler
294
         *          u5 cc_block_count  (== cc_count / 2)
295
         *          u1 caption_extra_field_added (because odd cc_count)
296
         *          for cc_block_count * 2 + caption_extra_field_added
297
         *              u7 cc_filler_1
298
         *              u1 cc_field_is_odd
299
         *              u8 cc_data_1
300
         *              u8 cc_data_2
301
         */
302
4.05k
        if(i_src < 6)
303
0
            return;
304
4.05k
        const int b_truncate = p_src[4] & 0x01;
305
4.05k
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
4.05k
        const uint8_t *cc = &p_src[5];
307
4.05k
        i_src -= 5;
308
4.05k
        int i;
309
310
4.05k
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
54.2k
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
50.4k
        {
314
50.4k
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
18.6k
            {
316
18.6k
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
18.6k
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
208
                    break;
319
18.6k
            }
320
50.2k
            i_src -= 3;
321
50.2k
        }
322
4.05k
        c->b_reorder = false;
323
4.05k
    }
324
46.4k
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
1.36k
    {
326
1.36k
        if(i_src < 1)
327
0
            return;
328
1.36k
        const uint8_t *cc = &p_src[0];
329
18.2k
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
16.8k
             i_cc_count--, cc += 4 )
331
17.0k
        {
332
17.0k
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
17.0k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
247
                return;
335
17.0k
        }
336
1.11k
        c->b_reorder = false;
337
1.11k
    }
338
45.0k
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
30.7k
    {
340
        /* user_data(2)
341
         *          (u32 stripped earlier)
342
         *          u16 p_cc_scte20
343
         *          u5 cc_count
344
         *          for cc_count
345
         *              u2 cc_priority
346
         *              u2 cc_field_num
347
         *              u5 cc_line_offset
348
         *              u8 cc_data_1[1:8]
349
         *              u8 cc_data_2[1:8]
350
         *              u1 marker bit
351
         *          un additional_realtimevideodata
352
         *          un reserved
353
         */
354
30.7k
        if(i_src < 2)
355
0
            return;
356
30.7k
        bs_t s;
357
30.7k
        bs_init( &s, &p_src[2], i_src - 2 );
358
30.7k
        const int i_cc_count = bs_read( &s, 5 );
359
738k
        for( int i = 0; i < i_cc_count; i++ )
360
707k
        {
361
707k
            bs_skip( &s, 2 );
362
707k
            const int i_field_idx = bs_read( &s, 2 );
363
707k
            bs_skip( &s, 5 );
364
707k
            uint8_t cc[2];
365
2.12M
            for( int j = 0; j < 2; j++ )
366
1.41M
            {
367
1.41M
                cc[j] = 0;
368
12.7M
                for( int k = 0; k < 8; k++ )
369
11.3M
                    cc[j] |= bs_read( &s, 1 ) << k;
370
1.41M
            }
371
707k
            bs_skip( &s, 1 );
372
373
707k
            if( i_field_idx == 0 )
374
539k
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
168k
            int i_field = ((i_field_idx - 1) & 1);
378
168k
            if (!b_top_field_first)
379
155k
                i_field ^= 1;
380
381
168k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
10.0k
                continue;
383
168k
        }
384
30.7k
        c->b_reorder = true;
385
30.7k
    }
386
14.3k
    else // CC_PAYLOAD_CDP
387
14.3k
    {
388
14.3k
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
14.3k
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
14.3k
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
14.3k
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
14.3k
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
14.3k
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
14.3k
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
14.3k
        if(i_src < 7)
397
628
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
13.6k
        uint8_t cdp_length = p_src[2];
401
13.6k
        if(cdp_length < 8 || cdp_length > i_src)
402
827
            return;
403
12.8k
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
12.8k
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
12.8k
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
5.30k
        {
411
5.30k
            if( i_src < 5 ) // Shall be 5 bytes
412
251
                return;
413
5.05k
            p_src += 5; i_src -= 5;
414
5.05k
        }
415
        /* 5.4 ccdata_section */
416
12.6k
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
10.4k
        {
418
            /* ccdata_section()
419
             *      u8 0x72
420
             *      u3 marker bits(111)
421
             *      u5 cc_count
422
             *      for cc_count
423
             *          u5 marker bits(1111 1)
424
             *          u1 cc_valid
425
             *          u2 cc_type
426
             *          u8 cc_data_1
427
             *          u8 cc_data_2
428
             */
429
10.4k
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
4.37k
                return;
431
432
6.05k
            const uint8_t *cc = &p_src[1];
433
6.05k
            const int i_count_cc = cc[0]&0x1f;
434
435
6.05k
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
714
                return;
437
5.34k
            cc += 1;
438
70.1k
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
65.9k
            {
440
65.9k
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
1.18k
                    break;
442
65.9k
            }
443
5.34k
        }
444
        /* remaining data */
445
7.51k
        c->b_reorder = false;
446
7.51k
    }
447
59.6k
}
vc1.c:cc_Extract
Line
Count
Source
222
795
{
223
795
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
0
    {
225
0
        c->i_payload_other_count++;
226
0
        if( c->i_payload_other_count < 50 )
227
0
            return;
228
0
    }
229
795
    c->i_payload_type        = i_payload_type;
230
795
    c->i_payload_other_count = 0;
231
232
795
    if( i_payload_type == CC_PAYLOAD_RAW )
233
0
    {
234
0
        for( int i = 0; i + 2 < i_src; i += 3 )
235
0
        {
236
0
            const uint8_t *cc = &p_src[i];
237
0
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
0
                break;
239
0
        }
240
0
        c->b_reorder = true;
241
0
    }
242
795
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
795
    {
244
        /* cc_data()
245
         *          u1 reserved(1)
246
         *          u1 process_cc_data_flag
247
         *          u1 additional_data_flag
248
         *          u5 cc_count
249
         *          u8 reserved(1111 1111)
250
         *          for cc_count
251
         *              u5 marker bit(1111 1)
252
         *              u1 cc_valid
253
         *              u2 cc_type
254
         *              u8 cc_data_1
255
         *              u8 cc_data_2
256
         *          u8 marker bit(1111 1111)
257
         *          if additional_data_flag
258
         *              unknown
259
         */
260
        /* cc_type:
261
         *  0x00: field 1
262
         *  0x01: field 2
263
         */
264
795
        if(i_src < 1)
265
0
            return;
266
795
        const uint8_t *cc = &p_src[0];
267
795
        const int i_count_cc = cc[0]&0x1f;
268
795
        int i;
269
270
795
        if( !(cc[0]&0x40) ) // process flag
271
36
            return;
272
759
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
201
            return;
274
558
        if( i_count_cc <= 0 )   // no cc present
275
0
            return;
276
558
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
135
            return;
278
423
        cc += 2;
279
280
7.23k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
6.97k
        {
282
6.97k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
161
                break;
284
6.97k
        }
285
423
        c->b_reorder = true;
286
423
    }
287
0
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
0
    {
289
        /* user_data
290
         *          (u32 stripped earlier)
291
         *          u32 (0x43 0x43 0x01 0xf8)
292
         *          u1 caption_odd_field_first (CC1/CC2)
293
         *          u1 caption_filler
294
         *          u5 cc_block_count  (== cc_count / 2)
295
         *          u1 caption_extra_field_added (because odd cc_count)
296
         *          for cc_block_count * 2 + caption_extra_field_added
297
         *              u7 cc_filler_1
298
         *              u1 cc_field_is_odd
299
         *              u8 cc_data_1
300
         *              u8 cc_data_2
301
         */
302
0
        if(i_src < 6)
303
0
            return;
304
0
        const int b_truncate = p_src[4] & 0x01;
305
0
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
0
        const uint8_t *cc = &p_src[5];
307
0
        i_src -= 5;
308
0
        int i;
309
310
0
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
0
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
0
        {
314
0
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
0
            {
316
0
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
0
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
0
                    break;
319
0
            }
320
0
            i_src -= 3;
321
0
        }
322
0
        c->b_reorder = false;
323
0
    }
324
0
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
0
    {
326
0
        if(i_src < 1)
327
0
            return;
328
0
        const uint8_t *cc = &p_src[0];
329
0
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
0
             i_cc_count--, cc += 4 )
331
0
        {
332
0
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
0
                return;
335
0
        }
336
0
        c->b_reorder = false;
337
0
    }
338
0
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
0
    {
340
        /* user_data(2)
341
         *          (u32 stripped earlier)
342
         *          u16 p_cc_scte20
343
         *          u5 cc_count
344
         *          for cc_count
345
         *              u2 cc_priority
346
         *              u2 cc_field_num
347
         *              u5 cc_line_offset
348
         *              u8 cc_data_1[1:8]
349
         *              u8 cc_data_2[1:8]
350
         *              u1 marker bit
351
         *          un additional_realtimevideodata
352
         *          un reserved
353
         */
354
0
        if(i_src < 2)
355
0
            return;
356
0
        bs_t s;
357
0
        bs_init( &s, &p_src[2], i_src - 2 );
358
0
        const int i_cc_count = bs_read( &s, 5 );
359
0
        for( int i = 0; i < i_cc_count; i++ )
360
0
        {
361
0
            bs_skip( &s, 2 );
362
0
            const int i_field_idx = bs_read( &s, 2 );
363
0
            bs_skip( &s, 5 );
364
0
            uint8_t cc[2];
365
0
            for( int j = 0; j < 2; j++ )
366
0
            {
367
0
                cc[j] = 0;
368
0
                for( int k = 0; k < 8; k++ )
369
0
                    cc[j] |= bs_read( &s, 1 ) << k;
370
0
            }
371
0
            bs_skip( &s, 1 );
372
373
0
            if( i_field_idx == 0 )
374
0
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
0
            int i_field = ((i_field_idx - 1) & 1);
378
0
            if (!b_top_field_first)
379
0
                i_field ^= 1;
380
381
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
0
                continue;
383
0
        }
384
0
        c->b_reorder = true;
385
0
    }
386
0
    else // CC_PAYLOAD_CDP
387
0
    {
388
0
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
0
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
0
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
0
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
0
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
0
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
0
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
0
        if(i_src < 7)
397
0
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
0
        uint8_t cdp_length = p_src[2];
401
0
        if(cdp_length < 8 || cdp_length > i_src)
402
0
            return;
403
0
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
0
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
0
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
0
        {
411
0
            if( i_src < 5 ) // Shall be 5 bytes
412
0
                return;
413
0
            p_src += 5; i_src -= 5;
414
0
        }
415
        /* 5.4 ccdata_section */
416
0
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
0
        {
418
            /* ccdata_section()
419
             *      u8 0x72
420
             *      u3 marker bits(111)
421
             *      u5 cc_count
422
             *      for cc_count
423
             *          u5 marker bits(1111 1)
424
             *          u1 cc_valid
425
             *          u2 cc_type
426
             *          u8 cc_data_1
427
             *          u8 cc_data_2
428
             */
429
0
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
0
                return;
431
432
0
            const uint8_t *cc = &p_src[1];
433
0
            const int i_count_cc = cc[0]&0x1f;
434
435
0
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
0
                return;
437
0
            cc += 1;
438
0
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
0
            {
440
0
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
0
                    break;
442
0
            }
443
0
        }
444
        /* remaining data */
445
0
        c->b_reorder = false;
446
0
    }
447
795
}
Unexecuted instantiation: dav1d.c:cc_Extract
video.c:cc_Extract
Line
Count
Source
222
4.83k
{
223
4.83k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
0
    {
225
0
        c->i_payload_other_count++;
226
0
        if( c->i_payload_other_count < 50 )
227
0
            return;
228
0
    }
229
4.83k
    c->i_payload_type        = i_payload_type;
230
4.83k
    c->i_payload_other_count = 0;
231
232
4.83k
    if( i_payload_type == CC_PAYLOAD_RAW )
233
4.83k
    {
234
350k
        for( int i = 0; i + 2 < i_src; i += 3 )
235
345k
        {
236
345k
            const uint8_t *cc = &p_src[i];
237
345k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
109
                break;
239
345k
        }
240
4.83k
        c->b_reorder = true;
241
4.83k
    }
242
0
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
0
    {
244
        /* cc_data()
245
         *          u1 reserved(1)
246
         *          u1 process_cc_data_flag
247
         *          u1 additional_data_flag
248
         *          u5 cc_count
249
         *          u8 reserved(1111 1111)
250
         *          for cc_count
251
         *              u5 marker bit(1111 1)
252
         *              u1 cc_valid
253
         *              u2 cc_type
254
         *              u8 cc_data_1
255
         *              u8 cc_data_2
256
         *          u8 marker bit(1111 1111)
257
         *          if additional_data_flag
258
         *              unknown
259
         */
260
        /* cc_type:
261
         *  0x00: field 1
262
         *  0x01: field 2
263
         */
264
0
        if(i_src < 1)
265
0
            return;
266
0
        const uint8_t *cc = &p_src[0];
267
0
        const int i_count_cc = cc[0]&0x1f;
268
0
        int i;
269
270
0
        if( !(cc[0]&0x40) ) // process flag
271
0
            return;
272
0
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
0
            return;
274
0
        if( i_count_cc <= 0 )   // no cc present
275
0
            return;
276
0
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
0
            return;
278
0
        cc += 2;
279
280
0
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
0
        {
282
0
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
0
                break;
284
0
        }
285
0
        c->b_reorder = true;
286
0
    }
287
0
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
0
    {
289
        /* user_data
290
         *          (u32 stripped earlier)
291
         *          u32 (0x43 0x43 0x01 0xf8)
292
         *          u1 caption_odd_field_first (CC1/CC2)
293
         *          u1 caption_filler
294
         *          u5 cc_block_count  (== cc_count / 2)
295
         *          u1 caption_extra_field_added (because odd cc_count)
296
         *          for cc_block_count * 2 + caption_extra_field_added
297
         *              u7 cc_filler_1
298
         *              u1 cc_field_is_odd
299
         *              u8 cc_data_1
300
         *              u8 cc_data_2
301
         */
302
0
        if(i_src < 6)
303
0
            return;
304
0
        const int b_truncate = p_src[4] & 0x01;
305
0
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
0
        const uint8_t *cc = &p_src[5];
307
0
        i_src -= 5;
308
0
        int i;
309
310
0
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
0
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
0
        {
314
0
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
0
            {
316
0
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
0
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
0
                    break;
319
0
            }
320
0
            i_src -= 3;
321
0
        }
322
0
        c->b_reorder = false;
323
0
    }
324
0
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
0
    {
326
0
        if(i_src < 1)
327
0
            return;
328
0
        const uint8_t *cc = &p_src[0];
329
0
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
0
             i_cc_count--, cc += 4 )
331
0
        {
332
0
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
0
                return;
335
0
        }
336
0
        c->b_reorder = false;
337
0
    }
338
0
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
0
    {
340
        /* user_data(2)
341
         *          (u32 stripped earlier)
342
         *          u16 p_cc_scte20
343
         *          u5 cc_count
344
         *          for cc_count
345
         *              u2 cc_priority
346
         *              u2 cc_field_num
347
         *              u5 cc_line_offset
348
         *              u8 cc_data_1[1:8]
349
         *              u8 cc_data_2[1:8]
350
         *              u1 marker bit
351
         *          un additional_realtimevideodata
352
         *          un reserved
353
         */
354
0
        if(i_src < 2)
355
0
            return;
356
0
        bs_t s;
357
0
        bs_init( &s, &p_src[2], i_src - 2 );
358
0
        const int i_cc_count = bs_read( &s, 5 );
359
0
        for( int i = 0; i < i_cc_count; i++ )
360
0
        {
361
0
            bs_skip( &s, 2 );
362
0
            const int i_field_idx = bs_read( &s, 2 );
363
0
            bs_skip( &s, 5 );
364
0
            uint8_t cc[2];
365
0
            for( int j = 0; j < 2; j++ )
366
0
            {
367
0
                cc[j] = 0;
368
0
                for( int k = 0; k < 8; k++ )
369
0
                    cc[j] |= bs_read( &s, 1 ) << k;
370
0
            }
371
0
            bs_skip( &s, 1 );
372
373
0
            if( i_field_idx == 0 )
374
0
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
0
            int i_field = ((i_field_idx - 1) & 1);
378
0
            if (!b_top_field_first)
379
0
                i_field ^= 1;
380
381
0
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
0
                continue;
383
0
        }
384
0
        c->b_reorder = true;
385
0
    }
386
0
    else // CC_PAYLOAD_CDP
387
0
    {
388
0
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
0
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
0
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
0
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
0
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
0
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
0
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
0
        if(i_src < 7)
397
0
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
0
        uint8_t cdp_length = p_src[2];
401
0
        if(cdp_length < 8 || cdp_length > i_src)
402
0
            return;
403
0
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
0
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
0
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
0
        {
411
0
            if( i_src < 5 ) // Shall be 5 bytes
412
0
                return;
413
0
            p_src += 5; i_src -= 5;
414
0
        }
415
        /* 5.4 ccdata_section */
416
0
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
0
        {
418
            /* ccdata_section()
419
             *      u8 0x72
420
             *      u3 marker bits(111)
421
             *      u5 cc_count
422
             *      for cc_count
423
             *          u5 marker bits(1111 1)
424
             *          u1 cc_valid
425
             *          u2 cc_type
426
             *          u8 cc_data_1
427
             *          u8 cc_data_2
428
             */
429
0
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
0
                return;
431
432
0
            const uint8_t *cc = &p_src[1];
433
0
            const int i_count_cc = cc[0]&0x1f;
434
435
0
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
0
                return;
437
0
            cc += 1;
438
0
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
0
            {
440
0
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
0
                    break;
442
0
            }
443
0
        }
444
        /* remaining data */
445
0
        c->b_reorder = false;
446
0
    }
447
4.83k
}
448
449
450
static inline void cc_ProbeAndExtract( cc_data_t *c, bool b_top_field_first, const uint8_t *p_src, int i_src )
451
109k
{
452
109k
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
109k
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
109k
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
109k
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
109k
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
109k
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
109k
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
109k
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
109k
    if( i_src < 4 )
462
0
        return;
463
464
109k
    enum cc_payload_type_e i_payload_type;
465
109k
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
9.83k
    {
467
        /* CC from DVB/ATSC TS */
468
9.83k
        i_payload_type = CC_PAYLOAD_GA94;
469
9.83k
        i_src -= 5;
470
9.83k
        p_src += 5;
471
9.83k
    }
472
100k
    else if( !memcmp( p_cc_dvd, p_src, 4 ) && i_src > 4+1 )
473
4.64k
    {
474
4.64k
        i_payload_type = CC_PAYLOAD_DVD;
475
4.64k
    }
476
95.3k
    else if( i_src >= 2+2 + 2+2 &&
477
84.1k
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
83.3k
               ( !memcmp( p_cc_replaytv5a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv5b, &p_src[4], 2 ) ) ) )
479
1.70k
    {
480
1.70k
        i_payload_type = CC_PAYLOAD_REPLAYTV;
481
1.70k
    }
482
93.6k
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
86.7k
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
36.6k
    {
485
36.6k
        i_payload_type = CC_PAYLOAD_SCTE20;
486
36.6k
    }
487
56.9k
    else if (p_src[0] == 0x03 && p_src[1] == i_src - 2) /* DIRECTV */
488
3.75k
    {
489
3.75k
        i_payload_type = CC_PAYLOAD_GA94;
490
3.75k
        i_src -= 2;
491
3.75k
        p_src += 2;
492
3.75k
    }
493
53.2k
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
16.7k
    {
495
16.7k
        i_payload_type = CC_PAYLOAD_CDP;
496
16.7k
    }
497
36.4k
    else
498
36.4k
    {
499
#if 0
500
#define V(x) ( ( x < 0x20 || x >= 0x7f ) ? '?' : x )
501
        fprintf( stderr, "-------------- unknown user data " );
502
        for( int i = 0; i < i_src; i++ )
503
            fprintf( stderr, "%2.2x ", p_src[i] );
504
        for( int i = 0; i < i_src; i++ )
505
            fprintf( stderr, "%c ", V(p_src[i]) );
506
        fprintf( stderr, "\n" );
507
#undef V
508
#endif
509
36.4k
        return;
510
36.4k
    }
511
512
73.4k
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
73.4k
}
Unexecuted instantiation: mp4.c:cc_ProbeAndExtract
Unexecuted instantiation: ty.c:cc_ProbeAndExtract
Unexecuted instantiation: hxxx_common.c:cc_ProbeAndExtract
mpegvideo.c:cc_ProbeAndExtract
Line
Count
Source
451
108k
{
452
108k
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
108k
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
108k
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
108k
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
108k
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
108k
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
108k
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
108k
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
108k
    if( i_src < 4 )
462
0
        return;
463
464
108k
    enum cc_payload_type_e i_payload_type;
465
108k
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
9.03k
    {
467
        /* CC from DVB/ATSC TS */
468
9.03k
        i_payload_type = CC_PAYLOAD_GA94;
469
9.03k
        i_src -= 5;
470
9.03k
        p_src += 5;
471
9.03k
    }
472
99.8k
    else if( !memcmp( p_cc_dvd, p_src, 4 ) && i_src > 4+1 )
473
4.64k
    {
474
4.64k
        i_payload_type = CC_PAYLOAD_DVD;
475
4.64k
    }
476
95.1k
    else if( i_src >= 2+2 + 2+2 &&
477
84.0k
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
83.3k
               ( !memcmp( p_cc_replaytv5a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv5b, &p_src[4], 2 ) ) ) )
479
1.70k
    {
480
1.70k
        i_payload_type = CC_PAYLOAD_REPLAYTV;
481
1.70k
    }
482
93.4k
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
86.5k
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
36.6k
    {
485
36.6k
        i_payload_type = CC_PAYLOAD_SCTE20;
486
36.6k
    }
487
56.7k
    else if (p_src[0] == 0x03 && p_src[1] == i_src - 2) /* DIRECTV */
488
3.75k
    {
489
3.75k
        i_payload_type = CC_PAYLOAD_GA94;
490
3.75k
        i_src -= 2;
491
3.75k
        p_src += 2;
492
3.75k
    }
493
53.0k
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
16.7k
    {
495
16.7k
        i_payload_type = CC_PAYLOAD_CDP;
496
16.7k
    }
497
36.2k
    else
498
36.2k
    {
499
#if 0
500
#define V(x) ( ( x < 0x20 || x >= 0x7f ) ? '?' : x )
501
        fprintf( stderr, "-------------- unknown user data " );
502
        for( int i = 0; i < i_src; i++ )
503
            fprintf( stderr, "%2.2x ", p_src[i] );
504
        for( int i = 0; i < i_src; i++ )
505
            fprintf( stderr, "%c ", V(p_src[i]) );
506
        fprintf( stderr, "\n" );
507
#undef V
508
#endif
509
36.2k
        return;
510
36.2k
    }
511
512
72.6k
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
72.6k
}
vc1.c:cc_ProbeAndExtract
Line
Count
Source
451
971
{
452
971
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
971
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
971
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
971
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
971
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
971
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
971
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
971
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
971
    if( i_src < 4 )
462
0
        return;
463
464
971
    enum cc_payload_type_e i_payload_type;
465
971
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
795
    {
467
        /* CC from DVB/ATSC TS */
468
795
        i_payload_type = CC_PAYLOAD_GA94;
469
795
        i_src -= 5;
470
795
        p_src += 5;
471
795
    }
472
176
    else if( !memcmp( p_cc_dvd, p_src, 4 ) && i_src > 4+1 )
473
0
    {
474
0
        i_payload_type = CC_PAYLOAD_DVD;
475
0
    }
476
176
    else if( i_src >= 2+2 + 2+2 &&
477
35
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
35
               ( !memcmp( p_cc_replaytv5a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv5b, &p_src[4], 2 ) ) ) )
479
0
    {
480
0
        i_payload_type = CC_PAYLOAD_REPLAYTV;
481
0
    }
482
176
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
176
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
0
    {
485
0
        i_payload_type = CC_PAYLOAD_SCTE20;
486
0
    }
487
176
    else if (p_src[0] == 0x03 && p_src[1] == i_src - 2) /* DIRECTV */
488
0
    {
489
0
        i_payload_type = CC_PAYLOAD_GA94;
490
0
        i_src -= 2;
491
0
        p_src += 2;
492
0
    }
493
176
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
0
    {
495
0
        i_payload_type = CC_PAYLOAD_CDP;
496
0
    }
497
176
    else
498
176
    {
499
#if 0
500
#define V(x) ( ( x < 0x20 || x >= 0x7f ) ? '?' : x )
501
        fprintf( stderr, "-------------- unknown user data " );
502
        for( int i = 0; i < i_src; i++ )
503
            fprintf( stderr, "%2.2x ", p_src[i] );
504
        for( int i = 0; i < i_src; i++ )
505
            fprintf( stderr, "%c ", V(p_src[i]) );
506
        fprintf( stderr, "\n" );
507
#undef V
508
#endif
509
176
        return;
510
176
    }
511
512
795
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
795
}
Unexecuted instantiation: dav1d.c:cc_ProbeAndExtract
Unexecuted instantiation: video.c:cc_ProbeAndExtract
514
515
#endif /* _CC_H */
516