Coverage Report

Created: 2026-05-21 08:06

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
251k
#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
421k
{
79
421k
    c->i_608channels = 0;
80
421k
    c->i_708channels = 0;
81
421k
    c->i_data = 0;
82
421k
    c->b_reorder = false;
83
421k
    c->cea708.pktsize = 0;
84
421k
    c->cea708.seq = 0;
85
421k
    c->cea708.sid_bs = 0;
86
421k
    c->cea708.state = CEA708_PKT_END;
87
421k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
421k
    c->i_payload_other_count = 0;
89
421k
}
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
169k
{
79
169k
    c->i_608channels = 0;
80
169k
    c->i_708channels = 0;
81
169k
    c->i_data = 0;
82
    c->b_reorder = false;
83
169k
    c->cea708.pktsize = 0;
84
169k
    c->cea708.seq = 0;
85
169k
    c->cea708.sid_bs = 0;
86
169k
    c->cea708.state = CEA708_PKT_END;
87
169k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
169k
    c->i_payload_other_count = 0;
89
169k
}
mpegvideo.c:cc_Init
Line
Count
Source
78
45.3k
{
79
45.3k
    c->i_608channels = 0;
80
45.3k
    c->i_708channels = 0;
81
45.3k
    c->i_data = 0;
82
    c->b_reorder = false;
83
45.3k
    c->cea708.pktsize = 0;
84
45.3k
    c->cea708.seq = 0;
85
45.3k
    c->cea708.sid_bs = 0;
86
45.3k
    c->cea708.state = CEA708_PKT_END;
87
45.3k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
45.3k
    c->i_payload_other_count = 0;
89
45.3k
}
vc1.c:cc_Init
Line
Count
Source
78
232
{
79
232
    c->i_608channels = 0;
80
232
    c->i_708channels = 0;
81
232
    c->i_data = 0;
82
    c->b_reorder = false;
83
232
    c->cea708.pktsize = 0;
84
232
    c->cea708.seq = 0;
85
232
    c->cea708.sid_bs = 0;
86
232
    c->cea708.state = CEA708_PKT_END;
87
232
    c->i_payload_type = CC_PAYLOAD_NONE;
88
232
    c->i_payload_other_count = 0;
89
232
}
dav1d.c:cc_Init
Line
Count
Source
78
3.89k
{
79
3.89k
    c->i_608channels = 0;
80
3.89k
    c->i_708channels = 0;
81
3.89k
    c->i_data = 0;
82
    c->b_reorder = false;
83
3.89k
    c->cea708.pktsize = 0;
84
3.89k
    c->cea708.seq = 0;
85
3.89k
    c->cea708.sid_bs = 0;
86
3.89k
    c->cea708.state = CEA708_PKT_END;
87
3.89k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
3.89k
    c->i_payload_other_count = 0;
89
3.89k
}
video.c:cc_Init
Line
Count
Source
78
201k
{
79
201k
    c->i_608channels = 0;
80
201k
    c->i_708channels = 0;
81
201k
    c->i_data = 0;
82
    c->b_reorder = false;
83
201k
    c->cea708.pktsize = 0;
84
201k
    c->cea708.seq = 0;
85
201k
    c->cea708.sid_bs = 0;
86
201k
    c->cea708.state = CEA708_PKT_END;
87
201k
    c->i_payload_type = CC_PAYLOAD_NONE;
88
201k
    c->i_payload_other_count = 0;
89
201k
}
90
static inline void cc_Exit( cc_data_t *c )
91
170k
{
92
170k
    VLC_UNUSED(c);
93
170k
    return;
94
170k
}
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
169k
{
92
169k
    VLC_UNUSED(c);
93
169k
    return;
94
169k
}
Unexecuted instantiation: mpegvideo.c:cc_Exit
vc1.c:cc_Exit
Line
Count
Source
91
232
{
92
232
    VLC_UNUSED(c);
93
232
    return;
94
232
}
Unexecuted instantiation: dav1d.c:cc_Exit
Unexecuted instantiation: video.c:cc_Exit
95
static inline void cc_Flush( cc_data_t *c )
96
4.13M
{
97
4.13M
    c->i_data = 0;
98
4.13M
    c->cea708.state = CEA708_PKT_END;
99
4.13M
}
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.67M
{
97
3.67M
    c->i_data = 0;
98
3.67M
    c->cea708.state = CEA708_PKT_END;
99
3.67M
}
mpegvideo.c:cc_Flush
Line
Count
Source
96
177k
{
97
177k
    c->i_data = 0;
98
177k
    c->cea708.state = CEA708_PKT_END;
99
177k
}
vc1.c:cc_Flush
Line
Count
Source
96
27.7k
{
97
27.7k
    c->i_data = 0;
98
27.7k
    c->cea708.state = CEA708_PKT_END;
99
27.7k
}
dav1d.c:cc_Flush
Line
Count
Source
96
3.89k
{
97
3.89k
    c->i_data = 0;
98
3.89k
    c->cea708.state = CEA708_PKT_END;
99
3.89k
}
video.c:cc_Flush
Line
Count
Source
96
254k
{
97
254k
    c->i_data = 0;
98
254k
    c->cea708.state = CEA708_PKT_END;
99
254k
}
100
101
static inline void cc_ProbeCEA708OneByte( cc_data_t *c, bool b_start, const uint8_t cc )
102
545k
{
103
545k
    if( b_start )
104
121k
    {
105
121k
        const uint8_t i_pkt_sequence = cc >> 6;
106
121k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
47.6k
        {
108
47.6k
            c->cea708.pktsize = 0;
109
47.6k
            c->cea708.seq = i_pkt_sequence;
110
47.6k
            c->cea708.state = CEA708_PKT_END;
111
47.6k
        }
112
74.3k
        else
113
74.3k
        {
114
74.3k
            c->cea708.seq = i_pkt_sequence;
115
74.3k
            c->cea708.pktsize = cc & 63;
116
74.3k
            if( c->cea708.pktsize == 0 )
117
13.9k
                c->cea708.pktsize = 127;
118
60.3k
            else
119
60.3k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
74.3k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
74.3k
        }
122
121k
    }
123
423k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
85.4k
    {
125
85.4k
        c->cea708.state = CEA708_PKT_END;
126
85.4k
    }
127
337k
    else if( c->cea708.state != CEA708_PKT_END )
128
280k
    {
129
280k
        switch( c->cea708.state )
130
280k
        {
131
112k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
112k
            {
133
112k
                uint8_t i_sid = cc >> 5;
134
112k
                c->cea708.sid_bs = cc & 0x1F;
135
112k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
81.5k
                {
137
81.5k
                    if( i_sid != 0x07 )
138
64.6k
                    {
139
64.6k
                        const uint8_t mask = (1 << --i_sid);
140
64.6k
                        c->i_708channels |= (mask + (mask - 1));
141
64.6k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
64.6k
                    }
143
16.8k
                    else if( c->cea708.sid_bs < 2 )
144
2.75k
                    {
145
2.75k
                        c->cea708.state = CEA708_PKT_END;
146
2.75k
                    }
147
14.1k
                    else
148
14.1k
                    {
149
                        /* need to look up next byte in next pkt */
150
14.1k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
14.1k
                    }
152
81.5k
                }
153
30.7k
                else c->cea708.state = CEA708_PKT_END;
154
112k
            } break;
155
156
9.68k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
9.68k
            {
158
9.68k
                uint8_t i_extsid = cc & 0x3F;
159
9.68k
                if( i_extsid >= 0x07 )
160
4.79k
                {
161
4.79k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
4.79k
                    c->i_708channels |= (mask + (mask - 1));
163
4.79k
                }
164
9.68k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
9.68k
                else
167
9.68k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
9.68k
            } break;
169
170
157k
            case CEA708_PKT_IN_BLOCK:
171
157k
            {
172
157k
                c->cea708.sid_bs--;
173
157k
                if( c->cea708.sid_bs == 0 )
174
41.5k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
157k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
280k
        }
181
280k
        c->cea708.pktsize--;
182
183
280k
        if(c->cea708.pktsize == 0)
184
7.36k
            c->cea708.state = CEA708_PKT_END;
185
280k
    }
186
545k
}
Unexecuted instantiation: mp4.c:cc_ProbeCEA708OneByte
Unexecuted instantiation: ty.c:cc_ProbeCEA708OneByte
hxxx_common.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
206k
{
103
206k
    if( b_start )
104
51.7k
    {
105
51.7k
        const uint8_t i_pkt_sequence = cc >> 6;
106
51.7k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
17.9k
        {
108
17.9k
            c->cea708.pktsize = 0;
109
17.9k
            c->cea708.seq = i_pkt_sequence;
110
17.9k
            c->cea708.state = CEA708_PKT_END;
111
17.9k
        }
112
33.7k
        else
113
33.7k
        {
114
33.7k
            c->cea708.seq = i_pkt_sequence;
115
33.7k
            c->cea708.pktsize = cc & 63;
116
33.7k
            if( c->cea708.pktsize == 0 )
117
4.92k
                c->cea708.pktsize = 127;
118
28.8k
            else
119
28.8k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
33.7k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
33.7k
        }
122
51.7k
    }
123
154k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
30.9k
    {
125
30.9k
        c->cea708.state = CEA708_PKT_END;
126
30.9k
    }
127
123k
    else if( c->cea708.state != CEA708_PKT_END )
128
102k
    {
129
102k
        switch( c->cea708.state )
130
102k
        {
131
44.4k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
44.4k
            {
133
44.4k
                uint8_t i_sid = cc >> 5;
134
44.4k
                c->cea708.sid_bs = cc & 0x1F;
135
44.4k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
32.1k
                {
137
32.1k
                    if( i_sid != 0x07 )
138
25.3k
                    {
139
25.3k
                        const uint8_t mask = (1 << --i_sid);
140
25.3k
                        c->i_708channels |= (mask + (mask - 1));
141
25.3k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
25.3k
                    }
143
6.81k
                    else if( c->cea708.sid_bs < 2 )
144
1.08k
                    {
145
1.08k
                        c->cea708.state = CEA708_PKT_END;
146
1.08k
                    }
147
5.73k
                    else
148
5.73k
                    {
149
                        /* need to look up next byte in next pkt */
150
5.73k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
5.73k
                    }
152
32.1k
                }
153
12.3k
                else c->cea708.state = CEA708_PKT_END;
154
44.4k
            } break;
155
156
3.09k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
3.09k
            {
158
3.09k
                uint8_t i_extsid = cc & 0x3F;
159
3.09k
                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.09k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
3.09k
                else
167
3.09k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
3.09k
            } break;
169
170
54.4k
            case CEA708_PKT_IN_BLOCK:
171
54.4k
            {
172
54.4k
                c->cea708.sid_bs--;
173
54.4k
                if( c->cea708.sid_bs == 0 )
174
12.8k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
54.4k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
102k
        }
181
102k
        c->cea708.pktsize--;
182
183
102k
        if(c->cea708.pktsize == 0)
184
1.62k
            c->cea708.state = CEA708_PKT_END;
185
102k
    }
186
206k
}
mpegvideo.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
203k
{
103
203k
    if( b_start )
104
45.5k
    {
105
45.5k
        const uint8_t i_pkt_sequence = cc >> 6;
106
45.5k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
23.5k
        {
108
23.5k
            c->cea708.pktsize = 0;
109
23.5k
            c->cea708.seq = i_pkt_sequence;
110
23.5k
            c->cea708.state = CEA708_PKT_END;
111
23.5k
        }
112
21.9k
        else
113
21.9k
        {
114
21.9k
            c->cea708.seq = i_pkt_sequence;
115
21.9k
            c->cea708.pktsize = cc & 63;
116
21.9k
            if( c->cea708.pktsize == 0 )
117
4.90k
                c->cea708.pktsize = 127;
118
17.0k
            else
119
17.0k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
21.9k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
21.9k
        }
122
45.5k
    }
123
157k
    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
119k
    else if( c->cea708.state != CEA708_PKT_END )
128
101k
    {
129
101k
        switch( c->cea708.state )
130
101k
        {
131
37.0k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
37.0k
            {
133
37.0k
                uint8_t i_sid = cc >> 5;
134
37.0k
                c->cea708.sid_bs = cc & 0x1F;
135
37.0k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
27.1k
                {
137
27.1k
                    if( i_sid != 0x07 )
138
20.9k
                    {
139
20.9k
                        const uint8_t mask = (1 << --i_sid);
140
20.9k
                        c->i_708channels |= (mask + (mask - 1));
141
20.9k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
20.9k
                    }
143
6.15k
                    else if( c->cea708.sid_bs < 2 )
144
985
                    {
145
985
                        c->cea708.state = CEA708_PKT_END;
146
985
                    }
147
5.17k
                    else
148
5.17k
                    {
149
                        /* need to look up next byte in next pkt */
150
5.17k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
5.17k
                    }
152
27.1k
                }
153
9.98k
                else c->cea708.state = CEA708_PKT_END;
154
37.0k
            } break;
155
156
4.05k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
4.05k
            {
158
4.05k
                uint8_t i_extsid = cc & 0x3F;
159
4.05k
                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
4.05k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
4.05k
                else
167
4.05k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
4.05k
            } break;
169
170
60.7k
            case CEA708_PKT_IN_BLOCK:
171
60.7k
            {
172
60.7k
                c->cea708.sid_bs--;
173
60.7k
                if( c->cea708.sid_bs == 0 )
174
15.4k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
60.7k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
101k
        }
181
101k
        c->cea708.pktsize--;
182
183
101k
        if(c->cea708.pktsize == 0)
184
3.43k
            c->cea708.state = CEA708_PKT_END;
185
101k
    }
186
203k
}
vc1.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
11.5k
{
103
11.5k
    if( b_start )
104
2.61k
    {
105
2.61k
        const uint8_t i_pkt_sequence = cc >> 6;
106
2.61k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
1.53k
        {
108
1.53k
            c->cea708.pktsize = 0;
109
1.53k
            c->cea708.seq = i_pkt_sequence;
110
1.53k
            c->cea708.state = CEA708_PKT_END;
111
1.53k
        }
112
1.07k
        else
113
1.07k
        {
114
1.07k
            c->cea708.seq = i_pkt_sequence;
115
1.07k
            c->cea708.pktsize = cc & 63;
116
1.07k
            if( c->cea708.pktsize == 0 )
117
227
                c->cea708.pktsize = 127;
118
851
            else
119
851
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
1.07k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
1.07k
        }
122
2.61k
    }
123
8.95k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
3.39k
    {
125
3.39k
        c->cea708.state = CEA708_PKT_END;
126
3.39k
    }
127
5.55k
    else if( c->cea708.state != CEA708_PKT_END )
128
1.85k
    {
129
1.85k
        switch( c->cea708.state )
130
1.85k
        {
131
1.20k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
1.20k
            {
133
1.20k
                uint8_t i_sid = cc >> 5;
134
1.20k
                c->cea708.sid_bs = cc & 0x1F;
135
1.20k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
543
                {
137
543
                    if( i_sid != 0x07 )
138
248
                    {
139
248
                        const uint8_t mask = (1 << --i_sid);
140
248
                        c->i_708channels |= (mask + (mask - 1));
141
248
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
248
                    }
143
295
                    else if( c->cea708.sid_bs < 2 )
144
168
                    {
145
168
                        c->cea708.state = CEA708_PKT_END;
146
168
                    }
147
127
                    else
148
127
                    {
149
                        /* need to look up next byte in next pkt */
150
127
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
127
                    }
152
543
                }
153
658
                else c->cea708.state = CEA708_PKT_END;
154
1.20k
            } break;
155
156
44
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
44
            {
158
44
                uint8_t i_extsid = cc & 0x3F;
159
44
                if( i_extsid >= 0x07 )
160
33
                {
161
33
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
33
                    c->i_708channels |= (mask + (mask - 1));
163
33
                }
164
44
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
44
                else
167
44
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
44
            } break;
169
170
606
            case CEA708_PKT_IN_BLOCK:
171
606
            {
172
606
                c->cea708.sid_bs--;
173
606
                if( c->cea708.sid_bs == 0 )
174
123
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
606
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
1.85k
        }
181
1.85k
        c->cea708.pktsize--;
182
183
1.85k
        if(c->cea708.pktsize == 0)
184
46
            c->cea708.state = CEA708_PKT_END;
185
1.85k
    }
186
11.5k
}
Unexecuted instantiation: dav1d.c:cc_ProbeCEA708OneByte
video.c:cc_ProbeCEA708OneByte
Line
Count
Source
102
124k
{
103
124k
    if( b_start )
104
22.1k
    {
105
22.1k
        const uint8_t i_pkt_sequence = cc >> 6;
106
22.1k
        if( i_pkt_sequence > 0 && ((c->cea708.seq + 1) % 4) != i_pkt_sequence )
107
4.63k
        {
108
4.63k
            c->cea708.pktsize = 0;
109
4.63k
            c->cea708.seq = i_pkt_sequence;
110
4.63k
            c->cea708.state = CEA708_PKT_END;
111
4.63k
        }
112
17.4k
        else
113
17.4k
        {
114
17.4k
            c->cea708.seq = i_pkt_sequence;
115
17.4k
            c->cea708.pktsize = cc & 63;
116
17.4k
            if( c->cea708.pktsize == 0 )
117
3.92k
                c->cea708.pktsize = 127;
118
13.5k
            else
119
13.5k
                c->cea708.pktsize = c->cea708.pktsize * 2 - 1;
120
17.4k
            c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
121
17.4k
        }
122
22.1k
    }
123
102k
    else if( c->cea708.pktsize == 0 ) /* empty pkt reading service blocks */
124
13.4k
    {
125
13.4k
        c->cea708.state = CEA708_PKT_END;
126
13.4k
    }
127
88.7k
    else if( c->cea708.state != CEA708_PKT_END )
128
74.2k
    {
129
74.2k
        switch( c->cea708.state )
130
74.2k
        {
131
29.6k
            case CEA708_PKT_WAIT_BLOCK_HEADER: /* Byte is service block header */
132
29.6k
            {
133
29.6k
                uint8_t i_sid = cc >> 5;
134
29.6k
                c->cea708.sid_bs = cc & 0x1F;
135
29.6k
                if( i_sid != 0x00 && c->cea708.sid_bs != 0 )
136
21.7k
                {
137
21.7k
                    if( i_sid != 0x07 )
138
18.1k
                    {
139
18.1k
                        const uint8_t mask = (1 << --i_sid);
140
18.1k
                        c->i_708channels |= (mask + (mask - 1));
141
18.1k
                        c->cea708.state = CEA708_PKT_IN_BLOCK;
142
18.1k
                    }
143
3.60k
                    else if( c->cea708.sid_bs < 2 )
144
515
                    {
145
515
                        c->cea708.state = CEA708_PKT_END;
146
515
                    }
147
3.08k
                    else
148
3.08k
                    {
149
                        /* need to look up next byte in next pkt */
150
3.08k
                        c->cea708.state = CEA708_PKT_WAIT_EXT_BLOCK_HEADER;
151
3.08k
                    }
152
21.7k
                }
153
7.84k
                else c->cea708.state = CEA708_PKT_END;
154
29.6k
            } break;
155
156
2.50k
            case CEA708_PKT_WAIT_EXT_BLOCK_HEADER:
157
2.50k
            {
158
2.50k
                uint8_t i_extsid = cc & 0x3F;
159
2.50k
                if( i_extsid >= 0x07 )
160
1.24k
                {
161
1.24k
                    const uint64_t mask = (INT64_C(1) << --i_extsid);
162
1.24k
                    c->i_708channels |= (mask + (mask - 1));
163
1.24k
                }
164
2.50k
                if( c->cea708.sid_bs == 0 )
165
0
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
166
2.50k
                else
167
2.50k
                    c->cea708.state = CEA708_PKT_IN_BLOCK;
168
2.50k
            } break;
169
170
42.1k
            case CEA708_PKT_IN_BLOCK:
171
42.1k
            {
172
42.1k
                c->cea708.sid_bs--;
173
42.1k
                if( c->cea708.sid_bs == 0 )
174
13.1k
                    c->cea708.state = CEA708_PKT_WAIT_BLOCK_HEADER;
175
42.1k
            } break;
176
177
0
            default:
178
0
                vlc_assert_unreachable();
179
0
                break;
180
74.2k
        }
181
74.2k
        c->cea708.pktsize--;
182
183
74.2k
        if(c->cea708.pktsize == 0)
184
2.25k
            c->cea708.state = CEA708_PKT_END;
185
74.2k
    }
186
124k
}
187
188
static inline void cc_ProbeCEA708( cc_data_t *c, uint8_t i_field, const uint8_t cc[2] )
189
272k
{
190
272k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
121k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
150k
    else /* DTVCC_PACKET_DATA */
193
150k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
272k
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
272k
}
Unexecuted instantiation: mp4.c:cc_ProbeCEA708
Unexecuted instantiation: ty.c:cc_ProbeCEA708
hxxx_common.c:cc_ProbeCEA708
Line
Count
Source
189
103k
{
190
103k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
51.7k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
51.3k
    else /* DTVCC_PACKET_DATA */
193
51.3k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
103k
}
mpegvideo.c:cc_ProbeCEA708
Line
Count
Source
189
101k
{
190
101k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
45.5k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
56.0k
    else /* DTVCC_PACKET_DATA */
193
56.0k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
101k
}
vc1.c:cc_ProbeCEA708
Line
Count
Source
189
5.78k
{
190
5.78k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
2.61k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
3.16k
    else /* DTVCC_PACKET_DATA */
193
3.16k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
5.78k
}
Unexecuted instantiation: dav1d.c:cc_ProbeCEA708
video.c:cc_ProbeCEA708
Line
Count
Source
189
62.1k
{
190
62.1k
    if( i_field == 3 ) /* DTVCC_PACKET_START */
191
22.1k
        cc_ProbeCEA708OneByte( c, true,  cc[0] );
192
40.0k
    else /* DTVCC_PACKET_DATA */
193
40.0k
        cc_ProbeCEA708OneByte( c, false, cc[0] );
194
    cc_ProbeCEA708OneByte( c, false, cc[1] );
195
62.1k
}
196
197
static inline bool cc_AppendData( cc_data_t *c, uint8_t cc_preamble, const uint8_t cc[2] )
198
892k
{
199
892k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
14.9k
        return false;
201
202
877k
    const uint8_t i_field = cc_preamble & 0x03;
203
877k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
605k
    {
205
605k
        c->i_608channels |= (3 << (2 * i_field));
206
605k
    }
207
272k
    else
208
272k
    {
209
272k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
272k
        c->i_708channels |= 1;
212
272k
    }
213
214
877k
    c->p_data[c->i_data++] = cc_preamble;
215
877k
    c->p_data[c->i_data++] = cc[0];
216
877k
    c->p_data[c->i_data++] = cc[1];
217
877k
    return true;
218
892k
}
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
116k
{
199
116k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
442
        return false;
201
202
116k
    const uint8_t i_field = cc_preamble & 0x03;
203
116k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
13.1k
    {
205
13.1k
        c->i_608channels |= (3 << (2 * i_field));
206
13.1k
    }
207
103k
    else
208
103k
    {
209
103k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
103k
        c->i_708channels |= 1;
212
103k
    }
213
214
116k
    c->p_data[c->i_data++] = cc_preamble;
215
116k
    c->p_data[c->i_data++] = cc[0];
216
116k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
116k
}
mpegvideo.c:cc_AppendData
Line
Count
Source
198
365k
{
199
365k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
14.2k
        return false;
201
202
351k
    const uint8_t i_field = cc_preamble & 0x03;
203
351k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
249k
    {
205
249k
        c->i_608channels |= (3 << (2 * i_field));
206
249k
    }
207
101k
    else
208
101k
    {
209
101k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
101k
        c->i_708channels |= 1;
212
101k
    }
213
214
351k
    c->p_data[c->i_data++] = cc_preamble;
215
351k
    c->p_data[c->i_data++] = cc[0];
216
351k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
365k
}
vc1.c:cc_AppendData
Line
Count
Source
198
14.5k
{
199
14.5k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
202
        return false;
201
202
14.3k
    const uint8_t i_field = cc_preamble & 0x03;
203
14.3k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
8.58k
    {
205
8.58k
        c->i_608channels |= (3 << (2 * i_field));
206
8.58k
    }
207
5.78k
    else
208
5.78k
    {
209
5.78k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
5.78k
        c->i_708channels |= 1;
212
5.78k
    }
213
214
14.3k
    c->p_data[c->i_data++] = cc_preamble;
215
14.3k
    c->p_data[c->i_data++] = cc[0];
216
14.3k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
14.5k
}
Unexecuted instantiation: dav1d.c:cc_AppendData
video.c:cc_AppendData
Line
Count
Source
198
352k
{
199
352k
    if (c->i_data + 3 > ARRAY_SIZE(c->p_data))
200
109
        return false;
201
202
352k
    const uint8_t i_field = cc_preamble & 0x03;
203
352k
    if( i_field == 0 || i_field == 1 ) /* NTSC_CC_FIELD_1 NTSC_CC_FIELD_2 */
204
290k
    {
205
290k
        c->i_608channels |= (3 << (2 * i_field));
206
290k
    }
207
62.1k
    else
208
62.1k
    {
209
62.1k
        cc_ProbeCEA708( c, i_field, cc );
210
        /* By default enable at least channel 1 */
211
62.1k
        c->i_708channels |= 1;
212
62.1k
    }
213
214
352k
    c->p_data[c->i_data++] = cc_preamble;
215
352k
    c->p_data[c->i_data++] = cc[0];
216
352k
    c->p_data[c->i_data++] = cc[1];
217
    return true;
218
352k
}
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
135k
{
223
135k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
13.3k
    {
225
13.3k
        c->i_payload_other_count++;
226
13.3k
        if( c->i_payload_other_count < 50 )
227
13.1k
            return;
228
13.3k
    }
229
122k
    c->i_payload_type        = i_payload_type;
230
122k
    c->i_payload_other_count = 0;
231
232
122k
    if( i_payload_type == CC_PAYLOAD_RAW )
233
4.83k
    {
234
357k
        for( int i = 0; i + 2 < i_src; i += 3 )
235
352k
        {
236
352k
            const uint8_t *cc = &p_src[i];
237
352k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
109
                break;
239
352k
        }
240
4.83k
        c->b_reorder = true;
241
4.83k
    }
242
117k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
64.9k
    {
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
64.9k
        if(i_src < 1)
265
314
            return;
266
64.6k
        const uint8_t *cc = &p_src[0];
267
64.6k
        const int i_count_cc = cc[0]&0x1f;
268
64.6k
        int i;
269
270
64.6k
        if( !(cc[0]&0x40) ) // process flag
271
3.06k
            return;
272
61.5k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
5.20k
            return;
274
56.3k
        if( i_count_cc <= 0 )   // no cc present
275
762
            return;
276
55.6k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
9.10k
            return;
278
46.5k
        cc += 2;
279
280
267k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
221k
        {
282
221k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
1.07k
                break;
284
221k
        }
285
46.5k
        c->b_reorder = true;
286
46.5k
    }
287
52.4k
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
3.84k
    {
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
3.84k
        if(i_src < 6)
303
0
            return;
304
3.84k
        const int b_truncate = p_src[4] & 0x01;
305
3.84k
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
3.84k
        const uint8_t *cc = &p_src[5];
307
3.84k
        i_src -= 5;
308
3.84k
        int i;
309
310
40.5k
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
44.1k
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
40.5k
        {
314
40.5k
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
14.1k
            {
316
14.1k
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
14.1k
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
208
                    break;
319
14.1k
            }
320
40.3k
            i_src -= 3;
321
40.3k
        }
322
3.84k
        c->b_reorder = false;
323
3.84k
    }
324
48.6k
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
1.42k
    {
326
1.42k
        if(i_src < 1)
327
0
            return;
328
1.42k
        const uint8_t *cc = &p_src[0];
329
19.6k
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
18.2k
             i_cc_count--, cc += 4 )
331
18.4k
        {
332
18.4k
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
18.4k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
249
                return;
335
18.4k
        }
336
1.17k
        c->b_reorder = false;
337
1.17k
    }
338
47.2k
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
32.4k
    {
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
32.4k
        if(i_src < 2)
355
0
            return;
356
32.4k
        bs_t s;
357
32.4k
        bs_init( &s, &p_src[2], i_src - 2 );
358
32.4k
        const int i_cc_count = bs_read( &s, 5 );
359
770k
        for( int i = 0; i < i_cc_count; i++ )
360
737k
        {
361
737k
            bs_skip( &s, 2 );
362
737k
            const int i_field_idx = bs_read( &s, 2 );
363
737k
            bs_skip( &s, 5 );
364
737k
            uint8_t cc[2];
365
2.21M
            for( int j = 0; j < 2; j++ )
366
1.47M
            {
367
1.47M
                cc[j] = 0;
368
13.2M
                for( int k = 0; k < 8; k++ )
369
11.8M
                    cc[j] |= bs_read( &s, 1 ) << k;
370
1.47M
            }
371
737k
            bs_skip( &s, 1 );
372
373
737k
            if( i_field_idx == 0 )
374
561k
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
175k
            int i_field = ((i_field_idx - 1) & 1);
378
175k
            if (!b_top_field_first)
379
161k
                i_field ^= 1;
380
381
175k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
12.1k
                continue;
383
175k
        }
384
32.4k
        c->b_reorder = true;
385
32.4k
    }
386
14.7k
    else // CC_PAYLOAD_CDP
387
14.7k
    {
388
14.7k
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
14.7k
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
14.7k
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
14.7k
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
14.7k
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
14.7k
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
14.7k
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
14.7k
        if(i_src < 7)
397
909
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
13.8k
        uint8_t cdp_length = p_src[2];
401
13.8k
        if(cdp_length < 8 || cdp_length > i_src)
402
828
            return;
403
12.9k
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
12.9k
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
12.9k
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
5.32k
        {
411
5.32k
            if( i_src < 5 ) // Shall be 5 bytes
412
252
                return;
413
5.07k
            p_src += 5; i_src -= 5;
414
5.07k
        }
415
        /* 5.4 ccdata_section */
416
12.7k
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
10.5k
        {
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.5k
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
4.44k
                return;
431
432
6.09k
            const uint8_t *cc = &p_src[1];
433
6.09k
            const int i_count_cc = cc[0]&0x1f;
434
435
6.09k
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
714
                return;
437
5.38k
            cc += 1;
438
70.7k
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
66.5k
            {
440
66.5k
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
1.18k
                    break;
442
66.5k
            }
443
5.38k
        }
444
        /* remaining data */
445
7.57k
        c->b_reorder = false;
446
7.57k
    }
447
122k
}
Unexecuted instantiation: mp4.c:cc_Extract
Unexecuted instantiation: ty.c:cc_Extract
hxxx_common.c:cc_Extract
Line
Count
Source
222
52.7k
{
223
52.7k
    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
52.7k
    c->i_payload_type        = i_payload_type;
230
52.7k
    c->i_payload_other_count = 0;
231
232
52.7k
    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
52.7k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
52.7k
    {
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
52.7k
        if(i_src < 1)
265
314
            return;
266
52.4k
        const uint8_t *cc = &p_src[0];
267
52.4k
        const int i_count_cc = cc[0]&0x1f;
268
52.4k
        int i;
269
270
52.4k
        if( !(cc[0]&0x40) ) // process flag
271
1.64k
            return;
272
50.7k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
2.21k
            return;
274
48.5k
        if( i_count_cc <= 0 )   // no cc present
275
513
            return;
276
48.0k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
6.75k
            return;
278
41.2k
        cc += 2;
279
280
157k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
116k
        {
282
116k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
442
                break;
284
116k
        }
285
41.2k
        c->b_reorder = true;
286
41.2k
    }
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
52.7k
}
mpegvideo.c:cc_Extract
Line
Count
Source
222
75.9k
{
223
75.9k
    if( c->i_payload_type != CC_PAYLOAD_NONE && c->i_payload_type != i_payload_type )
224
13.3k
    {
225
13.3k
        c->i_payload_other_count++;
226
13.3k
        if( c->i_payload_other_count < 50 )
227
13.1k
            return;
228
13.3k
    }
229
62.7k
    c->i_payload_type        = i_payload_type;
230
62.7k
    c->i_payload_other_count = 0;
231
232
62.7k
    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
62.7k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
10.2k
    {
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
10.2k
        if(i_src < 1)
265
0
            return;
266
10.2k
        const uint8_t *cc = &p_src[0];
267
10.2k
        const int i_count_cc = cc[0]&0x1f;
268
10.2k
        int i;
269
270
10.2k
        if( !(cc[0]&0x40) ) // process flag
271
1.36k
            return;
272
8.90k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
2.67k
            return;
274
6.22k
        if( i_count_cc <= 0 )   // no cc present
275
249
            return;
276
5.97k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
1.45k
            return;
278
4.51k
        cc += 2;
279
280
94.6k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
90.5k
        {
282
90.5k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
433
                break;
284
90.5k
        }
285
4.51k
        c->b_reorder = true;
286
4.51k
    }
287
52.4k
    else if( i_payload_type == CC_PAYLOAD_DVD )
288
3.84k
    {
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
3.84k
        if(i_src < 6)
303
0
            return;
304
3.84k
        const int b_truncate = p_src[4] & 0x01;
305
3.84k
        const int i_count_cc2 = ((p_src[4] >> 1) & 0x1f);
306
3.84k
        const uint8_t *cc = &p_src[5];
307
3.84k
        i_src -= 5;
308
3.84k
        int i;
309
310
3.84k
#define CC_ALIGNMENT_TEST   (0x7f)
311
312
44.1k
        for( i = 0; i < 2*i_count_cc2 + b_truncate && i_src >= 3; i++, cc+=3 )
313
40.5k
        {
314
40.5k
            if( (cc[0] >> 1) == CC_ALIGNMENT_TEST )
315
14.1k
            {
316
14.1k
                const bool even_field = (cc[0] & 0x01) ? 0 : 1;
317
14.1k
                if (!cc_AppendData( c, CC_PKT_BYTE0(even_field), &cc[1] ))
318
208
                    break;
319
14.1k
            }
320
40.3k
            i_src -= 3;
321
40.3k
        }
322
3.84k
        c->b_reorder = false;
323
3.84k
    }
324
48.6k
    else if( i_payload_type == CC_PAYLOAD_REPLAYTV )
325
1.42k
    {
326
1.42k
        if(i_src < 1)
327
0
            return;
328
1.42k
        const uint8_t *cc = &p_src[0];
329
19.6k
        for( int i_cc_count = i_src >> 2; i_cc_count > 0;
330
18.2k
             i_cc_count--, cc += 4 )
331
18.4k
        {
332
18.4k
            uint8_t i_field = (cc[0] & 0x02) >> 1;
333
18.4k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[2] ))
334
249
                return;
335
18.4k
        }
336
1.17k
        c->b_reorder = false;
337
1.17k
    }
338
47.2k
    else if( i_payload_type == CC_PAYLOAD_SCTE20 )
339
32.4k
    {
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
32.4k
        if(i_src < 2)
355
0
            return;
356
32.4k
        bs_t s;
357
32.4k
        bs_init( &s, &p_src[2], i_src - 2 );
358
32.4k
        const int i_cc_count = bs_read( &s, 5 );
359
770k
        for( int i = 0; i < i_cc_count; i++ )
360
737k
        {
361
737k
            bs_skip( &s, 2 );
362
737k
            const int i_field_idx = bs_read( &s, 2 );
363
737k
            bs_skip( &s, 5 );
364
737k
            uint8_t cc[2];
365
2.21M
            for( int j = 0; j < 2; j++ )
366
1.47M
            {
367
1.47M
                cc[j] = 0;
368
13.2M
                for( int k = 0; k < 8; k++ )
369
11.8M
                    cc[j] |= bs_read( &s, 1 ) << k;
370
1.47M
            }
371
737k
            bs_skip( &s, 1 );
372
373
737k
            if( i_field_idx == 0 )
374
561k
                continue;
375
376
            /* 1,2,3 -> 0,1,0. I.E. repeated field 3 is merged with field 1 */
377
175k
            int i_field = ((i_field_idx - 1) & 1);
378
175k
            if (!b_top_field_first)
379
161k
                i_field ^= 1;
380
381
175k
            if (!cc_AppendData( c, CC_PKT_BYTE0(i_field), &cc[0] ))
382
12.1k
                continue;
383
175k
        }
384
32.4k
        c->b_reorder = true;
385
32.4k
    }
386
14.7k
    else // CC_PAYLOAD_CDP
387
14.7k
    {
388
14.7k
#       define CDP_FLAG_TIME_CODE_PRESENT  (1<<7)
389
14.7k
#       define CDP_FLAG_CC_DATA_PRESENT    (1<<6)
390
14.7k
#       define CDP_FLAG_SVC_INFO_PRESENT   (1<<5)
391
14.7k
#       define CDP_FLAG_SVC_INFO_START     (1<<4)
392
14.7k
#       define CDP_FLAG_SVC_INFO_CHANGE    (1<<3)
393
14.7k
#       define CDP_FLAG_SVC_INFO_COMPLETE  (1<<2)
394
14.7k
#       define CDP_FLAG_CAPTION_SVC_ACTIVE (1<<1)
395
396
14.7k
        if(i_src < 7)
397
909
            return;
398
399
        /* ST334-2 5.2 cdp_header() */
400
13.8k
        uint8_t cdp_length = p_src[2];
401
13.8k
        if(cdp_length < 8 || cdp_length > i_src)
402
828
            return;
403
12.9k
        uint8_t cdp_flags = p_src[4];
404
405
        /* skip header */
406
12.9k
        p_src += 7; i_src -= 7;
407
408
        /* 5.3 time_code_section() */
409
12.9k
        if( cdp_flags & CDP_FLAG_TIME_CODE_PRESENT )
410
5.32k
        {
411
5.32k
            if( i_src < 5 ) // Shall be 5 bytes
412
252
                return;
413
5.07k
            p_src += 5; i_src -= 5;
414
5.07k
        }
415
        /* 5.4 ccdata_section */
416
12.7k
        if( cdp_flags & CDP_FLAG_CC_DATA_PRESENT )
417
10.5k
        {
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.5k
            if( i_src < 2 || p_src[0] != 0x72 ) // marker
430
4.44k
                return;
431
432
6.09k
            const uint8_t *cc = &p_src[1];
433
6.09k
            const int i_count_cc = cc[0]&0x1f;
434
435
6.09k
            if( i_src - 2 < i_count_cc*3 )  // broken packet
436
714
                return;
437
5.38k
            cc += 1;
438
70.7k
            for( int i = 0; i < i_count_cc; i++, cc += 3 )
439
66.5k
            {
440
66.5k
                if (!cc_AppendData( c, cc[0], &cc[1] ))
441
1.18k
                    break;
442
66.5k
            }
443
5.38k
        }
444
        /* remaining data */
445
7.57k
        c->b_reorder = false;
446
7.57k
    }
447
62.7k
}
vc1.c:cc_Extract
Line
Count
Source
222
1.97k
{
223
1.97k
    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
1.97k
    c->i_payload_type        = i_payload_type;
230
1.97k
    c->i_payload_other_count = 0;
231
232
1.97k
    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
1.97k
    else if( i_payload_type == CC_PAYLOAD_GA94 )
243
1.97k
    {
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
1.97k
        if(i_src < 1)
265
0
            return;
266
1.97k
        const uint8_t *cc = &p_src[0];
267
1.97k
        const int i_count_cc = cc[0]&0x1f;
268
1.97k
        int i;
269
270
1.97k
        if( !(cc[0]&0x40) ) // process flag
271
59
            return;
272
1.91k
        if( i_src < 1+1 + i_count_cc*3 + 1)  // broken packet
273
310
            return;
274
1.60k
        if( i_count_cc <= 0 )   // no cc present
275
0
            return;
276
1.60k
        if( cc[2+i_count_cc * 3] != 0xff )  // marker absent
277
896
            return;
278
709
        cc += 2;
279
280
15.0k
        for( i = 0; i < i_count_cc; i++, cc += 3 )
281
14.5k
        {
282
14.5k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
283
202
                break;
284
14.5k
        }
285
709
        c->b_reorder = true;
286
709
    }
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
1.97k
}
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
357k
        for( int i = 0; i + 2 < i_src; i += 3 )
235
352k
        {
236
352k
            const uint8_t *cc = &p_src[i];
237
352k
            if (!cc_AppendData( c, cc[0], &cc[1] ))
238
109
                break;
239
352k
        }
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
116k
{
452
116k
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
116k
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
116k
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
116k
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
116k
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
116k
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
116k
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
116k
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
116k
    if( i_src < 4 )
462
0
        return;
463
464
116k
    enum cc_payload_type_e i_payload_type;
465
116k
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
11.2k
    {
467
        /* CC from DVB/ATSC TS */
468
11.2k
        i_payload_type = CC_PAYLOAD_GA94;
469
11.2k
        i_src -= 5;
470
11.2k
        p_src += 5;
471
11.2k
    }
472
105k
    else if( !memcmp( p_cc_dvd, p_src, 4 ) && i_src > 4+1 )
473
4.12k
    {
474
4.12k
        i_payload_type = CC_PAYLOAD_DVD;
475
4.12k
    }
476
100k
    else if( i_src >= 2+2 + 2+2 &&
477
89.2k
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
88.4k
               ( !memcmp( p_cc_replaytv5a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv5b, &p_src[4], 2 ) ) ) )
479
1.77k
    {
480
1.77k
        i_payload_type = CC_PAYLOAD_REPLAYTV;
481
1.77k
    }
482
99.1k
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
91.2k
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
38.4k
    {
485
38.4k
        i_payload_type = CC_PAYLOAD_SCTE20;
486
38.4k
    }
487
60.7k
    else if (p_src[0] == 0x03 && p_src[1] == i_src - 2) /* DIRECTV */
488
5.04k
    {
489
5.04k
        i_payload_type = CC_PAYLOAD_GA94;
490
5.04k
        i_src -= 2;
491
5.04k
        p_src += 2;
492
5.04k
    }
493
55.6k
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
17.2k
    {
495
17.2k
        i_payload_type = CC_PAYLOAD_CDP;
496
17.2k
    }
497
38.3k
    else
498
38.3k
    {
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
38.3k
        return;
510
38.3k
    }
511
512
77.9k
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
77.9k
}
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
114k
{
452
114k
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
114k
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
114k
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
114k
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
114k
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
114k
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
114k
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
114k
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
114k
    if( i_src < 4 )
462
0
        return;
463
464
114k
    enum cc_payload_type_e i_payload_type;
465
114k
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
9.29k
    {
467
        /* CC from DVB/ATSC TS */
468
9.29k
        i_payload_type = CC_PAYLOAD_GA94;
469
9.29k
        i_src -= 5;
470
9.29k
        p_src += 5;
471
9.29k
    }
472
104k
    else if( !memcmp( p_cc_dvd, p_src, 4 ) && i_src > 4+1 )
473
4.12k
    {
474
4.12k
        i_payload_type = CC_PAYLOAD_DVD;
475
4.12k
    }
476
100k
    else if( i_src >= 2+2 + 2+2 &&
477
89.1k
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
88.4k
               ( !memcmp( p_cc_replaytv5a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv5b, &p_src[4], 2 ) ) ) )
