Re: [FFmpeg-devel] [PATCH v1 06/11] avformat: add demuxer and probe support for H266/VVC
On Wed, 19 Oct 2022 at 14:07, Michael Niedermayer wrote: > On Wed, Oct 19, 2022 at 09:25:03AM +0200, thomas...@spin-digital.com > wrote: > > From: Thomas Siedel > > > > Add demuxer to probe raw vvc and parse vvcc byte stream format. > > > > Signed-off-by: Thomas Siedel > > --- > > libavformat/Makefile | 1 + > > libavformat/allformats.c | 1 + > > libavformat/demux.c | 7 +- > > libavformat/vvc.c| 918 +++ > > libavformat/vvc.h| 99 + > > libavformat/vvcdec.c | 61 +++ > > 6 files changed, 1085 insertions(+), 2 deletions(-) > > create mode 100644 libavformat/vvc.c > > create mode 100644 libavformat/vvc.h > > create mode 100644 libavformat/vvcdec.c > > > > diff --git a/libavformat/Makefile b/libavformat/Makefile > > index d7f198bf39..00ab4ded89 100644 > > --- a/libavformat/Makefile > > +++ b/libavformat/Makefile > > @@ -595,6 +595,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 47c419a009..a4e3822681 100644 > > --- a/libavformat/allformats.c > > +++ b/libavformat/allformats.c > > @@ -474,6 +474,7 @@ extern const AVOutputFormat ff_voc_muxer; > > extern const AVInputFormat ff_vpk_demuxer; > > extern const AVInputFormat ff_vplayer_demuxer; > > extern const AVInputFormat ff_vqf_demuxer; > > +extern const AVInputFormat ff_vvc_demuxer; > > extern const AVInputFormat ff_w64_demuxer; > > extern const AVOutputFormat ff_w64_muxer; > > extern const AVInputFormat ff_wav_demuxer; > > diff --git a/libavformat/demux.c b/libavformat/demux.c > > index 2dfd82a63c..8dbde23fcd 100644 > > --- a/libavformat/demux.c > > +++ b/libavformat/demux.c > > @@ -120,6 +120,7 @@ static int set_codec_from_probe_data(AVFormatContext > *s, AVStream *st, > > { "mp3",AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO > }, > > { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO > }, > > { "truehd", AV_CODEC_ID_TRUEHD, AVMEDIA_TYPE_AUDIO > }, > > +{ "vvc",AV_CODEC_ID_VVC, AVMEDIA_TYPE_VIDEO > }, > > { 0 } > > }; > > int score; > > @@ -743,7 +744,8 @@ static int64_t select_from_pts_buffer(AVStream *st, > int64_t *pts_buffer, int64_t > > { > > FFStream *const sti = ffstream(st); > > int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 && > > - st->codecpar->codec_id != AV_CODEC_ID_HEVC; > > + st->codecpar->codec_id != AV_CODEC_ID_HEVC && > > + st->codecpar->codec_id != AV_CODEC_ID_VVC; > > > > if (!onein_oneout) { > > int delay = sti->avctx->has_b_frames; > > @@ -933,7 +935,8 @@ static void compute_pkt_fields(AVFormatContext *s, > AVStream *st, > > int64_t offset; > > AVRational duration; > > int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 && > > - st->codecpar->codec_id != AV_CODEC_ID_HEVC; > > + st->codecpar->codec_id != AV_CODEC_ID_HEVC && > > + st->codecpar->codec_id != AV_CODEC_ID_VVC; > > > > if (s->flags & AVFMT_FLAG_NOFILLIN) > > return; > > diff --git a/libavformat/vvc.c b/libavformat/vvc.c > > new file mode 100644 > > index 00..fd0527242f > > --- /dev/null > > +++ b/libavformat/vvc.c > > @@ -0,0 +1,918 @@ > > +/* > > + * VVC helper functions for muxers > > + * > > + * Copyright (C) 2022, Thomas Siedel > > + * > > + * 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/get_bits.h" > > +#include "libavcodec/golomb.h" > > +#include "libavcodec/vvc.h" > > +#include "libavutil/intreadwrite.h" > > +#include "avc.
Re: [FFmpeg-devel] [PATCH v1 06/11] avformat: add demuxer and probe support for H266/VVC
On Wed, Oct 19, 2022 at 09:25:03AM +0200, thomas...@spin-digital.com wrote: > From: Thomas Siedel > > Add demuxer to probe raw vvc and parse vvcc byte stream format. > > Signed-off-by: Thomas Siedel > --- > libavformat/Makefile | 1 + > libavformat/allformats.c | 1 + > libavformat/demux.c | 7 +- > libavformat/vvc.c| 918 +++ > libavformat/vvc.h| 99 + > libavformat/vvcdec.c | 61 +++ > 6 files changed, 1085 insertions(+), 2 deletions(-) > create mode 100644 libavformat/vvc.c > create mode 100644 libavformat/vvc.h > create mode 100644 libavformat/vvcdec.c > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index d7f198bf39..00ab4ded89 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -595,6 +595,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 47c419a009..a4e3822681 100644 > --- a/libavformat/allformats.c > +++ b/libavformat/allformats.c > @@ -474,6 +474,7 @@ extern const AVOutputFormat ff_voc_muxer; > extern const AVInputFormat ff_vpk_demuxer; > extern const AVInputFormat ff_vplayer_demuxer; > extern const AVInputFormat ff_vqf_demuxer; > +extern const AVInputFormat ff_vvc_demuxer; > extern const AVInputFormat ff_w64_demuxer; > extern const AVOutputFormat ff_w64_muxer; > extern const AVInputFormat ff_wav_demuxer; > diff --git a/libavformat/demux.c b/libavformat/demux.c > index 2dfd82a63c..8dbde23fcd 100644 > --- a/libavformat/demux.c > +++ b/libavformat/demux.c > @@ -120,6 +120,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, > AVStream *st, > { "mp3",AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO}, > { "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO}, > { "truehd", AV_CODEC_ID_TRUEHD, AVMEDIA_TYPE_AUDIO}, > +{ "vvc",AV_CODEC_ID_VVC, AVMEDIA_TYPE_VIDEO}, > { 0 } > }; > int score; > @@ -743,7 +744,8 @@ static int64_t select_from_pts_buffer(AVStream *st, > int64_t *pts_buffer, int64_t > { > FFStream *const sti = ffstream(st); > int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 && > - st->codecpar->codec_id != AV_CODEC_ID_HEVC; > + st->codecpar->codec_id != AV_CODEC_ID_HEVC && > + st->codecpar->codec_id != AV_CODEC_ID_VVC; > > if (!onein_oneout) { > int delay = sti->avctx->has_b_frames; > @@ -933,7 +935,8 @@ static void compute_pkt_fields(AVFormatContext *s, > AVStream *st, > int64_t offset; > AVRational duration; > int onein_oneout = st->codecpar->codec_id != AV_CODEC_ID_H264 && > - st->codecpar->codec_id != AV_CODEC_ID_HEVC; > + st->codecpar->codec_id != AV_CODEC_ID_HEVC && > + st->codecpar->codec_id != AV_CODEC_ID_VVC; > > if (s->flags & AVFMT_FLAG_NOFILLIN) > return; > diff --git a/libavformat/vvc.c b/libavformat/vvc.c > new file mode 100644 > index 00..fd0527242f > --- /dev/null > +++ b/libavformat/vvc.c > @@ -0,0 +1,918 @@ > +/* > + * VVC helper functions for muxers > + * > + * Copyright (C) 2022, Thomas Siedel > + * > + * 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/get_bits.h" > +#include "libavcodec/golomb.h" > +#include "libavcodec/vvc.h" > +#include "libavutil/intreadwrite.h" > +#include "avc.h" > +#include "avio.h" > +#include "avio_internal.h" > +#include "vvc.h" > + > +typedef struct VVCCNALUnitArray { > +uint8_t array_completeness; > +uint8_t NAL_unit_type; > +uint16_t num_nalus; > +uint16_t *nal_unit_length; > +uint8_t **n