2 * RAW H.266 / VVC video demuxer
3 * Copyright (c) 2020 Nuo Mi <nuomi2021@gmail.com>
5 * This file is part of FFmpeg.
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.
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.
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
22 #include "libavcodec/vvc.h"
27 static int check_temporal_id(uint8_t nuh_temporal_id_plus1
, int type
)
29 if (nuh_temporal_id_plus1
== 0)
32 if (nuh_temporal_id_plus1
!= 1) {
33 if (type
>= VVC_IDR_W_RADL
&& type
<= VVC_RSV_IRAP_11
34 || type
== VVC_DCI_NUT
|| type
== VVC_OPI_NUT
35 || type
== VVC_VPS_NUT
|| type
== VVC_SPS_NUT
36 || type
== VVC_EOS_NUT
|| type
== VVC_EOB_NUT
)
43 static int vvc_probe(const AVProbeData
*p
)
46 int sps
= 0, pps
= 0, irap
= 0;
49 for (i
= 0; i
< p
->buf_size
- 1; i
++) {
50 code
= (code
<< 8) + p
->buf
[i
];
51 if ((code
& 0xffffff00) == 0x100) {
52 uint8_t nal2
= p
->buf
[i
+ 1];
53 int type
= (nal2
& 0xF8) >> 3;
55 if (code
& 0x80) // forbidden_zero_bit
58 if (!check_temporal_id(nal2
& 0x7, type
))
62 case VVC_SPS_NUT
: sps
++; break;
63 case VVC_PPS_NUT
: pps
++; break;
67 case VVC_GDR_NUT
: irap
++; break;
72 if (sps
&& pps
&& irap
)
73 return AVPROBE_SCORE_EXTENSION
+ 1; // 1 more than .mpg
77 FF_DEF_RAWVIDEO_DEMUXER(vvc
, "raw H.266/VVC video", vvc_probe
, "h266,266,vvc", AV_CODEC_ID_VVC
)