Re: [FFmpeg-devel] [PATCH] avfilter: add shufflepixels video filter

2020-12-20 Thread Paul B Mahol
Will apply soon!

On Thu, Dec 17, 2020 at 3:53 PM Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  doc/filters.texi   |  27 ++
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_shufflepixels.c | 456 +
>  4 files changed, 485 insertions(+)
>  create mode 100644 libavfilter/vf_shufflepixels.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index a290239a02..0e61ac32ce 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -17837,6 +17837,33 @@ ffmpeg -i INPUT -vf "shuffleframes=9 1 2 3 4 5 6
> 7 8 0" OUTPUT
>  @end example
>  @end itemize
>
> +@section shufflepixels
> +
> +Reorder pixels in video frames.
> +
> +This filter accepts the following options:
> +
> +@table @option
> +@item direction, d
> +Set shuffle direction. Can be forward or inverse direction.
> +Default direction is forward.
> +
> +@item mode, m
> +Set shuffle mode. Can be horizontal, vertical or block mode.
> +
> +@item width, w
> +@item height, h
> +Set shuffle block_size. In case of horizontal shuffle mode only width
> +part of size is used, and in case of vertical shuffle mode only height
> +part of size is used.
> +
> +@item seed, s
> +Set random seed used with shuffling pixels. Mainly useful to set to be
> able
> +to reverse filtering process to get original input.
> +For example, to reverse forward shuffle you need to use same parameters
> +and exact same seed and to set direction to inverse.
> +@end table
> +
>  @section shuffleplanes
>
>  Reorder and/or duplicate video planes.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index e8db1be5df..b0fb58e9d7 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -408,6 +408,7 @@ OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+=
> vf_misc_vaapi.o vaapi_vpp.o
>  OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
>  OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
>  OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  += vf_shuffleframes.o
> +OBJS-$(CONFIG_SHUFFLEPIXELS_FILTER)  += vf_shufflepixels.o
>  OBJS-$(CONFIG_SHUFFLEPLANES_FILTER)  += vf_shuffleplanes.o
>  OBJS-$(CONFIG_SIDEDATA_FILTER)   += f_sidedata.o
>  OBJS-$(CONFIG_SIGNALSTATS_FILTER)+= vf_signalstats.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index b1413730e6..c4a841b4d6 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -389,6 +389,7 @@ extern AVFilter ff_vf_sharpness_vaapi;
>  extern AVFilter ff_vf_showinfo;
>  extern AVFilter ff_vf_showpalette;
>  extern AVFilter ff_vf_shuffleframes;
> +extern AVFilter ff_vf_shufflepixels;
>  extern AVFilter ff_vf_shuffleplanes;
>  extern AVFilter ff_vf_sidedata;
>  extern AVFilter ff_vf_signalstats;
> diff --git a/libavfilter/vf_shufflepixels.c
> b/libavfilter/vf_shufflepixels.c
> new file mode 100644
> index 00..463bb66bc8
> --- /dev/null
> +++ b/libavfilter/vf_shufflepixels.c
> @@ -0,0 +1,456 @@
> +/*
> + * Copyright (c) 2020 Paul B Mahol
> + *
> + * 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/avassert.h"
> +#include "libavutil/avstring.h"
> +#include "libavutil/common.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/imgutils.h"
> +#include "libavutil/lfg.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +#include "libavutil/random_seed.h"
> +
> +#include "avfilter.h"
> +#include "internal.h"
> +#include "video.h"
> +
> +typedef struct ShufflePixelsContext {
> +const AVClass *class;
> +
> +int block_w, block_h;
> +int mode;
> +int direction;
> +int64_t seed;
> +
> +int depth;
> +int nb_planes;
> +int linesize[4];
> +int planewidth[4];
> +int planeheight[4];
> +
> +int nb_blocks;
> +
> +uint8_t *used;
> +int32_t *map;
> +
> +AVLFG c;
> +
> +int (*shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs);
> +} ShufflePixelsContext;
> +
> +static int query_formats(AVFilterContext *ctx)
> +{
> +static const enum AVPixelFormat pix_fmts[] = {
> +AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10,
> AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16,

Re: [FFmpeg-devel] [PATCH] avformat/libamqp: add option vhost

2020-12-20 Thread Florian Levis
Thanks Marton for the clarification
Thanks Andriy

--
Florian LEVIS


Le dim. 20 déc. 2020 à 02:30, Andriy Gelman  a
écrit :

> On Sat, 19. Dec 18:41, Florian Levis wrote:
> > I have no idea how to do it.
> > I can take a look ; but I'm really not sure how to do it.
> >
> > If one of you can handle it it might be safer ; if you can't, I will try.
> > Just let me know.
>
> I can send in the patch.
>
> --
> Andriy
>
___
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 0/3] add vvc raw demuxer

2020-12-20 Thread Nuo Mi
Hi James,
Thanks for the suggestion. Now the vvcdec decoder is workable. The md5 is
matched with the vvdecapp. I am working on the conformance test. Hope I can
send the patch later.
thanks


On Thu, Dec 17, 2020 at 4:56 AM James Almer  wrote:

> On 12/15/2020 10:43 AM, Nuo Mi wrote:
> > On Tue, Dec 15, 2020 at 4:44 AM Mark Thompson  wrote:
> >
> >> On 14/12/2020 13:31, Nuo Mi wrote:
> >>> Hi Mark,
> >>> I have almost done the cbs for sps, pps, and slice header. I will start
> >> to
> >>> implement the parser.
> >>
> >> This looks fun :)
> >>
> >>> Few questions for you:
> >>> 1. We need over-read some nals to detect the frame boundaries. But
> those
> >>> nals may switch/replace sps/pps. Do we need to use an output cbs and
> get
> >>> frames from the output cbs?
> >>
> >> I'm not seeing where this can happen - if you see a new parameter set
> then
> >> you must be in a new AU so you don't parse it, while a new VCL NAL as
> part
> >> of a new frame with no PS before it must have a parsable header?  (Or
> am I
> >> missing some problematic case?)
> >>
> >
> >>> 2. We can't handle an incompleted nal in current cbs.
> >>>
> >>
> https://github.com/FFmpeg/FFmpeg/blob/03c8fe49ea3f2a2444607e541dff15a1ccd7f0c2/libavcodec/h2645_parse.c#L437
> >> ,
> >>> do we have a plan to fix it? What's your suggstion for the frame split?
> >>
> >> I'm unsure what the question is.  You will always need to keep reading
> >> until you split a valid NAL unit which isn't in the current AU (noting
> that
> >> a slice is the last slice in the current frame is never sufficient,
> because
> >> suffixes might follow).
> >>
> >> I want to feed the input buffer to cbs and get nal units from it. Seems
> it
> > does not work like this.
> > We still need a frame split in the parser. And feed the entire frame to
> > cbs.
>
> The parser is meant to look byte by byte until it has found enough data
> to complete an entire Access Unit worth of NALUs.
> See how hevc does it in
>
> https://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/hevc_parser.c;h=463d352055b971bdcc27a27b3fcd7aa4b609286e;hb=HEAD#l261
>
>
> Once the delimitation of an AU is found, then the resulting buffer can
> be parsed (In VVC's case, we want that to be done by CBS) and ultimately
> propagated so the generic demux code in libavformat can create complete
> packets.
>
> >
> >
> >>> 3. How to well test the cbs?
> >>
> >> Passthrough is the best initial test, by making an h266_metadata bsf
> (even
> >> if it has no options).  The existing test coverage in FATE of CBS is
> >> primarily driven by this - for H.26[45], the input streams there are a
> >> subset of the H.26[45].1 conformance test streams chosen to cover as
> much
> >> of the header space as possible.
> >>
> >> I recommend enabling the write support ASAP (by adding the second
> include
> >> of cbs_h266_syntax_template.c), because the double build can shake out
> >> other problems too.
> >>
> >> My original plan is cbs->parser->vvdec decoder->60% comfornace passrate
> ->
> > check in -> h266_metadata.
> > are you suggest we implement h266_metadata firstly?
> >
> > thanks
> >
> > Thanks,
> >>
> >> - Mark
> >> ___
> >> 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".
> >
>
> ___
> 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".

[FFmpeg-devel] [PATCH] avcodec/mjpegdec: Cleanup ff_smvjpeg_decoder()

2020-12-20 Thread Michael Niedermayer
Fixes: memleaks
Fixes: 
28533/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-6242529653686272

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mjpegdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 11fb809c10..901ee228ab 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -3031,7 +3031,7 @@ AVCodec ff_smvjpeg_decoder = {
 .receive_frame  = ff_mjpeg_receive_frame,
 .flush  = decode_flush,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING |
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP 
| FF_CODEC_CAP_EXPORTS_CROPPING |
   FF_CODEC_CAP_SETS_PKT_DTS,
 };
 #endif
-- 
2.17.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] avfilter/vf_framerate: fix infinite loop with 1-frame input

2020-12-20 Thread Marton Balint
Fixes infinite loop in:
ffmpeg -f lavfi -i testsrc=d=0.04 -vf framerate=50 -f null none

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 6c8d01c94b..f5085705a4 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -170,7 +170,9 @@ static int process_work_frame(AVFilterContext *ctx)
 return 0;
 
 if (!s->f0) {
-s->work = av_frame_clone(s->f1);
+av_assert1(s->flush);
+s->work = s->f1;
+s->f1 = NULL;
 } else {
 if (work_pts >= s->pts1 + s->delta && s->flush)
 return 0;
-- 
2.26.2

___
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 1/3] avcodec/mjpegdec: Cleanup ff_smvjpeg_decoder()

2020-12-20 Thread Michael Niedermayer
Fixes: memleaks
Fixes: 
28533/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SMVJPEG_fuzzer-6242529653686272

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/mjpegdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 11fb809c10..901ee228ab 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -3031,7 +3031,7 @@ AVCodec ff_smvjpeg_decoder = {
 .receive_frame  = ff_mjpeg_receive_frame,
 .flush  = decode_flush,
 .capabilities   = AV_CODEC_CAP_DR1,
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_EXPORTS_CROPPING |
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP 
| FF_CODEC_CAP_EXPORTS_CROPPING |
   FF_CODEC_CAP_SETS_PKT_DTS,
 };
 #endif
-- 
2.17.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 3/3] avcodec/cfhd: More strictly check tag order and multiplicity

2020-12-20 Thread Michael Niedermayer
This is based on the encoder and a small number of CFHD sample files
It should make the decoder more robust against crafted input.
Due to the lack of a proper specification it is possible that this
may be too strict and may need to be tuned as files not following this
ordering are found.

Fixes: segfault
Fixes: OOM
Fixes: null pointer dereference
Fixes: left shift of negative value -12
Fixes: out of array write
Fixes: 
25367/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4865603750592512
Fixes: 
25958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4851579923202048
Fixes: 
25988/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5643617157513216
Fixes: 
25995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5177442380283904
Fixes: 
25996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5663296026574848
Fixes: 
26082/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5126180416782336
Fixes: 
27872/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4916296355151872
Fixes: 
28305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6041755829010432

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cfhd.c | 154 ++
 libavcodec/cfhd.h |   4 ++
 2 files changed, 158 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index 997beac7f4..5120e95f04 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -363,6 +363,151 @@ static int alloc_buffers(AVCodecContext *avctx)
 return 0;
 }
 
+typedef struct TagDescriptor {
+int16_t previous_marker1;
+int16_t previous_marker2;
+uint8_t mandatory : 1;
+uint8_t single: 1;
+} TagDescriptor;
+
+static TagDescriptor tag_descriptor[LastTag]={
+[SampleType   /*   1*/] = { .previous_marker1 = 0x0c0c, 
.previous_marker2 = -1,  },
+[SampleIndexTable /*   2*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[  3  ] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[BitstreamMarker  /*   4*/] = { },
+[VersionMajor /*   5*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[VersionMinor /*   6*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[VersionRevision  /*   7*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[VersionEdit  /*   8*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[  9  ] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[TransformType/*  10*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[NumFrames/*  11*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[ChannelCount /*  12*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[WaveletCount /*  13*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[SubbandCount /*  14*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[NumSpatial   /*  15*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[FirstWavelet /*  16*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 1 },
+[ 17  ] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[GroupTrailer /*  18*/] = { .previous_marker1 = 0x0c0c, .single = 1, 
.mandatory = 0 },
+[FrameType/*  19*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[ImageWidth   /*  20*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[ImageHeight  /*  21*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[ 22  ] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[FrameIndex   /*  23*/] = { .previous_marker1 = -1, .single = 1, 
.mandatory = 0 },
+[ 24  ] = { .previous_marker1 = 0x0c0c, .single = 1, 
.mandatory = 0 },
+[LowpassSubband   /*  25*/] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[NumLevels/*  26*/] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[LowpassWidth /*  27*/] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[LowpassHeight/*  28*/] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[ 29  ] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[ 30  ] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[ 31  ] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[ 32  ] = { .previous_marker1 = 0x1a4a, .single = 1, 
.mandatory = 1 },
+[PixelOffset  /*  33*/] = { .previous_marker1 = 0x1a4a, .sing

[FFmpeg-devel] [PATCH 2/3] avcodec/cfhd: check peak.offset

2020-12-20 Thread Michael Niedermayer
Fixes: signed integer overflow: -2147483648 - 4 cannot be represented in type 
'int'
Fixes: 
26907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5746202330267648

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/cfhd.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index a2b9c7c76a..997beac7f4 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -617,6 +617,12 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, 
int *got_frame,
 s->peak.level   = 0;
 } else if (tag == -PeakLevel && s->peak.offset) {
 s->peak.level = data;
+if (s->peak.offset < 4 - bytestream2_tell(&s->peak.base) ||
+s->peak.offset > 4 + bytestream2_get_bytes_left(&s->peak.base)
+) {
+ret = AVERROR_INVALIDDATA;
+goto end;
+}
 bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
 } else
 av_log(avctx, AV_LOG_DEBUG,  "Unknown tag %i data %x\n", tag, 
data);
-- 
2.17.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 5/5] avcodec/cfhd: check peak.offset so it stays within the 32bit range