479
1.77k
    {
480
1.77k
        i_payload_type = CC_PAYLOAD_REPLAYTV;
481
1.77k
    }
482
99.0k
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
91.1k
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
38.4k
    {
485
38.4k
        i_payload_type = CC_PAYLOAD_SCTE20;
486
38.4k
    }
487
60.6k
    else if (p_src[0] == 0x03 && p_src[1] == i_src - 2) /* DIRECTV */
488
5.04k
    {
489
5.04k
        i_payload_type = CC_PAYLOAD_GA94;
490
5.04k
        i_src -= 2;
491
5.04k
        p_src += 2;
492
5.04k
    }
493
55.5k
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
17.2k
    {
495
17.2k
        i_payload_type = CC_PAYLOAD_CDP;
496
17.2k
    }
497
38.3k
    else
498
38.3k
    {
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
38.3k
        return;
510
38.3k
    }
511
512
75.9k
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
75.9k
}
vc1.c:cc_ProbeAndExtract
Line
Count
Source
451
2.04k
{
452
2.04k
    static const uint8_t p_cc_ga94[4] = { 0x47, 0x41, 0x39, 0x34 };
453
2.04k
    static const uint8_t p_cc_dvd[4] = { 0x43, 0x43, 0x01, 0xf8 }; /* ascii 'CC', type_code, cc_block_size */
454
2.04k
    static const uint8_t p_cc_replaytv4a[2] = { 0xbb, 0x02 };/* RTV4K, BB02xxxxCC02 */
455
2.04k
    static const uint8_t p_cc_replaytv4b[2] = { 0xcc, 0x02 };/* see DVR-ClosedCaption in samples */
456
2.04k
    static const uint8_t p_cc_replaytv5a[2] = { 0x99, 0x02 };/* RTV5K, 9902xxxxAA02 */
457
2.04k
    static const uint8_t p_cc_replaytv5b[2] = { 0xaa, 0x02 };/* see DVR-ClosedCaption in samples */
458
2.04k
    static const uint8_t p_cc_scte20[2] = { 0x03, 0x81 };    /* user_data_type_code, SCTE 20 */
459
2.04k
    static const uint8_t p_cc_scte20_old[2] = { 0x03, 0x01 };/* user_data_type_code, old, Note 1 */
460
461
2.04k
    if( i_src < 4 )
462
0
        return;
463
464
2.04k
    enum cc_payload_type_e i_payload_type;
465
2.04k
    if( !memcmp( p_cc_ga94, p_src, 4 ) && i_src >= 5+1+1+1 && p_src[4] == 0x03 )
466
1.97k
    {
467
        /* CC from DVB/ATSC TS */
468
1.97k
        i_payload_type = CC_PAYLOAD_GA94;
469
1.97k
        i_src -= 5;
470
1.97k
        p_src += 5;
471
1.97k
    }
472
75
    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
75
    else if( i_src >= 2+2 + 2+2 &&
477
20
             ( ( !memcmp( p_cc_replaytv4a, &p_src[0], 2 ) && !memcmp( p_cc_replaytv4b, &p_src[4], 2 ) ) ||
478
20
               ( !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
75
    else if( ( !memcmp( p_cc_scte20, p_src, 2 ) ||
483
75
               !memcmp( p_cc_scte20_old, p_src, 2 ) ) && i_src > 2 )
484
0
    {
485
0
        i_payload_type = CC_PAYLOAD_SCTE20;
486
0
    }
487
75
    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
75
    else if (p_src[0] == 0x96 && p_src[1] == 0x69) /* CDP */
494
0
    {
495
0
        i_payload_type = CC_PAYLOAD_CDP;
496
0
    }
497
75
    else
498
75
    {
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
75
        return;
510
75
    }
511
512
1.97k
    cc_Extract( c, i_payload_type, b_top_field_first, p_src, i_src );
513
1.97k
}
Unexecuted instantiation: dav1d.c:cc_ProbeAndExtract
Unexecuted instantiation: video.c:cc_ProbeAndExtract
514
515
#endif /* _CC_H */
516