Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * AVS2 video stream probe. | ||
3 | * | ||
4 | * Copyright (C) 2018 Huiwen Ren, <hwrenx@126.com> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg 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 GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | #include "avformat.h" | ||
24 | #include "rawdec.h" | ||
25 | #include "libavcodec/startcode.h" | ||
26 | #include "libavutil/intreadwrite.h" | ||
27 | |||
28 | #define AVS2_ISSQH(x) ((x) == 0xB0) | ||
29 | #define AVS2_ISEND(x) ((x) == 0xB1) | ||
30 | #define AVS2_ISPIC(x) ((x) == 0xB3 || (x) == 0xB6) | ||
31 | #define AVS2_ISUNIT(x) (AVS2_ISSQH(x) || AVS2_ISEND(x) || (x) == 0xB2 || AVS2_ISPIC(x) || (x) == 0xB5 || (x) == 0xB7) | ||
32 | #define AVS2_ISPROFILE(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32) | ||
33 | |||
34 | 7186 | static int avs2_probe(const AVProbeData *p) | |
35 | { | ||
36 | 7186 | uint32_t code = -1, hds = 0, pic = 0, seq = 0; | |
37 | 7186 | uint8_t state = 0; | |
38 | 7186 | const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb = 0; | |
39 |
2/2✓ Branch 0 taken 7138 times.
✓ Branch 1 taken 48 times.
|
7186 | if (AV_RB32(p->buf) != 0x1B0){ |
40 | 7138 | return 0; | |
41 | } | ||
42 | |||
43 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1 times.
|
52 | while (ptr < end) { |
44 | 51 | ptr = avpriv_find_start_code(ptr, end, &code); | |
45 | 51 | state = code & 0xFF; | |
46 |
2/2✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1 times.
|
51 | if ((code & 0xffffff00) == 0x100) { |
47 |
9/14✓ Branch 0 taken 2 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
|
50 | if (AVS2_ISUNIT(state)) { |
48 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
49 | if (sqb && !hds) { |
49 | 1 | hds = ptr - sqb; | |
50 | } | ||
51 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1 times.
|
49 | if (AVS2_ISSQH(state)) { |
52 |
5/8✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
|
48 | if (!AVS2_ISPROFILE(*ptr)) |
53 | 47 | return 0; | |
54 | 1 | sqb = ptr; | |
55 | 1 | seq++; | |
56 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1 | } else if (AVS2_ISPIC(state)) { |
57 | 1 | pic++; | |
58 | ✗ | } else if (AVS2_ISEND(state)) { | |
59 | ✗ | break; | |
60 | } | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 |
2/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | if (seq && hds >= 21 && pic){ |
65 | ✗ | return AVPROBE_SCORE_EXTENSION + 2; // more than cavs | |
66 | } | ||
67 | |||
68 | 1 | return 0; | |
69 | } | ||
70 | |||
71 | FF_DEF_RAWVIDEO_DEMUXER(avs2, "raw AVS2-P2/IEEE1857.4", avs2_probe, "avs,avs2", AV_CODEC_ID_AVS2) | ||
72 |