2020-12-20 Thread Michael Niedermayer
On Sun, Nov 08, 2020 at 03:42:30AM +0100, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: signed integer overflow: -2147483648 - 4 cannot be represented in 
> > type 'int'
> > Fixes: 
> > 26907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5746202330267648
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/cfhd.c | 4 
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> > index a2b9c7c76a..e3fbfa4b91 100644
> > --- a/libavcodec/cfhd.c
> > +++ b/libavcodec/cfhd.c
> > @@ -617,6 +617,10 @@ static int cfhd_decode(AVCodecContext *avctx, void 
> > *data, int *got_frame,
> >  s->peak.level   = 0;
> >  } else if (tag == -PeakLevel && s->peak.offset) {
> >  s->peak.level = data;
> > +if (s->peak.offset < INT_MIN + 4) {
> > +ret = AVERROR_INVALIDDATA;
> > +goto end;
> > +}
> >  bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
> >  } else
> >  av_log(avctx, AV_LOG_DEBUG,  "Unknown tag %i data %x\n", tag, 
> > data);
> > 
> Is this peak.offset actually intended to be signed? 

it is signed in the reference code ive seen


> And if so wouldn't
> it make more sense to actually check that the buffer contains the seek
> target?

the reference code does not check that but i agree it of course makes
sense. posted a patch which should do that

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban


