FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavformat/vc1dec.c
Date: 2024-05-03 05:27:13
Exec Total Coverage
Lines: 43 43 100.0%
Functions: 1 1 100.0%
Branches: 24 26 92.3%

Line Branch Exec Source
1 /*
2 * VC-1 demuxer
3 * Copyright (c) 2015 Carl Eugen Hoyos
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 "avformat.h"
23 #include "rawdec.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavcodec/vc1_common.h"
26
27 7128 static int vc1_probe(const AVProbeData *p)
28 {
29 7128 int seq = 0, entry = 0, invalid = 0, frame = 0, i;
30
31
2/2
✓ Branch 0 taken 367494191 times.
✓ Branch 1 taken 7128 times.
367501319 for (i = 0; i < p->buf_size + 5; i++) {
32 367494191 uint32_t code = AV_RB32(p->buf + i);
33
2/2
✓ Branch 0 taken 31557 times.
✓ Branch 1 taken 367462634 times.
367494191 if ((code & 0xffffffe0) == 0x100) {
34 31557 int type = code & 0x11f;
35 31557 i += 4;
36
4/4
✓ Branch 0 taken 449 times.
✓ Branch 1 taken 527 times.
✓ Branch 2 taken 1414 times.
✓ Branch 3 taken 29167 times.
31557 switch (type) {
37 449 case VC1_CODE_SEQHDR: {
38 int profile, level, chromaformat;
39 449 profile = (p->buf[i] & 0xc0) >> 6;
40
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 49 times.
449 if (profile != PROFILE_ADVANCED) {
41 400 seq = 0;
42 400 invalid++;
43 400 continue;
44 }
45 49 level = (p->buf[i] & 0x38) >> 3;
46
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 33 times.
49 if (level >= 5) {
47 16 seq = 0;
48 16 invalid++;
49 16 continue;
50 }
51 33 chromaformat = (p->buf[i] & 0x6) >> 1;
52
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 31 times.
33 if (chromaformat != 1) {
53 2 seq = 0;
54 2 invalid++;
55 2 continue;
56 }
57 31 seq++;
58 31 i += 6;
59 31 break;
60 }
61 527 case VC1_CODE_ENTRYPOINT:
62
2/2
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 51 times.
527 if (!seq) {
63 476 invalid++;
64 476 continue;
65 }
66 51 entry++;
67 51 i += 2;
68 51 break;
69 1414 case VC1_CODE_FRAME:
70 case VC1_CODE_FIELD:
71 case VC1_CODE_SLICE:
72
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1375 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
1414 if (seq && entry)
73 39 frame++;
74 1414 break;
75 }
76 }
77 }
78
79
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 7122 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
7128 if (frame > 1 && frame >> 1 > invalid)
80 6 return AVPROBE_SCORE_EXTENSION / 2 + 1;
81
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 7099 times.
7122 if (frame >= 1)
82 23 return AVPROBE_SCORE_EXTENSION / 4;
83 7099 return 0;
84 }
85
86 FF_DEF_RAWVIDEO_DEMUXER2(vc1, "raw VC-1", vc1_probe, "vc1", AV_CODEC_ID_VC1, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)
87