[FFmpeg-devel] [PATCH v5 03/10] avformat: add vvc raw demux
Nuo Mi
nuomi2021 at gmail.com
Thu Feb 11 16:36:04 EET 2021
---
libavformat/Makefile | 1 +
libavformat/allformats.c | 1 +
libavformat/vvcdec.c | 61 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
create mode 100644 libavformat/vvcdec.c
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 10fee749c8..2b9d0eee7f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -564,6 +564,7 @@ OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o
OBJS-$(CONFIG_VPK_DEMUXER) += vpk.o
OBJS-$(CONFIG_VPLAYER_DEMUXER) += vplayerdec.o subtitles.o
OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o
+OBJS-$(CONFIG_VVC_DEMUXER) += vvcdec.o rawdec.o
OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o w64.o pcm.o
OBJS-$(CONFIG_W64_MUXER) += wavenc.o w64.o
OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index f837ddabc8..fb06723fb9 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -463,6 +463,7 @@ extern AVOutputFormat ff_voc_muxer;
extern AVInputFormat ff_vpk_demuxer;
extern AVInputFormat ff_vplayer_demuxer;
extern AVInputFormat ff_vqf_demuxer;
+extern AVInputFormat ff_vvc_demuxer;
extern AVInputFormat ff_w64_demuxer;
extern AVOutputFormat ff_w64_muxer;
extern AVInputFormat ff_wav_demuxer;
diff --git a/libavformat/vvcdec.c b/libavformat/vvcdec.c
new file mode 100644
index 0000000000..149f39f28e
--- /dev/null
+++ b/libavformat/vvcdec.c
@@ -0,0 +1,61 @@
+/*
+ * RAW VVC video demuxer
+ * Copyright (c) 2020 Nuo Mi <nuomi2021 at gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/vvc.h"
+
+#include "avformat.h"
+#include "rawdec.h"
+
+static int vvc_probe(const AVProbeData *p)
+{
+ uint32_t code = -1;
+ int sps = 0, pps = 0, irap = 0;
+ int i;
+
+ for (i = 0; i < p->buf_size - 1; i++) {
+ code = (code << 8) + p->buf[i];
+ if ((code & 0xffffff00) == 0x100) {
+ uint8_t nal2 = p->buf[i + 1];
+ int type = (nal2 & 0xF8) >> 3;
+
+ if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit
+ return 0;
+
+ if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1
+ return 0;
+
+ switch (type) {
+ case VVC_SPS_NUT: sps++; break;
+ case VVC_PPS_NUT: pps++; break;
+ case VVC_IDR_N_LP:
+ case VVC_IDR_W_RADL:
+ case VVC_CRA_NUT:
+ case VVC_GDR_NUT: irap++; break;
+ }
+ }
+ }
+
+ if (sps && pps && irap)
+ return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg
+ return 0;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(vvc, "raw VVC video", vvc_probe, "h266,266,vvc", AV_CODEC_ID_VVC)
--
2.25.1
More information about the ffmpeg-devel
mailing list