signature.asc
Description: PGP signature
___
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 3/3] avcodec/cfhd: More strictly check tag order and multiplicity

2020-12-20 Thread Paul B Mahol
Unacceptable, please share privately sample that allows to reproduce this.

On Sun, Dec 20, 2020 at 10:16 PM Michael Niedermayer 
wrote:

> This is based on the encoder and a small number of CFHD sample files
> It should make the decoder more robust against crafted input.
> Due to the lack of a proper specification it is possible that this
> may be too strict and may need to be tuned as files not following this
> ordering are found.
>
> Fixes: segfault
> Fixes: OOM
> Fixes: null pointer dereference
> Fixes: left shift of negative value -12
> Fixes: out of array write
> Fixes:
> 25367/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4865603750592512
> Fixes:
> 25958/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4851579923202048
> Fixes:
> 25988/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5643617157513216
> Fixes:
> 25995/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5177442380283904
> Fixes:
> 25996/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5663296026574848
> Fixes:
> 26082/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5126180416782336
> Fixes:
> 27872/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4916296355151872
> Fixes:
> 28305/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-6041755829010432
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/cfhd.c | 154 ++
>  libavcodec/cfhd.h |   4 ++
>  2 files changed, 158 insertions(+)
>
> diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
> index 997beac7f4..5120e95f04 100644
> --- a/libavcodec/cfhd.c
> +++ b/libavcodec/cfhd.c
> @@ -363,6 +363,151 @@ static int alloc_buffers(AVCodecContext *avctx)
>  return 0;
>  }
>
> +typedef struct TagDescriptor {
> +int16_t previous_marker1;
> +int16_t previous_marker2;
> +uint8_t mandatory : 1;
> +uint8_t single: 1;
> +} TagDescriptor;
> +
> +static TagDescriptor tag_descriptor[LastTag]={
> +[SampleType   /*   1*/] = { .previous_marker1 = 0x0c0c,
> .previous_marker2 = -1,  },
> +[SampleIndexTable /*   2*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[  3  ] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[BitstreamMarker  /*   4*/] = { },
> +[VersionMajor /*   5*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[VersionMinor /*   6*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[VersionRevision  /*   7*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[VersionEdit  /*   8*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[  9  ] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[TransformType/*  10*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[NumFrames/*  11*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[ChannelCount /*  12*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[WaveletCount /*  13*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[SubbandCount /*  14*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[NumSpatial   /*  15*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[FirstWavelet /*  16*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 1 },
> +[ 17  ] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[GroupTrailer /*  18*/] = { .previous_marker1 = 0x0c0c, .single =
> 1, .mandatory = 0 },
> +[FrameType/*  19*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[ImageWidth   /*  20*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[ImageHeight  /*  21*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[ 22  ] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[FrameIndex   /*  23*/] = { .previous_marker1 = -1, .single =
> 1, .mandatory = 0 },
> +[ 24  ] = { .previous_marker1 = 0x0c0c, .single =
> 1, .mandatory = 0 },
> +[LowpassSubband   /*  25*/] = { .previous_marker1 = 0x1a4a, .single =
> 1, .mandatory = 1 },
> +[NumLevels/*  26*/] = { .previous_marker1 = 0x1a4a, .single =
> 1, .mandatory = 1 },
> +[LowpassWidth /*  27*/] = { .previous_marker1 = 0x1a4a, .single =
> 1, .mandatory = 1 },
> +[LowpassHeight/*  28*/] = { .previous_marker1 = 0x1a4a, .single =
> 1, .mandatory = 1 },
> +[ 29  ] = { .previous_marker1 = 0x1a4a

Re: [FFmpeg-devel] [PATCH] avformat/amqp: parse vhost in uri

2020-12-20 Thread Marton Balint



On Sat, 19 Dec 2020, Andriy Gelman wrote:


From: Andriy Gelman 

Signed-off-by: Andriy Gelman 
---
doc/protocols.texi|  7 ---
libavformat/libamqp.c | 31 ++-
2 files changed, 30 insertions(+), 8 deletions(-)


LGTM, thanks.

Regards,
Marton



diff --git a/doc/protocols.texi b/doc/protocols.texi
index b4efa14509..de377a9546 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -63,16 +63,17 @@ After starting the broker, an FFmpeg client may stream data 
to the broker using
the command:

@example
-ffmpeg -re -i input -f mpegts amqp://[[user]:[password]@@]hostname[:port]
+ffmpeg -re -i input -f mpegts 
amqp://[[user]:[password]@@]hostname[:port][/vhost]
@end example

Where hostname and port (default is 5672) is the address of the broker. The
client may also set a user/password for authentication. The default for both
-fields is "guest".
+fields is "guest". Name of virtual host on broker can be set with vhost. The
+default value is "/".

Muliple subscribers may stream from the broker using the command:
@example
-ffplay amqp://[[user]:[password]@@]hostname[:port]
+ffplay amqp://[[user]:[password]@@]hostname[:port][/vhost]
@end example

In RabbitMQ all data published to the broker flows through a specific exchange,
diff --git a/libavformat/libamqp.c b/libavformat/libamqp.c
index 81df724a6d..c3b9c484ea 100644
--- a/libavformat/libamqp.c
+++ b/libavformat/libamqp.c
@@ -62,10 +62,10 @@ static const AVOption options[] = {
static int amqp_proto_open(URLContext *h, const char *uri, int flags)
{
int ret, server_msg;
-char hostname[STR_LEN], credentials[STR_LEN];
+char hostname[STR_LEN], credentials[STR_LEN], path[STR_LEN];
int port;
-const char *user, *password = NULL;
-const char *user_decoded, *password_decoded;
+const char *user, *password = NULL, *vhost;
+const char *user_decoded, *password_decoded, *vhost_decoded;
char *p;
amqp_rpc_reply_t broker_reply;
struct timeval tval = { 0 };
@@ -76,7 +76,7 @@ static int amqp_proto_open(URLContext *h, const char *uri, 
int flags)
h->max_packet_size = s->pkt_size;

av_url_split(NULL, 0, credentials, sizeof(credentials),
- hostname, sizeof(hostname), &port, NULL, 0, uri);
+ hostname, sizeof(hostname), &port, path, sizeof(path), uri);

if (port < 0)
port = 5672;
@@ -109,8 +109,27 @@ static int amqp_proto_open(URLContext *h, const char *uri, 
int flags)
return AVERROR(ENOMEM);
}

+/* skip query for now */
+p = strchr(path, '?');
+if (p)
+*p = '\0';
+
+vhost = path;
+if (*vhost == '\0')
+vhost = "/";
+else
+vhost++; /* skip leading '/' */
+
+vhost_decoded = ff_urldecode(vhost, 0);
+if (!vhost_decoded) {
+av_freep(&user_decoded);
+av_freep(&password_decoded);
+return AVERROR(ENOMEM);
+}
+
s->conn = amqp_new_connection();
if (!s->conn) {
+av_freep(&vhost_decoded);
av_freep(&user_decoded);
av_freep(&password_decoded);
av_log(h, AV_LOG_ERROR, "Error creating connection\n");
@@ -136,7 +155,7 @@ static int amqp_proto_open(URLContext *h, const char *uri, 
int flags)
goto destroy_connection;
}

-broker_reply = amqp_login(s->conn, "/", 0, s->pkt_size, 0,
+broker_reply = amqp_login(s->conn, vhost_decoded, 0, s->pkt_size, 0,
  AMQP_SASL_METHOD_PLAIN, user_decoded, 
password_decoded);

if (broker_reply.reply_type != AMQP_RESPONSE_NORMAL) {
@@ -195,6 +214,7 @@ static int amqp_proto_open(URLContext *h, const char *uri, 
int flags)
}
}

+av_freep(&vhost_decoded);
av_freep(&user_decoded);
av_freep(&password_decoded);
return 0;
@@ -206,6 +226,7 @@ close_connection:
destroy_connection:
amqp_destroy_connection(s->conn);

+av_freep(&vhost_decoded);
av_freep(&user_decoded);
av_freep(&password_decoded);
return AVERROR_EXTERNAL;
--
2.29.2

___
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 2/8] avformat/mpegts: simplify nb_packets code

2020-12-20 Thread Marton Balint



On Sat, 19 Dec 2020, Michael Niedermayer wrote:


Signed-off-by: Michael Niedermayer 
---
libavformat/mpegts.c | 7 ++-
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 1122455f66..cc292ab929 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -3090,7 +3090,6 @@ static int mpegts_read_header(AVFormatContext *s)
AVStream *st;
int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
int64_t pcrs[2], pcr_h;
-int packet_count[2];
uint8_t packet[TS_PACKET_SIZE];
const uint8_t *data;

@@ -3116,7 +3115,6 @@ static int mpegts_read_header(AVFormatContext *s)
parse_pcr(&pcr_h, &pcr_l, data) == 0) {
finished_reading_packet(s, ts->raw_packet_size);
pcr_pid = pid;
-packet_count[nb_pcrs] = nb_packets;
pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
nb_pcrs++;
if (nb_pcrs >= 2) {
@@ -3126,7 +3124,6 @@ static int mpegts_read_header(AVFormatContext *s)
} else {
av_log(ts->stream, AV_LOG_WARNING, "invalid pcr pair %"PRId64" >= 
%"PRId64"\n", pcrs[0], pcrs[1]);
pcrs[0] = pcrs[1];
-packet_count[0] = packet_count[1];
nb_pcrs--;
}
}
@@ -3138,8 +3135,8 @@ static int mpegts_read_header(AVFormatContext *s)

/* NOTE1: the bitrate is computed without the FEC */
/* NOTE2: it is only the bitrate of the start of the stream */
-ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - 
packet_count[0]);
-ts->cur_pcr  = pcrs[0] - ts->pcr_incr * packet_count[0];
+ts->pcr_incr = pcrs[1] - pcrs[0];
+ts->cur_pcr  = pcrs[0] - ts->pcr_incr * (nb_packets - 1);
s->bit_rate  = TS_PACKET_SIZE * 8 * 2700LL / ts->pcr_incr;
st->codecpar->bit_rate = s->bit_rate;
st->start_time  = ts->cur_pcr;


