Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * RAW AVS3-P2/IEEE1857.10 video demuxer | ||
3 | * Copyright (c) 2020 Zhenyu Wang <wangzhenyu@pkusz.edu.cn> | ||
4 | * Bingjie Han <hanbj@pkusz.edu.cn> | ||
5 | * Huiwen Ren <hwrenx@gmail.com> | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #include "libavcodec/avs3.h" | ||
25 | #include "libavcodec/startcode.h" | ||
26 | #include "avformat.h" | ||
27 | #include "rawdec.h" | ||
28 | |||
29 | 7203 | static int avs3video_probe(const AVProbeData *p) | |
30 | { | ||
31 | 7203 | const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size; | |
32 | 7203 | uint32_t code = -1; | |
33 | 7203 | uint8_t state = 0; | |
34 | 7203 | int pic = 0, seq = 0, slice_pos = 0; | |
35 | 7203 | int ret = 0; | |
36 | |||
37 |
2/2✓ Branch 0 taken 21189 times.
✓ Branch 1 taken 5284 times.
|
26473 | while (ptr < end) { |
38 | 21189 | ptr = avpriv_find_start_code(ptr, end, &code); | |
39 | 21189 | state = code & 0xFF; | |
40 |
2/2✓ Branch 0 taken 15953 times.
✓ Branch 1 taken 5236 times.
|
21189 | if ((code & 0xFFFFFF00) == 0x100) { |
41 |
2/2✓ Branch 0 taken 14327 times.
✓ Branch 1 taken 1626 times.
|
15953 | if (state < AVS3_SEQ_START_CODE) { |
42 |
2/2✓ Branch 0 taken 994 times.
✓ Branch 1 taken 13333 times.
|
14327 | if (code < slice_pos) |
43 | 994 | return 0; | |
44 | 13333 | slice_pos = code; | |
45 | } else { | ||
46 | 1626 | slice_pos = 0; | |
47 | } | ||
48 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 14903 times.
|
14959 | if (state == AVS3_SEQ_START_CODE) { |
49 | 56 | seq++; | |
50 |
3/4✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
|
56 | if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != AVS3_PROFILE_BASELINE_MAIN10) |
51 | 55 | return 0; | |
52 |
4/4✓ Branch 0 taken 14643 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 14613 times.
|
14903 | } else if (AVS3_ISPIC(state)) { |
53 | 290 | pic++; | |
54 |
4/4✓ Branch 0 taken 14606 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 863 times.
✓ Branch 3 taken 13743 times.
|
14613 | } else if ((state == AVS3_UNDEF_START_CODE) || |
55 | (state > AVS3_VIDEO_EDIT_CODE)) { | ||
56 | 870 | return 0; | |
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 |
4/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5283 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
|
5284 | if (seq && pic && av_match_ext(p->filename, "avs3")) { |
62 | ✗ | ret = AVPROBE_SCORE_MAX; | |
63 | } | ||
64 | |||
65 | 5284 | return ret; | |
66 | } | ||
67 | |||
68 | FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, "avs3", AV_CODEC_ID_AVS3) | ||
69 |