FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/timecode_internal.c
Date: 2025-03-08 20:38:41
Exec Total Coverage
Lines: 17 19 89.5%
Functions: 2 2 100.0%
Branches: 10 14 71.4%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2006 Smartjog S.A.S, Baptiste Coudurier <baptiste.coudurier@gmail.com>
3 * Copyright (c) 2011-2012 Smartjog S.A.S, Clément Bœsch <clement.boesch@smartjog.com>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "timecode_internal.h"
23
24 4104 static unsigned bcd2uint(uint8_t bcd)
25 {
26 4104 unsigned low = bcd & 0xf;
27 4104 unsigned high = bcd >> 4;
28
2/4
✓ Branch 0 taken 4104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4104 times.
4104 if (low > 9 || high > 9)
29 return 0;
30 4104 return low + 10*high;
31 }
32
33 1026 void ff_timecode_set_smpte(unsigned *drop, unsigned *hh, unsigned *mm, unsigned *ss, unsigned *ff,
34 AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
35 {
36 1026 *hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours
37 1026 *mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes
38 1026 *ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds
39 1026 *ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
40
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
1026 *drop = tcsmpte & 1<<30 && !prevent_df; // 1-bit drop if not arbitrary bit
41
42
2/2
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 979 times.
1026 if (av_cmp_q(rate, (AVRational) {30, 1}) == 1) {
43 47 *ff <<= 1;
44
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 4 times.
47 if (!skip_field) {
45
1/2
✓ Branch 1 taken 43 times.
✗ Branch 2 not taken.
43 if (av_cmp_q(rate, (AVRational) {50, 1}) == 0)
46 43 *ff += !!(tcsmpte & 1 << 7);
47 else
48 *ff += !!(tcsmpte & 1 << 23);
49 }
50 }
51 1026 }
52