LGTM for this and the preivous as well.

(BTW did anybody hear of anyone ever using the mpegts raw demuxer?)

Thanks,
Marton
___
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] avformat/amqp: parse vhost in uri

2020-12-20 Thread Andriy Gelman
On Sun, 20. Dec 23:11, Marton Balint wrote:
> 
> 
> On Sat, 19 Dec 2020, Andriy Gelman wrote:
> 
> > From: Andriy Gelman 
> > 
> > Signed-off-by: Andriy Gelman 
> > ---
> > doc/protocols.texi|  7 ---
> > libavformat/libamqp.c | 31 ++-
> > 2 files changed, 30 insertions(+), 8 deletions(-)
> 
> LGTM, thanks.

Thanks, will apply.

-- 
Andriy
___
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]lavd/decklink_dec: Use correct case for codec point / fourcc v210

2020-12-20 Thread Marton Balint



On Sun, 13 Dec 2020, Carl Eugen Hoyos wrote:


Am Sa., 12. Dez. 2020 um 10:57 Uhr schrieb Marton Balint :


On Fri, 11 Dec 2020, Carl Eugen Hoyos wrote:


Attached patch fixes ticket #9005.


Why are the codec_tags set at all? Can't we simply remove setting of all
the codec tags in decklink? They hold no additional information to
codec id and pixel format. This should also fix the issue IMHO.


Alternative patch attached, completely untested.


I have tested it and it fixes the ticket. Patch LGTM.

Thanks,
Marton
___
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 2/6] avcodec: add h266 codec id and profiles

2020-12-20 Thread Nuo Mi
---
 libavcodec/avcodec.h| 2 ++
 libavcodec/codec_desc.c | 8 
 libavcodec/codec_id.h   | 2 ++
 libavcodec/profiles.c   | 5 +
 libavcodec/profiles.h   | 1 +
 5 files changed, 18 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 1d3099d50a..f7ea4d5849 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1961,6 +1961,8 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
 
