2 * AVS2 video stream probe.
4 * Copyright (C) 2018 Huiwen Ren, <hwrenx@126.com>
6 * This file is part of FFmpeg.
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.
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.
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
25 #include "libavcodec/internal.h"
26 #include "libavutil/intreadwrite.h"
28 #define ISSQH(x) ((x) == 0xB0 )
29 #define ISEND(x) ((x) == 0xB1 )
30 #define ISPIC(x) ((x) == 0xB3 || (x) == 0xB6)
31 #define ISUNIT(x) ( ISSQH(x) || ISEND(x) || (x) == 0xB2 || ISPIC(x) || (x) == 0xB5 || (x) == 0xB7 )
32 #define ISAVS2(x) ((x) == 0x20 || (x) == 0x22 || (x) == 0x30 || (x) == 0x32 )
34 static int avs2_probe(const AVProbeData *p)
36 uint32_t code= -1, hds=0, pic=0, seq=0;
38 const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size, *sqb=0;
39 if (AV_RB32(p->buf) != 0x1B0){
44 ptr = avpriv_find_start_code(ptr, end, &code);
46 if ((code & 0xffffff00) == 0x100) {
56 } else if (ISPIC(state)) {
58 } else if (ISEND(state)) {
64 if (seq && hds >= 21 && pic){
65 return AVPROBE_SCORE_EXTENSION + 2; // more than cavs
71 FF_DEF_RAWVIDEO_DEMUXER(avs2, "raw AVS2-P2/IEEE1857.4", avs2_probe, "avs,avs2", AV_CODEC_ID_AVS2)