Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-08-14 Thread Dai, Jianhui J



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Andreas Rheinhardt
> Sent: Saturday, August 12, 2023 5:41 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for
> VP8 codec bitstream READ methods
> 
> Dai, Jianhui J:
> > This commit adds VP8 into cbs supported codec list, and enables the
> > `trace_headers` bitstream filters to support VP8, besides existing
> > AV1, H.264, H.265 and VP9. It can be useful to debug VP8 stream issues.
> >
> > Only the READ methods `read_unit` and `split_fragment` are
> > implemented, the WRITE methods `write_unit` and `assemble_fragment`
> > return `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8
> > WRITE is unlikely used by any applications at the moment. The WRITE
> > methods can be added later if there are real requirments.
> >
> > TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
> > -bsf:v trace_headers -f null -
> >
> > Signed-off-by: Jianhui Dai 
> > ---
> >  configure|   4 +-
> >  libavcodec/Makefile  |   1 +
> >  libavcodec/cbs.c |   6 +
> >  libavcodec/cbs_internal.h|   1 +
> >  libavcodec/cbs_vp8.c | 360 +++
> >  libavcodec/cbs_vp8.h | 112 +
> >  libavcodec/cbs_vp8_syntax_template.c | 224 +
> >  7 files changed, 707 insertions(+), 1 deletion(-)  create mode 100644
> > libavcodec/cbs_vp8.c  create mode 100644 libavcodec/cbs_vp8.h  create
> > mode 100644 libavcodec/cbs_vp8_syntax_template.c
> >
> > diff --git a/configure b/configure
> > index bb7be67676..b8960d2639 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
> >  cbs_h265
> >  cbs_jpeg
> >  cbs_mpeg2
> > +cbs_vp8
> >  cbs_vp9
> >  deflate_wrapper
> >  dirac_parse
> > @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
> >  cbs_h265_select="cbs"
> >  cbs_jpeg_select="cbs"
> >  cbs_mpeg2_select="cbs"
> > +cbs_vp8_select="cbs"
> >  cbs_vp9_select="cbs"
> >  dct_select="rdft"
> >  deflate_wrapper_deps="zlib"
> > @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
> >  hevc_metadata_bsf_select="cbs_h265"
> >  mjpeg2jpeg_bsf_select="jpegtables"
> >  mpeg2_metadata_bsf_select="cbs_mpeg2"
> > -trace_headers_bsf_select="cbs"
> > +trace_headers_bsf_select="cbs cbs_vp8"
> >  vp9_metadata_bsf_select="cbs_vp9"
> >
> >  # external libraries
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> > 3cfb7e..1c4f0da1d2 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
> >  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> > +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
> >  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> >  OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
> >  OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
> > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index
> > 504197e06d..c77110abb1 100644
> > --- a/libavcodec/cbs.c
> > +++ b/libavcodec/cbs.c
> > @@ -46,6 +46,9 @@ static const CodedBitstreamType *const
> > cbs_type_table[] = {  #if CONFIG_CBS_MPEG2
> >  _cbs_type_mpeg2,
> >  #endif
> > +#if CONFIG_CBS_VP8
> > +_cbs_type_vp8,
> > +#endif
> >  #if CONFIG_CBS_VP9
> >  _cbs_type_vp9,
> >  #endif
> > @@ -67,6 +70,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {  #if
> > CONFIG_CBS_MPEG2
> >  AV_CODEC_ID_MPEG2VIDEO,
> >  #endif
> > +#if CONFIG_CBS_VP8
> > +AV_CODEC_ID_VP8,
> > +#endif
> >  #if CONFIG_CBS_VP9
> >  AV_CODEC_ID_VP9,
> >  #endif
> > diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> > index e585c77934..beaf8505d1 100644
> > --- a/libavcodec/cbs_internal.h
> > +++ b/libavcodec/cbs_internal.h
> > @@ -247,6 +247,7 @@ extern const CodedBitstreamType
> ff_cbs_type_h264;
> > extern const CodedBitstreamType ff_cbs_type_h265;  extern const
>

Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-08-11 Thread Andreas Rheinhardt
Dai, Jianhui J:
> This commit adds VP8 into cbs supported codec list, and enables the
> `trace_headers` bitstream filters to support VP8, besides existing AV1,
> H.264, H.265 and VP9. It can be useful to debug VP8 stream issues.
> 
> Only the READ methods `read_unit` and `split_fragment` are implemented,
> the WRITE methods `write_unit` and `assemble_fragment` return
> `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8 WRITE is
> unlikely used by any applications at the moment. The WRITE methods can
> be added later if there are real requirments.
> 
> TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
> -bsf:v trace_headers -f null -
> 
> Signed-off-by: Jianhui Dai 
> ---
>  configure|   4 +-
>  libavcodec/Makefile  |   1 +
>  libavcodec/cbs.c |   6 +
>  libavcodec/cbs_internal.h|   1 +
>  libavcodec/cbs_vp8.c | 360 +++
>  libavcodec/cbs_vp8.h | 112 +
>  libavcodec/cbs_vp8_syntax_template.c | 224 +
>  7 files changed, 707 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/cbs_vp8.c
>  create mode 100644 libavcodec/cbs_vp8.h
>  create mode 100644 libavcodec/cbs_vp8_syntax_template.c
> 
> diff --git a/configure b/configure
> index bb7be67676..b8960d2639 100755
> --- a/configure
> +++ b/configure
> @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
>  cbs_h265
>  cbs_jpeg
>  cbs_mpeg2
> +cbs_vp8
>  cbs_vp9
>  deflate_wrapper
>  dirac_parse
> @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
>  cbs_h265_select="cbs"
>  cbs_jpeg_select="cbs"
>  cbs_mpeg2_select="cbs"
> +cbs_vp8_select="cbs"
>  cbs_vp9_select="cbs"
>  dct_select="rdft"
>  deflate_wrapper_deps="zlib"
> @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
>  hevc_metadata_bsf_select="cbs_h265"
>  mjpeg2jpeg_bsf_select="jpegtables"
>  mpeg2_metadata_bsf_select="cbs_mpeg2"
> -trace_headers_bsf_select="cbs"
> +trace_headers_bsf_select="cbs cbs_vp8"
>  vp9_metadata_bsf_select="cbs_vp9"
>  
>  # external libraries
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 3cfb7e..1c4f0da1d2 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
>  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
>  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
>  OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
>  OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
> index 504197e06d..c77110abb1 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -46,6 +46,9 @@ static const CodedBitstreamType *const cbs_type_table[] = {
>  #if CONFIG_CBS_MPEG2
>  _cbs_type_mpeg2,
>  #endif
> +#if CONFIG_CBS_VP8
> +_cbs_type_vp8,
> +#endif
>  #if CONFIG_CBS_VP9
>  _cbs_type_vp9,
>  #endif
> @@ -67,6 +70,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {
>  #if CONFIG_CBS_MPEG2
>  AV_CODEC_ID_MPEG2VIDEO,
>  #endif
> +#if CONFIG_CBS_VP8
> +AV_CODEC_ID_VP8,
> +#endif
>  #if CONFIG_CBS_VP9
>  AV_CODEC_ID_VP9,
>  #endif
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
> index e585c77934..beaf8505d1 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -247,6 +247,7 @@ extern const CodedBitstreamType ff_cbs_type_h264;
>  extern const CodedBitstreamType ff_cbs_type_h265;
>  extern const CodedBitstreamType ff_cbs_type_jpeg;
>  extern const CodedBitstreamType ff_cbs_type_mpeg2;
> +extern const CodedBitstreamType ff_cbs_type_vp8;
>  extern const CodedBitstreamType ff_cbs_type_vp9;
>  
>  
> diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c
> new file mode 100644
> index 00..a890590cd9
> --- /dev/null
> +++ b/libavcodec/cbs_vp8.c
> @@ -0,0 +1,360 @@
> +/*
> + * 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"

Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-08-09 Thread Xiang, Haihao
On Ma, 2023-07-31 at 02:14 +, Dai, Jianhui J wrote:
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Dai,
> > Jianhui J
> > Sent: Tuesday, June 20, 2023 9:42 AM
> > To: FFmpeg development discussions and patches 
> > Subject: Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8
> > codec bitstream READ methods
> > 
> > 
> > 
> > > -Original Message-
> > > From: Dai, Jianhui J
> > > Sent: Thursday, June 8, 2023 11:18 AM
> > > To: FFmpeg development discussions and patches
> > > 
> > > Subject: RE: [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec
> > > bitstream READ methods
> > > 
> > > 
> > > 
> > > > -Original Message-
> > > > From: ffmpeg-devel  On Behalf Of
> > > > Dai, Jianhui J
> > > > Sent: Tuesday, May 30, 2023 4:00 PM
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Subject: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for
> > > > VP8 codec bitstream READ methods
> > > > 
> > > > This commit adds VP8 into cbs supported codec list, and enables the
> > > > `trace_headers` bitstream filters to support VP8, besides existing
> > > > AV1, H.264,
> > > > H.265 and VP9. It can be useful to debug VP8 stream issues.
> > > > 
> > > > Only the READ methods `read_unit` and `split_fragment` are
> > > > implemented, the WRITE methods `write_unit` and `assemble_fragment`
> > > > return `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8
> > > > WRITE is unlikely used by any applications at the moment. The WRITE
> > > > methods can be added later if there are real requirments.
> > > > 
> > > > TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
> > > > -bsf:v trace_headers -f null -
> > > > 
> > > > Signed-off-by: Jianhui Dai 
> > > > ---
> > > >  configure    |   4 +-
> > > >  libavcodec/Makefile  |   1 +
> > > >  libavcodec/cbs.c |   6 +
> > > >  libavcodec/cbs_internal.h    |   1 +
> > > >  libavcodec/cbs_vp8.c | 360 +++
> > > >  libavcodec/cbs_vp8.h | 112 +
> > > >  libavcodec/cbs_vp8_syntax_template.c | 224 +
> > > >  7 files changed, 707 insertions(+), 1 deletion(-)  create mode
> > > > 100644 libavcodec/cbs_vp8.c  create mode 100644 libavcodec/cbs_vp8.h
> > > > create mode
> > > > 100644 libavcodec/cbs_vp8_syntax_template.c
> > > > 
> > > > diff --git a/configure b/configure
> > > > index bb7be67676..b8960d2639 100755
> > > > --- a/configure
> > > > +++ b/configure
> > > > @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
> > > >  cbs_h265
> > > >  cbs_jpeg
> > > >  cbs_mpeg2
> > > > +    cbs_vp8
> > > >  cbs_vp9
> > > >  deflate_wrapper
> > > >  dirac_parse
> > > > @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
> > > >  cbs_h265_select="cbs"
> > > >  cbs_jpeg_select="cbs"
> > > >  cbs_mpeg2_select="cbs"
> > > > +cbs_vp8_select="cbs"
> > > >  cbs_vp9_select="cbs"
> > > >  dct_select="rdft"
> > > >  deflate_wrapper_deps="zlib"
> > > > @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
> > > >  hevc_metadata_bsf_select="cbs_h265"
> > > >  mjpeg2jpeg_bsf_select="jpegtables"
> > > >  mpeg2_metadata_bsf_select="cbs_mpeg2"
> > > > -trace_headers_bsf_select="cbs"
> > > > +trace_headers_bsf_select="cbs cbs_vp8"
> > > >  vp9_metadata_bsf_select="cbs_vp9"
> > > > 
> > > >  # external libraries
> > > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> > > > 3cfb7e..1c4f0da1d2 100644
> > > > --- a/libavcodec/Makefile
> > > > +++ b/libavcodec/Makefile
> > > > @@ -78,6 +78,7 @@ 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-$(CONFI

Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-07-30 Thread Dai, Jianhui J



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Dai,
> Jianhui J
> Sent: Tuesday, June 20, 2023 9:42 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8
> codec bitstream READ methods
> 
> 
> 
> > -Original Message-
> > From: Dai, Jianhui J
> > Sent: Thursday, June 8, 2023 11:18 AM
> > To: FFmpeg development discussions and patches
> > 
> > Subject: RE: [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec
> > bitstream READ methods
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel  On Behalf Of
> > > Dai, Jianhui J
> > > Sent: Tuesday, May 30, 2023 4:00 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for
> > > VP8 codec bitstream READ methods
> > >
> > > This commit adds VP8 into cbs supported codec list, and enables the
> > > `trace_headers` bitstream filters to support VP8, besides existing
> > > AV1, H.264,
> > > H.265 and VP9. It can be useful to debug VP8 stream issues.
> > >
> > > Only the READ methods `read_unit` and `split_fragment` are
> > > implemented, the WRITE methods `write_unit` and `assemble_fragment`
> > > return `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8
> > > WRITE is unlikely used by any applications at the moment. The WRITE
> > > methods can be added later if there are real requirments.
> > >
> > > TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
> > > -bsf:v trace_headers -f null -
> > >
> > > Signed-off-by: Jianhui Dai 
> > > ---
> > >  configure|   4 +-
> > >  libavcodec/Makefile  |   1 +
> > >  libavcodec/cbs.c |   6 +
> > >  libavcodec/cbs_internal.h|   1 +
> > >  libavcodec/cbs_vp8.c | 360 +++
> > >  libavcodec/cbs_vp8.h | 112 +
> > >  libavcodec/cbs_vp8_syntax_template.c | 224 +
> > >  7 files changed, 707 insertions(+), 1 deletion(-)  create mode
> > > 100644 libavcodec/cbs_vp8.c  create mode 100644 libavcodec/cbs_vp8.h
> > > create mode
> > > 100644 libavcodec/cbs_vp8_syntax_template.c
> > >
> > > diff --git a/configure b/configure
> > > index bb7be67676..b8960d2639 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
> > >  cbs_h265
> > >  cbs_jpeg
> > >  cbs_mpeg2
> > > +cbs_vp8
> > >  cbs_vp9
> > >  deflate_wrapper
> > >  dirac_parse
> > > @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
> > >  cbs_h265_select="cbs"
> > >  cbs_jpeg_select="cbs"
> > >  cbs_mpeg2_select="cbs"
> > > +cbs_vp8_select="cbs"
> > >  cbs_vp9_select="cbs"
> > >  dct_select="rdft"
> > >  deflate_wrapper_deps="zlib"
> > > @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
> > >  hevc_metadata_bsf_select="cbs_h265"
> > >  mjpeg2jpeg_bsf_select="jpegtables"
> > >  mpeg2_metadata_bsf_select="cbs_mpeg2"
> > > -trace_headers_bsf_select="cbs"
> > > +trace_headers_bsf_select="cbs cbs_vp8"
> > >  vp9_metadata_bsf_select="cbs_vp9"
> > >
> > >  # external libraries
> > > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> > > 3cfb7e..1c4f0da1d2 100644
> > > --- a/libavcodec/Makefile
> > > +++ b/libavcodec/Makefile
> > > @@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
> > >  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> > > +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
> > >  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> > >  OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
> > >  OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o 
> > > dct32_float.o
> > > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index
> > > 504197e06d..c77110ab

Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-06-19 Thread Dai, Jianhui J



> -Original Message-
> From: Dai, Jianhui J
> Sent: Thursday, June 8, 2023 11:18 AM
> To: FFmpeg development discussions and patches 
> Subject: RE: [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream
> READ methods
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of Dai,
> > Jianhui J
> > Sent: Tuesday, May 30, 2023 4:00 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for
> > VP8 codec bitstream READ methods
> >
> > This commit adds VP8 into cbs supported codec list, and enables the
> > `trace_headers` bitstream filters to support VP8, besides existing
> > AV1, H.264,
> > H.265 and VP9. It can be useful to debug VP8 stream issues.
> >
> > Only the READ methods `read_unit` and `split_fragment` are
> > implemented, the WRITE methods `write_unit` and `assemble_fragment`
> > return `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8
> > WRITE is unlikely used by any applications at the moment. The WRITE
> > methods can be added later if there are real requirments.
> >
> > TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
> > -bsf:v trace_headers -f null -
> >
> > Signed-off-by: Jianhui Dai 
> > ---
> >  configure|   4 +-
> >  libavcodec/Makefile  |   1 +
> >  libavcodec/cbs.c |   6 +
> >  libavcodec/cbs_internal.h|   1 +
> >  libavcodec/cbs_vp8.c | 360 +++
> >  libavcodec/cbs_vp8.h | 112 +
> >  libavcodec/cbs_vp8_syntax_template.c | 224 +
> >  7 files changed, 707 insertions(+), 1 deletion(-)  create mode 100644
> > libavcodec/cbs_vp8.c  create mode 100644 libavcodec/cbs_vp8.h  create
> > mode
> > 100644 libavcodec/cbs_vp8_syntax_template.c
> >
> > diff --git a/configure b/configure
> > index bb7be67676..b8960d2639 100755
> > --- a/configure
> > +++ b/configure
> > @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
> >  cbs_h265
> >  cbs_jpeg
> >  cbs_mpeg2
> > +cbs_vp8
> >  cbs_vp9
> >  deflate_wrapper
> >  dirac_parse
> > @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
> >  cbs_h265_select="cbs"
> >  cbs_jpeg_select="cbs"
> >  cbs_mpeg2_select="cbs"
> > +cbs_vp8_select="cbs"
> >  cbs_vp9_select="cbs"
> >  dct_select="rdft"
> >  deflate_wrapper_deps="zlib"
> > @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
> >  hevc_metadata_bsf_select="cbs_h265"
> >  mjpeg2jpeg_bsf_select="jpegtables"
> >  mpeg2_metadata_bsf_select="cbs_mpeg2"
> > -trace_headers_bsf_select="cbs"
> > +trace_headers_bsf_select="cbs cbs_vp8"
> >  vp9_metadata_bsf_select="cbs_vp9"
> >
> >  # external libraries
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> > 3cfb7e..1c4f0da1d2 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
> >  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> > +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
> >  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> >  OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
> >  OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
> > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index
> > 504197e06d..c77110abb1
> > 100644
> > --- a/libavcodec/cbs.c
> > +++ b/libavcodec/cbs.c
> > @@ -46,6 +46,9 @@ static const CodedBitstreamType *const
> > cbs_type_table[] = {  #if CONFIG_CBS_MPEG2
> >  _cbs_type_mpeg2,
> >  #endif
> > +#if CONFIG_CBS_VP8
> > +_cbs_type_vp8,
> > +#endif
> >  #if CONFIG_CBS_VP9
> >  _cbs_type_vp9,
> >  #endif
> > @@ -67,6 +70,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {  #if
> > CONFIG_CBS_MPEG2
> >  AV_CODEC_ID_MPEG2VIDEO,
> >  #endif
> > +#if CONFIG_CBS_VP8
> > +AV_CODEC_ID_VP8,
> > +#endif
> >  #if CONFIG_CBS_VP9
> >  AV_CODEC_ID_VP9,
> >  #endif
> > diff --git a/libav

Re: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-06-07 Thread Dai, Jianhui J



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Dai,
> Jianhui J
> Sent: Tuesday, May 30, 2023 4:00 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8
> codec bitstream READ methods
> 
> This commit adds VP8 into cbs supported codec list, and enables the
> `trace_headers` bitstream filters to support VP8, besides existing AV1, H.264,
> H.265 and VP9. It can be useful to debug VP8 stream issues.
> 
> Only the READ methods `read_unit` and `split_fragment` are implemented, the
> WRITE methods `write_unit` and `assemble_fragment` return
> `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8 WRITE is
> unlikely used by any applications at the moment. The WRITE methods can be
> added later if there are real requirments.
> 
> TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy -bsf:v
> trace_headers -f null -
> 
> Signed-off-by: Jianhui Dai 
> ---
>  configure|   4 +-
>  libavcodec/Makefile  |   1 +
>  libavcodec/cbs.c |   6 +
>  libavcodec/cbs_internal.h|   1 +
>  libavcodec/cbs_vp8.c | 360 +++
>  libavcodec/cbs_vp8.h | 112 +
>  libavcodec/cbs_vp8_syntax_template.c | 224 +
>  7 files changed, 707 insertions(+), 1 deletion(-)  create mode 100644
> libavcodec/cbs_vp8.c  create mode 100644 libavcodec/cbs_vp8.h  create mode
> 100644 libavcodec/cbs_vp8_syntax_template.c
> 
> diff --git a/configure b/configure
> index bb7be67676..b8960d2639 100755
> --- a/configure
> +++ b/configure
> @@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
>  cbs_h265
>  cbs_jpeg
>  cbs_mpeg2
> +cbs_vp8
>  cbs_vp9
>  deflate_wrapper
>  dirac_parse
> @@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
>  cbs_h265_select="cbs"
>  cbs_jpeg_select="cbs"
>  cbs_mpeg2_select="cbs"
> +cbs_vp8_select="cbs"
>  cbs_vp9_select="cbs"
>  dct_select="rdft"
>  deflate_wrapper_deps="zlib"
> @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
>  hevc_metadata_bsf_select="cbs_h265"
>  mjpeg2jpeg_bsf_select="jpegtables"
>  mpeg2_metadata_bsf_select="cbs_mpeg2"
> -trace_headers_bsf_select="cbs"
> +trace_headers_bsf_select="cbs cbs_vp8"
>  vp9_metadata_bsf_select="cbs_vp9"
> 
>  # external libraries
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> 3cfb7e..1c4f0da1d2 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
>  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
> +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
>  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
>  OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
>  OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
> diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 504197e06d..c77110abb1
> 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -46,6 +46,9 @@ static const CodedBitstreamType *const cbs_type_table[]
> = {  #if CONFIG_CBS_MPEG2
>  _cbs_type_mpeg2,
>  #endif
> +#if CONFIG_CBS_VP8
> +_cbs_type_vp8,
> +#endif
>  #if CONFIG_CBS_VP9
>  _cbs_type_vp9,
>  #endif
> @@ -67,6 +70,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {  #if
> CONFIG_CBS_MPEG2
>  AV_CODEC_ID_MPEG2VIDEO,
>  #endif
> +#if CONFIG_CBS_VP8
> +AV_CODEC_ID_VP8,
> +#endif
>  #if CONFIG_CBS_VP9
>  AV_CODEC_ID_VP9,
>  #endif
> diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index
> e585c77934..beaf8505d1 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -247,6 +247,7 @@ extern const CodedBitstreamType ff_cbs_type_h264;
> extern const CodedBitstreamType ff_cbs_type_h265;  extern const
> CodedBitstreamType ff_cbs_type_jpeg;  extern const CodedBitstreamType
> ff_cbs_type_mpeg2;
> +extern const CodedBitstreamType ff_cbs_type_vp8;
>  extern const CodedBitstreamType ff_cbs_type_vp9;
> 
> 
> diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c new file mode 100644
> index 00..a890590cd9
> --- /dev/null
> +++ b/libavcodec/cbs_vp8.c
> @@ -0,0 +1,360 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribut

[FFmpeg-devel] [PATCH v3] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods

2023-05-30 Thread Dai, Jianhui J
This commit adds VP8 into cbs supported codec list, and enables the
`trace_headers` bitstream filters to support VP8, besides existing AV1,
H.264, H.265 and VP9. It can be useful to debug VP8 stream issues.

Only the READ methods `read_unit` and `split_fragment` are implemented,
the WRITE methods `write_unit` and `assemble_fragment` return
`AVERROR_PATCHWELCOME` error code. It is because the CBS VP8 WRITE is
unlikely used by any applications at the moment. The WRITE methods can
be added later if there are real requirments.

TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy
-bsf:v trace_headers -f null -

Signed-off-by: Jianhui Dai 
---
 configure|   4 +-
 libavcodec/Makefile  |   1 +
 libavcodec/cbs.c |   6 +
 libavcodec/cbs_internal.h|   1 +
 libavcodec/cbs_vp8.c | 360 +++
 libavcodec/cbs_vp8.h | 112 +
 libavcodec/cbs_vp8_syntax_template.c | 224 +
 7 files changed, 707 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/cbs_vp8.c
 create mode 100644 libavcodec/cbs_vp8.h
 create mode 100644 libavcodec/cbs_vp8_syntax_template.c

diff --git a/configure b/configure
index bb7be67676..b8960d2639 100755
--- a/configure
+++ b/configure
@@ -2432,6 +2432,7 @@ CONFIG_EXTRA="
 cbs_h265
 cbs_jpeg
 cbs_mpeg2
+cbs_vp8
 cbs_vp9
 deflate_wrapper
 dirac_parse
@@ -2713,6 +2714,7 @@ cbs_h264_select="cbs"
 cbs_h265_select="cbs"
 cbs_jpeg_select="cbs"
 cbs_mpeg2_select="cbs"
+cbs_vp8_select="cbs"
 cbs_vp9_select="cbs"
 dct_select="rdft"
 deflate_wrapper_deps="zlib"
@@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264"
 hevc_metadata_bsf_select="cbs_h265"
 mjpeg2jpeg_bsf_select="jpegtables"
 mpeg2_metadata_bsf_select="cbs_mpeg2"
-trace_headers_bsf_select="cbs"
+trace_headers_bsf_select="cbs cbs_vp8"
 vp9_metadata_bsf_select="cbs_vp9"
 
 # external libraries
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cfb7e..1c4f0da1d2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -78,6 +78,7 @@ 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_JPEG)+= cbs_jpeg.o
 OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
+OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o
 OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
 OBJS-$(CONFIG_CRYSTALHD)   += crystalhd.o
 OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index 504197e06d..c77110abb1 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -46,6 +46,9 @@ static const CodedBitstreamType *const cbs_type_table[] = {
 #if CONFIG_CBS_MPEG2
 _cbs_type_mpeg2,
 #endif
+#if CONFIG_CBS_VP8
+_cbs_type_vp8,
+#endif
 #if CONFIG_CBS_VP9
 _cbs_type_vp9,
 #endif
@@ -67,6 +70,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = {
 #if CONFIG_CBS_MPEG2
 AV_CODEC_ID_MPEG2VIDEO,
 #endif
+#if CONFIG_CBS_VP8
+AV_CODEC_ID_VP8,
+#endif
 #if CONFIG_CBS_VP9
 AV_CODEC_ID_VP9,
 #endif
diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h
index e585c77934..beaf8505d1 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -247,6 +247,7 @@ extern const CodedBitstreamType ff_cbs_type_h264;
 extern const CodedBitstreamType ff_cbs_type_h265;
 extern const CodedBitstreamType ff_cbs_type_jpeg;
 extern const CodedBitstreamType ff_cbs_type_mpeg2;
+extern const CodedBitstreamType ff_cbs_type_vp8;
 extern const CodedBitstreamType ff_cbs_type_vp9;
 
 
diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c
new file mode 100644
index 00..a890590cd9
--- /dev/null
+++ b/libavcodec/cbs_vp8.c
@@ -0,0 +1,360 @@
+/*
+ * 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 "cbs.h"
+#include "cbs_internal.h"
+#include "cbs_vp8.h"
+
+#include "vp8data.h"
+
+// Wrap of VPXRangeCoder to support size check.
+typedef struct CBSVP8RangeCoder {
+VPXRangeCoder c;
+const uint8_t *buffer;
+int buffer_size;
+} CBSVP8RangeCoder;
+