Coverage Report

Created: 2026-05-16 07:49

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavformat/vc1dec.c
Line
Count
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
static int vc1_probe(const AVProbeData *p)
28
971k
{
29
971k
    int seq = 0, entry = 0, invalid = 0, frame = 0, i;
30
31
3.38G
    for (i = 0; i < p->buf_size + 5; i++) {
32
3.38G
        uint32_t code = AV_RB32(p->buf + i);
33
3.38G
        if ((code & 0xffffffe0) == 0x100) {
34
13.1M
            int type = code & 0x11f;
35
13.1M
            i += 4;
36
13.1M
            switch (type) {
37
881k
            case VC1_CODE_SEQHDR: {
38
881k
                int profile, level, chromaformat;
39
881k
                profile = (p->buf[i] & 0xc0) >> 6;
40
881k
                if (profile != PROFILE_ADVANCED) {
41
307k
                    seq = 0;
42
307k
                    invalid++;
43
307k
                    continue;
44
307k
                }
45
574k
                level = (p->buf[i] & 0x38) >> 3;
46
574k
                if (level >= 5) {
47
33.3k
                    seq = 0;
48
33.3k
                    invalid++;
49
33.3k
                    continue;
50
33.3k
                }
51
540k
                chromaformat = (p->buf[i] & 0x6) >> 1;
52
540k
                if (chromaformat != 1) {
53
360k
                    seq = 0;
54
360k
                    invalid++;
55
360k
                    continue;
56
360k
                }
57
180k
                seq++;
58
180k
                i += 6;
59
180k
                break;
60
540k
            }
61
120k
            case VC1_CODE_ENTRYPOINT:
62
120k
                if (!seq) {
63
63.6k
                    invalid++;
64
63.6k
                    continue;
65
63.6k
                }
66
57.1k
                entry++;
67
57.1k
                i += 2;
68
57.1k
                break;
69
203k
            case VC1_CODE_FRAME:
70
265k
            case VC1_CODE_FIELD:
71
388k
            case VC1_CODE_SLICE:
72
388k
                if (seq && entry)
73
78.1k
                    frame++;
74
388k
                break;
75
13.1M
            }
76
13.1M
        }
77
3.38G
    }
78
79
971k
    if (frame > 1 && frame >> 1 > invalid)
80
1.39k
        return AVPROBE_SCORE_EXTENSION / 2 + 1;
81
970k
    if (frame >= 1)
82
3.84k
        return AVPROBE_SCORE_EXTENSION / 4;
83
966k
    return 0;
84
970k
}
85
86
FF_DEF_RAWVIDEO_DEMUXER2(vc1, "raw VC-1", vc1_probe, "vc1", AV_CODEC_ID_VC1, AVFMT_GENERIC_INDEX|AVFMT_NOTIMESTAMPS)