+#define FF_PROFILE_H266_MAIN_10  1
+
 #define FF_PROFILE_AV1_MAIN 0
 #define FF_PROFILE_AV1_HIGH 1
 #define FF_PROFILE_AV1_PROFESSIONAL 2
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 404c460f8f..62fe0f453d 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1426,6 +1426,14 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Microsoft Paint (MSP) version 2"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_H266,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "h266",
+.long_name = NULL_IF_CONFIG_SMALL("H.266 / VVC (Versatile Video 
Coding)"),
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
+.profiles  = NULL_IF_CONFIG_SMALL(ff_h266_profiles),
+},
 {
 .id= AV_CODEC_ID_Y41P,
 .type  = AVMEDIA_TYPE_VIDEO,
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 6133e03bb9..7a8a896bfe 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -244,6 +244,8 @@ enum AVCodecID {
 AV_CODEC_ID_PGX,
 AV_CODEC_ID_AVS3,
 AV_CODEC_ID_MSP2,
+AV_CODEC_ID_VVC,
+#define AV_CODEC_ID_H266 AV_CODEC_ID_VVC
 
 AV_CODEC_ID_Y41P = 0x8000,
 AV_CODEC_ID_AVRP,
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index e59a3a5c12..710f2c01e2 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -74,6 +74,11 @@ const AVProfile ff_h264_profiles[] = {
 { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_h266_profiles[] = {
+{ FF_PROFILE_H266_MAIN_10, "Main 10" },
+{ FF_PROFILE_UNKNOWN },
+};
+
 const AVProfile ff_hevc_profiles[] = {
 { FF_PROFILE_HEVC_MAIN, "Main"},
 { FF_PROFILE_HEVC_MAIN_10,  "Main 10" },
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 6baaba5701..7a353dbf3d 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -60,6 +60,7 @@ extern const AVProfile ff_aac_profiles[];
 extern const AVProfile ff_dca_profiles[];
 extern const AVProfile ff_dnxhd_profiles[];
 extern const AVProfile ff_h264_profiles[];
+extern const AVProfile ff_h266_profiles[];
 extern const AVProfile ff_hevc_profiles[];
 extern const AVProfile ff_jpeg2000_profiles[];
 extern const AVProfile ff_mpeg2_video_profiles[];
-- 
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 6/6] avcodec: add vvdec H.266/VVC decoder

2020-12-20 Thread Nuo Mi
you can download test clips here:
https://www.itu.int/wftp3/av-arch/jvet-site/bitstream_exchange/VVC/under_test/VTM-11.0/

68.48% (163/238) clips are md5 matched with VTM 11:

passed:
10b400_A_Bytedance_2.bit
10b400_B_Bytedance_2.bit
8b400_A_Bytedance_2.bit
8b400_B_Bytedance_2.bit
8b420_A_Bytedance_2.bit
8b420_B_Bytedance_2.bit
ACTPIC_A_Huawei_3.bit
ACTPIC_B_Huawei_3.bit
ACTPIC_C_Huawei_3.bit
AFF_A_HUAWEI_2.bit
AFF_B_HUAWEI_2.bit
ALF_A_Huawei_3.bit
ALF_B_Huawei_3.bit
ALF_C_KDDI_2.bit
ALF_D_Qualcomm_2.bit
AMVR_A_HHI_3.bit
AMVR_B_HHI_3.bit
APSALF_A_Qualcomm_2.bit
APSLMCS_A_Dolby_3.bit
APSLMCS_B_Dolby_3.bit
APSLMCS_C_Dolby_2.bit
APSMULT_A_MediaTek_3.bit
APSMULT_B_MediaTek_3.bit
AUD_A_Broadcom_3.bit
BCW_A_MediaTek_3.bit
BDOF_A_MediaTek_3.bit
BDPCM_A_Orange_2.bit
CCALF_A_Sharp_3.bit
CCALF_B_Sharp_3.bit
CCALF_C_Sharp_3.bit
CCALF_D_Sharp_3.bit
CCLM_A_KDDI_1.bit
CIIP_A_MediaTek_3.bit
CodingToolsSets_A_Tencent_2.bit
CodingToolsSets_B_Tencent_2.bit
CodingToolsSets_C_Tencent_2.bit
CodingToolsSets_D_Tencent_2.bit
CROP_A_Panasonic_3.bit
CROP_B_Panasonic_4.bit
CST_A_MediaTek_3.bit
CTU_A_MediaTek_3.bit
CTU_B_MediaTek_3.bit
CTU_C_MediaTek_3.bit
CUBEMAP_A_MediaTek_3.bit
CUBEMAP_B_MediaTek_3.bit
CUBEMAP_C_MediaTek_3.bit
DEBLOCKING_A_Sharp_3.bit
DEBLOCKING_B_Sharp_2.bit
DEBLOCKING_C_Huawei_3.bit
DEBLOCKING_E_Ericsson_2.bit
DMVR_A_Huawei_3.bit
DMVR_B_KDDI_3.bit
DPB_A_Sharplabs_2.bit
DPB_B_Sharplabs_2.bit
DQ_A_HHI_3.bit
ENT444HIGHTIER_A_Sony_3.bit
ENT444HIGHTIER_B_Sony_3.bit
ENT444HIGHTIER_C_Sony_3.bit
ENT444HIGHTIER_D_Sony_3.bit
ENT444MAINTIER_A_Sony_3.bit
ENT444MAINTIER_B_Sony_3.bit
ENT444MAINTIER_C_Sony_3.bit
ENT444MAINTIER_D_Sony_3.bit
ENTHIGHTIER_A_Sony_3.bit
ENTHIGHTIER_B_Sony_3.bit
ENTHIGHTIER_C_Sony_3.bit
ENTHIGHTIER_D_Sony_3.bit
ENTMAINTIER_A_Sony_3.bit
ENTMAINTIER_B_Sony_3.bit
ENTMAINTIER_C_Sony_3.bit
ENTMAINTIER_D_Sony_3.bit
ENTROPY_A_Chipsnmedia_2.bit
ENTROPY_A_Qualcomm_2.bit
ENTROPY_B_Sharp_2.bit
ERP_A_MediaTek_3.bit
FILLER_A_Bytedance_1.bit
GPM_A_Alibaba_3.bit
IBC_A_Tencent_2.bit
IBC_B_Tencent_2.bit
IBC_C_Tencent_2.bit
IBC_D_Tencent_2.bit
IP_B_Nokia_1.bit
ISP_A_HHI_3.bit
ISP_B_HHI_3.bit
JCCR_A_Nokia_2.bit
JCCR_B_Nokia_2.bit
JCCR_C_HHI_3.bit
JCCR_E_Nokia_1.bit
JCCR_F_Nokia_1.bit
LFNST_A_LGE_3.bit
LFNST_B_LGE_3.bit
LFNST_C_HHI_3.bit
LMCS_A_Dolby_3.bit
LOSSLESS_B_HHI_3.bit
LTRP_A_ERICSSON_2.bit
MERGE_A_Qualcomm_2.bit
MERGE_B_Qualcomm_2.bit
MERGE_C_Qualcomm_2.bit
MERGE_D_Qualcomm_2.bit
MERGE_E_Qualcomm_2.bit
MERGE_F_Qualcomm_2.bit
MERGE_G_Qualcomm_2.bit
MERGE_H_Qualcomm_2.bit
MERGE_I_Qualcomm_2.bit
MERGE_J_Qualcomm_2.bit
MIP_A_HHI_3.bit
MIP_B_HHI_3.bit
MPM_A_LGE_3.bit
MRLP_A_HHI_2.bit
MRLP_B_HHI_2.bit
MTS_A_LGE_3.bit
MTS_B_LGE_3.bit
MTS_LFNST_A_LGE_3.bit
MTS_LFNST_B_LGE_3.bit
MVCOMP_A_Sharp_2.bit
PDPC_A_Qualcomm_3.bit
PDPC_B_Qualcomm_3.bit
PDPC_C_Qualcomm_2.bit
PHSH_B_Sharp_1.bit
POC_A_Nokia_1.bit
POUT_A_Sharplabs_2.bit
PROF_A_Interdigital_3.bit
PROF_B_Interdigital_3.bit
QTBTT_A_MediaTek_3.bit
QUANT_A_Huawei_2.bit
QUANT_B_Huawei_2.bit
QUANT_C_Huawei_2.bit
RPL_A_ERICSSON_2.bit
SAO_A_SAMSUNG_3.bit
SAO_B_SAMSUNG_3.bit
SAO_C_SAMSUNG_3.bit
SbTMVP_A_Bytedance_3.bit
SbTMVP_B_Bytedance_3.bit
SBT_A_HUAWEI_2.bit
SCALING_A_InterDigital_1.bit
SCALING_B_InterDigital_1.bit
SCALING_C_InterDigital_1.bit
SDH_A_Dolby_2.bit
SMVD_A_HUAWEI_2.bit
TEMPSCAL_A_Panasonic_4.bit
TEMPSCAL_C_Panasonic_3.bit
TILE_A_Nokia_2.bit
TILE_B_Nokia_2.bit
TILE_C_Nokia_2.bit
TILE_D_Nokia_2.bit
TILE_E_Nokia_2.bit
TILE_F_Nokia_2.bit
TMVP_A_Chipsnmedia_3.bit
TMVP_B_Chipsnmedia_3.bit
TMVP_C_Chipsnmedia_3.bit
TMVP_D_Chipsnmedia_3.bit
TRANS_A_Chipsnmedia_2.bit
TRANS_B_Chipsnmedia_2.bit
TRANS_C_Chipsnmedia_2.bit
TRANS_D_Chipsnmedia_2.bit
WPP_A_Sharp_3.bit
WPP_B_Sharp_2.bit
WP_A_InterDigital_3.bit
WP_B_InterDigital_3.bit
WRAP_A_InterDigital_4.bit
WRAP_B_InterDigital_4.bit
WRAP_C_InterDigital_4.bit
---
 configure   |   5 +-
 libavcodec/Makefile |   1 +
 libavcodec/allcodecs.c  |   1 +
 libavcodec/libvvdec.cpp | 244 
 4 files changed, 250 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libvvdec.cpp

diff --git a/configure b/configure
index 77272948e3..1e9a44db31 100755
--- a/configure
+++ b/configure
@@ -285,6 +285,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 video encoding via libvvdec [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]
@@ -1816,6 +1817,7 @@ EXTERNAL_LIBRARY_LIST="
 libvmaf
 libvorbis
 libvpx
+libvvdec
 libwebp
 libxml2
 libzimg
@@ -3281,6 +3283,7 @@ libvpx_vp8_decoder_deps="libvpx"
 libvpx_vp8_encoder_deps="libvpx"
 libvpx_vp9_decoder_deps="libvpx"
 libvpx_vp9_encoder_deps="libvpx"
+li

Re: [FFmpeg-devel] [PATCH 1/6] avcodec/h266: add shared header for h266

2020-12-20 Thread Nuo Mi
This patch set need work with https://github.com/fraunhoferhhi/vvdec/pull/18


On Mon, Dec 21, 2020 at 2:08 PM Nuo Mi  wrote:

> ---
>  libavcodec/h266.h | 121 ++
>  1 file changed, 121 insertions(+)
>  create mode 100644 libavcodec/h266.h
>
> diff --git a/libavcodec/h266.h b/libavcodec/h266.h
> new file mode 100644
> index 00..d5793b76fc
> --- /dev/null
> +++ b/libavcodec/h266.h
> @@ -0,0 +1,121 @@
> +/*
> + * H.266 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 H266NALUnitType {
> +H266_NAL_TRAIL   = 0,
> +H266_NAL_STSA= 1,
> +H266_NAL_RADL= 2,
> +H266_NAL_RASL= 3,
> +H266_NAL_RSV_VCL_4   = 4,
> +H266_NAL_RSV_VCL_5   = 5,
> +H266_NAL_RSV_VCL_6   = 6,
> +H266_NAL_IDR_W_RADL  = 7,
> +H266_NAL_IDR_N_LP= 8,
> +H266_NAL_CRA_NUT = 9,
> +H266_NAL_GDR_NUT = 10,
> +H266_NAL_RSV_IRAP_11 = 11,
> +H266_NAL_OPI = 12,
> +H266_NAL_DCI = 13,
> +H266_NAL_VPS = 14,
> +H266_NAL_SPS = 15,
> +H266_NAL_PPS = 16,
> +H266_NAL_PREFIX_APS  = 17,
> +H266_NAL_SUFFIX_APS  = 18,
> +H266_NAL_PH  = 19,
> +H266_NAL_AUD = 20,
> +H266_NAL_EOS_NUT = 21,
> +H266_NAL_EOB_NUT = 22,
> +H266_NAL_PREFIX_SEI  = 23,
> +H266_NAL_SUFFIX_SEI  = 24,
> +H266_NAL_FD_NUT  = 25,
> +H266_NAL_RSV_NVCL_26 = 26,
> +H266_NAL_RSV_NVCL_27 = 27,
> +H266_NAL_UNSPEC_28   = 28,
> +H266_NAL_UNSPEC_29   = 29,
> +H266_NAL_UNSPEC_30   = 30,
> +H266_NAL_UNSPEC_31   = 31,
> +};
> +
> +enum H266SliceType {
> +H266_SLICE_B = 0,
> +H266_SLICE_P = 1,
> +H266_SLICE_I = 2,
> +};
> +
> +enum {
> +H266_MAX_PLANES = 3,
> +//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the
> range of 0 to 6, inclusive
> +H266_MAX_SUB_LAYERS = 7,
> +
> +// 7.3.2.3: vps_video_parameter_set_id is u(4).
> +H266_MAX_VPS_COUNT = 16,
> +// 7.3.2.4: sps_seq_parameter_set_id is in [0, 15].
> +H266_MAX_SPS_COUNT = 16,
> +// 7.3.2.5: pps_pic_parameter_set_id is in [0, 63].
> +H266_MAX_PPS_COUNT = 64,
> +
> +// A.4.2: MaxDpbSize is bounded above by 16.
> +H266_MAX_DPB_SIZE = 16,
> +
> +//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
> +H266_MAX_REF_PIC_LISTS = 64,
> +
> +//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]
> +H266_MAX_POINTS_IN_QP_TABLE = 75,
> +
> +// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
> +H266_MAX_CPB_CNT = 32,
> +
> +// A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651
> 584.
> +H266_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.
> +H266_MAX_WIDTH  = 16888,
> +H266_MAX_HEIGHT = 16888,
> +
> +// A.4.1: table A.1 allows at most 20 tile rows for any level.
> +H266_MAX_TILE_ROWS= 20,
> +// A.4.1: table A.1 allows at most 20 tile columns for any level.
> +H266_MAX_TILE_COLUMNS = 20,
> +
> +// A.4.1 table A.1 allows at most 600 slice for any level.
> +H266_MAX_SLICES = 600,
> +
> +// 7.4.8: in the worst case (tiles_enabled_flag and
> +// entropy_coding_sync_enabled_flag are both set), entry points can be
> +// placed at the beginning of every Ctb row in every tile, giving an
> +// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY -
> 1.
> +// Only a stream with very high resolution and perverse parameters
> could
> +// get near that, though, so set a lower limit here with the maximum
> +// possible value for 8K video (at most 135

[FFmpeg-devel] [PATCH 1/6] avcodec/h266: add shared header for h266

2020-12-20 Thread Nuo Mi
---
 libavcodec/h266.h | 121 ++
 1 file changed, 121 insertions(+)
 create mode 100644 libavcodec/h266.h

diff --git a/libavcodec/h266.h b/libavcodec/h266.h
new file mode 100644
index 00..d5793b76fc
--- /dev/null
+++ b/libavcodec/h266.h
@@ -0,0 +1,121 @@
+/*
+ * H.266 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 H266NALUnitType {
+H266_NAL_TRAIL   = 0,
+H266_NAL_STSA= 1,
+H266_NAL_RADL= 2,
+H266_NAL_RASL= 3,
+H266_NAL_RSV_VCL_4   = 4,
+H266_NAL_RSV_VCL_5   = 5,
+H266_NAL_RSV_VCL_6   = 6,
+H266_NAL_IDR_W_RADL  = 7,
+H266_NAL_IDR_N_LP= 8,
+H266_NAL_CRA_NUT = 9,
+H266_NAL_GDR_NUT = 10,
+H266_NAL_RSV_IRAP_11 = 11,
+H266_NAL_OPI = 12,
+H266_NAL_DCI = 13,
+H266_NAL_VPS = 14,
+H266_NAL_SPS = 15,
+H266_NAL_PPS = 16,
+H266_NAL_PREFIX_APS  = 17,
+H266_NAL_SUFFIX_APS  = 18,
+H266_NAL_PH  = 19,
+H266_NAL_AUD = 20,
+H266_NAL_EOS_NUT = 21,
+H266_NAL_EOB_NUT = 22,
+H266_NAL_PREFIX_SEI  = 23,
+H266_NAL_SUFFIX_SEI  = 24,
+H266_NAL_FD_NUT  = 25,
+H266_NAL_RSV_NVCL_26 = 26,
+H266_NAL_RSV_NVCL_27 = 27,
+H266_NAL_UNSPEC_28   = 28,
+H266_NAL_UNSPEC_29   = 29,
+H266_NAL_UNSPEC_30   = 30,
+H266_NAL_UNSPEC_31   = 31,
+};
+
+enum H266SliceType {
+H266_SLICE_B = 0,
+H266_SLICE_P = 1,
+H266_SLICE_I = 2,
+};
+
+enum {
+H266_MAX_PLANES = 3,
+//7.4.3.3 The value of vps_max_sublayers_minus1 shall be in the range of 0 
to 6, inclusive
+H266_MAX_SUB_LAYERS = 7,
+
+// 7.3.2.3: vps_video_parameter_set_id is u(4).
+H266_MAX_VPS_COUNT = 16,
+// 7.3.2.4: sps_seq_parameter_set_id is in [0, 15].
+H266_MAX_SPS_COUNT = 16,
+// 7.3.2.5: pps_pic_parameter_set_id is in [0, 63].
+H266_MAX_PPS_COUNT = 64,
+
+// A.4.2: MaxDpbSize is bounded above by 16.
+H266_MAX_DPB_SIZE = 16,
+
+//7.4.3.4 sps_num_ref_pic_lists in range [0, 64]
+H266_MAX_REF_PIC_LISTS = 64,
+
+//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]
+H266_MAX_POINTS_IN_QP_TABLE = 75,
+
+// 7.4.6.1: hrd_cpb_cnt_minus1 is in [0, 31].
+H266_MAX_CPB_CNT = 32,
+
+// A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584.
+H266_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.
+H266_MAX_WIDTH  = 16888,
+H266_MAX_HEIGHT = 16888,
+
+// A.4.1: table A.1 allows at most 20 tile rows for any level.
+H266_MAX_TILE_ROWS= 20,
+// A.4.1: table A.1 allows at most 20 tile columns for any level.
+H266_MAX_TILE_COLUMNS = 20,
+
+// A.4.1 table A.1 allows at most 600 slice for any level.
+H266_MAX_SLICES = 600,
+
+// 7.4.8: in the worst case (tiles_enabled_flag and
+// entropy_coding_sync_enabled_flag are both set), entry points can be
+// placed at the beginning of every Ctb row in every tile, giving an
+// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
+// Only a stream with very high resolution and perverse parameters could
+// get near that, though, so set a lower limit here with the maximum
+// possible value for 8K video (at most 135 32x32 Ctb rows).
+H266_MAX_ENTRY_POINT_OFFSETS = H266_MAX_TILE_COLUMNS * 135,
+};
+
+#endif /* AVCODEC_H266_H */
-- 
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 5/6] avcodec: add h266 parser

2020-12-20 Thread Nuo Mi
---
 configure|   3 +
 libavcodec/Makefile  |   1 +
 libavcodec/h2645_parse.c |  73 +-
 libavcodec/h266_parser.c | 284 +++
 libavcodec/parsers.c |   1 +
 5 files changed, 360 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/h266_parser.c

diff --git a/configure b/configure
index 90914752f1..77272948e3 100755
--- a/configure
+++ b/configure
@@ -2354,6 +2354,7 @@ CONFIG_EXTRA="
 cbs_av1
 cbs_h264
 cbs_h265
+cbs_h266
 cbs_jpeg
 cbs_mpeg2
 cbs_vp9
@@ -2622,6 +2623,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"
@@ -3158,6 +3160,7 @@ av1_qsv_decoder_select="qsvdec"
 aac_parser_select="adts_header"
 av1_parser_select="cbs_av1"
 h264_parser_select="atsc_a53 golomb h264dsp h264parse"
+h266_parser_select="cbs_h266"
 hevc_parser_select="hevcparse"
 mpegaudio_parser_select="mpegaudioheader"
 mpegvideo_parser_select="mpegvideo"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 4045c002b7..82cc9b8b93 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1098,6 +1098,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 h264_sei.o h264data.o
+OBJS-$(CONFIG_H266_PARSER) += h266_parser.o
 OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_data.o
 OBJS-$(CONFIG_IPU_PARSER)  += ipu_parser.o
 OBJS-$(CONFIG_JPEG2000_PARSER) += jpeg2000_parser.o
diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 0f98b49fbe..2600371d3c 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -29,6 +29,7 @@
 #include "bytestream.h"
 #include "hevc.h"
 #include "h264.h"
+#include "h266.h"
 #include "h2645_parse.h"
 
 int ff_h2645_extract_rbsp(const uint8_t *src, int length,
@@ -146,6 +147,47 @@ nsc:
 return si;
 }
 
+static const char *h266_nal_type_name[64] = {
+"TRAIL", //H266_NAL_TRAIL
+"STSA", //H266_NAL_STSA
+"RADL", //H266_NAL_RADL
+"RASL", //H266_NAL_RASL
+"RSV_VCL_4", //H266_NAL_RSV_VCL_4
+"RSV_VCL_5", //H266_NAL_RSV_VCL_5
+"RSV_VCL_6", //H266_NAL_RSV_VCL_6
+"IDR_W_RAD", //H266_NAL_IDR_W_RADL
+"IDR_N_LP", //H266_NAL_IDR_N_LP
+"CRA_NUT", //H266_NAL_CRA_NUT
+"GDR_NUT", //H266_NAL_GDR_NUT
+"RSV_IRAP_11", //H266_NAL_RSV_IRAP_11
+"OPI", //H266_NAL_OPI
+"DCI", //H266_NAL_DCI
+"VPS", //H266_NAL_VPS
+"SPS", //H266_NAL_SPS
+"PPS", //H266_NAL_PPS
+"PREFIX_AP", //H266_NAL_PREFIX_APS
+"SUFFIX_AP", //H266_NAL_SUFFIX_APS
+"PH", //H266_NAL_PH
+"AUD", //H266_NAL_AUD
+"EOS_NUT", //H266_NAL_EOS_NUT
+"EOB_NUT", //H266_NAL_EOB_NUT
+"PREFIX_SE", //H266_NAL_PREFIX_SEI
+"SUFFIX_SE", //H266_NAL_SUFFIX_SEI
+"FD_NUT", //H266_NAL_FD_NUT
+"RSV_NVCL_26", //H266_NAL_RSV_NVCL_26
+"RSV_NVCL_27", //H266_NAL_RSV_NVCL_27
+"UNSPEC_28", //H266_NAL_UNSPEC_28
+"UNSPEC_29", //H266_NAL_UNSPEC_29
+"UNSPEC_30", //H266_NAL_UNSPEC_30
+"UNSPEC_31", //H266_NAL_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 *hevc_nal_type_name[64] = {
 "TRAIL_N", // HEVC_NAL_TRAIL_N
 "TRAIL_R", // HEVC_NAL_TRAIL_R
@@ -289,6 +331,32 @@ static int get_bit_length(H2645NAL *nal, 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;
+
+if (get_bits1(gb) != 0) //nuh_reserved_zero_bit
+return AVERROR_INVALIDDATA;
+
+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 >= H266_NAL_IDR_W_RADL && nal->type <= 
H266_NAL_RSV_IRAP_11) && nal->temporal_id)
+return AVERROR_INVALIDDATA;
+
+av_log(logctx, AV_LOG_DEBUG,
+  "nal_unit_type: %d(%s), nuh_layer_id: %d, temporal_id: %d\n",
+   nal->type, h266_nal_unit_name(nal->type), nal->nuh_layer_id, 
nal->temporal_id);
+
+return 0;
+}
+
 static int hevc_parse_nal_header(H2645NAL *nal, void *logctx)
 {
 GetBitContext *gb = &nal->gb;
@@ -503,8 +571,9 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t 
*buf, int length,
 
 /* Reset type in case it contains a stale value from a previously 
parsed NAL */
 nal->type = 0;
-
-if (codec_id == AV_CODEC_ID_HEVC)
+if (codec_id == AV_CODEC_ID_H2

[FFmpeg-devel] [PATCH 3/6] avformat: add h266 raw demux

2020-12-20 Thread Nuo Mi
---
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/h266dec.c| 61 
 3 files changed, 63 insertions(+)
 create mode 100644 libavformat/h266dec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 97d868081b..c685aad66e 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -231,6 +231,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 0e0caaad39..8b64b4eb4b 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -189,6 +189,7 @@ extern AVInputFormat  ff_h263_demuxer;
 extern AVOutputFormat ff_h263_muxer;
 extern AVInputFormat  ff_h264_demuxer;
 extern AVOutputFormat ff_h264_muxer;
+extern AVInputFormat  ff_h266_demuxer;
 extern AVOutputFormat ff_hash_muxer;
 extern AVInputFormat  ff_hca_demuxer;
 extern AVInputFormat  ff_hcom_demuxer;
diff --git a/libavformat/h266dec.c b/libavformat/h266dec.c
new file mode 100644
index 00..bf0de5b829
--- /dev/null
+++ b/libavformat/h266dec.c
@@ -0,0 +1,61 @@
+/*
+ * RAW H266 video demuxer
+ * Copyright (c) 2020 Nuo Mi 
+ *
+ * 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/h266.h"
+
+#include "avformat.h"
+#include "rawdec.h"
+
+static int h266_probe(const AVProbeData *p)
+{
+uint32_t code = -1;
+int sps = 0, pps = 0, irap = 0;
+int i;
+
+for (i = 0; i < p->buf_size - 1; i++) {
+code = (code << 8) + p->buf[i];
+if ((code & 0xff00) == 0x100) {
+uint8_t nal2 = p->buf[i + 1];
+int type = (nal2 & 0xF8) >> 3;
+
+if (code & 0xc0) // forbidden_zero_bit and nuh_reserved_zero_bit
+return 0;
+
+if ((nal2 & 0x7) == 0) // nuh_temporal_id_plus1
+return 0;
+
+switch (type) {
+case H266_NAL_SPS:   sps++;  break;
+case H266_NAL_PPS:   pps++;  break;
+case H266_NAL_IDR_N_LP:
+case H266_NAL_IDR_W_RADL:
+case H266_NAL_CRA_NUT:
+case H266_NAL_GDR_NUT:   irap++; break;
+}
+}
+}
+
+if (sps && pps && irap)
+return AVPROBE_SCORE_EXTENSION + 1; // 1 more than .mpg
+return 0;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(h266, "raw H266 video", h266_probe, "h266,266,vvc", 
AV_CODEC_ID_H266)
-- 
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 4/6] avcodec: add cbs for h266

2020-12-20 Thread Nuo Mi
---
 libavcodec/Makefile   |1 +
 libavcodec/cbs.c  |6 +
 libavcodec/cbs_h2645.c|  337 ++
 libavcodec/cbs_h266.h |  711 
 libavcodec/cbs_h266_syntax_template.c | 1493 +
 libavcodec/cbs_internal.h |1 +
 6 files changed, 2549 insertions(+)
 create mode 100644 libavcodec/cbs_h266.h
 create mode 100644 libavcodec/cbs_h266_syntax_template.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 450781886d..4045c002b7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -73,6 +73,7 @@ OBJS-$(CONFIG_CBS) += cbs.o
 OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
 OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
 OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
+OBJS-$(CONFIG_CBS_H266)+= cbs_h2645.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
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index f98531e131..2b4f3b2bea 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -38,6 +38,9 @@ static const CodedBitstreamType *cbs_type_table[] = {
 #if CONFIG_CBS_H265
 &ff_cbs_type_h265,
 #endif
+#if CONFIG_CBS_H266
+&ff_cbs_type_h266,
+#endif
 #if CONFIG_CBS_JPEG
 &ff_cbs_type_jpeg,
 #endif
@@ -59,6 +62,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {
 #if CONFIG_CBS_H265
 AV_CODEC_ID_H265,
 #endif
+#if CONFIG_CBS_H266
+AV_CODEC_ID_H266,
+#endif
 #if CONFIG_CBS_JPEG
 AV_CODEC_ID_MJPEG,
 #endif
diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 434322492c..0b884c1ed0 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -24,11 +24,13 @@
 #include "cbs_internal.h"
 #include "cbs_h264.h"
 #include "cbs_h265.h"
+#include "cbs_h266.h"
 #include "h264.h"
 #include "h264_sei.h"
 #include "h2645_parse.h"
 #include "hevc.h"
 #include "hevc_sei.h"
+#include "h266.h"
 
 
 static int cbs_read_ue_golomb(CodedBitstreamContext *ctx, GetBitContext *gbc,
@@ -256,6 +258,7 @@ static int cbs_h265_payload_extension_present(GetBitContext 
*gbc, uint32_t paylo
 #define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
 #define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
 #define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
+#define FUNC_H266(rw, name) FUNC_NAME(rw, h266, name)
 
 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ 
}) : NULL)
 
@@ -364,6 +367,10 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext 
*gbc)
 #include "cbs_h265_syntax_template.c"
 #undef FUNC
 
+#define FUNC(name) FUNC_H266(READWRITE, name)
+#include "cbs_h266_syntax_template.c"
+#undef FUNC
+
 #undef READ
 #undef READWRITE
 #undef RWContext
@@ -679,6 +686,9 @@ cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
 cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
 cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id)
 cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
+cbs_h2645_replace_ps(6, VPS, vps, vps_video_parameter_set_id)
+cbs_h2645_replace_ps(6, SPS, sps, sps_seq_parameter_set_id)
+cbs_h2645_replace_ps(6, PPS, pps, pps_pic_parameter_set_id)
 
 static int cbs_h264_read_nal_unit(CodedBitstreamContext *ctx,
   CodedBitstreamUnit *unit)
@@ -920,6 +930,117 @@ static int cbs_h265_read_nal_unit(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
+static int cbs_h266_read_nal_unit(CodedBitstreamContext *ctx,
+  CodedBitstreamUnit *unit)
+{
+GetBitContext gbc;
+int err;
+
+err = init_get_bits(&gbc, unit->data, 8 * unit->data_size);
+if (err < 0)
+return err;
+
+err = ff_cbs_alloc_unit_content2(ctx, unit);
+if (err < 0)
+return err;
+
+switch (unit->type) {
+case H266_NAL_VPS:
+{
+H266RawVPS *vps = unit->content;
+
+err = cbs_h266_read_vps(ctx, &gbc, vps);
+if (err < 0)
+return err;
+
+err = cbs_h266_replace_vps(ctx, unit);
+if (err < 0)
+return err;
+}
+break;
+case H266_NAL_SPS:
+{
+H266RawSPS *sps = unit->content;
+
+err = cbs_h266_read_sps(ctx, &gbc, sps);
+if (err < 0)
+return err;
+
+err = cbs_h266_replace_sps(ctx, unit);
+if (err < 0)
+return err;
+}
+break;
+
+case H266_NAL_PPS:
+{
+H266RawPPS *pps = unit->content;
+
+err = cbs_h266_read_pps(ctx, &gbc, pps);
+if (err < 0)
+return err;
+
+err = cbs_h266_replace_pps(ctx, unit);
+if (err < 0)
+return err;
+}
+break;
+
+case H266_NAL_TRAIL:
+case H266_NAL_STSA: