Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: add muxer support for H266/VVC

2024-01-29 Thread Thomas Siedel
On Fri, 26 Jan 2024 at 16:22, Nuo Mi  wrote:

>
>
> On Fri, Jan 26, 2024 at 10:04 PM Thomas Siedel 
> wrote:
>
>> Thanks for picking up the patch set!
>>
>> On Thu, 25 Jan 2024 at 13:26, Nuo Mi  wrote:
>>
>>> From: Thomas Siedel 
>>>
>>> Add muxer for vvcc byte stream format.
>>> Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
>>> Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
>>> vvc1 defined in ISO/IEC 14496-15:2021).
>>> Add VvcConfigurationBox vvcC which extends FullBox type in
>>> ISO/IEC 14496-15:2021.
>>> Add ff_vvc_muxer to RAW muxers.
>>>
>>> Tested with:
>>> ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v libvvenc test.mp4
>>> && ffmpeg -i test.mp4 -f null -
>>> ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v copy test.mp4
>>>  && ffmpeg -i test.mp4 -f md5 -
>>>
>>> Signed-off-by: Thomas Siedel 
>>> Co-Authored-By: Nuo Mi 
>>> ---
>>>  libavformat/Makefile|   6 +-
>>>  libavformat/isom.c  |   1 +
>>>  libavformat/isom_tags.c |   3 +
>>>  libavformat/mov.c   |   6 +
>>>  libavformat/movenc.c|  41 +-
>>>  libavformat/vvc.c   | 971 
>>>  libavformat/vvc.h   |  99 
>>>  7 files changed, 1123 insertions(+), 4 deletions(-)
>>>  create mode 100644 libavformat/vvc.c
>>>  create mode 100644 libavformat/vvc.h
>>>
>>> diff --git a/libavformat/Makefile b/libavformat/Makefile
>>> index dcc99eeac4..05b9b8a115 100644
>>> --- a/libavformat/Makefile
>>> +++ b/libavformat/Makefile
>>> @@ -343,7 +343,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  +=
>>> matroskadec.o matroska.o  \
>>>  oggparsevorbis.o
>>> vorbiscomment.o \
>>>  qtpalette.o replaygain.o
>>> dovi_isom.o
>>>  OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
>>> -av1.o avc.o hevc.o \
>>> +av1.o avc.o hevc.o vvc.o\
>>>  flacenc_header.o
>>> avlanguage.o \
>>>  vorbiscomment.o wv.o
>>> dovi_isom.o
>>>  OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
>>> @@ -365,7 +365,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
>>>  OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
>>>  OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o
>>> \
>>>  qtpalette.o replaygain.o
>>> dovi_isom.o
>>> -OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
>>> vpcc.o \
>>> +OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
>>> vvc.o vpcc.o \
>>>  movenchint.o mov_chan.o
>>> rtp.o \
>>>  movenccenc.o movenc_ttml.o
>>> rawutils.o \
>>>  dovi_isom.o evc.o
>>> @@ -520,7 +520,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o
>>>  \
>>>  rtpenc_vp8.o  \
>>>  rtpenc_vp9.o
>>> \
>>>  rtpenc_xiph.o \
>>> -avc.o hevc.o
>>> +avc.o hevc.o vvc.o
>>>  OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o
>>> \
>>>  urldecode.o
>>>  OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o
>>> \
>>> diff --git a/libavformat/isom.c b/libavformat/isom.c
>>> index 6d019881e5..9fbccd4437 100644
>>> --- a/libavformat/isom.c
>>> +++ b/libavformat/isom.c
>>> @@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
>>>  { AV_CODEC_ID_MPEG4   , 0x20 },
>>>  { AV_CODEC_ID_H264, 0x21 },
>>>  { AV_CODEC_ID_HEVC, 0x23 },
>>> +{ AV_CODEC_ID_VVC , 0x33 },
>>>  { AV_CODEC_ID_AAC , 0x40 },
>>>  { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
>>>  { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPE

Re: [FFmpeg-devel] [PATCH v3 1/6] avformat: add muxer support for H266/VVC

2024-01-29 Thread Thomas Siedel
On Sat, 27 Jan 2024 at 16:57, Nuo Mi  wrote:

>
>
> On Sat, Jan 27, 2024 at 10:38 PM James Almer  wrote:
>
>> On 1/27/2024 1:15 AM, Nuo Mi wrote:
>> > diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
>> > index a575b7c160..705811e950 100644
>> > --- a/libavformat/isom_tags.c
>> > +++ b/libavformat/isom_tags.c
>> > @@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>> >   { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based
>> Dolby Vision derived from hev1 */
>> >/* dvh1 is
>> handled within mov.c */
>> >
>> > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266
>> which indicates parameter sets may be in ES */
>> > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266
>> which indicates parameter shall not be in ES */
>> > +
>> >   { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
>> >   { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
>> >   { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') },
>>
>
>
>>
>> This list is for mov only, not mp4. You're already adding these two
>> entries to codec_mp4_tags[] bellow, for ISOBMFF.
>>
> Hi James,
> Thank you for the review.
> I guess not, @Thomas Siedel  ,  could you
> give us some insights?
> thank you.
>
>>
>> Are these defined anywhere in Apple's documentation?
>>
>
For mov I was only copy&pasting it from mp4 to be honest, without checking
the Apple documentation, sorry for that.

Therefore I guess these 2 entries should be removed from the
ff_codec_movvideo_tags table.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 2/5] avformat: add muxer support for H266/VVC

2024-01-26 Thread Thomas Siedel
On Fri, 5 Jan 2024 at 01:21, Nuo Mi  wrote:

> On Fri, Nov 3, 2023 at 5:58 PM Thomas Siedel 
> wrote:
>
> > Add muxer for vvcc byte stream format.
> > Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
> > Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
> > vvc1 defined in ISO/IEC 14496-15:2021).
> > Add VvcConfigurationBox vvcC which extends FullBox type in
> > ISO/IEC 14496-15:2021.
> > Add ff_vvc_muxer to RAW muxers.
> >
> > Signed-off-by: Thomas Siedel 
> > ---
> >  libavformat/Makefile|   6 +-
> >  libavformat/isom.c  |   1 +
> >  libavformat/isom_tags.c |   3 +
> >  libavformat/mov.c   |   6 +
> >  libavformat/movenc.c|  41 +-
> >  libavformat/vvc.c   | 998 
> >  libavformat/vvc.h   |  99 
> >  7 files changed, 1150 insertions(+), 4 deletions(-)
> >  create mode 100644 libavformat/vvc.c
> >  create mode 100644 libavformat/vvc.h
> >
> Hi Thomas,
> Thank you for the patch set. Could you please provide some small MP4 and
> MPEG files? We can add them to FATE.
>

Sorry for the late reply.  I created some files using two
different encoders. You can download them here:
https://drive.google.com/drive/folders/1v4PipPu9zc2RmwSndE3L3wCd9WHVVJ1j?usp=drive_link

Is this sufficient? Let me know if you need anything else / something more
specific.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 2/5] avformat: add muxer support for H266/VVC

2024-01-26 Thread Thomas Siedel
On Fri, 5 Jan 2024 at 01:31, James Almer  wrote:

> On 11/3/2023 6:57 AM, Thomas Siedel wrote:
> > Add muxer for vvcc byte stream format.
> > Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
> > Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
> > vvc1 defined in ISO/IEC 14496-15:2021).
> > Add VvcConfigurationBox vvcC which extends FullBox type in
> > ISO/IEC 14496-15:2021.
> > Add ff_vvc_muxer to RAW muxers.
> >
> > Signed-off-by: Thomas Siedel 
> > ---
> >   libavformat/Makefile|   6 +-
> >   libavformat/isom.c  |   1 +
> >   libavformat/isom_tags.c |   3 +
> >   libavformat/mov.c   |   6 +
> >   libavformat/movenc.c|  41 +-
> >   libavformat/vvc.c   | 998 
> >   libavformat/vvc.h   |  99 
> >   7 files changed, 1150 insertions(+), 4 deletions(-)
> >   create mode 100644 libavformat/vvc.c
> >   create mode 100644 libavformat/vvc.h
> >
> > diff --git a/libavformat/Makefile b/libavformat/Makefile
> > index 329055ccfd..595f6bdf08 100644
> > --- a/libavformat/Makefile
> > +++ b/libavformat/Makefile
> > @@ -341,7 +341,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  +=
> matroskadec.o matroska.o  \
> >   oggparsevorbis.o
> vorbiscomment.o \
> >   qtpalette.o replaygain.o
> dovi_isom.o
> >   OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
> > -av1.o avc.o hevc.o \
> > +av1.o avc.o hevc.o vvc.o\
> >   flacenc_header.o
> avlanguage.o \
> >   vorbiscomment.o wv.o
> dovi_isom.o
> >   OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
> > @@ -363,7 +363,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
> >   OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
> >   OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o
> mov_esds.o \
> >   qtpalette.o replaygain.o
> dovi_isom.o
> > -OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
> vpcc.o \
> > +OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
> vvc.o vpcc.o \
> >   movenchint.o mov_chan.o
> rtp.o \
> >   movenccenc.o movenc_ttml.o
> rawutils.o \
> >   dovi_isom.o evc.o
> > @@ -516,7 +516,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o
>  \
> >   rtpenc_vp8.o  \
> >   rtpenc_vp9.o
>   \
> >   rtpenc_xiph.o \
> > -avc.o hevc.o
> > +avc.o hevc.o vvc.o
> >   OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o
> httpauth.o \
> >   urldecode.o
> >   OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o
> httpauth.o \
> > diff --git a/libavformat/isom.c b/libavformat/isom.c
> > index 6d019881e5..9fbccd4437 100644
> > --- a/libavformat/isom.c
> > +++ b/libavformat/isom.c
> > @@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
> >   { AV_CODEC_ID_MPEG4   , 0x20 },
> >   { AV_CODEC_ID_H264, 0x21 },
> >   { AV_CODEC_ID_HEVC, 0x23 },
> > +{ AV_CODEC_ID_VVC , 0x33 },
> >   { AV_CODEC_ID_AAC , 0x40 },
> >   { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
> >   { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
> > diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
> > index a575b7c160..705811e950 100644
> > --- a/libavformat/isom_tags.c
> > +++ b/libavformat/isom_tags.c
> > @@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
> >   { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based
> Dolby Vision derived from hev1 */
> >/* dvh1 is
> handled within mov.c */
> >
> > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which
> indicates parameter sets may be in ES */
> > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c'

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat: add muxer support for H266/VVC

2024-01-26 Thread Thomas Siedel
Thanks for picking up the patch set!

On Thu, 25 Jan 2024 at 13:26, Nuo Mi  wrote:

> From: Thomas Siedel 
>
> Add muxer for vvcc byte stream format.
> Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
> Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
> vvc1 defined in ISO/IEC 14496-15:2021).
> Add VvcConfigurationBox vvcC which extends FullBox type in
> ISO/IEC 14496-15:2021.
> Add ff_vvc_muxer to RAW muxers.
>
> Tested with:
> ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v libvvenc test.mp4 &&
> ffmpeg -i test.mp4 -f null -
> ffmpeg -i NovosobornayaSquare_1920x1080.mp4 -c:v copy test.mp4 &&
> ffmpeg -i test.mp4 -f md5 -
>
> Signed-off-by: Thomas Siedel 
> Co-Authored-By: Nuo Mi 
> ---
>  libavformat/Makefile|   6 +-
>  libavformat/isom.c  |   1 +
>  libavformat/isom_tags.c |   3 +
>  libavformat/mov.c   |   6 +
>  libavformat/movenc.c|  41 +-
>  libavformat/vvc.c   | 971 
>  libavformat/vvc.h   |  99 
>  7 files changed, 1123 insertions(+), 4 deletions(-)
>  create mode 100644 libavformat/vvc.c
>  create mode 100644 libavformat/vvc.h
>
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index dcc99eeac4..05b9b8a115 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -343,7 +343,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  +=
> matroskadec.o matroska.o  \
>  oggparsevorbis.o
> vorbiscomment.o \
>  qtpalette.o replaygain.o
> dovi_isom.o
>  OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
> -av1.o avc.o hevc.o \
> +av1.o avc.o hevc.o vvc.o\
>  flacenc_header.o avlanguage.o
> \
>  vorbiscomment.o wv.o
> dovi_isom.o
>  OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
> @@ -365,7 +365,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
>  OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
>  OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
>  qtpalette.o replaygain.o
> dovi_isom.o
> -OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
> vpcc.o \
> +OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o
> vvc.o vpcc.o \
>  movenchint.o mov_chan.o rtp.o
> \
>  movenccenc.o movenc_ttml.o
> rawutils.o \
>  dovi_isom.o evc.o
> @@ -520,7 +520,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o
>\
>  rtpenc_vp8.o  \
>  rtpenc_vp9.o\
>  rtpenc_xiph.o \
> -avc.o hevc.o
> +avc.o hevc.o vvc.o
>  OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
>  urldecode.o
>  OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 6d019881e5..9fbccd4437 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
>  { AV_CODEC_ID_MPEG4   , 0x20 },
>  { AV_CODEC_ID_H264, 0x21 },
>  { AV_CODEC_ID_HEVC, 0x23 },
> +{ AV_CODEC_ID_VVC , 0x33 },
>  { AV_CODEC_ID_AAC , 0x40 },
>  { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
>  { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
> diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
> index a575b7c160..705811e950 100644
> --- a/libavformat/isom_tags.c
> +++ b/libavformat/isom_tags.c
> @@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
>  { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby
> Vision derived from hev1 */
>   /* dvh1 is handled
> within mov.c */
>
> +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which
> indicates parameter sets may be in ES */
> +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266 which
> indicates parameter shall not be in ES */
> +
>  { AV

[FFmpeg-devel] [PATCH v1 5/5] avcodec: add external decoder libvvdec for H266/VVC

2023-11-03 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.

Signed-off-by: Thomas Siedel 
---
 configure|6 +-
 fftools/ffmpeg_dec.c |3 +-
 libavcodec/Makefile  |1 +
 libavcodec/allcodecs.c   |1 +
 libavcodec/libvvdec.c|  567 +
 libavcodec/vvc_paramset.c| 1005 ++
 libavcodec/vvc_paramset.h|  307 +
 libavcodec/vvc_parse_extradata.c |  246 
 libavcodec/vvc_parse_extradata.h |   36 ++
 9 files changed, 2170 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index 69021a038b..37ca1c9ecf 100755
--- a/configure
+++ b/configure
@@ -286,6 +286,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable H.266/VVC decoding via vvdec [no]
   --enable-libvvencenable H.266/VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
@@ -1901,6 +1902,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libvvenc
 libwebp
 libxml2
@@ -3446,8 +3448,9 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libvvenc_encoder_deps="libvvenc"
-libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6857,6 +6860,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index fcee8b65ac..9b4e68e75c 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -301,7 +301,8 @@ static int video_frame_process(InputStream *ist, AVFrame 
*frame)
 // The following line may be required in some cases where there is no 
parser
 // or the parser does not has_b_frames correctly
 if (ist->par->video_delay < ist->dec_ctx->has_b_frames) {
-if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) {
+if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264 ||
+ist->dec_ctx->codec_id == AV_CODEC_ID_VVC) {
 ist->par->video_delay = ist->dec_ctx->has_b_frames;
 } else
 av_log(ist->dec_ctx, AV_LOG_WARNING,
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b2bec7a2c2..1a5acae064 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1140,6 +1140,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 2e8cb1f8fd..31a2fd2e97 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -805,6 +805,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern const FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..601855c40

[FFmpeg-devel] [PATCH v1 4/5] avcodec: increase minor version for H266/VVC

2023-11-03 Thread Thomas Siedel
Increase avcodec minor version for VVenC support.

Signed-off-by: Thomas Siedel 
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index d6f1440d54..62e7eba3db 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  32
+#define LIBAVCODEC_VERSION_MINOR  33
 #define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.34.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v1 2/5] avformat: add muxer support for H266/VVC

2023-11-03 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.

Signed-off-by: Thomas Siedel 
---
 libavformat/Makefile|   6 +-
 libavformat/isom.c  |   1 +
 libavformat/isom_tags.c |   3 +
 libavformat/mov.c   |   6 +
 libavformat/movenc.c|  41 +-
 libavformat/vvc.c   | 998 
 libavformat/vvc.h   |  99 
 7 files changed, 1150 insertions(+), 4 deletions(-)
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 329055ccfd..595f6bdf08 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -341,7 +341,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -363,7 +363,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o evc.o
@@ -516,7 +516,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index a575b7c160..705811e950 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266 which 
indicates parameter shall not be in ES */
+
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') },
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') },
diff --git a/libavformat/mov.c b/libavformat/mov.c
index e8efccf6eb..11b43ac135 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2117,6 +2117,11 @@ static int mov_read_glbl(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 if ((uint64_t)atom.size > (1<<30))
 return AVERROR_INVALIDDATA;
 
+if (atom.type == MKTAG('v','v','c','C')) {
+avio_rb32(pb);
+atom.size -= 4;
+}
+
 if (atom.size >= 10) {
 // Broken files created by legacy versions of libavformat

[FFmpeg-devel] [PATCH v1 3/5] avformat: add ts stream types for H266/VVC

2023-11-03 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.

Signed-off-by: Thomas Siedel 
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index dab6427b41..69021a038b 100755
--- a/configure
+++ b/configure
@@ -3521,7 +3521,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf rangecoder"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 781c3162d6..a0f2c6da05 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c7fd1f5d1f..bef00c88e7 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -812,6 +812,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -867,6 +868,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('V', 'A', 'N', 'C'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_2038 },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 84edd418f0..1ca3d49058 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -368,6 +368,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -467,6 +470,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE

[FFmpeg-devel] [PATCH v1 1/5] avcodec: add external encoder libvvenc for H266/VVC

2023-11-03 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Signed-off-by: Thomas Siedel 
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 500 +
 4 files changed, 507 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index 7afeebebcd..dab6427b41 100755
--- a/configure
+++ b/configure
@@ -286,6 +286,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1900,6 +1901,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3444,6 +3446,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6853,6 +6857,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ab7fba394a..b2bec7a2c2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1140,6 +1140,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 5136a566f1..2e8cb1f8fd 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -805,6 +805,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern const FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..14cbecea4a
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,500 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h"
+#include "libavutil/imgutils.h"
+#include "libavutil/frame.h"
+#include "libavut

[FFmpeg-devel] [PATCH v1 0/5] Add support for H266/VVC encoding

2023-11-03 Thread Thomas Siedel
This patch set adds H266/VVC encoding and muxing support. 
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.

As the counterpart to the encoder, decoding support via the external library
VVdeC (https://github.com/fraunhoferhhi/vvdec.git) is also added in the
last patch of the patch set. It can be enabled with --enable-libvvdec.
Although a native VVC decoder is in development, this additional VVdeC
decoder can be useful for streams with VVC tools that are not supported
by the native decoder yet. 

Thomas Siedel (5):
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add muxer support for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC

 configure|   11 +-
 fftools/ffmpeg_dec.c |3 +-
 libavcodec/Makefile  |2 +
 libavcodec/allcodecs.c   |2 +
 libavcodec/libvvdec.c|  567 +
 libavcodec/libvvenc.c|  500 +++
 libavcodec/version.h |2 +-
 libavcodec/vvc_paramset.c| 1005 ++
 libavcodec/vvc_paramset.h|  307 +
 libavcodec/vvc_parse_extradata.c |  246 
 libavcodec/vvc_parse_extradata.h |   36 ++
 libavformat/Makefile |6 +-
 libavformat/isom.c   |1 +
 libavformat/isom_tags.c  |3 +
 libavformat/mov.c|6 +
 libavformat/movenc.c |   41 +-
 libavformat/mpeg.c   |3 +
 libavformat/mpeg.h   |1 +
 libavformat/mpegts.c |2 +
 libavformat/mpegts.h |1 +
 libavformat/mpegtsenc.c  |   65 ++
 libavformat/vvc.c|  998 +
 libavformat/vvc.h|   99 +++
 23 files changed, 3900 insertions(+), 7 deletions(-)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h

-- 
2.34.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v7 00/11] Add support for H266/VVC

2023-07-03 Thread Thomas Siedel
On Thu, 29 Jun 2023 at 19:39, James Almer  wrote:

> On 3/21/2023 12:01 PM, Thomas Siedel wrote:
> > This patch set adds H266/VVC support.
> > This includes parsing, muxing, demuxing, decoding and encoding.
> > Decoding is done using the external library VVdeC
> > (https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
> > --enable-libvvdec.
> > Encoding is done using the external library VVenC
> > (https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
> > --enable-libvvenc.
> >
> > For conformance testing, the following JVET bitstreams can be used:
> >
> https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/draft_conformance/draft6/
> > DVB test streams can be found here:
> > https://dvb.org/specifications/verification-validation/vvc-test-content/
> > All JVET conformance bitstreams that are supported by VVdeC can be
> decoded.
> > Pallete mode and multi-layer streams are unsupported.
> > The DVB MP4 and TS reference files can be decoded as well.
>
> I have pushed patches 1 to 6, and the raw muxer part of 7. Will look at
> the ISOBMFF and ts stuff better later, as well as the encoder wrapper.
>

That is great, thank you for pushing the patches.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v5 04/10] avcodec: add MP4 to annexb support for H266/VVC

2023-02-10 Thread Thomas Siedel
On Wed, 1 Feb 2023 at 16:34, zhilizhao(赵志立)  wrote:

>
>
> > On Jan 3, 2023, at 21:40, Thomas Siedel 
> wrote:
> >
> > Add parser for VVC MP4 to Annex B byte stream format.
> >
> > Co-authored-by: Nuo Mi 
> > ---
> > configure|   1 +
> > libavcodec/Makefile  |   2 +
> > libavcodec/bitstream_filters.c   |   2 +
> > libavcodec/h266_metadata_bsf.c   | 146 ++
> > libavcodec/vvc_mp4toannexb_bsf.c | 329 +++
>
> Please add these bsfs in separate patches.
>

Thank you for your feedback.
I separated them now in the new patch set version 6.


> > 5 files changed, 480 insertions(+)
> > create mode 100644 libavcodec/h266_metadata_bsf.c
> > create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
>
> I don’t know the reason behind h265_metadata_bsf/hevc_mp4toannexb_bsf,
> but I prefer use the same prefix unless there are technical reasons.
> Such alias is annoying when browsing and searching the source code.
>

I took the naming of the HEVC implementation as an orientation.
But yes, I agree that this kind of mix might be problematic.
In the new patch set, I now decided on the ITU syntax and renamed all the
files and functions from vvc to h266 prefix.
With this, they are now also alphabetically close to h264 and hevc.
However, I did not rename the VVC_* enum types, because this would change a
lot of code, and I am worried that
this makes things more complicated when comparing different versions of the
code, e.g., for review.

What do you, and the other developers, think about this?
Which naming pattern would you prefer? Should the enums also be renamed?


> > --- a/libavcodec/bitstream_filters.c
> > +++ b/libavcodec/bitstream_filters.c
> > @@ -64,6 +64,8 @@ extern const FFBitStreamFilter ff_vp9_metadata_bsf;
> > extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
> > extern const FFBitStreamFilter ff_vp9_superframe_bsf;
> > extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
> > +extern const FFBitStreamFilter ff_vvc_mp4toannexb_bsf;
> > +extern const FFBitStreamFilter ff_vvc_metadata_bsf;
>
> Please sort by alphabetical order.
>

OK, this is done now in the new patch set version.


>
> >
> > #include "libavcodec/bsf_list.c"
> >
> > diff --git a/libavcodec/h266_metadata_bsf.c
> b/libavcodec/h266_metadata_bsf.c
> > new file mode 100644
> > index 00..f2bd2f31f3
> > --- /dev/null
> > +++ b/libavcodec/h266_metadata_bsf.c
> > @@ -0,0 +1,146 @@
> > +/*
> > + * 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 "libavutil/common.h"
> > +#include "libavutil/opt.h"
> > +
> > +#include "bsf.h"
> > +#include "bsf_internal.h"
> > +#include "cbs.h"
> > +#include "cbs_bsf.h"
> > +#include "cbs_h266.h"
> > +#include "vvc.h"
> > +
> > +#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL &&
> nut <= VVC_GDR_NUT))
> > +#define IS_PH(nut) (nut == VVC_PH_NUT)
>
> They are duplicated inside vvc_parser.c. How about add a prefix and share
> these macros?
>

Thank you for the suggestion.
I did it now in the new patch set version.


>
> > +
> > +typedef struct VVCMetadataContext {
> > +CBSBSFContext common;
> > +
> > +H266RawAUD aud_nal;
> > +
> > +int aud;
> > +} VVCMetadataContext;
> > +
> > +static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket
> *pkt,
> > + CodedBitstreamFragment *pu)
> > +{
> > +VVCMetadataContext *ctx = bsf->priv_data;
> > +int err, i;
> > +
> > +// If an AUD is present, it must be the first NAL unit.
> >

Re: [FFmpeg-devel] [PATCH v5 02/10] avcodec: add cbs for H266/VVC

2023-02-10 Thread Thomas Siedel
On Wed, 1 Feb 2023 at 09:21, "zhilizhao(赵志立)" 
wrote:

>
>
> > On Jan 3, 2023, at 21:40, Thomas Siedel 
> wrote:
> ...
> > diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> > index 4ee06003c3..8ae8ae6cda 100644
> > --- a/libavcodec/cbs_h2645.c
> > +++ b/libavcodec/cbs_h2645.c
> > @@ -24,10 +24,16 @@
> > #include "cbs_internal.h"
> > #include "cbs_h264.h"
> > #include "cbs_h265.h"
> > +#include "cbs_h266.h"
> > #include "h264.h"
> > #include "h2645_parse.h"
> > #include "hevc.h"
> > +#include "vvc.h"
> >
> > +static av_always_inline unsigned int h266_ceil(unsigned int v, unsigned
> int align)
> > +{
> > +return (((v) + (align) - 1) / (align));
> > +}
>
> Does AV_CEIL_RSHIFT() work for the usecase?
>
>
Yes, it can be used instead. Thank you for the suggestion.
I changed it now in the new version of the patch set.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 11/11] avcodec: increase minor version for H266/VVC

2023-02-10 Thread Thomas Siedel
Increase avcodec minor version for vvc support.
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 8c3d476003..5957009457 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR   0
+#define LIBAVCODEC_VERSION_MINOR   1
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 10/11] avformat: add ts stream types for H266/VVC

2023-02-10 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index d86161665c..568d709912 100755
--- a/configure
+++ b/configure
@@ -3472,7 +3472,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf h266_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 00ad426086..1bd2ea8485 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_PCM_BLURAY:
 stream_type = 0x80;
 break;
@@ -1783,6 +1791,21 @@ static int check_hevc_startcode(AVFormatContext *s, 
const AVStream *st, const AV
 return 0;
 }
 
+static int check_vvc_startcode(AVFormatContext *s, const AVStream *st, const 
AVPacket *pkt)
+{
+if (pkt->size < 5 || AV_RB32(pkt->data) != 0x001 && AV_RB24(pkt->data) 
!= 0x01) {
+if 

[FFmpeg-devel] [PATCH v6 09/11] avcodec: add external encoder libvvenc for H266/VVC

2023-02-10 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 469 +
 4 files changed, 476 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index 3bfbc963e6..d86161665c 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable H.266/VVC decoding via vvdec [no]
+  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1863,6 +1864,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3395,6 +3397,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="h266_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6723,6 +6727,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index aad301aeed..3397895124 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1124,6 +1124,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o h266_parse_extradata.o 
h266_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 99f22db57c..fbda2c1fa1 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -799,6 +799,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..52097aeaa8
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,469 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h"
+#include

[FFmpeg-devel] [PATCH v6 08/11] avcodec: add external decoder libvvdec for H266/VVC

2023-02-10 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.
---
 configure |5 +
 libavcodec/Makefile   |1 +
 libavcodec/allcodecs.c|1 +
 libavcodec/h266_paramset.c| 1005 +
 libavcodec/h266_paramset.h|  307 +
 libavcodec/h266_parse_extradata.c |  249 +++
 libavcodec/h266_parse_extradata.h |   36 ++
 libavcodec/libvvdec.c |  548 
 8 files changed, 2152 insertions(+)
 create mode 100644 libavcodec/h266_paramset.c
 create mode 100644 libavcodec/h266_paramset.h
 create mode 100644 libavcodec/h266_parse_extradata.c
 create mode 100644 libavcodec/h266_parse_extradata.h
 create mode 100644 libavcodec/libvvdec.c

diff --git a/configure b/configure
index e50ce5a484..3bfbc963e6 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable H.266/VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1861,6 +1862,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3391,6 +3393,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="h266_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6718,6 +6722,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8d227d21fa..aad301aeed 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1123,6 +1123,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o h266_parse_extradata.o 
h266_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b80b6983e9..99f22db57c 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -798,6 +798,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/h266_paramset.c b/libavcodec/h266_paramset.c
new file mode 100644
index 00..4e0e958750
--- /dev/null
+++ b/libavcodec/h266_paramset.c
@@ -0,0 +1,1005 @@
+/*
+ * H.266 / VVC Parameter Set decoding
+ *
+ * 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 &

[FFmpeg-devel] [PATCH v6 07/11] avformat: add muxer support for H266/VVC

2023-02-10 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 722dbf7ae8..e7b6f1dcb2 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -246,6 +246,7 @@ OBJS-$(CONFIG_H263_MUXER)+= rawenc.o
 OBJS-$(CONFIG_H264_DEMUXER)  += h264dec.o rawdec.o
 OBJS-$(CONFIG_H264_MUXER)+= rawenc.o
 OBJS-$(CONFIG_H266_DEMUXER)  += h266dec.o rawdec.o
+OBJS-$(CONFIG_H266_MUXER)+= rawenc.o
 OBJS-$(CONFIG_HASH_MUXER)+= hashenc.o
 OBJS-$(CONFIG_HCA_DEMUXER)   += hca.o
 OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
@@ -337,7 +338,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o h266.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -359,7 +360,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o h266.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -509,7 +510,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o h266.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 437616bf0f..2dd76dd07a 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -200,6 +200,7 @@ extern const FFOutputFormat ff_h263_muxer;
 extern const AVInputFormat  ff_h264_demuxer;
 extern const FFOutputFormat ff_h264_muxer;
 extern const AVInputFormat  ff_h266_demuxer;
+extern const FFOutputFormat ff_h266_muxer;
 extern const FFOutputFormat ff_hash_muxer;
 extern const AVInputFormat  ff_hca_demuxer;
 extern const AVInputFormat  ff_hcom_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266 which 
indicates parameter shall not be in ES */
+
 { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }

[FFmpeg-devel] [PATCH v6 06/11] avformat: add demuxer and probe support for H266/VVC

2023-02-10 Thread Thomas Siedel
Add demuxer to probe raw vvc and parse vvcc byte stream format.

Co-authored-by: Nuo Mi 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/demux.c  |   7 +-
 libavformat/h266.c   | 984 +++
 libavformat/h266.h   |  99 
 libavformat/h266dec.c|  61 +++
 6 files changed, 1151 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/h266.c
 create mode 100644 libavformat/h266.h
 create mode 100644 libavformat/h266dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 5d219afc06..722dbf7ae8 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -245,6 +245,7 @@ OBJS-$(CONFIG_H263_DEMUXER)  += h263dec.o 
rawdec.o
 OBJS-$(CONFIG_H263_MUXER)+= rawenc.o
 OBJS-$(CONFIG_H264_DEMUXER)  += h264dec.o rawdec.o
 OBJS-$(CONFIG_H264_MUXER)+= rawenc.o
+OBJS-$(CONFIG_H266_DEMUXER)  += h266dec.o rawdec.o
 OBJS-$(CONFIG_HASH_MUXER)+= hashenc.o
 OBJS-$(CONFIG_HCA_DEMUXER)   += hca.o
 OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 365d7f3428..437616bf0f 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -199,6 +199,7 @@ extern const AVInputFormat  ff_h263_demuxer;
 extern const FFOutputFormat ff_h263_muxer;
 extern const AVInputFormat  ff_h264_demuxer;
 extern const FFOutputFormat ff_h264_muxer;
+extern const AVInputFormat  ff_h266_demuxer;
 extern const FFOutputFormat ff_hash_muxer;
 extern const AVInputFormat  ff_hca_demuxer;
 extern const AVInputFormat  ff_hcom_demuxer;
diff --git a/libavformat/demux.c b/libavformat/demux.c
index b19ab86d08..f0c6d7895f 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/h266.c b/libavformat/h266.c
new file mode 100644
index 00..a012f0c579
--- /dev/null
+++ b/libavformat/h266.c
@@ -0,0 +1,984 @@
+/*
+ * H.266/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/h266.h"
+#include "libavutil/intreadwrite.h"
+#include "avc.h"
+#include "avio.h"
+#include "avio_internal.h"
+#include "h266.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_prof

[FFmpeg-devel] [PATCH v6 05/11] avcodec: add MP4 to annexb support for H266/VVC

2023-02-10 Thread Thomas Siedel
Add parser for H.266/VVC MP4 to Annex B byte stream format.
---
 libavcodec/Makefile   |   1 +
 libavcodec/bitstream_filters.c|   1 +
 libavcodec/h266_mp4toannexb_bsf.c | 329 ++
 3 files changed, 331 insertions(+)
 create mode 100644 libavcodec/h266_mp4toannexb_bsf.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4029e4f9e0..8d227d21fa 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1219,6 +1219,7 @@ OBJS-$(CONFIG_H264_METADATA_BSF)  += 
h264_metadata_bsf.o h264_levels.o \
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
 OBJS-$(CONFIG_H266_METADATA_BSF)  += h266_metadata_bsf.o
+OBJS-$(CONFIG_H266_MP4TOANNEXB_BSF)   += h266_mp4toannexb_bsf.o
 OBJS-$(CONFIG_HAPQA_EXTRACT_BSF)  += hapqa_extract_bsf.o hap.o
 OBJS-$(CONFIG_HEVC_METADATA_BSF)  += h265_metadata_bsf.o 
h265_profile_level.o \
  h2645data.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index 848f430014..e0e3116eb4 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -40,6 +40,7 @@ extern const FFBitStreamFilter ff_h264_metadata_bsf;
 extern const FFBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const FFBitStreamFilter ff_h264_redundant_pps_bsf;
 extern const FFBitStreamFilter ff_h266_metadata_bsf;
+extern const FFBitStreamFilter ff_h266_mp4toannexb_bsf;
 extern const FFBitStreamFilter ff_hapqa_extract_bsf;
 extern const FFBitStreamFilter ff_hevc_metadata_bsf;
 extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf;
diff --git a/libavcodec/h266_mp4toannexb_bsf.c 
b/libavcodec/h266_mp4toannexb_bsf.c
new file mode 100644
index 00..1f7bf0618d
--- /dev/null
+++ b/libavcodec/h266_mp4toannexb_bsf.c
@@ -0,0 +1,329 @@
+/*
+ * H.266/VVC MP4 to Annex B byte stream format filter
+ * 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 
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+
+#include "avcodec.h"
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "bytestream.h"
+#include "h266.h"
+
+#include "libavcodec/get_bits.h"
+
+#define MIN_VVCC_LENGTH 23
+
+typedef struct H266BSFContext {
+uint8_t length_size;
+int extradata_parsed;
+} H266BSFContext;
+
+static int h266_extradata_to_annexb(AVBSFContext *ctx)
+{
+GetByteContext gb;
+int length_size, num_arrays, i, j;
+int ret = 0;
+int temp = 0;
+int ptl_present;
+
+uint8_t *new_extradata = NULL;
+size_t new_extradata_size = 0;
+
+int max_picture_width = 0;
+int max_picture_height = 0;
+int avg_frame_rate = 0;
+
+bytestream2_init(&gb, ctx->par_in->extradata, ctx->par_in->extradata_size);
+temp = bytestream2_get_byte(&gb);
+length_size = ((temp & 6) >> 1) + 1;
+ptl_present = temp & 1;
+if (ptl_present) {
+int num_bytes_constraint_info;
+int general_profile_idc;
+int general_tier_flag;
+int general_level_idc;
+int ptl_frame_only_constraint_flag;
+int ptl_multi_layer_enabled_flag;
+int ptl_num_sub_profiles;
+int temp3, temp4, temp5;
+int temp2 = bytestream2_get_be16(&gb);
+int ols_idx = (temp2 >> 7) & 0x1ff;
+int num_sublayers = (temp2 >> 4) & 0x7;
+int constant_frame_rate = (temp2 >> 2) & 0x3;
+int chroma_format_idc = temp2 & 0x3;
+int bit_depth_minus8 = (bytestream2_get_byte(&gb) >> 5) & 0x7;
+av_log(ctx, AV_LOG_DEBUG,
+   "bit_depth_minus8 %d chroma_format_idc %d\n", bit_depth_minus8,
+   chroma_format_idc);
+av_log(ctx, AV_LOG_DEBUG, "constant_frame_rate %d, ols_idx %d\n",
+   constant_frame_rate, ols_idx);
+// VvcPTLRecord(num_sublayers) native_ptl
+temp3 = bytestream2_get_byte(&gb);
+num_bytes_constraint_info = (temp3) & 0x3f;
+temp4 = bytestream2_get_

[FFmpeg-devel] [PATCH v6 04/11] avcodec: add h266_metadata_bsf support for H266/VVC

2023-02-10 Thread Thomas Siedel
From: Nuo Mi 

Add H.266/VVC metadata bsf.
---
 configure  |   1 +
 libavcodec/Makefile|   1 +
 libavcodec/bitstream_filters.c |   1 +
 libavcodec/h266_metadata_bsf.c | 147 +
 4 files changed, 150 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c

diff --git a/configure b/configure
index f375ec2f5e..e50ce5a484 100755
--- a/configure
+++ b/configure
@@ -3283,6 +3283,7 @@ filter_units_bsf_select="cbs"
 h264_metadata_bsf_deps="const_nan"
 h264_metadata_bsf_select="cbs_h264"
 h264_redundant_pps_bsf_select="cbs_h264"
+h266_metadata_bsf_select="cbs_h266"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2cf4300575..4029e4f9e0 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1218,6 +1218,7 @@ OBJS-$(CONFIG_H264_METADATA_BSF)  += 
h264_metadata_bsf.o h264_levels.o \
  h2645data.o
 OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF)   += h264_mp4toannexb_bsf.o
 OBJS-$(CONFIG_H264_REDUNDANT_PPS_BSF) += h264_redundant_pps_bsf.o
+OBJS-$(CONFIG_H266_METADATA_BSF)  += h266_metadata_bsf.o
 OBJS-$(CONFIG_HAPQA_EXTRACT_BSF)  += hapqa_extract_bsf.o hap.o
 OBJS-$(CONFIG_HEVC_METADATA_BSF)  += h265_metadata_bsf.o 
h265_profile_level.o \
  h2645data.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index e8216819ca..848f430014 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -39,6 +39,7 @@ extern const FFBitStreamFilter ff_filter_units_bsf;
 extern const FFBitStreamFilter ff_h264_metadata_bsf;
 extern const FFBitStreamFilter ff_h264_mp4toannexb_bsf;
 extern const FFBitStreamFilter ff_h264_redundant_pps_bsf;
+extern const FFBitStreamFilter ff_h266_metadata_bsf;
 extern const FFBitStreamFilter ff_hapqa_extract_bsf;
 extern const FFBitStreamFilter ff_hevc_metadata_bsf;
 extern const FFBitStreamFilter ff_hevc_mp4toannexb_bsf;
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..05e476071f
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,147 @@
+/*
+ * 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 "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "h266.h"
+
+typedef struct H266MetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+} H266MetadataContext;
+
+static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *pu)
+{
+H266MetadataContext *ctx = bsf->priv_data;
+int err, i;
+
+// If an AUD is present, it must be the first NAL unit.
+if (pu->units[0].type == VVC_AUD_NUT) {
+if (ctx->aud == BSF_ELEMENT_REMOVE)
+ff_cbs_delete_unit(pu, 0);
+} else if ( pkt && ctx->aud == BSF_ELEMENT_INSERT) {
+const H266RawSlice *first_slice = NULL;
+const H266RawPH *ph = NULL;
+H266RawAUD *aud = &ctx->aud_nal;
+int pic_type = 0, temporal_id = 8, layer_id = 0;
+for (i = 0; i < pu->nb_units; i++) {
+const H266RawNALUnitHeader *nal = pu->units[i].content;
+if (!nal)
+continue;
+if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
+temporal_id = nal->nuh_temporal_id_plus1 - 1;
+if ( nal->nal_unit_type == VVC_PH_NUT ) {
+ph = pu->units[i].content;
+} else if (IS_H266_SLICE(nal->nal_unit_type)) {
+const H266RawSlice *slice = pu->units[i].content;
+layer_id = nal->nuh_layer_id;
+if (slice->header.sh_slice_type == VVC_SLICE_TYPE_B &&
+pic_type < 2)
+pic_type = 2;
+if (slice->header.sh_slice_type == VVC_SLICE_TYPE_P &&
+pic_type < 1)
+pic_type = 1;
+if (!first_slice) {
+first_slice = sl

[FFmpeg-devel] [PATCH v6 03/11] avcodec: add bitstream parser for H266/VVC

2023-02-10 Thread Thomas Siedel
From: Nuo Mi 

Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Co-authored-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/h266_parser.c | 601 +++
 libavcodec/parsers.c |   1 +
 5 files changed, 675 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/h266_parser.c

diff --git a/configure b/configure
index 1417df3772..f375ec2f5e 100755
--- a/configure
+++ b/configure
@@ -3266,6 +3266,7 @@ av1_amf_encoder_deps="amf"
 aac_parser_select="adts_header mpeg4audio"
 av1_parser_select="cbs_av1"
 h264_parser_select="golomb h264dsp h264parse h264_sei"
+h266_parser_select="cbs_h266"
 hevc_parser_select="hevcparse hevc_sei"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4971832ff4..2cf4300575 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1165,6 +1166,7 @@ OBJS-$(CONFIG_GSM_PARSER)  += gsm_parser.o
 OBJS-$(CONFIG_H261_PARSER) += h261_parser.o
 OBJS-$(CONFIG_H263_PARSER) += h263_parser.o
 OBJS-$(CONFIG_H264_PARSER) += h264_parser.o h264data.o
+OBJS-$(CONFIG_H266_PARSER) += h266_parser.o
 OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
 OBJS-$(CONFIG_HDR_PARSER)  += hdr_parser.o
 OBJS-$(CONFIG_IPU_PARSER)  += ipu_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..5261c3e568 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -30,6 +30,7 @@
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
+#include "h266.h"
 
 int ff_h2645_extract_rbsp(const uint8_t *src, int length,
   H2645RBSP *rbsp, H2645NAL *nal, int small_padding)
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const h266_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *h266_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return h266_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int h266_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = &nal->gb;
+
+if (get_bits1(gb) != 0) //forbidden_zero_bit
+return AVERROR_INVALIDDATA;
+
+skip_bits1(gb); //nuh_reserved_zero_bit
+
+nal->nuh_layer_id = get_bits(gb, 6);
+nal->type = get_bits(gb, 5);
+nal->temporal_id = get_bits(gb,

[FFmpeg-devel] [PATCH v6 01/11] avcodec: add enum types for H266/VVC

2023-02-10 Thread Thomas Siedel
From: Nuo Mi 

Add types as nal unit types, slice types and vvc typedefs needed
for parsing vvc high-level syntax.
---
 libavcodec/h266.h | 142 ++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/h266.h

diff --git a/libavcodec/h266.h b/libavcodec/h266.h
new file mode 100644
index 00..697592cf50
--- /dev/null
+++ b/libavcodec/h266.h
@@ -0,0 +1,142 @@
+/*
+ * H.266 / VVC shared code
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_H266_H
+#define AVCODEC_H266_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed at the be

[FFmpeg-devel] [PATCH v6 00/11] Add support for H266/VVC

2023-02-10 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.


Changes since v5:

general:
- align filename to h266 pattern ( feedback zhilizhao(赵志立) )
  - mv vvc_mp4toannexb_bsf h266_mp4toannexb_bsf
  - mv vvc_paramset h266_paramset
  - mv vvc.h/.c h266.h./c 
  - mv vvcdec h266dec
  - mv vvc_parse_extradata h266_parse_extradata
  - mv vvc_parser h266_parser
- rename functions in renamed files to h266 syntax
- split patch 4 into 2 seperated patches

PATCH 2/10  ( feedback zhilizhao(赵志立) )
  - cbs_h266_syntax_template: replacing h266_ceil() with
AV_CEIL_RSHIFT()
  - bugfix: cbs_h266_free_sei: using H266RawSEI instead of H265RawSEI

PATCH 3/10
  - bugfix: h266_parser.c parse_nal_units() parsing all frames correctly
(before frames could be missing)

PATCH 4/10 ( feedback zhilizhao(赵志立) )
  - mv vvc_mp4toannexb_bsf h266_mp4toannexb_bsf
  - add IS_H266_SLICE in cbs_h266.h (remove duplicate macro from
vvc_parser.c h266_metadata.bsf )
  - bitstream_filters.c sort FFBitStreamFilter
  - h266_metadata_update_fragment: check pkt!=NULL, replace else{ if() }
by else if()

split Patch 4 into separate patches
- PATCH 4 is now h266_metadata_bsf 
- PATCH 5 is h266_mp4toannexb_bsf 

PATH 8/10
 - cleanup h266_paramset.h ( remove duplicate structs from cbs_h266.h)


Nuo Mi (4):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC
  avcodec: add h266_metadata_bsf support for H266/VVC

Thomas Siedel (7):
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  370 ++-
 libavcodec/cbs_h266.h |  793 +++
 libavcodec/cbs_h266_syntax_template.c | 3096 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266.h |  142 ++
 libavcodec/h266_metadata_bsf.c|  147 ++
 libavcodec/h266_mp4toannexb_bsf.c |  329 +++
 libavcodec/h266_paramset.c| 1005 
 libavcodec/h266_paramset.h|  307 +++
 libavcodec/h266_parse_extradata.c |  249 ++
 libavcodec/h266_parse_extradata.h |   36 +
 libavcodec/h266_parser.c  |  601 +
 libavcodec/libvvdec.c |  548 +
 libavcodec/libvvenc.c |  469 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/h266.c|  984 
 libavformat/h266.h|   99 +
 libavformat/h266dec.c |   61 +
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 39 files changed, 9523 insertions(+), 12 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266.h
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/h266_mp4toannexb_bsf.c
 create mode 100644 libavcodec/h266_paramset.c
 create mode 100644 libavcodec/h266_paramset.h
 create mode 100644 libavcodec/h266_parse_extradata.c
 create mode 100644 libavcodec/h266_parse_extradata.h
 create mode 100644 libavcodec/h266_parser.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavformat/h266.c
 create mode 100644 libavformat/h266.h
 create mode 100644 libavformat/h266dec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg

Re: [FFmpeg-devel] [PATCH v1 00/11] Add support for H266/VVC

2023-01-03 Thread Thomas Siedel
On Thu, 15 Dec 2022 at 10:11, Thomas Siedel 
wrote:

> On Tue, 13 Dec 2022 at 07:19, Nuo Mi  wrote:
>
>> Hi Thomas,
>> Thank you for sending the patch set.
>> It seems the patchset is based on
>> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3487
>> Please do not change the author's name.
>>
>> thank you
>>
>
> Some code regarding VVC parsing is based on another FFmpeg fork. This fork
> had been based on your patch set, it seems.
> On top of this, I did additional modifications to the parsing code and
> added the other code regarding format support and the decoder and encoder
> integration.
>
> It was not my intent to hide you as an author of the parsing code.
> Your patch set has been in an unmerged state for over 1.5 years now
> without new progress, so I assumed that these patches are kind of
> discontinued.
> Therefore I started submitting my own patchset to get VVC integrated into
> FFmpeg.
> I kept your original copyright notices in libavformat/vvcdec.c and
> livavcodec/vvc_parser.c.
> Apart from this, I am not sure how / where else this could be documented
> and how other authors can be appropriately referenced.
>
> Could you explain in more detail what you mean by changing the author's
> name?
> Do you have any suggestions on what to do in this case or how to change it?
>
>
I just submitted a new version of the patch set.
Among other changes, I now put you as the author of the first three
patches, as most of their content is based on your original patch set.
I made some modifications to them, so I added myself as a co-author.
For patches 4 and 5, I put you as the co-author because some of their
content is based on your original patch set, but only to a smaller extent.
All other patches are independent.

I hope that this solution is OK for you. If not, please let me know.


>
> On Wed, Oct 19, 2022 at 3:26 PM  wrote:
>>
>>> From: Thomas Siedel 
>>>
>>> This patch set adds H266/VVC support.
>>> This includes parsing, muxing, demuxing, decoding and encoding.
>>> Decoding is done using the external library VVdeC
>>> (https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
>>> --enable-libvvdec.
>>> Encoding is done using the external library VVenC
>>> (https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
>>> --enable-libvvenc.
>>>
>>> Thomas Siedel (11):
>>>   avcodec: add enum types for H266/VVC
>>>   avcodec: add cbs for H266/VVC
>>>   avcodec: enable cbs for H266/VVC
>>>   avcodec: add bitstream parser for H266/VVC
>>>   avcodec: add MP4 to annexb support for H266/VVC
>>>   avformat: add demuxer and probe support for H266/VVC
>>>   avformat: add muxer support for H266/VVC
>>>   avcodec: add external decoder libvvdec for H266/VVC
>>>   avcodec: add external encoder libvvenc for H266/VVC
>>>   avformat: add ts stream types for H266/VVC
>>>   avcodec: increase minor version for H266/VVC
>>>
>>>  configure |   16 +-
>>>  libavcodec/Makefile   |6 +
>>>  libavcodec/allcodecs.c|2 +
>>>  libavcodec/bitstream_filters.c|2 +
>>>  libavcodec/cbs.c  |6 +
>>>  libavcodec/cbs_h2645.c|  384 +++-
>>>  libavcodec/cbs_h266.h |  791 +++
>>>  libavcodec/cbs_h266_syntax_template.c | 3010 +
>>>  libavcodec/cbs_internal.h |3 +-
>>>  libavcodec/cbs_sei.c  |   29 +
>>>  libavcodec/h2645_parse.c  |   71 +-
>>>  libavcodec/h266_metadata_bsf.c|  145 ++
>>>  libavcodec/libvvdec.c |  511 +
>>>  libavcodec/libvvenc.c |  432 
>>>  libavcodec/parsers.c  |1 +
>>>  libavcodec/version.h  |2 +-
>>>  libavcodec/vvc.h  |  142 ++
>>>  libavcodec/vvc_mp4toannexb_bsf.c  |  318 +++
>>>  libavcodec/vvc_paramset.c |  972 
>>>  libavcodec/vvc_paramset.h |  429 
>>>  libavcodec/vvc_parse_extradata.c  |  241 ++
>>>  libavcodec/vvc_parse_extradata.h  |   36 +
>>>  libavcodec/vvc_parser.c   |  588 +
>>>  libavformat/Makefile  |8 +-
>>>  libavformat/allformats.c  |2 +
>>>  libavformat/demux.c   |7 +-
>>>  libavformat/isom.c|1 +
>>>  libavformat/isom_tags.c

[FFmpeg-devel] [PATCH v5 09/10] avformat: add ts stream types for H266/VVC

2023-01-03 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index c89c42241a..e648a88c1a 100755
--- a/configure
+++ b/configure
@@ -3470,7 +3470,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..85546f6a49 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_PCM_BLURAY:
 stream_type = 0x80;
 break;
@@ -1783,6 +1791,21 @@ static int check_hevc_startcode(AVFormatContext *s, 
const AVStream *st, const AV
 return 0;
 }
 
+static int check_vvc_startcode(AVFormatContext *s, const AVStream *st, const 
AVPacket *pkt)
+{
+if (pkt->size < 5 || AV_RB32(pkt->data) != 0x001 && AV_RB24(pkt->data) 
!= 0x01) {
+if (

[FFmpeg-devel] [PATCH v5 07/10] avcodec: add external decoder libvvdec for H266/VVC

2023-01-03 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.
---
 configure|5 +
 libavcodec/Makefile  |1 +
 libavcodec/allcodecs.c   |1 +
 libavcodec/libvvdec.c|  548 
 libavcodec/vvc_paramset.c| 1005 ++
 libavcodec/vvc_paramset.h|  429 +
 libavcodec/vvc_parse_extradata.c |  249 
 libavcodec/vvc_parse_extradata.h |   36 ++
 8 files changed, 2274 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index 776a972663..d62cd579b6 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1861,6 +1862,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3389,6 +3391,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6711,6 +6715,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 2dee099f25..79f363b129 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1114,6 +1114,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b009848a44..b73939f6be 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..bd16d15571
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,548 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * 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 "config_components.h&qu

[FFmpeg-devel] [PATCH v5 08/10] avcodec: add external encoder libvvenc for H266/VVC

2023-01-03 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 469 +
 4 files changed, 476 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index d62cd579b6..c89c42241a 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable VVC decoding via vvdec [no]
+  --enable-libvvencenable VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1863,6 +1864,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3393,6 +3395,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="vvc_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6716,6 +6720,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 79f363b129..4a40419656 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1115,6 +1115,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b73939f6be..cc56ebe400 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -795,6 +795,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..a503a6ff0d
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,469 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h"
+#include "libavutil/i

[FFmpeg-devel] [PATCH v5 06/10] avformat: add muxer support for H266/VVC

2023-01-03 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 00ab4ded89..9ee2526eef 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -336,7 +336,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -358,7 +358,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -508,7 +508,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
@@ -596,6 +596,7 @@ 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_VVC_MUXER) += rawenc.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 5fce5b4774..9ca9e9e9eb 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -478,6 +478,7 @@ 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 AVOutputFormat ff_vvc_muxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') },  /* VVC/H.266 which 
indicates parameter shall not be in ES */
+
 { AV_CODEC_ID_H264, MKTAG('a

[FFmpeg-devel] [PATCH v5 05/10] avformat: add demuxer and probe support for H266/VVC

2023-01-03 Thread Thomas Siedel
Add demuxer to probe raw vvc and parse vvcc byte stream format.

Co-authored-by: Nuo Mi 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/demux.c  |   7 +-
 libavformat/vvc.c| 984 +++
 libavformat/vvc.h|  99 
 libavformat/vvcdec.c |  61 +++
 6 files changed, 1151 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 62262ae935..5fce5b4774 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -477,6 +477,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..ce112705c3
--- /dev/null
+++ b/libavformat/vvc.c
@@ -0,0 +1,984 @@
+/*
+ * 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_prof

[FFmpeg-devel] [PATCH v5 10/10] avcodec: increase minor version for H266/VVC

2023-01-03 Thread Thomas Siedel
Increase avcodec minor version for vvc support.
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 6b8a1dbb79..dfd3d5d7e5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  56
+#define LIBAVCODEC_VERSION_MINOR  57
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v5 04/10] avcodec: add MP4 to annexb support for H266/VVC

2023-01-03 Thread Thomas Siedel
  if (slice->header.sh_slice_type == VVC_SLICE_TYPE_B &&
+pic_type < 2)
+pic_type = 2;
+if (slice->header.sh_slice_type == VVC_SLICE_TYPE_P &&
+pic_type < 1)
+pic_type = 1;
+if (!first_slice) {
+first_slice = slice;
+if (first_slice->header.
+sh_picture_header_in_slice_header_flag)
+ph = &first_slice->header.sh_picture_header;
+else if (!ph)
+break;
+}
+}
+}
+if (!ph) {
+av_log(bsf, AV_LOG_ERROR, "no avaliable picture header");
+return AVERROR_INVALIDDATA;
+}
+
+aud->nal_unit_header = (H266RawNALUnitHeader) {
+.nal_unit_type = VVC_AUD_NUT,
+.nuh_layer_id  = layer_id,
+.nuh_temporal_id_plus1 = temporal_id + 1,
+};
+aud->aud_pic_type = pic_type;
+aud->aud_irap_or_gdr_flag = ph->ph_gdr_or_irap_pic_flag;
+
+err = ff_cbs_insert_unit_content(pu, 0, VVC_AUD_NUT, aud, NULL);
+if (err < 0) {
+av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
+return err;
+}
+}
+}
+return 0;
+}
+
+static const CBSBSFType h266_metadata_type = {
+.codec_id= AV_CODEC_ID_VVC,
+.fragment_name   = "access unit",
+.unit_name   = "NAL unit",
+.update_fragment = &h266_metadata_update_fragment,
+};
+
+static int vvc_metadata_init(AVBSFContext *bsf)
+{
+return ff_cbs_bsf_generic_init(bsf, &h266_metadata_type);
+}
+
+#define OFFSET(x) offsetof(VVCMetadataContext, x)
+#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
+static const AVOption vvc_metadata_options[] = {
+BSF_ELEMENT_OPTIONS_PIR("aud", "Access Unit Delimiter NAL units",
+aud, FLAGS),
+
+{ NULL }
+};
+
+static const AVClass vvc_metadata_class = {
+.class_name = "vvc_metadata_bsf",
+.item_name  = av_default_item_name,
+.option = vvc_metadata_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static const enum AVCodecID vvc_metadata_codec_ids[] = {
+AV_CODEC_ID_VVC, AV_CODEC_ID_NONE,
+};
+
+const FFBitStreamFilter ff_vvc_metadata_bsf = {
+.p.name = "vvc_metadata",
+.p.codec_ids= vvc_metadata_codec_ids,
+.p.priv_class   = &vvc_metadata_class,
+.priv_data_size = sizeof(VVCMetadataContext),
+.init   = &vvc_metadata_init,
+.close  = &ff_cbs_bsf_generic_close,
+.filter = &ff_cbs_bsf_generic_filter,
+};
diff --git a/libavcodec/vvc_mp4toannexb_bsf.c b/libavcodec/vvc_mp4toannexb_bsf.c
new file mode 100644
index 00..bdf40b531f
--- /dev/null
+++ b/libavcodec/vvc_mp4toannexb_bsf.c
@@ -0,0 +1,329 @@
+/*
+ * VVC MP4 to Annex B byte stream format filter
+ * 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 
+
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+
+#include "avcodec.h"
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "bytestream.h"
+#include "vvc.h"
+
+#include "libavcodec/get_bits.h"
+
+#define MIN_VVCC_LENGTH 23
+
+typedef struct VVCBSFContext {
+uint8_t length_size;
+int extradata_parsed;
+} VVCBSFContext;
+
+static int vvc_extradata_to_annexb(AVBSFContext *ctx)
+{
+GetByteContext gb;
+int length_size, num_arrays, i, j;
+int ret = 0;
+int temp = 0;
+int ptl_present;
+
+uint8_t *new_extradata = NULL;
+size_t new_extradata_size = 0;
+
+int max_picture_width = 0;
+int max_picture_height = 0;
+int avg_frame_rate = 0;
+
+bytestream2_init(&gb, ctx->par_in->extradata, ctx->par_in->extradata_size);
+temp = bytestream2_get_byte(&gb);
+

[FFmpeg-devel] [PATCH v5 03/10] avcodec: add bitstream parser for H266/VVC

2023-01-03 Thread Thomas Siedel
From: Nuo Mi 

Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Co-authored-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/parsers.c |   1 +
 libavcodec/vvc_parser.c  | 603 +++
 5 files changed, 677 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index 3cb2936901..2408dca0f5 100755
--- a/configure
+++ b/configure
@@ -3268,6 +3268,7 @@ hevc_parser_select="hevcparse hevc_sei"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+vvc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3ab448dd49..3e858b200b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1184,6 +1185,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XBM_PARSER)  += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..9fbeee3edd 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = &nal->gb;
+
+if (get_bits1(gb) != 0) //forbidden_zero_bit
+return AVERROR_INVALIDDATA;
+
+skip_bits1(gb); //nuh_reserved_zero_bit
+
+nal->nuh_layer_id = get_bits(gb, 6);
+nal->type = get_bits(gb, 5);
+nal->temporal_id = get_bits(gb, 3) - 1;
+if (nal->temporal_id < 0)
+return AVERROR_INVALIDDATA;
+
+if ((nal->type >= VVC_IDR_W_RADL && nal->type <=

[FFmpeg-devel] [PATCH v5 01/10] avcodec: add enum types for H266/VVC

2023-01-03 Thread Thomas Siedel
From: Nuo Mi 

Add types as nal unit types, slice types and vvc typedefs needed
for parsing vvc high-level syntax.
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..586934a7bf
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed at the beginning of eve

[FFmpeg-devel] [PATCH v5 00/10] Add support for H266/VVC

2023-01-03 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.

Changes since v4:

General:
- Add original author to patches 01-03
- Add co-author to patches 04 and 05

PATCH 02/10 configure / cbs_h266_syntax_template
- bugfix: add cbs_h266, cbs_h266_select (moved from patch 03/10)
- bugfix: parsing multilayer in cbs_h265_syntax_template

PATCH 03/10 libavcodec/vvc_parser.c
- bugfix: check startcode length (3 or 4 byte) to 
  find correct frame end position

PATCH 06/10 libavformat/movenc.c
- merge movenc.c with upstream

PATCH 07/10 libavcodec/libvvdec.c
- bugfix: set correct avframe pts for decoded picture
- bugfix: print additional info if decoding fails

Nuo Mi (3):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC

Thomas Siedel (7):
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  373 ++-
 libavcodec/cbs_h266.h |  791 +++
 libavcodec/cbs_h266_syntax_template.c | 3096 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266_metadata_bsf.c|  146 ++
 libavcodec/libvvdec.c |  548 +
 libavcodec/libvvenc.c |  469 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_mp4toannexb_bsf.c  |  329 +++
 libavcodec/vvc_paramset.c | 1005 
 libavcodec/vvc_paramset.h |  429 
 libavcodec/vvc_parse_extradata.c  |  249 ++
 libavcodec/vvc_parse_extradata.h  |   36 +
 libavcodec/vvc_parser.c   |  603 +
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 libavformat/vvc.c |  984 
 libavformat/vvc.h |   99 +
 libavformat/vvcdec.c  |   61 +
 39 files changed, 9648 insertions(+), 11 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 00/11] Add support for H266/VVC

2022-12-15 Thread Thomas Siedel
On Tue, 13 Dec 2022 at 07:19, Nuo Mi  wrote:

> Hi Thomas,
> Thank you for sending the patch set.
> It seems the patchset is based on
> https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=3487
> Please do not change the author's name.
>
> thank you
>

Some code regarding VVC parsing is based on another FFmpeg fork. This fork
had been based on your patch set, it seems.
On top of this, I did additional modifications to the parsing code and
added the other code regarding format support and the decoder and encoder
integration.

It was not my intent to hide you as an author of the parsing code.
Your patch set has been in an unmerged state for over 1.5 years now without
new progress, so I assumed that these patches are kind of discontinued.
Therefore I started submitting my own patchset to get VVC integrated into
FFmpeg.
I kept your original copyright notices in libavformat/vvcdec.c and
livavcodec/vvc_parser.c.
Apart from this, I am not sure how / where else this could be documented
and how other authors can be appropriately referenced.

Could you explain in more detail what you mean by changing the author's
name?
Do you have any suggestions on what to do in this case or how to change it?


On Wed, Oct 19, 2022 at 3:26 PM  wrote:
>
>> From: Thomas Siedel 
>>
>> This patch set adds H266/VVC support.
>> This includes parsing, muxing, demuxing, decoding and encoding.
>> Decoding is done using the external library VVdeC
>> (https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
>> --enable-libvvdec.
>> Encoding is done using the external library VVenC
>> (https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
>> --enable-libvvenc.
>>
>> Thomas Siedel (11):
>>   avcodec: add enum types for H266/VVC
>>   avcodec: add cbs for H266/VVC
>>   avcodec: enable cbs for H266/VVC
>>   avcodec: add bitstream parser for H266/VVC
>>   avcodec: add MP4 to annexb support for H266/VVC
>>   avformat: add demuxer and probe support for H266/VVC
>>   avformat: add muxer support for H266/VVC
>>   avcodec: add external decoder libvvdec for H266/VVC
>>   avcodec: add external encoder libvvenc for H266/VVC
>>   avformat: add ts stream types for H266/VVC
>>   avcodec: increase minor version for H266/VVC
>>
>>  configure |   16 +-
>>  libavcodec/Makefile   |6 +
>>  libavcodec/allcodecs.c|2 +
>>  libavcodec/bitstream_filters.c|2 +
>>  libavcodec/cbs.c  |6 +
>>  libavcodec/cbs_h2645.c|  384 +++-
>>  libavcodec/cbs_h266.h |  791 +++
>>  libavcodec/cbs_h266_syntax_template.c | 3010 +
>>  libavcodec/cbs_internal.h |3 +-
>>  libavcodec/cbs_sei.c  |   29 +
>>  libavcodec/h2645_parse.c  |   71 +-
>>  libavcodec/h266_metadata_bsf.c|  145 ++
>>  libavcodec/libvvdec.c |  511 +
>>  libavcodec/libvvenc.c |  432 
>>  libavcodec/parsers.c  |1 +
>>  libavcodec/version.h  |2 +-
>>  libavcodec/vvc.h  |  142 ++
>>  libavcodec/vvc_mp4toannexb_bsf.c  |  318 +++
>>  libavcodec/vvc_paramset.c |  972 
>>  libavcodec/vvc_paramset.h |  429 
>>  libavcodec/vvc_parse_extradata.c  |  241 ++
>>  libavcodec/vvc_parse_extradata.h  |   36 +
>>  libavcodec/vvc_parser.c   |  588 +
>>  libavformat/Makefile  |8 +-
>>  libavformat/allformats.c  |2 +
>>  libavformat/demux.c   |7 +-
>>  libavformat/isom.c|1 +
>>  libavformat/isom_tags.c   |3 +
>>  libavformat/mov.c |6 +
>>  libavformat/movenc.c  |   41 +-
>>  libavformat/mpeg.c|3 +
>>  libavformat/mpeg.h|1 +
>>  libavformat/mpegts.c  |2 +
>>  libavformat/mpegts.h  |1 +
>>  libavformat/mpegtsenc.c   |   65 +
>>  libavformat/rawenc.c  |   23 +
>>  libavformat/vvc.c |  918 
>>  libavformat/vvc.h |   99 +
>>  libavformat/vvcdec.c  |   61 +
>>  39 files changed, 9366 insertions(+), 12 deletions(-)
>>  create mode 100644 libavcodec/cbs_h266.h
>>  create mode 100644 libavcodec/cbs_h266_syntax_template.c
>>  create mode 100644 libavcodec/h266_metadata_bsf.c
>>  create mode 100644 libavcode

Re: [FFmpeg-devel] [PATCH v3 05/10] avformat: add demuxer and probe support for H266/VVC

2022-11-15 Thread Thomas Siedel
On Mon, 7 Nov 2022 at 03:28, myp...@gmail.com  wrote:

> On Thu, Nov 3, 2022 at 8:23 PM Thomas Siedel 
> wrote:
> >
> > 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| 919 +++
> >  libavformat/vvc.h|  99 +
> >  libavformat/vvcdec.c |  61 +++
> >  6 files changed, 1086 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..b27a522009
> > --- /dev/null
> > +++ b/libavformat/vvc.c
> > @@ -0,0 +1,919 @@
> > +/*
> > + * 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

[FFmpeg-devel] [PATCH v4 09/10] avformat: add ts stream types for H266/VVC

2022-11-15 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.

Signed-off-by: Thomas Siedel 
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index c004f697b0..8f19e850a0 100755
--- a/configure
+++ b/configure
@@ -3476,7 +3476,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..85546f6a49 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+  

[FFmpeg-devel] [PATCH v4 07/10] avcodec: add external decoder libvvdec for H266/VVC

2022-11-15 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.

Signed-off-by: Thomas Siedel 
---
 configure|5 +
 libavcodec/Makefile  |1 +
 libavcodec/allcodecs.c   |1 +
 libavcodec/libvvdec.c|  544 
 libavcodec/vvc_paramset.c| 1005 ++
 libavcodec/vvc_paramset.h|  429 +
 libavcodec/vvc_parse_extradata.c |  249 
 libavcodec/vvc_parse_extradata.h |   36 ++
 8 files changed, 2270 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index be432247ad..20f626b4a2 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1875,6 +1876,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3395,6 +3397,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6721,6 +6725,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ee99d7e407..863ece22d5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1105,6 +1105,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f5ec3bc6e1..eda5ce3c43 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -793,6 +793,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..45c7ecb858
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,544 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * 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
+ */
+
+#inc

[FFmpeg-devel] [PATCH v4 08/10] avcodec: add external encoder libvvenc for H266/VVC

2022-11-15 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Signed-off-by: Thomas Siedel 
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 469 +
 4 files changed, 476 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index 20f626b4a2..c004f697b0 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable VVC decoding via vvdec [no]
+  --enable-libvvencenable VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3399,6 +3401,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="vvc_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6726,6 +6730,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 863ece22d5..dfce7d4966 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1106,6 +1106,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index eda5ce3c43..3eb24a40ba 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..a503a6ff0d
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,469 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h&qu

[FFmpeg-devel] [PATCH v4 06/10] avformat: add muxer support for H266/VVC

2022-11-15 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.

Signed-off-by: Thomas Siedel 
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 00ab4ded89..9ee2526eef 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -336,7 +336,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -358,7 +358,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -508,7 +508,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
@@ -596,6 +596,7 @@ 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_VVC_MUXER) += rawenc.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 a4e3822681..006a7dc125 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -475,6 +475,7 @@ 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 AVOutputFormat ff_vvc_muxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG(&#

[FFmpeg-devel] [PATCH v4 05/10] avformat: add demuxer and probe support for H266/VVC

2022-11-15 Thread 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| 984 +++
 libavformat/vvc.h|  99 
 libavformat/vvcdec.c |  61 +++
 6 files changed, 1151 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..ce112705c3
--- /dev/null
+++ b/libavformat/vvc.c
@@ -0,0 +1,984 @@
+/*
+ * 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_prof

[FFmpeg-devel] [PATCH v4 10/10] avcodec: increase minor version for H266/VVC

2022-11-15 Thread Thomas Siedel
Increase avcodec minor version for vvc support.

Signed-off-by: Thomas Siedel 
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 480dbd3b67..27620d6432 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  52
+#define LIBAVCODEC_VERSION_MINOR  53
 #define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v4 04/10] avcodec: add MP4 to annexb support for H266/VVC

2022-11-15 Thread Thomas Siedel
Add parser for VVC MP4 to Annex B byte stream format.

Signed-off-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/bitstream_filters.c   |   2 +
 libavcodec/h266_metadata_bsf.c   | 146 ++
 libavcodec/vvc_mp4toannexb_bsf.c | 329 +++
 5 files changed, 480 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c

diff --git a/configure b/configure
index bd11b67949..be432247ad 100755
--- a/configure
+++ b/configure
@@ -3292,6 +3292,7 @@ mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs"
 vp9_metadata_bsf_select="cbs_vp9"
+vvc_metadata_bsf_select="cbs_h266"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8eea3bf243..ee99d7e407 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1225,6 +1225,8 @@ OBJS-$(CONFIG_VP9_METADATA_BSF)   += 
vp9_metadata_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
+OBJS-$(CONFIG_VVC_METADATA_BSF)   += h266_metadata_bsf.o
+OBJS-$(CONFIG_VVC_MP4TOANNEXB_BSF)+= vvc_mp4toannexb_bsf.o
 
 # thread libraries
 OBJS-$(HAVE_LIBC_MSVCRT)   += file_open.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index a3bebefe5f..403884f3d7 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -64,6 +64,8 @@ extern const FFBitStreamFilter ff_vp9_metadata_bsf;
 extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
+extern const FFBitStreamFilter ff_vvc_mp4toannexb_bsf;
+extern const FFBitStreamFilter ff_vvc_metadata_bsf;
 
 #include "libavcodec/bsf_list.c"
 
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..f2bd2f31f3
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,146 @@
+/*
+ * 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 "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "vvc.h"
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+#define IS_PH(nut) (nut == VVC_PH_NUT)
+
+typedef struct VVCMetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+} VVCMetadataContext;
+
+static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *pu)
+{
+VVCMetadataContext *ctx = bsf->priv_data;
+int err, i;
+
+// If an AUD is present, it must be the first NAL unit.
+if (pu->units[0].type == VVC_AUD_NUT) {
+if (ctx->aud == BSF_ELEMENT_REMOVE)
+ff_cbs_delete_unit(pu, 0);
+} else {
+if (ctx->aud == BSF_ELEMENT_INSERT) {
+const H266RawSlice *first_slice = NULL;
+const H266RawPH *ph = NULL;
+H266RawAUD *aud = &ctx->aud_nal;
+int pic_type = 0, temporal_id = 8, layer_id = 0;
+for (i = 0; i < pu->nb_units; i++) {
+const H266RawNALUnitHeader *nal = pu->units[i].content;
+if (!nal)
+continue;
+if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
+temporal_id = nal->nuh_temporal_id_plus1 - 1;
+if (IS_PH(nal->nal_unit_type)) {
+ph = pu->units[i].content;
+} else if (IS_SLICE(nal->nal_unit_type)) {
+const H266RawSlice *slice = pu->units[i].content;
+layer_id = nal->nuh_layer_id;
+  

[FFmpeg-devel] [PATCH v4 03/10] avcodec: add bitstream parser for H266/VVC

2022-11-15 Thread Thomas Siedel
Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Signed-off-by: Thomas Siedel 
---
 configure|   3 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/parsers.c |   1 +
 libavcodec/vvc_parser.c  | 601 +++
 5 files changed, 677 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index e6470dc03b..bd11b67949 100755
--- a/configure
+++ b/configure
@@ -2447,6 +2447,7 @@ CONFIG_EXTRA="
 cbs_av1
 cbs_h264
 cbs_h265
+cbs_h266
 cbs_jpeg
 cbs_mpeg2
 cbs_vp9
@@ -2727,6 +2728,7 @@ threads_if_any="$THREADS_LIST"
 cbs_av1_select="cbs"
 cbs_h264_select="cbs"
 cbs_h265_select="cbs"
+cbs_h266_select="cbs"
 cbs_jpeg_select="cbs"
 cbs_mpeg2_select="cbs"
 cbs_vp9_select="cbs"
@@ -3272,6 +3274,7 @@ hevc_parser_select="hevcparse"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+vvc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 94dc75a1b2..8eea3bf243 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1175,6 +1176,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XBM_PARSER)  += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..9fbeee3edd 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = &nal->gb;
+
+if (

[FFmpeg-devel] [PATCH v4 01/10] avcodec: add enum types for H266/VVC

2022-11-15 Thread Thomas Siedel
Add types as nal unit types, slice types and vvc typedefs needed
for parsing vvc high-level syntax.

Signed-off-by: Thomas Siedel 
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..586934a7bf
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed at the

[FFmpeg-devel] [PATCH v4 00/10] Add support for H266/VVC

2022-11-15 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.

Changes since v3:

PATCH 01-09/10:
- code formating/indent: 'indent -i4 -kr -nut -l80'
- cleanup auto formated files

PATCH 07/10 libavcodec/libvvdec.c
- replacing FFCodec.p.longname with macro CODEC_LONG_NAME

PATCH 08/10 libavcodec/libvvenc.c
- replacing FFCodec.p.longname with macro CODEC_LONG_NAME

Thomas Siedel (10):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  373 ++-
 libavcodec/cbs_h266.h |  791 +++
 libavcodec/cbs_h266_syntax_template.c | 3095 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266_metadata_bsf.c|  146 ++
 libavcodec/libvvdec.c |  544 +
 libavcodec/libvvenc.c |  469 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_mp4toannexb_bsf.c  |  329 +++
 libavcodec/vvc_paramset.c | 1005 
 libavcodec/vvc_paramset.h |  429 
 libavcodec/vvc_parse_extradata.c  |  249 ++
 libavcodec/vvc_parse_extradata.h  |   36 +
 libavcodec/vvc_parser.c   |  601 +
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 libavformat/vvc.c |  984 
 libavformat/vvc.h |   99 +
 libavformat/vvcdec.c  |   61 +
 39 files changed, 9641 insertions(+), 11 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 08/10] avcodec: add external encoder libvvenc for H266/VVC

2022-11-03 Thread Thomas Siedel
On Mon, 24 Oct 2022 at 16:38, quietvoid  wrote:

> On 24/10/2022 10.06, Thomas Siedel wrote:
>
> > Add external encoder VVenC for H266/VVC encoding.
> > Register new encoder libvvencc
> > Add libvvenc to wrap the vvenc interface into ffmpeg
> > libvvenc implements encoder option:
> > preset,qp,period,subjopt,vvenc-params,levelidc,tier
> > Enable encoder by adding --enable-libvvenc in configure step
> >
> > Signed-off-by: Thomas Siedel
> > ---
> > configure | 5 +
> > libavcodec/Makefile | 1 +
> > libavcodec/allcodecs.c | 1 +
> > libavcodec/libvvenc.c | 442 +
> > 4 files changed, 449 insertions(+)
> > create mode 100644 libavcodec/libvvenc.c
> >
> > diff --git a/configure b/configure
> > index 978f15f772..f8f7965371 100755
> > --- a/configure
> > +++ b/configure
> > @@ -289,6 +289,7 @@ External library support:
> > native implementation exists [no]
> > --enable-libvpx enable VP8 and VP9 de/encoding via libvpx [no]
> > --enable-libvvdec enable VVC decoding via vvdec [no]
> > + --enable-libvvenc enable VVC encoding via vvenc [no]
> > --enable-libwebp enable WebP encoding via libwebp [no]
> > --enable-libx264 enable H.264 encoding via x264 [no]
> > --enable-libx265 enable HEVC encoding via x265 [no]
> > @@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST="
> > libvorbis
> > libvpx
> > libvvdec
> > + libvvenc
> > libwebp
> > libxml2
> > libzimg
> > @@ -3409,6 +3411,8 @@ libvpx_vp9_decoder_deps="libvpx"
> > libvpx_vp9_encoder_deps="libvpx"
> > libvvdec_decoder_deps="libvvdec"
> > libvvdec_decoder_select="vvc_mp4toannexb_bsf"
> > +libvvenc_encoder_deps="libvvenc"
> > +libvvenc_encoder_select="atsc_a53"
> > libwebp_encoder_deps="libwebp"
> > libwebp_anim_encoder_deps="libwebp"
> > libx262_encoder_deps="libx262"
> > @@ -6740,6 +6744,7 @@ enabled libvpx && {
> > fi
> > }
> > enabled libvvdec && require_pkg_config libvvdec "libvvdec >= 1.6.0"
> > "vvdec/vvdec.h" vvdec_get_version
> > +enabled libvvenc && require_pkg_config libvvenc "libvvenc >= 1.6.1"
> > "vvenc/vvenc.h" vvenc_get_version
> > enabled libwebp && {
> > enabled libwebp_encoder && require_pkg_config libwebp "libwebp >=
> > 0.2.0" webp/encode.h WebPGetEncoderVersion
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index f4cdbc9be1..badd266e66 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1105,6 +1105,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
> > OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
> > OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
> > OBJS-$(CONFIG_LIBVVDEC_DECODER) += libvvdec.o vvc_parse_extradata.o
> > vvc_paramset.o
> > +OBJS-$(CONFIG_LIBVVENC_ENCODER) += libvvenc.o
> > OBJS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.o libwebpenc.o
> > OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER) += libwebpenc_common.o
> > libwebpenc_animencoder.o
> > OBJS-$(CONFIG_LIBX262_ENCODER) += libx264.o
> > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> > index 9813b291f4..73c36f3134 100644
> > --- a/libavcodec/allcodecs.c
> > +++ b/libavcodec/allcodecs.c
> > @@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
> > extern FFCodec ff_libvpx_vp9_encoder;
> > extern FFCodec ff_libvpx_vp9_decoder;
> > extern const FFCodec ff_libvvdec_decoder;
> > +extern const FFCodec ff_libvvenc_encoder;
> > /* preferred over libwebp */
> > extern const FFCodec ff_libwebp_anim_encoder;
> > extern const FFCodec ff_libwebp_encoder;
> > diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
> > new file mode 100644
> > index 00..508fe6ceff
> > --- /dev/null
> > +++ b/libavcodec/libvvenc.c
> > @@ -0,0 +1,442 @@
> > +/*
> > + * H.266 encoding using the VVenC library
> > + *
> > + * 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

Re: [FFmpeg-devel] [PATCH v2 03/10] avcodec: add bitstream parser for H266/VVC

2022-11-03 Thread Thomas Siedel
On Mon, 31 Oct 2022 at 21:02, James Almer  wrote:

> On 10/31/2022 7:16 AM, Thomas Siedel wrote:
> > On Mon, 24 Oct 2022 at 16:38, James Almer  wrote:
> >
> >> On 10/24/2022 11:06 AM, Thomas Siedel wrote:
> >>> +static int combine_au(AVCodecParserContext *ctx, AVCodecContext
> *avctx,
> >>> +  const uint8_t **buf, int *buf_size)
> >>> +{
> >>
> >> This is being called only when you first assembled AUs from what's
> >> assumed to be raw input. When PARSER_FLAG_COMPLETE_FRAMES is set, it
> >> should also parse the AU for bitstream information.
> >>
> >
> > Yes, currently, "combine_au" is only called when
> > PARSER_FLAG_COMPLETE_FRAMES is disabled, but I do not really understand
> > what the issue is here.
>
> I'm not talking about combine_au() but parse_nal_units(), which is only
> called from within combine_au(). My comment was about bitstream parsing,
> not AU assembling. Apologies if it wasn't clear.
>
> > As far as I know, all bitstream information is parsed properly for any
> kind
> > of supported content (currently, ES, MP4, and TS are supported).
> > Would you happen to have an example of a use case where
> > PARSER_FLAG_COMPLETE_FRAMES is enabled, and the bitstream information is
> > needed or not parsed correctly from the current implementation?
>
> libavformat and its demuxers are not the only user of AVCodecParsers.
>
> >
> >   The current behavior is pretty similar to other codec
> > parser implementations like hevc, avc, and av1. Why should the vvc parser
> > code differ from the (default) behavior of other codecs?
>
> Both h264 and hevc parsers call parse_nal_units() regardless of
> PARSER_FLAG_COMPLETE_FRAMES being set or not.
>
> AVCodecParsers have two purposes. One is assembling a full packet for a
> given timestamp (access unit for these codecs, temporal unit for av1,
> the like) depending on the value of AVCodecParserContext.flags, and the
> other is parsing the full packet for bitstream information. If a parser
> does the latter, it should do it regardless of having assembled a packet
> before that or not.
> The parser doesn't know where the packet came from. It could have been a
> lavf demuxer, or it could have been from some other lavc user, because
> this API after all is from lavc and not lavf. So it must always fill the
> AVCodecParserContext struct with the parsed information if it's present
> and readable.
>
> If i set the PARSER_FLAG_COMPLETE_FRAMES flag, this parser as you wrote
> it is a no-op.
>

It seems I misunderstood your previous comment, but now it is clear. Thanks
for the explanation.

I now changed the implementation, it is included in version 3 of the patch
set.
combine_au() has been moved so that it is always called when the input
buffer is valid.
Now, this should be the same behavior as in other codecs.


> >
> >
> >>> +VVCParserContext *s = ctx->priv_data;
> >>> +CodedBitstreamFragment *pu = &s->picture_unit;
> >>> +int ret;
> >>> +
> >>> +s->cbc->log_ctx = avctx;
> >>> +
> >>> +if (avctx->extradata_size && !s->parsed_extradata) {
> >>> +s->parsed_extradata = 1;
> >>> +
> >>> +if ((ret = ff_cbs_read(s->cbc, pu, avctx->extradata,
> >> avctx->extradata_size)) < 0)
> >>
> >> ff_cbs_read_extradata_from_codec()
>

Thanks for pointing this out. I am now using
ff_cbs_read_extradata_from_codec instead of ff_cbs_read.
The code has been moved into vvc_parser_parse.
In older versions, the vvc_parser_parse function returned an error with
'AVERROR_PATCHWELCOME', so
that the extradata parsing couldn´t be reached.
Now ff_cbs_read_extradata_from_codec has been moved here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 10/10] avcodec: increase minor version for H266/VVC

2022-11-03 Thread Thomas Siedel
Increase avcodec minor version for vvc support.

Signed-off-by: Thomas Siedel 
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index 43d0d9a9fc..c3f344e46a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  51
+#define LIBAVCODEC_VERSION_MINOR  52
 #define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 09/10] avformat: add ts stream types for H266/VVC

2022-11-03 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream.
Add basic transport stream support for TS mux/demux.

Signed-off-by: Thomas Siedel 
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 8e3d11bca5..c5a11a6ed3 100755
--- a/configure
+++ b/configure
@@ -3485,7 +3485,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..85546f6a49 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+  

[FFmpeg-devel] [PATCH v3 08/10] avcodec: add external encoder libvvenc for H266/VVC

2022-11-03 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvenc.
Add libvvenc to wrap the vvenc interface.
libvvenc implements encoder option: preset,qp,period,subjopt,
vvenc-params,levelidc,tier.
Enable encoder by adding --enable-libvvenc in configure step.

Signed-off-by: Thomas Siedel 
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 449 +
 4 files changed, 456 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index 5893c81cf4..8e3d11bca5 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable VVC decoding via vvdec [no]
+  --enable-libvvencenable VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3409,6 +3411,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="vvc_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6734,6 +6738,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9d2107050f..c4efdfb76c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1104,6 +1104,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 9813b291f4..73c36f3134 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..b5de063110
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,449 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "libavutil/common.h&qu

[FFmpeg-devel] [PATCH v3 07/10] avcodec: add external decoder libvvdec for H266/VVC

2022-11-03 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec.
Add vvc_parse_extradata to support parse/probe of vvcC stream input.
Add vvc_paramset that implements the parser of vvcC configuration boxes.
Add libvvdec to wrap the vvdec interface.
Enable decoder by adding --enable-libvvdec in configure step.

Signed-off-by: Thomas Siedel 
---
 configure|   5 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libvvdec.c| 511 
 libavcodec/vvc_paramset.c| 972 +++
 libavcodec/vvc_paramset.h| 429 ++
 libavcodec/vvc_parse_extradata.c | 242 
 libavcodec/vvc_parse_extradata.h |  36 ++
 8 files changed, 2197 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index 7dbc939ed9..5893c81cf4 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1875,6 +1876,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3405,6 +3407,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6729,6 +6733,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c3789277e2..9d2107050f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1103,6 +1103,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4f1d66cb0c..9813b291f4 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -793,6 +793,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..28f3a548ca
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,511 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * 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 "

[FFmpeg-devel] [PATCH v3 06/10] avformat: add muxer support for H266/VVC

2022-11-03 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type.
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1,
vvc1 defined in ISO/IEC 14496-15:2021).
Add VvcConfigurationBox vvcC which extends FullBox type in
ISO/IEC 14496-15:2021.
Add ff_vvc_muxer to RAW muxers.

Signed-off-by: Thomas Siedel 
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 00ab4ded89..9ee2526eef 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -336,7 +336,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -358,7 +358,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -508,7 +508,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
@@ -596,6 +596,7 @@ 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_VVC_MUXER) += rawenc.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 a4e3822681..006a7dc125 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -475,6 +475,7 @@ 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 AVOutputFormat ff_vvc_muxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG(&#

[FFmpeg-devel] [PATCH v3 05/10] avformat: add demuxer and probe support for H266/VVC

2022-11-03 Thread 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| 919 +++
 libavformat/vvc.h|  99 +
 libavformat/vvcdec.c |  61 +++
 6 files changed, 1086 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..b27a522009
--- /dev/null
+++ b/libavformat/vvc.c
@@ -0,0 +1,919 @@
+/*
+ * 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  ge

[FFmpeg-devel] [PATCH v3 04/10] avcodec: add MP4 to annexb support for H266/VVC

2022-11-03 Thread Thomas Siedel
Add parser for VVC MP4 to Annex B byte stream format.

Signed-off-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/bitstream_filters.c   |   2 +
 libavcodec/h266_metadata_bsf.c   | 145 ++
 libavcodec/vvc_mp4toannexb_bsf.c | 319 +++
 5 files changed, 469 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c

diff --git a/configure b/configure
index 5fac892afb..7dbc939ed9 100755
--- a/configure
+++ b/configure
@@ -3302,6 +3302,7 @@ mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs"
 vp9_metadata_bsf_select="cbs_vp9"
+vvc_metadata_bsf_select="cbs_h266"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f7e3ffb412..c3789277e2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1223,6 +1223,8 @@ OBJS-$(CONFIG_VP9_METADATA_BSF)   += 
vp9_metadata_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
+OBJS-$(CONFIG_VVC_METADATA_BSF)   += h266_metadata_bsf.o
+OBJS-$(CONFIG_VVC_MP4TOANNEXB_BSF)+= vvc_mp4toannexb_bsf.o
 
 # thread libraries
 OBJS-$(HAVE_LIBC_MSVCRT)   += file_open.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index a3bebefe5f..403884f3d7 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -64,6 +64,8 @@ extern const FFBitStreamFilter ff_vp9_metadata_bsf;
 extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
+extern const FFBitStreamFilter ff_vvc_mp4toannexb_bsf;
+extern const FFBitStreamFilter ff_vvc_metadata_bsf;
 
 #include "libavcodec/bsf_list.c"
 
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..bc3c10f581
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,145 @@
+/*
+ * 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 "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "vvc.h"
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+#define IS_PH(nut) (nut == VVC_PH_NUT)
+
+typedef struct VVCMetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+} VVCMetadataContext;
+
+static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *pu)
+{
+VVCMetadataContext *ctx = bsf->priv_data;
+int err, i;
+
+// If an AUD is present, it must be the first NAL unit.
+if (pu->units[0].type == VVC_AUD_NUT) {
+if (ctx->aud == BSF_ELEMENT_REMOVE)
+ff_cbs_delete_unit(pu, 0);
+} else {
+if (ctx->aud == BSF_ELEMENT_INSERT) {
+const H266RawSlice *first_slice = NULL;
+const H266RawPH*ph = NULL;
+H266RawAUD *aud = &ctx->aud_nal;
+int pic_type = 0, temporal_id = 8, layer_id = 0;
+for (i = 0; i < pu->nb_units; i++) {
+const H266RawNALUnitHeader *nal = pu->units[i].content;
+if (!nal)
+continue;
+if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
+temporal_id = nal->nuh_temporal_id_plus1 - 1;
+if (IS_PH(nal->nal_unit_type)) {
+ph = pu->units[i].content;
+} else if(IS_SLICE(nal->nal_unit_type)) {
+const H266RawSlice *slice = pu->units[i].content;
+layer_id = nal->nuh_layer_id;
+  

[FFmpeg-devel] [PATCH v3 03/10] avcodec: add bitstream parser for H266/VVC

2022-11-03 Thread Thomas Siedel
Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Signed-off-by: Thomas Siedel 
---
 configure|   3 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/parsers.c |   1 +
 libavcodec/vvc_parser.c  | 591 +++
 5 files changed, 667 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index 30f0ce4e26..5fac892afb 100755
--- a/configure
+++ b/configure
@@ -2447,6 +2447,7 @@ CONFIG_EXTRA="
 cbs_av1
 cbs_h264
 cbs_h265
+cbs_h266
 cbs_jpeg
 cbs_mpeg2
 cbs_vp9
@@ -2728,6 +2729,7 @@ threads_if_any="$THREADS_LIST"
 cbs_av1_select="cbs"
 cbs_h264_select="cbs"
 cbs_h265_select="cbs"
+cbs_h266_select="cbs"
 cbs_jpeg_select="cbs"
 cbs_mpeg2_select="cbs"
 cbs_vp9_select="cbs"
@@ -3282,6 +3284,7 @@ hevc_parser_select="hevcparse"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+vvc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 72d2f92901..f7e3ffb412 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1173,6 +1174,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XBM_PARSER)  += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..9fbeee3edd 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = &nal->gb;
+
+if (

[FFmpeg-devel] [PATCH v3 01/10] avcodec: add enum types for H266/VVC

2022-11-03 Thread Thomas Siedel
Add types as nal unit types, slice types and vvc typedefs needed
for parsing vvc high-level syntax.

Signed-off-by: Thomas Siedel 
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..19979b7017
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed at the

[FFmpeg-devel] [PATCH v3 00/10] Add support for H266/VVC

2022-11-03 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc

Changes since v2:

PATCH 03/10 libavcodec/vvc_parser.c
- fixing behavior of vvc_parser_parse ( always call parse_nal_units
  for valid buffer )
- using ff_cbs_read_extradata_from_codec instead of ff_cbs_read and
  move code to correct position
- cleanup: use AVCodecParserContext *s instead of
  AVCodecParserContext *ctx, to align to other parser
implementations

PATCH 04/10 libavcodec/vvc_mp4toannexb_bsf.c
- fix parsing of OPI and DCI NUTs in vvcC box

PATCH 07/10 libavcodec/vvc_parse_extradata.c
- fix parsing of OPI and DCI NUTs in ff_vvc_decode_extradata

PATCH 08/10 libavcodec/libvvenc.c
- use AVColor enum for hdr initialization
- fix hlg mode init, depending on color primaries
- set correct sdr bt709 mode

 General:
- adapt commit messages ( add line breaks for long bodies in commit
  message )

Thomas Siedel (10):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  373 ++-
 libavcodec/cbs_h266.h |  791 +++
 libavcodec/cbs_h266_syntax_template.c | 3010 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266_metadata_bsf.c|  145 ++
 libavcodec/libvvdec.c |  511 +
 libavcodec/libvvenc.c |  449 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_mp4toannexb_bsf.c  |  319 +++
 libavcodec/vvc_paramset.c |  972 
 libavcodec/vvc_paramset.h |  429 
 libavcodec/vvc_parse_extradata.c  |  242 ++
 libavcodec/vvc_parse_extradata.h  |   36 +
 libavcodec/vvc_parser.c   |  591 +
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 libavformat/vvc.c |  919 
 libavformat/vvc.h |   99 +
 libavformat/vvcdec.c  |   61 +
 39 files changed, 9377 insertions(+), 11 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 03/10] avcodec: add bitstream parser for H266/VVC

2022-10-31 Thread Thomas Siedel
On Mon, 24 Oct 2022 at 16:38, James Almer  wrote:

> On 10/24/2022 11:06 AM, Thomas Siedel wrote:
> > +static int combine_au(AVCodecParserContext *ctx, AVCodecContext *avctx,
> > +  const uint8_t **buf, int *buf_size)
> > +{
>
> This is being called only when you first assembled AUs from what's
> assumed to be raw input. When PARSER_FLAG_COMPLETE_FRAMES is set, it
> should also parse the AU for bitstream information.
>

Yes, currently, "combine_au" is only called when
PARSER_FLAG_COMPLETE_FRAMES is disabled, but I do not really understand
what the issue is here.
As far as I know, all bitstream information is parsed properly for any kind
of supported content (currently, ES, MP4, and TS are supported).
Would you happen to have an example of a use case where
PARSER_FLAG_COMPLETE_FRAMES is enabled, and the bitstream information is
needed or not parsed correctly from the current implementation?

 The current behavior is pretty similar to other codec
parser implementations like hevc, avc, and av1. Why should the vvc parser
code differ from the (default) behavior of other codecs?


> > +VVCParserContext *s = ctx->priv_data;
> > +CodedBitstreamFragment *pu = &s->picture_unit;
> > +int ret;
> > +
> > +s->cbc->log_ctx = avctx;
> > +
> > +if (avctx->extradata_size && !s->parsed_extradata) {
> > +s->parsed_extradata = 1;
> > +
> > +if ((ret = ff_cbs_read(s->cbc, pu, avctx->extradata,
> avctx->extradata_size)) < 0)
>
> ff_cbs_read_extradata_from_codec()
>
> > +av_log(avctx, AV_LOG_WARNING, "Failed to parse
> extradata.\n");
> > +
> > +ff_cbs_fragment_reset(pu);
> > +}
> > +av_packet_unref(&s->last_au);
> > +ret = parse_nal_units(ctx, *buf, *buf_size, avctx);
> > +if (ret == 0) {
> > +if (s->last_au.size) {
> > +*buf = s->last_au.data;
> > +*buf_size = s->last_au.size;
> > +} else {
> > +//no output
> > +ret = 1;
> > +}
> > +}
> > +s->cbc->log_ctx = NULL;
> > +return ret;
> > +}
> > +
> > +static int vvc_parser_parse(AVCodecParserContext *ctx, AVCodecContext
> *avctx,
> > +  const uint8_t **poutbuf, int *poutbuf_size,
> > +  const uint8_t *buf, int buf_size)
> > +{
> > +int next;
> > +VVCParserContext *s = ctx->priv_data;
> > +ParseContext *pc = &s->pc;
> > +
> > +if (avctx->extradata && !s->parsed_extradata) {
> > +av_log(avctx, AV_LOG_INFO, "extra data is not supported
> yet.\n");
> > +return AVERROR_PATCHWELCOME;
> > +}
> > +
> > +if (ctx->flags & PARSER_FLAG_COMPLETE_FRAMES) {
> > +next = buf_size;
> > +} else {
> > +int ret, flush = !buf_size;
> > +next = find_frame_end(ctx, buf, buf_size);
> > +if (ff_combine_frame(pc, next, &buf, &buf_size) < 0)
> > +goto no_out;
> > +ret = combine_au(ctx, avctx, &buf, &buf_size);
> > +if (ret > 0 && flush) {
> > +buf_size = 0;
> > +ret = combine_au(ctx, avctx, &buf, &buf_size);
> > +}
> > +if (ret != 0) {
> > +buf_size = next;
> > +goto no_out;
> > +}
> > +}
> > +*poutbuf  = buf;
> > +*poutbuf_size = buf_size;
> > +return next;
> > +no_out:
> > +*poutbuf  = NULL;
> > +*poutbuf_size = 0;
> > +return buf_size;
> > +}
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 03/11] avcodec: enable cbs for H266/VVC

2022-10-24 Thread Thomas Siedel
On Thu, 20 Oct 2022 at 01:07, James Almer  wrote:

> On 10/19/2022 4:25 AM, thomas...@spin-digital.com wrote:
> > From: Thomas Siedel 
> >
> > Add ff_cbs_type_h266 to cbs types tables and AV_CODEC_ID_H266 to cbs
> codec ids.
> > Change CBS_MAX_UNIT_TYPES to 8 as VVC implements 8 different slice types
> >
> > Signed-off-by: Thomas Siedel 
> > ---
> >   libavcodec/Makefile   | 1 +
> >   libavcodec/cbs.c  | 6 ++
> >   libavcodec/cbs_internal.h | 3 ++-
> >   3 files changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index c7dc5da0f9..b3fcf173e9 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o
> cbs_bsf.o
> >   OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
> >   OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> >   OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> > +OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
>
> CONFIG_CBS_H266 is undefined. You need to add cbs_h266 to configure here
> instead of in patch 4/11, even if no module selects it just yet.
>
> Also, this patch should be squashed with patch 2/11.
>

Thank you for your feedback, I did not notice this before. I now changed it
as you suggested and also combined patches 2 and 3.
The changes are included in the new version of the patch set that I just
submitted.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v1 06/11] avformat: add demuxer and probe support for H266/VVC

2022-10-24 Thread Thomas Siedel
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 l

[FFmpeg-devel] [PATCH v2 07/10] avcodec: add external decoder libvvdec for H266/VVC

2022-10-24 Thread Thomas Siedel
Add external decoder VVdeC for H266/VVC decoding.
Register new decoder libvvdec
Add vvc_parse_extradata to support parse/probe of vvcC stream input
Add vvc_paramset that implements the parser of vvcC configuration boxes
Add libvvdec to wrap the vvdec interface into ffmpeg
libvvdec implements decoder option externmem to use AVBufferPool (default) or 
copy image after receiving from decoder
Enable decoder by adding --enable-libvvdec in configure step

Signed-off-by: Thomas Siedel 
---
 configure|   5 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libvvdec.c| 511 
 libavcodec/vvc_paramset.c| 972 +++
 libavcodec/vvc_paramset.h| 429 ++
 libavcodec/vvc_parse_extradata.c | 241 
 libavcodec/vvc_parse_extradata.h |  36 ++
 8 files changed, 2196 insertions(+)
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h

diff --git a/configure b/configure
index 4d54ce2a93..978f15f772 100755
--- a/configure
+++ b/configure
@@ -288,6 +288,7 @@ External library support:
   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
+  --enable-libvvdecenable VVC decoding via vvdec [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1875,6 +1876,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3405,6 +3407,8 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+libvvdec_decoder_deps="libvvdec"
+libvvdec_decoder_select="vvc_mp4toannexb_bsf"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6735,6 +6739,7 @@ enabled libvpx&& {
 die "libvpx enabled but no supported decoders found"
 fi
 }
+enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index c6652e5e09..f4cdbc9be1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1104,6 +1104,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
 OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
+OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4f1d66cb0c..9813b291f4 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -793,6 +793,7 @@ extern const FFCodec ff_libvpx_vp8_encoder;
 extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
+extern const FFCodec ff_libvvdec_decoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvdec.c b/libavcodec/libvvdec.c
new file mode 100644
index 00..28f3a548ca
--- /dev/null
+++ b/libavcodec/libvvdec.c
@@ -0,0 +1,511 @@
+/*
+ * H.266 decoding using the VVdeC library
+ *
+ * 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 

[FFmpeg-devel] [PATCH v2 10/10] avcodec: increase minor version for H266/VVC

2022-10-24 Thread Thomas Siedel
Increase avcodec minor version for vvc support.

Signed-off-by: Thomas Siedel 
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index f8abc803b6..86ac0f3871 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  51
+#define LIBAVCODEC_VERSION_MINOR  52
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 08/10] avcodec: add external encoder libvvenc for H266/VVC

2022-10-24 Thread Thomas Siedel
Add external encoder VVenC for H266/VVC encoding.
Register new encoder libvvencc
Add libvvenc to wrap the vvenc interface into ffmpeg
libvvenc implements encoder option: 
preset,qp,period,subjopt,vvenc-params,levelidc,tier
Enable encoder by adding --enable-libvvenc in configure step

Signed-off-by: Thomas Siedel 
---
 configure  |   5 +
 libavcodec/Makefile|   1 +
 libavcodec/allcodecs.c |   1 +
 libavcodec/libvvenc.c  | 442 +
 4 files changed, 449 insertions(+)
 create mode 100644 libavcodec/libvvenc.c

diff --git a/configure b/configure
index 978f15f772..f8f7965371 100755
--- a/configure
+++ b/configure
@@ -289,6 +289,7 @@ External library support:
native implementation exists [no]
   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx [no]
   --enable-libvvdecenable VVC decoding via vvdec [no]
+  --enable-libvvencenable VVC encoding via vvenc [no]
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
@@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libvvdec
+libvvenc
 libwebp
 libxml2
 libzimg
@@ -3409,6 +3411,8 @@ libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
 libvvdec_decoder_deps="libvvdec"
 libvvdec_decoder_select="vvc_mp4toannexb_bsf"
+libvvenc_encoder_deps="libvvenc"
+libvvenc_encoder_select="atsc_a53"
 libwebp_encoder_deps="libwebp"
 libwebp_anim_encoder_deps="libwebp"
 libx262_encoder_deps="libx262"
@@ -6740,6 +6744,7 @@ enabled libvpx&& {
 fi
 }
 enabled libvvdec  && require_pkg_config libvvdec "libvvdec >= 1.6.0" 
"vvdec/vvdec.h" vvdec_get_version
+enabled libvvenc  && require_pkg_config libvvenc "libvvenc >= 1.6.1" 
"vvenc/vvenc.h" vvenc_get_version
 
 enabled libwebp   && {
 enabled libwebp_encoder  && require_pkg_config libwebp "libwebp >= 
0.2.0" webp/encode.h WebPGetEncoderVersion
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f4cdbc9be1..badd266e66 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1105,6 +1105,7 @@ OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
 OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBVVDEC_DECODER)   += libvvdec.o vvc_parse_extradata.o 
vvc_paramset.o
+OBJS-$(CONFIG_LIBVVENC_ENCODER)   += libvvenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc_common.o libwebpenc.o
 OBJS-$(CONFIG_LIBWEBP_ANIM_ENCODER)   += libwebpenc_common.o 
libwebpenc_animencoder.o
 OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 9813b291f4..73c36f3134 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -794,6 +794,7 @@ extern const FFCodec ff_libvpx_vp8_decoder;
 extern FFCodec ff_libvpx_vp9_encoder;
 extern FFCodec ff_libvpx_vp9_decoder;
 extern const FFCodec ff_libvvdec_decoder;
+extern const FFCodec ff_libvvenc_encoder;
 /* preferred over libwebp */
 extern const FFCodec ff_libwebp_anim_encoder;
 extern const FFCodec ff_libwebp_encoder;
diff --git a/libavcodec/libvvenc.c b/libavcodec/libvvenc.c
new file mode 100644
index 00..508fe6ceff
--- /dev/null
+++ b/libavcodec/libvvenc.c
@@ -0,0 +1,442 @@
+/*
+ * H.266 encoding using the VVenC library
+ *
+ * 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 "config_components.h"
+
+#include 
+#include 
+
+#include "avcodec.h"
+#include "codec_internal.h"
+#include "encode.h"
+#include "internal.h"
+#include "packet_internal.h"
+#include "profiles.h"
+
+#include "libavutil/avutil.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/opt.h"
+#include "liba

[FFmpeg-devel] [PATCH v2 06/10] avformat: add muxer support for H266/VVC

2022-10-24 Thread Thomas Siedel
Add muxer for vvcc byte stream format.
Add AV_CODEC_ID_VVC to ff_mp4_obj_type
Add AV_CODEC_ID_VVC to ISO Media codec (VvcConfigurationBox vvi1, vvc1 defined 
in ISO/IEC 14496-15:2021)
Add VvcConfigurationBox vvcC which extends FullBox type in ISO/IEC 14496-15:2021
Add ff_vvc_muxer to RAW muxers

Signed-off-by: Thomas Siedel 
---
 libavformat/Makefile |  7 ---
 libavformat/allformats.c |  1 +
 libavformat/isom.c   |  1 +
 libavformat/isom_tags.c  |  3 +++
 libavformat/mov.c|  6 ++
 libavformat/movenc.c | 41 +++-
 libavformat/rawenc.c | 23 ++
 7 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 00ab4ded89..9ee2526eef 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -336,7 +336,7 @@ OBJS-$(CONFIG_MATROSKA_DEMUXER)  += matroskadec.o 
matroska.o  \
 oggparsevorbis.o vorbiscomment.o \
 qtpalette.o replaygain.o 
dovi_isom.o
 OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \
-av1.o avc.o hevc.o \
+av1.o avc.o hevc.o vvc.o\
 flacenc_header.o avlanguage.o \
 vorbiscomment.o wv.o dovi_isom.o
 OBJS-$(CONFIG_MCA_DEMUXER)   += mca.o
@@ -358,7 +358,7 @@ OBJS-$(CONFIG_MODS_DEMUXER)  += mods.o
 OBJS-$(CONFIG_MOFLEX_DEMUXER)+= moflex.o
 OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o mov_chan.o mov_esds.o \
 qtpalette.o replaygain.o 
dovi_isom.o
-OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
+OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vvc.o 
vpcc.o \
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
 dovi_isom.o
@@ -508,7 +508,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \
 rtpenc_vp8.o  \
 rtpenc_vp9.o\
 rtpenc_xiph.o \
-avc.o hevc.o
+avc.o hevc.o vvc.o
 OBJS-$(CONFIG_RTSP_DEMUXER)  += rtsp.o rtspdec.o httpauth.o \
 urldecode.o
 OBJS-$(CONFIG_RTSP_MUXER)+= rtsp.o rtspenc.o httpauth.o \
@@ -596,6 +596,7 @@ 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_VVC_MUXER) += rawenc.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 a4e3822681..006a7dc125 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -475,6 +475,7 @@ 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 AVOutputFormat ff_vvc_muxer;
 extern const AVInputFormat  ff_w64_demuxer;
 extern const AVOutputFormat ff_w64_muxer;
 extern const AVInputFormat  ff_wav_demuxer;
diff --git a/libavformat/isom.c b/libavformat/isom.c
index 6d019881e5..9fbccd4437 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -36,6 +36,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
 { AV_CODEC_ID_MPEG4   , 0x20 },
 { AV_CODEC_ID_H264, 0x21 },
 { AV_CODEC_ID_HEVC, 0x23 },
+{ AV_CODEC_ID_VVC , 0x33 },
 { AV_CODEC_ID_AAC , 0x40 },
 { AV_CODEC_ID_MP4ALS  , 0x40 }, /* 14496-3 ALS */
 { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG-2 Main */
diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c
index e2b80405cc..ec93bdc363 100644
--- a/libavformat/isom_tags.c
+++ b/libavformat/isom_tags.c
@@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby 
Vision derived from hev1 */
  /* dvh1 is handled within 
mov.c */
 
+{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') },  /* VVC/H.266 which 
indicates parameter sets may be in ES */
+{ AV_CODEC_ID_VVC, MKTAG(&#

[FFmpeg-devel] [PATCH v2 05/10] avformat: add demuxer and probe support for H266/VVC

2022-10-24 Thread 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| 919 +++
 libavformat/vvc.h|  99 +
 libavformat/vvcdec.c |  61 +++
 6 files changed, 1086 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..b27a522009
--- /dev/null
+++ b/libavformat/vvc.c
@@ -0,0 +1,919 @@
+/*
+ * 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  ge

[FFmpeg-devel] [PATCH v2 09/10] avformat: add ts stream types for H266/VVC

2022-10-24 Thread Thomas Siedel
Add transport stream stream type 0x33 for vvc.
Add STREAM_TYPE_VIDEO_VVC to MPEG-1/2 and MPEG-2 transport stream
Add basic transport stream support for TS mux/demux

Signed-off-by: Thomas Siedel 
---
 configure   |  2 +-
 libavformat/mpeg.c  |  3 ++
 libavformat/mpeg.h  |  1 +
 libavformat/mpegts.c|  2 ++
 libavformat/mpegts.h|  1 +
 libavformat/mpegtsenc.c | 65 +
 6 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index f8f7965371..d8dca3656c 100755
--- a/configure
+++ b/configure
@@ -3485,7 +3485,7 @@ mp3_demuxer_select="mpegaudio_parser"
 mp3_muxer_select="mpegaudioheader"
 mp4_muxer_select="mov_muxer"
 mpegts_demuxer_select="iso_media"
-mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf"
+mpegts_muxer_select="ac3_parser adts_muxer latm_muxer h264_mp4toannexb_bsf 
hevc_mp4toannexb_bsf vvc_mp4toannexb_bsf"
 mpegtsraw_demuxer_select="mpegts_demuxer"
 mxf_muxer_select="pcm_rechunk_bsf"
 mxf_d10_muxer_select="mxf_muxer"
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index 864b08d8f8..970926df6b 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -546,6 +546,9 @@ redo:
 } else if (es_type == STREAM_TYPE_VIDEO_HEVC) {
 codec_id = AV_CODEC_ID_HEVC;
 type = AVMEDIA_TYPE_VIDEO;
+} else if (es_type == STREAM_TYPE_VIDEO_VVC) {
+codec_id = AV_CODEC_ID_VVC;
+type = AVMEDIA_TYPE_VIDEO;
 } else if (es_type == STREAM_TYPE_AUDIO_AC3) {
 codec_id = AV_CODEC_ID_AC3;
 type = AVMEDIA_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index b635295776..20592eb184 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -56,6 +56,7 @@
 #define STREAM_TYPE_VIDEO_MPEG4 0x10
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 
 #define STREAM_TYPE_AUDIO_AC3   0x81
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index d97702fcd7..61a800c85f 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -811,6 +811,7 @@ static const StreamType ISO_types[] = {
 { 0x20, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_H264   },
 { 0x21, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_JPEG2000   },
 { 0x24, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC   },
+{ 0x33, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC},
 { 0x42, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_CAVS   },
 { 0xd1, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_DIRAC  },
 { 0xd2, AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_AVS2   },
@@ -865,6 +866,7 @@ static const StreamType REGD_types[] = {
 { MKTAG('D', 'T', 'S', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_DTS   },
 { MKTAG('E', 'A', 'C', '3'), AVMEDIA_TYPE_AUDIO, AV_CODEC_ID_EAC3  },
 { MKTAG('H', 'E', 'V', 'C'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_HEVC  },
+{ MKTAG('V', 'V', 'C', ' '), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VVC   },
 { MKTAG('K', 'L', 'V', 'A'), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_SMPTE_KLV },
 { MKTAG('I', 'D', '3', ' '), AVMEDIA_TYPE_DATA,  AV_CODEC_ID_TIMED_ID3 },
 { MKTAG('V', 'C', '-', '1'), AVMEDIA_TYPE_VIDEO, AV_CODEC_ID_VC1   },
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index a48f14e768..14ae312c50 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -128,6 +128,7 @@
 #define STREAM_TYPE_METADATA0x15
 #define STREAM_TYPE_VIDEO_H264  0x1b
 #define STREAM_TYPE_VIDEO_HEVC  0x24
+#define STREAM_TYPE_VIDEO_VVC   0x33
 #define STREAM_TYPE_VIDEO_CAVS  0x42
 #define STREAM_TYPE_VIDEO_AVS2  0xd2
 #define STREAM_TYPE_VIDEO_AVS3  0xd4
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 48d39e6a7d..4c32cddff1 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -366,6 +366,9 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream 
*st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+stream_type = STREAM_TYPE_VIDEO_VVC;
+break;
 case AV_CODEC_ID_CAVS:
 stream_type = STREAM_TYPE_VIDEO_CAVS;
 break;
@@ -462,6 +465,11 @@ static int get_m2ts_stream_type(AVFormatContext *s, 
AVStream *st)
 case AV_CODEC_ID_HEVC:
 stream_type = STREAM_TYPE_VIDEO_HEVC;
 break;
+case AV_CODEC_ID_VVC:
+av_log(s, AV_LOG_ERROR,
+"MPEGTS VVC %s.\n", avcodec_get_name(st->codecpar->codec_id));
+stream_type = STREAM_TYPE_VIDEO_VVC;
+

[FFmpeg-devel] [PATCH v2 04/10] avcodec: add MP4 to annexb support for H266/VVC

2022-10-24 Thread Thomas Siedel
Add parser for VVC MP4 to Annex B byte stream format.

Signed-off-by: Thomas Siedel 
---
 configure|   1 +
 libavcodec/Makefile  |   2 +
 libavcodec/bitstream_filters.c   |   2 +
 libavcodec/h266_metadata_bsf.c   | 145 ++
 libavcodec/vvc_mp4toannexb_bsf.c | 318 +++
 5 files changed, 468 insertions(+)
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c

diff --git a/configure b/configure
index 691e8da6d0..4d54ce2a93 100755
--- a/configure
+++ b/configure
@@ -3302,6 +3302,7 @@ mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
 trace_headers_bsf_select="cbs"
 vp9_metadata_bsf_select="cbs_vp9"
+vvc_metadata_bsf_select="cbs_h266"
 
 # external libraries
 aac_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 092f714d67..c6652e5e09 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1224,6 +1224,8 @@ OBJS-$(CONFIG_VP9_METADATA_BSF)   += 
vp9_metadata_bsf.o
 OBJS-$(CONFIG_VP9_RAW_REORDER_BSF)+= vp9_raw_reorder_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_BSF) += vp9_superframe_bsf.o
 OBJS-$(CONFIG_VP9_SUPERFRAME_SPLIT_BSF)   += vp9_superframe_split_bsf.o
+OBJS-$(CONFIG_VVC_METADATA_BSF)   += h266_metadata_bsf.o
+OBJS-$(CONFIG_VVC_MP4TOANNEXB_BSF)+= vvc_mp4toannexb_bsf.o
 
 # thread libraries
 OBJS-$(HAVE_LIBC_MSVCRT)   += file_open.o
diff --git a/libavcodec/bitstream_filters.c b/libavcodec/bitstream_filters.c
index a3bebefe5f..403884f3d7 100644
--- a/libavcodec/bitstream_filters.c
+++ b/libavcodec/bitstream_filters.c
@@ -64,6 +64,8 @@ extern const FFBitStreamFilter ff_vp9_metadata_bsf;
 extern const FFBitStreamFilter ff_vp9_raw_reorder_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_bsf;
 extern const FFBitStreamFilter ff_vp9_superframe_split_bsf;
+extern const FFBitStreamFilter ff_vvc_mp4toannexb_bsf;
+extern const FFBitStreamFilter ff_vvc_metadata_bsf;
 
 #include "libavcodec/bsf_list.c"
 
diff --git a/libavcodec/h266_metadata_bsf.c b/libavcodec/h266_metadata_bsf.c
new file mode 100644
index 00..bc3c10f581
--- /dev/null
+++ b/libavcodec/h266_metadata_bsf.c
@@ -0,0 +1,145 @@
+/*
+ * 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 "libavutil/common.h"
+#include "libavutil/opt.h"
+
+#include "bsf.h"
+#include "bsf_internal.h"
+#include "cbs.h"
+#include "cbs_bsf.h"
+#include "cbs_h266.h"
+#include "vvc.h"
+
+#define IS_SLICE(nut) (nut <= VVC_RASL_NUT || (nut >= VVC_IDR_W_RADL && nut <= 
VVC_GDR_NUT))
+#define IS_PH(nut) (nut == VVC_PH_NUT)
+
+typedef struct VVCMetadataContext {
+CBSBSFContext common;
+
+H266RawAUD aud_nal;
+
+int aud;
+} VVCMetadataContext;
+
+static int h266_metadata_update_fragment(AVBSFContext *bsf, AVPacket *pkt,
+ CodedBitstreamFragment *pu)
+{
+VVCMetadataContext *ctx = bsf->priv_data;
+int err, i;
+
+// If an AUD is present, it must be the first NAL unit.
+if (pu->units[0].type == VVC_AUD_NUT) {
+if (ctx->aud == BSF_ELEMENT_REMOVE)
+ff_cbs_delete_unit(pu, 0);
+} else {
+if (ctx->aud == BSF_ELEMENT_INSERT) {
+const H266RawSlice *first_slice = NULL;
+const H266RawPH*ph = NULL;
+H266RawAUD *aud = &ctx->aud_nal;
+int pic_type = 0, temporal_id = 8, layer_id = 0;
+for (i = 0; i < pu->nb_units; i++) {
+const H266RawNALUnitHeader *nal = pu->units[i].content;
+if (!nal)
+continue;
+if (nal->nuh_temporal_id_plus1 < temporal_id + 1)
+temporal_id = nal->nuh_temporal_id_plus1 - 1;
+if (IS_PH(nal->nal_unit_type)) {
+ph = pu->units[i].content;
+} else if(IS_SLICE(nal->nal_unit_type)) {
+const H266RawSlice *slice = pu->units[i].content;
+layer_id = nal->nuh_layer_id;
+  

[FFmpeg-devel] [PATCH v2 03/10] avcodec: add bitstream parser for H266/VVC

2022-10-24 Thread Thomas Siedel
Add nal parser ff_vvc_parser to parse vvc elementary bitstreams.

Signed-off-by: Thomas Siedel 
---
 configure|   3 +
 libavcodec/Makefile  |   2 +
 libavcodec/h2645_parse.c |  71 -
 libavcodec/parsers.c |   1 +
 libavcodec/vvc_parser.c  | 588 +++
 5 files changed, 664 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/vvc_parser.c

diff --git a/configure b/configure
index c5a466657f..691e8da6d0 100755
--- a/configure
+++ b/configure
@@ -2447,6 +2447,7 @@ CONFIG_EXTRA="
 cbs_av1
 cbs_h264
 cbs_h265
+cbs_h266
 cbs_jpeg
 cbs_mpeg2
 cbs_vp9
@@ -2728,6 +2729,7 @@ threads_if_any="$THREADS_LIST"
 cbs_av1_select="cbs"
 cbs_h264_select="cbs"
 cbs_h265_select="cbs"
+cbs_h266_select="cbs"
 cbs_jpeg_select="cbs"
 cbs_mpeg2_select="cbs"
 cbs_vp9_select="cbs"
@@ -3282,6 +3284,7 @@ hevc_parser_select="hevcparse"
 mpegaudio_parser_select="mpegaudioheader"
 mpeg4video_parser_select="h263dsp mpegvideodec qpeldsp"
 vc1_parser_select="vc1dsp"
+vvc_parser_select="cbs_h266"
 
 # bitstream_filters
 aac_adtstoasc_bsf_select="adts_header mpeg4audio"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 7761620de7..092f714d67 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -76,6 +76,7 @@ OBJS-$(CONFIG_CBS) += cbs.o cbs_bsf.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.o cbs_sei.o h2645_parse.o
 OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
@@ -1174,6 +1175,7 @@ OBJS-$(CONFIG_VC1_PARSER)  += vc1_parser.o 
vc1.o vc1data.o  \
 OBJS-$(CONFIG_VP3_PARSER)  += vp3_parser.o
 OBJS-$(CONFIG_VP8_PARSER)  += vp8_parser.o
 OBJS-$(CONFIG_VP9_PARSER)  += vp9_parser.o
+OBJS-$(CONFIG_VVC_PARSER)  += vvc_parser.o
 OBJS-$(CONFIG_WEBP_PARSER) += webp_parser.o
 OBJS-$(CONFIG_XBM_PARSER)  += xbm_parser.o
 OBJS-$(CONFIG_XMA_PARSER)  += xma_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 90944177c7..9fbeee3edd 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -27,6 +27,7 @@
 #include "libavutil/mem.h"
 
 #include "bytestream.h"
+#include "vvc.h"
 #include "hevc.h"
 #include "h264.h"
 #include "h2645_parse.h"
@@ -145,6 +146,47 @@ nsc:
 return si;
 }
 
+static const char *const vvc_nal_type_name[32] = {
+"TRAIL_NUT", // VVC_TRAIL_NUT
+"STSA_NUT", // VVC_STSA_NUT
+"RADL_NUT", // VVC_RADL_NUT
+"RASL_NUT", // VVC_RASL_NUT
+"RSV_VCL_4", // VVC_RSV_VCL_4
+"RSV_VCL_5", // VVC_RSV_VCL_5
+"RSV_VCL_6", // VVC_RSV_VCL_6
+"IDR_W_RADL", // VVC_IDR_W_RADL
+"IDR_N_LP", // VVC_IDR_N_LP
+"CRA_NUT", // VVC_CRA_NUT
+"GDR_NUT", // VVC_GDR_NUT
+"RSV_IRAP_11", // VVC_RSV_IRAP_11
+"OPI_NUT", // VVC_OPI_NUT
+"DCI_NUT", // VVC_DCI_NUT
+"VPS_NUT", // VVC_VPS_NUT
+"SPS_NUT", // VVC_SPS_NUT
+"PPS_NUT", // VVC_PPS_NUT
+"PREFIX_APS_NUT",// VVC_PREFIX_APS_NUT
+"SUFFIX_APS_NUT",// VVC_SUFFIX_APS_NUT
+"PH_NUT", // VVC_PH_NUT
+"AUD_NUT", // VVC_AUD_NUT
+"EOS_NUT", // VVC_EOS_NUT
+"EOB_NUT", // VVC_EOB_NUT
+"PREFIX_SEI_NUT",// VVC_PREFIX_SEI_NUT
+"SUFFIX_SEI_NUT",// VVC_SUFFIX_SEI_NUT
+"FD_NUT", // VVC_FD_NUT
+"RSV_NVCL_26", // VVC_RSV_NVCL_26
+"RSV_NVCL_27", // VVC_RSV_NVCL_27
+"UNSPEC_28", // VVC_UNSPEC_28
+"UNSPEC_29", // VVC_UNSPEC_29
+"UNSPEC_30", // VVC_UNSPEC_30
+"UNSPEC_31", // VVC_UNSPEC_31
+};
+
+static const char *vvc_nal_unit_name(int nal_type)
+{
+av_assert0(nal_type >= 0 && nal_type < 32);
+return vvc_nal_type_name[nal_type];
+}
+
 static const char *const hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -293,6 +335,31 @@ static int get_bit_length(H2645NAL *nal, int min_size, int 
skip_trailing_zeros)
  * @return AVERROR_INVALIDDATA if the packet is not a valid NAL unit,
  * 0 otherwise
  */
+static int vvc_parse_nal_header(H2645NAL *nal, void *logctx)
+{
+GetBitContext *gb = &nal->gb;
+
+if (

[FFmpeg-devel] [PATCH v2 01/10] avcodec: add enum types for H266/VVC

2022-10-24 Thread Thomas Siedel
Add needed types as nal unit types, slice types and vvc typedefs needed for 
parsing vvc high-level syntax

Signed-off-by: Thomas Siedel 
---
 libavcodec/vvc.h | 142 +++
 1 file changed, 142 insertions(+)
 create mode 100644 libavcodec/vvc.h

diff --git a/libavcodec/vvc.h b/libavcodec/vvc.h
new file mode 100644
index 00..19979b7017
--- /dev/null
+++ b/libavcodec/vvc.h
@@ -0,0 +1,142 @@
+/*
+ * VVC shared code
+ *
+ * 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
+ */
+
+#ifndef AVCODEC_VVC_H
+#define AVCODEC_VVC_H
+
+/**
+ * Table 5 – NAL unit type codes and NAL unit type classes
+ * in T-REC-H.266-202008
+ */
+enum VVCNALUnitType {
+VVC_TRAIL_NUT  = 0,
+VVC_STSA_NUT   = 1,
+VVC_RADL_NUT   = 2,
+VVC_RASL_NUT   = 3,
+VVC_RSV_VCL_4  = 4,
+VVC_RSV_VCL_5  = 5,
+VVC_RSV_VCL_6  = 6,
+VVC_IDR_W_RADL = 7,
+VVC_IDR_N_LP   = 8,
+VVC_CRA_NUT= 9,
+VVC_GDR_NUT= 10,
+VVC_RSV_IRAP_11= 11,
+VVC_OPI_NUT= 12,
+VVC_DCI_NUT= 13,
+VVC_VPS_NUT= 14,
+VVC_SPS_NUT= 15,
+VVC_PPS_NUT= 16,
+VVC_PREFIX_APS_NUT = 17,
+VVC_SUFFIX_APS_NUT = 18,
+VVC_PH_NUT = 19,
+VVC_AUD_NUT= 20,
+VVC_EOS_NUT= 21,
+VVC_EOB_NUT= 22,
+VVC_PREFIX_SEI_NUT = 23,
+VVC_SUFFIX_SEI_NUT = 24,
+VVC_FD_NUT = 25,
+VVC_RSV_NVCL_26= 26,
+VVC_RSV_NVCL_27= 27,
+VVC_UNSPEC_28  = 28,
+VVC_UNSPEC_29  = 29,
+VVC_UNSPEC_30  = 30,
+VVC_UNSPEC_31  = 31,
+};
+
+enum VVCSliceType {
+VVC_SLICE_TYPE_B = 0,
+VVC_SLICE_TYPE_P = 1,
+VVC_SLICE_TYPE_I = 2,
+};
+
+enum {
+//6.2 we can have 3 sample arrays
+VVC_MAX_SAMPLE_ARRAYS = 3,
+
+//7.4.3.3 vps_max_layers_minus1 is u(6)
+VVC_MAX_LAYERS = 64,
+
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+VVC_MAX_SUBLAYERS = 7,
+
+//7.4.3.3 vps_num_ptls_minus1 is u(8)
+VVC_MAX_PTLS = 256,
+
+//7.4.3.3 vps_num_output_layer_sets_minus2 is u(8)
+VVC_MAX_TOTAL_NUM_OLSS = 257,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+VVC_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is u(4)
+VVC_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is u(6)
+VVC_MAX_PPS_COUNT = 64,
+
+// 7.4.4.1: ptl_num_sub_profiles is u(8)
+VVC_MAX_SUB_PROFILES = 256,
+
+// A.4.2: according to (1577), MaxDpbSize is bounded above by 2 * 
maxDpbPicBuf(8)
+VVC_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+VVC_MAX_REF_PIC_LISTS = 64,
+
+//7.4.11 num_ref_entries in range [0, MaxDpbSize + 13]
+VVC_MAX_REF_ENTRIES = VVC_MAX_DPB_SIZE + 13,
+
+//7.4.3.3 sps_num_points_in_qp_table_minus1[i] in range [0, 36 − 
sps_qp_table_start_minus26[i]],
+//sps_qp_table_start_minus26[i] in range [sps_qp_table_start_minus26[i] 
−26 − QpBdOffset, 36]
+//for 10 bitsQpBdOffset is 12, so sps_num_points_in_qp_table_minus1[i] in 
range [0, 74]
+VVC_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+VVC_MAX_CPB_CNT = 32,
+
+// A.4.1: the highest level allows a MaxLumaPs of 35 651 584.
+VVC_MAX_LUMA_PS = 35651584,
+
+// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
+// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
+// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
+VVC_MAX_WIDTH  = 16888,
+VVC_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 440 tiles per au for any level.
+VVC_MAX_TILES_PER_AU = 440,
+// A.4.1: table A.1 did not define max tile rows.
+// in worest a case, we can have 1x440 tiles picture.
+VVC_MAX_TILE_ROWS= VVC_MAX_TILES_PER_AU,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+VVC_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+VVC_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (!pps_no_pic_partition_flag and
+// sps_entropy_coding_sync_enabled_flag are both true), entry points can be
+// placed

[FFmpeg-devel] [PATCH v2 00/10] Add support for H266/VVC

2022-10-24 Thread Thomas Siedel
This patch set adds H266/VVC support.
This includes parsing, muxing, demuxing, decoding and encoding.
Decoding is done using the external library VVdeC
(https://github.com/fraunhoferhhi/vvdec.git) and can be enabled with
--enable-libvvdec.
Encoding is done using the external library VVenC
(https://github.com/fraunhoferhhi/vvenc.git) and can be enabled with
--enable-libvvenc.

Changes since v1:

PATCH 03/10
- mv libavcodec/Makefile cbs changes into patch 3 to make it
  compilable
- cleanup cbs_h266_unit_types (adapt cbs_h266_unit_types to current
  syntax)

PATCH 05/10 libavformat/vvc.c
- change gci_general_constraints from unsigned __int128  to
  uint8_t[9]
- change uint8_t  *general_constraint_info to
  general_constraint_info[9]
- set correct constraints information in general_constraint_info
- vvcc_write fix indent of log output

PATCH 07/10 libavcodec/vvc_parse_extradata.c
- remove warning for sublayer_level_idc

PATCH 09/10 libavcodec/libvvenc.c
- set correct hdr mode, depending on color primaries


Thomas Siedel (10):
  avcodec: add enum types for H266/VVC
  avcodec: add cbs for H266/VVC
  avcodec: add bitstream parser for H266/VVC
  avcodec: add MP4 to annexb support for H266/VVC
  avformat: add demuxer and probe support for H266/VVC
  avformat: add muxer support for H266/VVC
  avcodec: add external decoder libvvdec for H266/VVC
  avcodec: add external encoder libvvenc for H266/VVC
  avformat: add ts stream types for H266/VVC
  avcodec: increase minor version for H266/VVC

 configure |   16 +-
 libavcodec/Makefile   |6 +
 libavcodec/allcodecs.c|2 +
 libavcodec/bitstream_filters.c|2 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  373 ++-
 libavcodec/cbs_h266.h |  791 +++
 libavcodec/cbs_h266_syntax_template.c | 3010 +
 libavcodec/cbs_internal.h |1 +
 libavcodec/cbs_sei.c  |   29 +
 libavcodec/h2645_parse.c  |   71 +-
 libavcodec/h266_metadata_bsf.c|  145 ++
 libavcodec/libvvdec.c |  511 +
 libavcodec/libvvenc.c |  442 
 libavcodec/parsers.c  |1 +
 libavcodec/version.h  |2 +-
 libavcodec/vvc.h  |  142 ++
 libavcodec/vvc_mp4toannexb_bsf.c  |  318 +++
 libavcodec/vvc_paramset.c |  972 
 libavcodec/vvc_paramset.h |  429 
 libavcodec/vvc_parse_extradata.c  |  241 ++
 libavcodec/vvc_parse_extradata.h  |   36 +
 libavcodec/vvc_parser.c   |  588 +
 libavformat/Makefile  |8 +-
 libavformat/allformats.c  |2 +
 libavformat/demux.c   |7 +-
 libavformat/isom.c|1 +
 libavformat/isom_tags.c   |3 +
 libavformat/mov.c |6 +
 libavformat/movenc.c  |   41 +-
 libavformat/mpeg.c|3 +
 libavformat/mpeg.h|1 +
 libavformat/mpegts.c  |2 +
 libavformat/mpegts.h  |1 +
 libavformat/mpegtsenc.c   |   65 +
 libavformat/rawenc.c  |   23 +
 libavformat/vvc.c |  919 
 libavformat/vvc.h |   99 +
 libavformat/vvcdec.c  |   61 +
 39 files changed, 9365 insertions(+), 11 deletions(-)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c
 create mode 100644 libavcodec/h266_metadata_bsf.c
 create mode 100644 libavcodec/libvvdec.c
 create mode 100644 libavcodec/libvvenc.c
 create mode 100644 libavcodec/vvc.h
 create mode 100644 libavcodec/vvc_mp4toannexb_bsf.c
 create mode 100644 libavcodec/vvc_paramset.c
 create mode 100644 libavcodec/vvc_paramset.h
 create mode 100644 libavcodec/vvc_parse_extradata.c
 create mode 100644 libavcodec/vvc_parse_extradata.h
 create mode 100644 libavcodec/vvc_parser.c
 create mode 100644 libavformat/vvc.c
 create mode 100644 libavformat/vvc.h
 create mode 100644 libavformat/vvcdec.c

-- 
2.25.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".