/src/ffmpeg/libavformat/avs3dec.c
Line | Count | 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 | | static int avs3video_probe(const AVProbeData *p) |
30 | 958k | { |
31 | 958k | const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size; |
32 | 958k | uint32_t code = -1; |
33 | 958k | uint8_t state = 0; |
34 | 958k | int pic = 0, seq = 0, slice_pos = 0; |
35 | 958k | int ret = 0; |
36 | | |
37 | 3.14M | while (ptr < end) { |
38 | 2.59M | ptr = avpriv_find_start_code(ptr, end, &code); |
39 | 2.59M | state = code & 0xFF; |
40 | 2.59M | if ((code & 0xFFFFFF00) == 0x100) { |
41 | 2.06M | if (state < AVS3_SEQ_START_CODE) { |
42 | 1.64M | if (code < slice_pos) |
43 | 204k | return 0; |
44 | 1.43M | slice_pos = code; |
45 | 1.43M | } else { |
46 | 425k | slice_pos = 0; |
47 | 425k | } |
48 | 1.86M | if (state == AVS3_SEQ_START_CODE) { |
49 | 51.3k | seq++; |
50 | 51.3k | if (*ptr != AVS3_PROFILE_BASELINE_MAIN && *ptr != AVS3_PROFILE_BASELINE_MAIN10) |
51 | 33.9k | return 0; |
52 | 1.81M | } else if (AVS3_ISPIC(state)) { |
53 | 166k | pic++; |
54 | 1.64M | } else if ((state == AVS3_UNDEF_START_CODE) || |
55 | 1.64M | (state > AVS3_VIDEO_EDIT_CODE)) { |
56 | 175k | return 0; |
57 | 175k | } |
58 | 1.86M | } |
59 | 2.59M | } |
60 | | |
61 | 544k | if (seq && pic && av_match_ext(p->filename, "avs3")) { |
62 | 4 | ret = AVPROBE_SCORE_MAX; |
63 | 4 | } |
64 | | |
65 | 544k | return ret; |
66 | 958k | } |
67 | | |
68 | | FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, "avs3", AV_CODEC_ID_AVS3) |