[FFmpeg-devel] [PATCH v1 06/11] avformat: add demuxer and probe support for H266/VVC
Michael Niedermayer
michael at niedermayer.cc
Wed Oct 19 15:06:56 EEST 2022
On Wed, Oct 19, 2022 at 09:25:03AM +0200, thomas.ff at spin-digital.com wrote:
> From: Thomas Siedel <thomas.ff at spin-digital.com>
>
> Add demuxer to probe raw vvc and parse vvcc byte stream format.
>
> Signed-off-by: Thomas Siedel <thomas.ff at spin-digital.com>
> ---
> 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 0000000000..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 **nal_unit;
> +} VVCCNALUnitArray;
> +
> +typedef struct VVCPTLRecord {
> + uint8_t num_bytes_constraint_info;
> + uint8_t general_profile_idc;
> + uint8_t general_tier_flag;
> + uint8_t general_level_idc;
> + uint8_t ptl_frame_only_constraint_flag;
> + uint8_t ptl_multilayer_enabled_flag;
> + uint8_t *general_constraint_info;
> + uint8_t *ptl_sublayer_level_present_flag;
> + uint8_t *sublayer_level_idc;
> + uint8_t ptl_num_sub_profiles;
> + uint32_t *general_sub_profile_idc;
> +} VVCPTLRecord;
> +
> +typedef struct VVCDecoderConfigurationRecord {
> + uint8_t lengthSizeMinusOne;
> + uint8_t ptl_present_flag;
> + uint16_t ols_idx;
> + uint8_t num_sublayers;
> + uint8_t constant_frame_rate;
> + uint8_t chroma_format_idc;
> + uint8_t bit_depth_minus8;
> + VVCPTLRecord ptl;
> + uint16_t max_picture_width;
> + uint16_t max_picture_height;
> + uint16_t avg_frame_rate;
> + uint8_t num_of_arrays;
> + VVCCNALUnitArray *array;
> +} VVCDecoderConfigurationRecord;
> +
> +typedef struct VVCCProfileTierLevel {
> + uint8_t profile_idc;
> + uint8_t tier_flag;
> + uint8_t general_level_idc;
> + uint8_t ptl_frame_only_constraint_flag;
> + uint8_t ptl_multilayer_enabled_flag;
> +// general_constraint_info
> + uint8_t gci_present_flag;
> + unsigned __int128 gci_general_constraints;
not standard and not building
src/libavformat/vvc.c:78:14: error: ‘__int128’ is not supported on this target
unsigned __int128 gci_general_constraints;
^~~~~~~~
src/ffbuild/common.mak:81: recipe for target 'libavformat/vvc.o' failed
make: *** [libavformat/vvc.o] Error 1
make: *** Waiting for unfinished jobs....
if you really need 128bit ints there is libavutil/integer.h
but maybe you dont need 128bit ints
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
You can kill me, but you cannot change the truth.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20221019/4462cc53/attachment.sig>
More information about the ffmpeg-devel
mailing list