Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp

2023-08-24 Thread Steven Liu
Marton Balint  于2023年8月25日周五 05:48写道:
Hi Marton,

>
>
>
> On Thu, 24 Aug 2023, Tristan Matthews wrote:
>
> > Hi,
> >
> > On Thu, Aug 24, 2023 at 1:32 AM Steven Liu  wrote:
> >>
> >> add option named rtmp_enhanced_codec,
> >> it would support hvc1,av01,vp09 now,
> >> the fourcc is using Array of strings.
> >>
> >> Signed-off-by: Steven Liu 
> >> ---
> >>  doc/protocols.texi  |  6 ++
> >>  libavformat/rtmpproto.c | 38 ++
> >>  2 files changed, 44 insertions(+)
> >>
> >> diff --git a/doc/protocols.texi b/doc/protocols.texi
> >> index b3fad55591..f2930fb3a2 100644
> >> --- a/doc/protocols.texi
> >> +++ b/doc/protocols.texi
> >> @@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and 
> >> specifying the name before
> >>  the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
> >>  times to construct arbitrary AMF sequences.
> >>
> >> +@item rtmp_enhanced_codec
>
> This is a list, so make it -rtmp_enhanced_codecs
>
> >> +Specify that the media is an enhanced rtmp live stream. This option should
> >> +set a sting like @code{hvc1,av01,vp09} for multiple codecs, or @code{hvc1}
> >
> > I think this should be more like "Specify the codecs to use in an
> > enhanced rtmp live stream", the wording here makes it sound more like
> > a boolean flag.
>
> Actually it is a *supported* list, not a to-be-used list. So maybe
> "Specify the list of codecs the client advertises to support in an
> enhanced RTMP stream" is more appropriate.
>
> >
> > Also nit: "set a string"
> >
> >> +for only one codec, set codec fourcc into fourCcLive property into
> >> +Connect Command Message,
> >> +
> >>  @item rtmp_flashver
> >>  Version of the Flash plugin used to run the SWF player. The default
> >>  is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
> >> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> >> index f0ef223f05..f7ce04244f 100644
> >> --- a/libavformat/rtmpproto.c
> >> +++ b/libavformat/rtmpproto.c
> >> @@ -127,6 +127,7 @@ typedef struct RTMPContext {
> >>  int   nb_streamid;///< The next stream id to 
> >> return on createStream calls
> >>  doubleduration;   ///< Duration of the stream 
> >> in seconds as returned by the server (only valid if non-zero)
> >>  int   tcp_nodelay;///< Use TCP_NODELAY to 
> >> disable Nagle's algorithm if set to 1
> >> +char  *enhanced;  ///< codecs list in 
> >> enhanced rtmp
>
> char *enhanced_codecs
>
> >
> > nit: "codec list"
> >>  char  username[50];
> >>  char  password[50];
> >>  char  auth_params[500];
> >> @@ -336,6 +337,42 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
> >>  ff_amf_write_field_name(, "app");
> >>  ff_amf_write_string2(, rt->app, rt->auth_params);
> >>
> >> +if (rt->enhanced) {
> >> +uint32_t list_len = 0;
> >> +char *fourcc_data = rt->enhanced;
> >> +int fourcc_str_len = fourcc_data ? strlen(fourcc_data) : 0;
>
> fourcc_data is always true.
>
> >> +
> >> +// check the string, fourcc + ',' + ...  + end fourcc correct 
> >> length should be (4+1)*n+4
> >> +if ((fourcc_str_len + 1) % 5 != 0)
> >> +return AVERROR(EINVAL);
> >> +
> >> +list_len = (fourcc_str_len + 1) / 5;
> >> +// write the fourCcList field name
> >> +ff_amf_write_field_name(, "fourCcList");
> >> +
> >> +// write the fourcc array length
> >> +ff_amf_write_array(, list_len);
> >> +
> >> +while(fourcc_data) {
>
> Still always true.
>
> >> +unsigned char fourcc[5];
> >> +switch (*(uint32_t *)fourcc_data) {
>
> AV_RN32
>
> >> +case MKTAG('h', 'v', 'c', '1'):
> >> +case MKTAG('a', 'v', '0', '1'):
> >> +case MKTAG('v', 'p', '0', '9'):
> >> +strncpy(fourcc, fourcc_data, 4);
> >> +fourcc[4] = '\0';
>
> av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
>
> >> +ff_amf_write_string(, fourcc);
> >> +break;
> >> +default:
> >> +return AVERROR(EINVAL);
> >> +}
> >> +
> >> +fourcc_data += (fourcc_str_len - (fourcc_data - 
> >> rt->enhanced)) > 4 ? 5 : 4;
>
> Why not simply fourcc_data += 5?
>
> >> +if (fourcc_data - rt->enhanced >= fourcc_str_len)
> >> +break;
>
> Why not check this as the loop condition instead?
>
> Regards,
> Marton
>
> >> +}
> >> +}
> >> +
> >>  if (!rt->is_input) {
> >>  ff_amf_write_field_name(, "type");
> >>  ff_amf_write_string(, "nonprivate");
> >> @@ -3104,6 +3141,7 @@ static const AVOption rtmp_options[] = {
> >>  {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
> >> OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
> >> 

Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp

2023-08-24 Thread Steven Liu
Tristan Matthews  于2023年8月25日周五 04:11写道:
>
> Hi,
Hi Tristan,

>
> On Thu, Aug 24, 2023 at 1:32 AM Steven Liu  wrote:
> >
> > add option named rtmp_enhanced_codec,
> > it would support hvc1,av01,vp09 now,
> > the fourcc is using Array of strings.
> >
> > Signed-off-by: Steven Liu 
> > ---
> >  doc/protocols.texi  |  6 ++
> >  libavformat/rtmpproto.c | 38 ++
> >  2 files changed, 44 insertions(+)
> >
> > diff --git a/doc/protocols.texi b/doc/protocols.texi
> > index b3fad55591..f2930fb3a2 100644
> > --- a/doc/protocols.texi
> > +++ b/doc/protocols.texi
> > @@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and 
> > specifying the name before
> >  the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
> >  times to construct arbitrary AMF sequences.
> >
> > +@item rtmp_enhanced_codec
> > +Specify that the media is an enhanced rtmp live stream. This option should
> > +set a sting like @code{hvc1,av01,vp09} for multiple codecs, or @code{hvc1}
>
> I think this should be more like "Specify the codecs to use in an
> enhanced rtmp live stream", the wording here makes it sound more like
> a boolean flag.
>
> Also nit: "set a string"
>
> > +for only one codec, set codec fourcc into fourCcLive property into
> > +Connect Command Message,
> > +
> >  @item rtmp_flashver
> >  Version of the Flash plugin used to run the SWF player. The default
> >  is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
> > diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> > index f0ef223f05..f7ce04244f 100644
> > --- a/libavformat/rtmpproto.c
> > +++ b/libavformat/rtmpproto.c
> > @@ -127,6 +127,7 @@ typedef struct RTMPContext {
> >  int   nb_streamid;///< The next stream id to 
> > return on createStream calls
> >  doubleduration;   ///< Duration of the stream 
> > in seconds as returned by the server (only valid if non-zero)
> >  int   tcp_nodelay;///< Use TCP_NODELAY to 
> > disable Nagle's algorithm if set to 1
> > +char  *enhanced;  ///< codecs list in enhanced 
> > rtmp
>
> nit: "codec list"
> >  char  username[50];
> >  char  password[50];
> >  char  auth_params[500];
> > @@ -336,6 +337,42 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
> >  ff_amf_write_field_name(, "app");
> >  ff_amf_write_string2(, rt->app, rt->auth_params);
> >
> > +if (rt->enhanced) {
> > +uint32_t list_len = 0;
> > +char *fourcc_data = rt->enhanced;
> > +int fourcc_str_len = fourcc_data ? strlen(fourcc_data) : 0;
> > +
> > +// check the string, fourcc + ',' + ...  + end fourcc correct 
> > length should be (4+1)*n+4
> > +if ((fourcc_str_len + 1) % 5 != 0)
> > +return AVERROR(EINVAL);
> > +
> > +list_len = (fourcc_str_len + 1) / 5;
> > +// write the fourCcList field name
> > +ff_amf_write_field_name(, "fourCcList");
> > +
> > +// write the fourcc array length
> > +ff_amf_write_array(, list_len);
> > +
> > +while(fourcc_data) {
> > +unsigned char fourcc[5];
> > +switch (*(uint32_t *)fourcc_data) {
> > +case MKTAG('h', 'v', 'c', '1'):
> > +case MKTAG('a', 'v', '0', '1'):
> > +case MKTAG('v', 'p', '0', '9'):
> > +strncpy(fourcc, fourcc_data, 4);
> > +fourcc[4] = '\0';
> > +ff_amf_write_string(, fourcc);
> > +break;
> > +default:
> > +return AVERROR(EINVAL);
> > +}
> > +
> > +fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) 
> > > 4 ? 5 : 4;
> > +if (fourcc_data - rt->enhanced >= fourcc_str_len)
> > +break;
> > +}
> > +}
> > +
> >  if (!rt->is_input) {
> >  ff_amf_write_field_name(, "type");
> >  ff_amf_write_string(, "nonprivate");
> > @@ -3104,6 +3141,7 @@ static const AVOption rtmp_options[] = {
> >  {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
> > OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
> >  {"rtmp_flashver", "Version of the Flash plugin used to run the SWF 
> > player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, 
> > DEC|ENC},
> >  {"rtmp_flush_interval", "Number of packets flushed in the same request 
> > (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 
> > INT_MAX, ENC},
> > +{"rtmp_enhanced_codec", "Specify that the codec in enhanced rtmp live 
> > stream", OFFSET(enhanced), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC},
>
> I think this should be more like "Specify the codec(s) to use in an
> enhanced rtmp live stream" ?
>
> >  {"rtmp_live", "Specify that the media is a live stream.", 
> > 

[FFmpeg-devel] [PATCH v2 2/2] avformat/rtmpproto: support enhanced rtmp

2023-08-24 Thread Steven Liu
Add option named rtmp_enhanced_codec,
it would support hvc1,av01,vp09 now,
the fourcc is using Array of strings.

Signed-off-by: Steven Liu 
---
 doc/protocols.texi  |  6 ++
 libavformat/rtmpproto.c | 35 +++
 2 files changed, 41 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b3fad55591..bd2b25e502 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and specifying 
the name before
 the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
 times to construct arbitrary AMF sequences.
 
+@item rtmp_enhanced_codecs
+Specify the list of codecs the client advertises to support in an
+enhanced RTMP stream. This option should set a string like 
@code{hvc1,av01,vp09}
+for multiple codecs, or @code{hvc1} for only one codec,
+set codec fourcc into fourCcLive property into Connect Command Message,
+
 @item rtmp_flashver
 Version of the Flash plugin used to run the SWF player. The default
 is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index f0ef223f05..ea25454362 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -127,6 +127,7 @@ typedef struct RTMPContext {
 int   nb_streamid;///< The next stream id to 
return on createStream calls
 doubleduration;   ///< Duration of the stream in 
seconds as returned by the server (only valid if non-zero)
 int   tcp_nodelay;///< Use TCP_NODELAY to disable 
Nagle's algorithm if set to 1
+char  *enhanced_codecs;   ///< codec list in enhanced rtmp
 char  username[50];
 char  password[50];
 char  auth_params[500];
@@ -336,6 +337,39 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
 ff_amf_write_field_name(, "app");
 ff_amf_write_string2(, rt->app, rt->auth_params);
 
+if (rt->enhanced_codecs) {
+uint32_t list_len = 0;
+char *fourcc_data = rt->enhanced_codecs;
+int fourcc_str_len = strlen(fourcc_data);
+
+// check the string, fourcc + ',' + ...  + end fourcc correct length 
should be (4+1)*n+4
+if ((fourcc_str_len + 1) % 5 != 0)
+return AVERROR(EINVAL);
+
+list_len = (fourcc_str_len + 1) / 5;
+// write the fourCcList field name
+ff_amf_write_field_name(, "fourCcList");
+
+// write the fourcc array length
+ff_amf_write_array_start(, list_len);
+
+while(fourcc_data - rt->enhanced_codecs < fourcc_str_len) {
+unsigned char fourcc[5];
+switch (AV_RN32(fourcc_data)) {
+case MKTAG('h', 'v', 'c', '1'):
+case MKTAG('a', 'v', '0', '1'):
+case MKTAG('v', 'p', '0', '9'):
+av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));
+ff_amf_write_string(, fourcc);
+break;
+default:
+return AVERROR(EINVAL);
+}
+
+fourcc_data += 5;
+}
+}
+
 if (!rt->is_input) {
 ff_amf_write_field_name(, "type");
 ff_amf_write_string(, "nonprivate");
@@ -3104,6 +3138,7 @@ static const AVOption rtmp_options[] = {
 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"rtmp_flashver", "Version of the Flash plugin used to run the SWF 
player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"rtmp_flush_interval", "Number of packets flushed in the same request 
(RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 
INT_MAX, ENC},
+{"rtmp_enhanced_codecs", "Specify the codec(s) to use in an enhanced rtmp 
live stream", OFFSET(enhanced_codecs), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 
0, ENC},
 {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
 {"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, "rtmp_live"},
 {"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, 
"rtmp_live"},
-- 
2.40.0

___
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 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings

2023-08-24 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/rtmppkt.c | 6 ++
 libavformat/rtmppkt.h | 8 
 2 files changed, 14 insertions(+)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..a602bf6a96 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
 bytestream_put_be64(dst, av_double2int(val));
 }
 
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length)
+{
+bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+bytestream_put_be32(dst, length);
+}
+
 void ff_amf_write_string(uint8_t **dst, const char *str)
 {
 bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..7c580f2224 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
  */
 void ff_amf_write_object_start(uint8_t **dst);
 
+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array_start(uint8_t **dst, uint32_t length);
+
 /**
  * Write string used as field name in AMF object to buffer.
  *
-- 
2.40.0

___
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 v4] avcodec/cbs_vp8: Add support for VP8 codec bitstream

2023-08-24 Thread Dai, Jianhui J



> -Original Message-
> From: ffmpeg-devel  On Behalf Of Dai,
> Jianhui J
> Sent: Friday, August 25, 2023 10:40 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v4] avcodec/cbs_vp8: Add support for VP8
> codec bitstream
> 
> This commit adds support for VP8 bitstream read methods to the cbs codec.
> This enables the trace_headers bitstream filter to support VP8, in addition to
> AV1, H.264, H.265, and VP9. This can be useful for debugging VP8 stream
> issues.
> 
> The CBS VP8 implements a simple VP8 boolean decoder with bounds
> checking to prevent overreads.
> 
> Only the read methods `read_unit` and `split_fragment` are implemented.
> The write methods `write_unit` and `assemble_fragment` return the error
> code AVERROR_PATCHWELCOME. This is because CBS VP8 write is unlikely to
> be used by any applications at the moment. The write methods can be added
> later if there is a real need for them.
> 
> 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 | 591 +++
>  libavcodec/cbs_vp8.h | 137 +++
>  libavcodec/cbs_vp8_syntax_template.c | 248 +++
>  7 files changed, 987 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 932998b8d6..2424ee61ad 100755
> --- a/configure
> +++ b/configure
> @@ -2479,6 +2479,7 @@ CONFIG_EXTRA="
>  cbs_h266
>  cbs_jpeg
>  cbs_mpeg2
> +cbs_vp8
>  cbs_vp9
>  deflate_wrapper
>  dirac_parse
> @@ -2764,6 +2765,7 @@ cbs_h265_select="cbs"
>  cbs_h266_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"
> @@ -3349,7 +3351,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"
>  vvc_metadata_bsf_select="cbs_h266"
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> 3c16b51462..04f735f45e 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -79,6 +79,7 @@ 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_VP8) += cbs_vp8.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 3ec8285e21..f891e7247f
> 100644
> --- a/libavcodec/cbs.c
> +++ b/libavcodec/cbs.c
> @@ -49,6 +49,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
> @@ -73,6 +76,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
> da84697a29..7ae7e477d6 100644
> --- a/libavcodec/cbs_internal.h
> +++ b/libavcodec/cbs_internal.h
> @@ -263,6 +263,7 @@ extern const CodedBitstreamType ff_cbs_type_h265;
> extern const CodedBitstreamType ff_cbs_type_h266;  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..6db295ce08
> --- /dev/null
> +++ b/libavcodec/cbs_vp8.c
> @@ -0,0 +1,591 @@
> +/*
> + * 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 

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/vulkan_decode: print also codec header name

2023-08-24 Thread Lynne
Aug 23, 2023, 22:06 by kaspe...@gmail.com:

> Signed-off-by: Kacper Michajłow 
> ---
>  libavcodec/vulkan_decode.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
> index 7607edf52e..0d561b7450 100644
> --- a/libavcodec/vulkan_decode.c
> +++ b/libavcodec/vulkan_decode.c
> @@ -863,6 +863,9 @@ static int vulkan_decode_get_profile(AVCodecContext 
> *avctx, AVBufferRef *frames_
>  caps->maxDpbSlots);
>  av_log(avctx, AV_LOG_VERBOSE, "Maximum active references: %u\n",
>  caps->maxActiveReferencePictures);
> +av_log(avctx, AV_LOG_VERBOSE, "Codec header name: '%s' (driver), 
> '%s' (compiled)\n",
> +   caps->stdHeaderVersion.extensionName,
> +   dec_ext[avctx->codec_id]->extensionName);
>  av_log(avctx, AV_LOG_VERBOSE, "Codec header version: %i.%i.%i (driver), 
> %i.%i.%i (compiled)\n",
>  CODEC_VER(caps->stdHeaderVersion.specVersion),
>  CODEC_VER(dec_ext[avctx->codec_id]->specVersion));
>

Pushed, along with the first commit in the patchset.
As for the second, Mesa still doesn't signal a correct version,a
and I'd rather have at least one fully working implementation at any time.
___
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 v3 5/5] lavfi/vf_xfade_vulkan: add wipes

2023-08-24 Thread Lynne
Aug 21, 2023, 22:46 by epira...@gmail.com:

> Add the wipetl, wipetr, wipebl, wipebr effects.
> ---
>  libavfilter/vf_xfade_vulkan.c | 60 +++
>  1 file changed, 60 insertions(+)
>

Patchset pushed,
Thanks
___
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] avcodec/cbs_vp8: Add support for VP8 codec bitstream

2023-08-24 Thread Dai, Jianhui J
This commit adds support for VP8 bitstream read methods to the cbs
codec. This enables the trace_headers bitstream filter to support VP8,
in addition to AV1, H.264, H.265, and VP9. This can be useful for
debugging VP8 stream issues.

The CBS VP8 implements a simple VP8 boolean decoder with bounds checking
to prevent overreads.

Only the read methods `read_unit` and `split_fragment` are implemented.
The write methods `write_unit` and `assemble_fragment` return the error
code AVERROR_PATCHWELCOME. This is because CBS VP8 write is unlikely to
be used by any applications at the moment. The write methods can be
added later if there is a real need for them.

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 | 591 +++
 libavcodec/cbs_vp8.h | 137 +++
 libavcodec/cbs_vp8_syntax_template.c | 248 +++
 7 files changed, 987 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 932998b8d6..2424ee61ad 100755
--- a/configure
+++ b/configure
@@ -2479,6 +2479,7 @@ CONFIG_EXTRA="
 cbs_h266
 cbs_jpeg
 cbs_mpeg2
+cbs_vp8
 cbs_vp9
 deflate_wrapper
 dirac_parse
@@ -2764,6 +2765,7 @@ cbs_h265_select="cbs"
 cbs_h266_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"
@@ -3349,7 +3351,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"
 vvc_metadata_bsf_select="cbs_h266"
 
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3c16b51462..04f735f45e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -79,6 +79,7 @@ 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_VP8) += cbs_vp8.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 3ec8285e21..f891e7247f 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -49,6 +49,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
@@ -73,6 +76,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 da84697a29..7ae7e477d6 100644
--- a/libavcodec/cbs_internal.h
+++ b/libavcodec/cbs_internal.h
@@ -263,6 +263,7 @@ extern const CodedBitstreamType ff_cbs_type_h265;
 extern const CodedBitstreamType ff_cbs_type_h266;
 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..6db295ce08
--- /dev/null
+++ b/libavcodec/cbs_vp8.c
@@ -0,0 +1,591 @@
+/*
+ * 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 
+
+#define DEFAULT_PROB 0x80
+
+static const uint8_t 

Re: [FFmpeg-devel] [PATCH 1/2] doc/developer: Reviews must be constructive

2023-08-24 Thread Vittorio Giovara
On Thu, Aug 24, 2023 at 9:56 PM Michael Niedermayer 
wrote:

> Suggested text is from Anton
>
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/developer.texi | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/doc/developer.texi b/doc/developer.texi
> index 0c2f2cd7d1..383120daaa 100644
> --- a/doc/developer.texi
> +++ b/doc/developer.texi
> @@ -853,6 +853,9 @@ Everyone is welcome to review patches. Also if you are
> waiting for your patch
>  to be reviewed, please consider helping to review other patches, that is
> a great
>  way to get everyone's patches reviewed sooner.
>
> +Reviews must be constructive and when rejecting a patch the reviewer must
> explain
> +their reasons and ideally suggest an alternative approach.
>

NAK
we shouldn't put extra burden on reviewers, nor guilt trap them into
suggesting an alternative approach
offlist and irc discussion is of course recommended, but writing this rules
in stone will only deter good reviews, in my opinion
-- 
Vittorio
___
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] lavfi/dnn: Add OpenVINO API 2.0 support

2023-08-24 Thread Guo, Yejun



> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> wenbin.chen-at-intel@ffmpeg.org
> Sent: Tuesday, August 15, 2023 4:27 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2] lavfi/dnn: Add OpenVINO API 2.0
> support
> 
> From: Wenbin Chen 
> 
> OpenVINO API 2.0 was released in March 2022, which introduced new
> features.
> This commit implements current OpenVINO features with new 2.0 APIs. And
> will add other features in API 2.0.
> Please add installation path, which include openvino.pc, to
> PKG_CONFIG_PATH mannually for new OpenVINO libs config.
> 
> Signed-off-by: Ting Fu 
> Signed-off-by: Wenbin Chen 
> ---

LGTM, will push tomorrow, thanks.
___
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 1/2] Revert "avcodec/apedec: fix decoding 24bit insane files with recent versions"

2023-08-24 Thread Michael Niedermayer
On Fri, Aug 25, 2023 at 01:37:27AM +0200, Paul B Mahol wrote:
> NAK
> 
> Breaks decoding of another sample.

please provide the sample

if noone provides a sample, i will disregard this objection.
Also as a sidenote, iam in contact with Matt Ashland and he also
doesnt know what your commit was trying to fix

thx

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

If the United States is serious about tackling the national security threats 
related to an insecure 5G network, it needs to rethink the extent to which it
values corporate profits and government espionage over security.-Bruce Schneier


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 1/2] Revert "avcodec/apedec: fix decoding 24bit insane files with recent versions"

2023-08-24 Thread Paul B Mahol
NAK

Breaks decoding of another sample.
___
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/2] avcodec/apedec: Fix CRC for 24bps and bigendian

2023-08-24 Thread Michael Niedermayer
Fixes CRC for vlc.ape and APE_48K_24bit_2CH_02_01.ape

Signed-off-by: Michael Niedermayer 
---
 libavcodec/apedec.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index cc0d7e2749..d48d3a676d 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1592,13 +1592,24 @@ static int ape_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 s->samples -= blockstodecode;
 
 if (avctx->err_recognition & AV_EF_CRCCHECK &&
-s->fileversion >= 3900 && s->bps < 24) {
+s->fileversion >= 3900) {
 uint32_t crc = s->CRC_state;
 const AVCRC *crc_tab = av_crc_get_table(AV_CRC_32_IEEE_LE);
+int stride = s->bps == 24 ? 4 : (s->bps>>3);
+int offset = s->bps == 24;
+int bytes  = s->bps >> 3;
+
 for (i = 0; i < blockstodecode; i++) {
 for (ch = 0; ch < s->channels; ch++) {
-uint8_t *smp = frame->data[ch] + (i*(s->bps >> 3));
-crc = av_crc(crc_tab, crc, smp, s->bps >> 3);
+#if HAVE_BIGENDIAN
+uint8_t *smp_native = frame->data[ch] + i*stride;
+uint8_t smp[4];
+for(int j = 0; jdata[ch] + i*stride;
+#endif
+crc = av_crc(crc_tab, crc, smp+offset, bytes);
 }
 }
 
-- 
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 1/2] Revert "avcodec/apedec: fix decoding 24bit insane files with recent versions"

2023-08-24 Thread Michael Niedermayer
Fixes: Ticket9816

This reverts commit ed0001482a74b60f3d5bc5cd7e304c9d65b2fcd5.
---
 libavcodec/apedec.c | 59 ++---
 1 file changed, 13 insertions(+), 46 deletions(-)

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index 613c76df0b..cc0d7e2749 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -134,21 +134,6 @@ typedef struct APEPredictor {
 unsigned int sample_pos;
 } APEPredictor;
 
-typedef struct APEPredictor64 {
-int64_t *buf;
-
-int64_t lastA[2];
-
-int64_t filterA[2];
-int64_t filterB[2];
-
-uint64_t coeffsA[2][4];  ///< adaption coefficients
-uint64_t coeffsB[2][5];  ///< adaption coefficients
-int64_t historybuffer[HISTORY_SIZE + PREDICTOR_SIZE];
-
-unsigned int sample_pos;
-} APEPredictor64;
-
 /** Decoder context */
 typedef struct APEContext {
 AVClass *class;  ///< class for AVOptions
@@ -168,7 +153,6 @@ typedef struct APEContext {
 uint32_t CRC_state;  ///< accumulated CRC
 int frameflags;  ///< frame flags
 APEPredictor predictor;  ///< predictor used for final 
reconstruction
-APEPredictor64 predictor64;  ///< 64bit predictor used for 
final reconstruction
 
 int32_t *decoded_buffer;
 int decoded_size;
@@ -808,20 +792,13 @@ static const int32_t initial_coeffs_3930[4] = {
 360, 317, -109, 98
 };
 
-static const int64_t initial_coeffs_3930_64bit[4] = {
-360, 317, -109, 98
-};
-
 static void init_predictor_decoder(APEContext *ctx)
 {
 APEPredictor *p = >predictor;
-APEPredictor64 *p64 = >predictor64;
 
 /* Zero the history buffers */
 memset(p->historybuffer, 0, PREDICTOR_SIZE * sizeof(*p->historybuffer));
-memset(p64->historybuffer, 0, PREDICTOR_SIZE * 
sizeof(*p64->historybuffer));
 p->buf = p->historybuffer;
-p64->buf = p64->historybuffer;
 
 /* Initialize and zero the coefficients */
 if (ctx->fileversion < 3930) {
@@ -839,11 +816,8 @@ static void init_predictor_decoder(APEContext *ctx)
 } else {
 memcpy(p->coeffsA[0], initial_coeffs_3930, 
sizeof(initial_coeffs_3930));
 memcpy(p->coeffsA[1], initial_coeffs_3930, 
sizeof(initial_coeffs_3930));
-memcpy(p64->coeffsA[0], initial_coeffs_3930_64bit, 
sizeof(initial_coeffs_3930_64bit));
-memcpy(p64->coeffsA[1], initial_coeffs_3930_64bit, 
sizeof(initial_coeffs_3930_64bit));
 }
 memset(p->coeffsB, 0, sizeof(p->coeffsB));
-memset(p64->coeffsB, 0, sizeof(p64->coeffsB));
 if (ctx->fileversion < 3930) {
 memcpy(p->coeffsB[0], initial_coeffs_b_3800,
sizeof(initial_coeffs_b_3800));
@@ -855,13 +829,7 @@ static void init_predictor_decoder(APEContext *ctx)
 p->filterB[0] = p->filterB[1] = 0;
 p->lastA[0]   = p->lastA[1]   = 0;
 
-p64->filterA[0] = p64->filterA[1] = 0;
-p64->filterB[0] = p64->filterB[1] = 0;
-p64->lastA[0]   = p64->lastA[1]   = 0;
-
 p->sample_pos = 0;
-
-p64->sample_pos = 0;
 }
 
 /** Get inverse sign of integer (-1 for positive, 1 for negative and 0 for 
zero) */
@@ -1181,17 +1149,16 @@ static void predictor_decode_mono_3930(APEContext *ctx, 
int count)
 }
 }
 
-static av_always_inline int predictor_update_filter(APEPredictor64 *p,
+static av_always_inline int predictor_update_filter(APEPredictor *p,
 const int decoded, const 
int filter,
 const int delayA,  const 
int delayB,
 const int adaptA,  const 
int adaptB)
 {
-int64_t predictionA, predictionB;
-int32_t sign;
+int32_t predictionA, predictionB, sign;
 
 p->buf[delayA] = p->lastA[filter];
 p->buf[adaptA] = APESIGN(p->buf[delayA]);
-p->buf[delayA - 1] = p->buf[delayA] - (uint64_t)p->buf[delayA - 1];
+p->buf[delayA - 1] = p->buf[delayA] - (unsigned)p->buf[delayA - 1];
 p->buf[adaptA - 1] = APESIGN(p->buf[delayA - 1]);
 
 predictionA = p->buf[delayA] * p->coeffsA[filter][0] +
@@ -1200,9 +1167,9 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
   p->buf[delayA - 3] * p->coeffsA[filter][3];
 
 /*  Apply a scaled first-order filter compression */
-p->buf[delayB] = p->filterA[filter ^ 1] - 
((int64_t)(p->filterB[filter] * 31ULL) >> 5);
+p->buf[delayB] = p->filterA[filter ^ 1] - ((int)(p->filterB[filter] * 
31U) >> 5);
 p->buf[adaptB] = APESIGN(p->buf[delayB]);
-p->buf[delayB - 1] = p->buf[delayB] - (uint64_t)p->buf[delayB - 1];
+p->buf[delayB - 1] = p->buf[delayB] - (unsigned)p->buf[delayB - 1];
 p->buf[adaptB - 1] = APESIGN(p->buf[delayB - 1]);
 p->filterB[filter] = p->filterA[filter ^ 1];
 
@@ -1212,8 +1179,8 @@ static av_always_inline int 
predictor_update_filter(APEPredictor64 *p,
   p->buf[delayB - 3] * 

Re: [FFmpeg-devel] [PATCH] OSQ lossless audio format support

2023-08-24 Thread Paul B Mahol
On Thu, Aug 24, 2023 at 11:51 PM James Almer  wrote:

> On 8/24/2023 6:11 PM, Paul B Mahol wrote:
> > On Thu, Aug 24, 2023 at 11:00 PM James Almer  wrote:
> >
> >> On 8/24/2023 6:52 AM, Paul B Mahol wrote:
> >>> +static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
> >>> +{
> >>> +OSQContext *s = avctx->priv_data;
> >>> +GetBitContext *gb = >gb;
> >>> +int ret, n;
> >>> +
> >>> +while (s->bitstream_size < s->max_framesize) {
> >>> +int size;
> >>> +
> >>> +if (!s->pkt->data) {
> >>> +ret = ff_decode_get_packet(avctx, s->pkt);
> >>> +if (ret == AVERROR_EOF && s->bitstream_size > 0)
> >>> +break;
> >>> +if (ret < 0)
> >>> +return ret;
> >>> +}
> >>> +
> >>> +size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize -
> >> s->bitstream_size);
> >>> +memcpy(s->bitstream + s->bitstream_size, s->pkt->data +
> >> s->pkt_offset, size);
> >>> +s->bitstream_size += size;
> >>> +s->pkt_offset += size;
> >>> +
> >>> +if (s->pkt_offset == s->pkt->size) {
> >>> +av_packet_unref(s->pkt);
> >>> +s->pkt_offset = 0;
> >>> +}
> >>
> >> This looks like you're assembling a packet of max_framesize bytes. You
> >> should instead do that in a parser, and ensure here that the packets fed
> >> to this decoder are <= max_framesize.
> >>
> >>> +}
> >>> +
> >>> +frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
> >>> +if (frame->nb_samples <= 0)
> >>> +return AVERROR_EOF;
> >>> +
> >>> +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> >>> +goto fail;
> >>> +
> >>> +if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) <
> 0)
> >>> +goto fail;
> >>> +
> >>> +if ((ret = osq_decode_block(avctx, frame)) < 0)
> >>> +goto fail;
> >>> +
> >>> +s->nb_samples -= frame->nb_samples;
> >>> +
> >>> +n = get_bits_count(gb) / 8;
> >>> +if (n > s->bitstream_size) {
> >>> +ret = AVERROR_INVALIDDATA;
> >>> +goto fail;
> >>> +}
> >>> +
> >>> +memmove(s->bitstream, >bitstream[n], s->bitstream_size - n);
> >>> +s->bitstream_size -= n;
> >>> +
> >>> +return 0;
> >>> +
> >>> +fail:
> >>> +s->bitstream_size = 0;
> >>> +s->pkt_offset = 0;
> >>> +av_packet_unref(s->pkt);
> >>> +
> >>> +return ret;
> >>> +}
> >>> +
> >>> +const AVInputFormat ff_osq_demuxer = {
> >>> +.name   = "osq",
> >>> +.long_name  = NULL_IF_CONFIG_SMALL("raw OSQ"),
> >>> +.read_probe = osq_probe,
> >>> +.read_header= osq_read_header,
> >>> +.read_packet= ff_raw_read_partial_packet,
> >>
> >> Instead of sending an arbitrarily sized packet (1024 bytes as of now),
> >> you should set codecpar->frame_size and propagate packets with that
> >> amount of bytes instead.
> >> A parser is still needed, though, for non seekable input (a pipe). And
> >> in case the decoder is fed with non lavf input.
> >>
> >
> > Format is not seekable, packet sizes are nowhere stored in .osq files.
>
> Same case as raw formats like H.264. No packet sizes, no seekability
> without having parsed the entire sequence to build a list of seek
> points, etc. A parser has to assemble access units.
>

But there is no any info how to assemble anything here, unless
you propose decoding inside parser?



>
> >
> > Think of this format like APAC/BONK/WAVARC but just no need to keep
> unused
> > bits from previous decoded data/packet.
> > With this fact, parser makes no sense to do.
>
> You know that frame_size is (frame_samples_per_channel * 16 + 1024) *
> channels. A parser can work with that (Look at gsm parser for example.
> There may be others too).
>

There is reason why variable is called max_framesize.

You should not propagate truncated data in 1024 byte chunks, and the
> decoder should not expect that either.
>

Nothing gets truncated. That is just worst case scenario size for packet.
In another words, size of packet can be anything between 33 and
max_framesize.


>
> >
> >
> >>> +.extensions = "osq",
> >>> +.flags  = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH |
> >> AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
> >>> +.raw_codec_id   = AV_CODEC_ID_OSQ,
> >>> +.priv_data_size = sizeof(FFRawDemuxerContext),
> >>> +.priv_class = _raw_demuxer_class,
> >>> +};
> >>
> >> ___
> >> 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] OSQ lossless audio format support

2023-08-24 Thread James Almer

On 8/24/2023 6:11 PM, Paul B Mahol wrote:

On Thu, Aug 24, 2023 at 11:00 PM James Almer  wrote:


On 8/24/2023 6:52 AM, Paul B Mahol wrote:

+static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+OSQContext *s = avctx->priv_data;
+GetBitContext *gb = >gb;
+int ret, n;
+
+while (s->bitstream_size < s->max_framesize) {
+int size;
+
+if (!s->pkt->data) {
+ret = ff_decode_get_packet(avctx, s->pkt);
+if (ret == AVERROR_EOF && s->bitstream_size > 0)
+break;
+if (ret < 0)
+return ret;
+}
+
+size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize -

s->bitstream_size);

+memcpy(s->bitstream + s->bitstream_size, s->pkt->data +

s->pkt_offset, size);

+s->bitstream_size += size;
+s->pkt_offset += size;
+
+if (s->pkt_offset == s->pkt->size) {
+av_packet_unref(s->pkt);
+s->pkt_offset = 0;
+}


This looks like you're assembling a packet of max_framesize bytes. You
should instead do that in a parser, and ensure here that the packets fed
to this decoder are <= max_framesize.


+}
+
+frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
+if (frame->nb_samples <= 0)
+return AVERROR_EOF;
+
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+goto fail;
+
+if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
+goto fail;
+
+if ((ret = osq_decode_block(avctx, frame)) < 0)
+goto fail;
+
+s->nb_samples -= frame->nb_samples;
+
+n = get_bits_count(gb) / 8;
+if (n > s->bitstream_size) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+memmove(s->bitstream, >bitstream[n], s->bitstream_size - n);
+s->bitstream_size -= n;
+
+return 0;
+
+fail:
+s->bitstream_size = 0;
+s->pkt_offset = 0;
+av_packet_unref(s->pkt);
+
+return ret;
+}
+
+const AVInputFormat ff_osq_demuxer = {
+.name   = "osq",
+.long_name  = NULL_IF_CONFIG_SMALL("raw OSQ"),
+.read_probe = osq_probe,
+.read_header= osq_read_header,
+.read_packet= ff_raw_read_partial_packet,


Instead of sending an arbitrarily sized packet (1024 bytes as of now),
you should set codecpar->frame_size and propagate packets with that
amount of bytes instead.
A parser is still needed, though, for non seekable input (a pipe). And
in case the decoder is fed with non lavf input.



Format is not seekable, packet sizes are nowhere stored in .osq files.


Same case as raw formats like H.264. No packet sizes, no seekability 
without having parsed the entire sequence to build a list of seek 
points, etc. A parser has to assemble access units.




Think of this format like APAC/BONK/WAVARC but just no need to keep unused
bits from previous decoded data/packet.
With this fact, parser makes no sense to do.


You know that frame_size is (frame_samples_per_channel * 16 + 1024) * 
channels. A parser can work with that (Look at gsm parser for example. 
There may be others too).
You should not propagate truncated data in 1024 byte chunks, and the 
decoder should not expect that either.






+.extensions = "osq",
+.flags  = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH |

AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,

+.raw_codec_id   = AV_CODEC_ID_OSQ,
+.priv_data_size = sizeof(FFRawDemuxerContext),
+.priv_class = _raw_demuxer_class,
+};


___
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".


Re: [FFmpeg-devel] [PATCH v1 2/2] avformat/rtmpproto: support enhanced rtmp

2023-08-24 Thread Marton Balint



On Thu, 24 Aug 2023, Tristan Matthews wrote:


Hi,

On Thu, Aug 24, 2023 at 1:32 AM Steven Liu  wrote:


add option named rtmp_enhanced_codec,
it would support hvc1,av01,vp09 now,
the fourcc is using Array of strings.

Signed-off-by: Steven Liu 
---
 doc/protocols.texi  |  6 ++
 libavformat/rtmpproto.c | 38 ++
 2 files changed, 44 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index b3fad55591..f2930fb3a2 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and specifying 
the name before
 the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
 times to construct arbitrary AMF sequences.

+@item rtmp_enhanced_codec


This is a list, so make it -rtmp_enhanced_codecs


+Specify that the media is an enhanced rtmp live stream. This option should
+set a sting like @code{hvc1,av01,vp09} for multiple codecs, or @code{hvc1}


I think this should be more like "Specify the codecs to use in an
enhanced rtmp live stream", the wording here makes it sound more like
a boolean flag.


Actually it is a *supported* list, not a to-be-used list. So maybe 
"Specify the list of codecs the client advertises to support in an 
enhanced RTMP stream" is more appropriate.




Also nit: "set a string"


+for only one codec, set codec fourcc into fourCcLive property into
+Connect Command Message,
+
 @item rtmp_flashver
 Version of the Flash plugin used to run the SWF player. The default
 is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index f0ef223f05..f7ce04244f 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -127,6 +127,7 @@ typedef struct RTMPContext {
 int   nb_streamid;///< The next stream id to 
return on createStream calls
 doubleduration;   ///< Duration of the stream in 
seconds as returned by the server (only valid if non-zero)
 int   tcp_nodelay;///< Use TCP_NODELAY to disable 
Nagle's algorithm if set to 1
+char  *enhanced;  ///< codecs list in enhanced rtmp


char *enhanced_codecs



nit: "codec list"

 char  username[50];
 char  password[50];
 char  auth_params[500];
@@ -336,6 +337,42 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
 ff_amf_write_field_name(, "app");
 ff_amf_write_string2(, rt->app, rt->auth_params);

+if (rt->enhanced) {
+uint32_t list_len = 0;
+char *fourcc_data = rt->enhanced;
+int fourcc_str_len = fourcc_data ? strlen(fourcc_data) : 0;


fourcc_data is always true.


+
+// check the string, fourcc + ',' + ...  + end fourcc correct length 
should be (4+1)*n+4
+if ((fourcc_str_len + 1) % 5 != 0)
+return AVERROR(EINVAL);
+
+list_len = (fourcc_str_len + 1) / 5;
+// write the fourCcList field name
+ff_amf_write_field_name(, "fourCcList");
+
+// write the fourcc array length
+ff_amf_write_array(, list_len);
+
+while(fourcc_data) {


Still always true.


+unsigned char fourcc[5];
+switch (*(uint32_t *)fourcc_data) {


AV_RN32


+case MKTAG('h', 'v', 'c', '1'):
+case MKTAG('a', 'v', '0', '1'):
+case MKTAG('v', 'p', '0', '9'):
+strncpy(fourcc, fourcc_data, 4);
+fourcc[4] = '\0';


av_strlcpy(fourcc, fourcc_data, sizeof(fourcc));


+ff_amf_write_string(, fourcc);
+break;
+default:
+return AVERROR(EINVAL);
+}
+
+fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) > 4 
? 5 : 4;


Why not simply fourcc_data += 5?


+if (fourcc_data - rt->enhanced >= fourcc_str_len)
+break;


Why not check this as the loop condition instead?

Regards,
Marton


+}
+}
+
 if (!rt->is_input) {
 ff_amf_write_field_name(, "type");
 ff_amf_write_string(, "nonprivate");
@@ -3104,6 +3141,7 @@ static const AVOption rtmp_options[] = {
 {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"rtmp_flashver", "Version of the Flash plugin used to run the SWF 
player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
 {"rtmp_flush_interval", "Number of packets flushed in the same request (RTMPT 
only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, INT_MAX, ENC},
+{"rtmp_enhanced_codec", "Specify that the codec in enhanced rtmp live 
stream", OFFSET(enhanced), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC},


I think this should be more like "Specify the codec(s) to use in an
enhanced rtmp live stream" ?


 

Re: [FFmpeg-devel] [PATCH] OSQ lossless audio format support

2023-08-24 Thread Paul B Mahol
On Thu, Aug 24, 2023 at 11:00 PM James Almer  wrote:

> On 8/24/2023 6:52 AM, Paul B Mahol wrote:
> > +static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
> > +{
> > +OSQContext *s = avctx->priv_data;
> > +GetBitContext *gb = >gb;
> > +int ret, n;
> > +
> > +while (s->bitstream_size < s->max_framesize) {
> > +int size;
> > +
> > +if (!s->pkt->data) {
> > +ret = ff_decode_get_packet(avctx, s->pkt);
> > +if (ret == AVERROR_EOF && s->bitstream_size > 0)
> > +break;
> > +if (ret < 0)
> > +return ret;
> > +}
> > +
> > +size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize -
> s->bitstream_size);
> > +memcpy(s->bitstream + s->bitstream_size, s->pkt->data +
> s->pkt_offset, size);
> > +s->bitstream_size += size;
> > +s->pkt_offset += size;
> > +
> > +if (s->pkt_offset == s->pkt->size) {
> > +av_packet_unref(s->pkt);
> > +s->pkt_offset = 0;
> > +}
>
> This looks like you're assembling a packet of max_framesize bytes. You
> should instead do that in a parser, and ensure here that the packets fed
> to this decoder are <= max_framesize.
>
> > +}
> > +
> > +frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
> > +if (frame->nb_samples <= 0)
> > +return AVERROR_EOF;
> > +
> > +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
> > +goto fail;
> > +
> > +if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
> > +goto fail;
> > +
> > +if ((ret = osq_decode_block(avctx, frame)) < 0)
> > +goto fail;
> > +
> > +s->nb_samples -= frame->nb_samples;
> > +
> > +n = get_bits_count(gb) / 8;
> > +if (n > s->bitstream_size) {
> > +ret = AVERROR_INVALIDDATA;
> > +goto fail;
> > +}
> > +
> > +memmove(s->bitstream, >bitstream[n], s->bitstream_size - n);
> > +s->bitstream_size -= n;
> > +
> > +return 0;
> > +
> > +fail:
> > +s->bitstream_size = 0;
> > +s->pkt_offset = 0;
> > +av_packet_unref(s->pkt);
> > +
> > +return ret;
> > +}
> > +
> > +const AVInputFormat ff_osq_demuxer = {
> > +.name   = "osq",
> > +.long_name  = NULL_IF_CONFIG_SMALL("raw OSQ"),
> > +.read_probe = osq_probe,
> > +.read_header= osq_read_header,
> > +.read_packet= ff_raw_read_partial_packet,
>
> Instead of sending an arbitrarily sized packet (1024 bytes as of now),
> you should set codecpar->frame_size and propagate packets with that
> amount of bytes instead.
> A parser is still needed, though, for non seekable input (a pipe). And
> in case the decoder is fed with non lavf input.
>

Format is not seekable, packet sizes are nowhere stored in .osq files.

Think of this format like APAC/BONK/WAVARC but just no need to keep unused
bits from previous decoded data/packet.
With this fact, parser makes no sense to do.


> > +.extensions = "osq",
> > +.flags  = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH |
> AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
> > +.raw_codec_id   = AV_CODEC_ID_OSQ,
> > +.priv_data_size = sizeof(FFRawDemuxerContext),
> > +.priv_class = _raw_demuxer_class,
> > +};
>
> ___
> 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] OSQ lossless audio format support

2023-08-24 Thread James Almer

On 8/24/2023 6:52 AM, Paul B Mahol wrote:

+static int osq_receive_frame(AVCodecContext *avctx, AVFrame *frame)
+{
+OSQContext *s = avctx->priv_data;
+GetBitContext *gb = >gb;
+int ret, n;
+
+while (s->bitstream_size < s->max_framesize) {
+int size;
+
+if (!s->pkt->data) {
+ret = ff_decode_get_packet(avctx, s->pkt);
+if (ret == AVERROR_EOF && s->bitstream_size > 0)
+break;
+if (ret < 0)
+return ret;
+}
+
+size = FFMIN(s->pkt->size - s->pkt_offset, s->max_framesize - 
s->bitstream_size);
+memcpy(s->bitstream + s->bitstream_size, s->pkt->data + s->pkt_offset, 
size);
+s->bitstream_size += size;
+s->pkt_offset += size;
+
+if (s->pkt_offset == s->pkt->size) {
+av_packet_unref(s->pkt);
+s->pkt_offset = 0;
+}


This looks like you're assembling a packet of max_framesize bytes. You 
should instead do that in a parser, and ensure here that the packets fed 
to this decoder are <= max_framesize.



+}
+
+frame->nb_samples = FFMIN(s->frame_samples, s->nb_samples);
+if (frame->nb_samples <= 0)
+return AVERROR_EOF;
+
+if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
+goto fail;
+
+if ((ret = init_get_bits8(gb, s->bitstream, s->bitstream_size)) < 0)
+goto fail;
+
+if ((ret = osq_decode_block(avctx, frame)) < 0)
+goto fail;
+
+s->nb_samples -= frame->nb_samples;
+
+n = get_bits_count(gb) / 8;
+if (n > s->bitstream_size) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+memmove(s->bitstream, >bitstream[n], s->bitstream_size - n);
+s->bitstream_size -= n;
+
+return 0;
+
+fail:
+s->bitstream_size = 0;
+s->pkt_offset = 0;
+av_packet_unref(s->pkt);
+
+return ret;
+}
+
+const AVInputFormat ff_osq_demuxer = {
+.name   = "osq",
+.long_name  = NULL_IF_CONFIG_SMALL("raw OSQ"),
+.read_probe = osq_probe,
+.read_header= osq_read_header,
+.read_packet= ff_raw_read_partial_packet,


Instead of sending an arbitrarily sized packet (1024 bytes as of now), 
you should set codecpar->frame_size and propagate packets with that 
amount of bytes instead.
A parser is still needed, though, for non seekable input (a pipe). And 
in case the decoder is fed with non lavf input.



+.extensions = "osq",
+.flags  = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | 
AVFMT_NO_BYTE_SEEK | AVFMT_NOTIMESTAMPS,
+.raw_codec_id   = AV_CODEC_ID_OSQ,
+.priv_data_size = sizeof(FFRawDemuxerContext),
+.priv_class = _raw_demuxer_class,
+};


___
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 1/2] avformat/rtmppkt: add ff_amf_write_array for write array strings

2023-08-24 Thread Marton Balint




On Thu, 24 Aug 2023, Steven Liu wrote:


Signed-off-by: Steven Liu 
---
libavformat/rtmppkt.c | 6 ++
libavformat/rtmppkt.h | 8 
2 files changed, 14 insertions(+)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 4b97c0833f..cd0c68ec8a 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -40,6 +40,12 @@ void ff_amf_write_number(uint8_t **dst, double val)
bytestream_put_be64(dst, av_double2int(val));
}

+void ff_amf_write_array(uint8_t **dst, uint32_t val)


ff_amf_write_array_start() would be a better name for the function, 
because it does not write the full array, only the beginning.


length would be a better name for the parameter.

Regards,
Marton


+{
+bytestream_put_byte(dst, AMF_DATA_TYPE_ARRAY);
+bytestream_put_be32(dst, val);
+}
+
void ff_amf_write_string(uint8_t **dst, const char *str)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_STRING);
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index a15d2a5773..44c3420436 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -244,6 +244,14 @@ void ff_amf_write_null(uint8_t **dst);
 */
void ff_amf_write_object_start(uint8_t **dst);

+/**
+ * Write marker and length for AMF array to buffer.
+ *
+ * @param dst pointer to the input buffer (will be modified)
+ * @param length value to write
+ */
+void ff_amf_write_array(uint8_t **dst, uint32_t val);
+
/**
 * Write string used as field name in AMF object to buffer.
 *
--
2.40.0

___
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] OSQ lossless audio format support

2023-08-24 Thread Paul B Mahol
On Thu, Aug 24, 2023 at 9:54 PM James Almer  wrote:

> On 8/24/2023 6:52 AM, Paul B Mahol wrote:
> > Patches attached.
> >
> > Stereo decoding have some issues with some predictors so not yet
> bitexact.
> >
> > Please comment.
>
> > +static av_cold int osq_close(AVCodecContext *avctx)
> > +{
> > +OSQContext *s = avctx->priv_data;
> > +
> > +av_freep(>bitstream);
> > +s->bitstream_size = 0;
> > +
> > +for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++)
>
> FFMIN(avctx->ch_layout.nb_channels, 2);
>
> This being a FF_CODEC_CAP_INIT_CLEANUP decoder, osq_close() could be
> called before osq_init() has a chance to validate nb_channels.
>

Will use ELEMS_ARRAY macro.


> > +av_freep(>decode_buffer[ch]);
> > +
> > +return 0;
> > +}
> > +
> > static av_cold int osq_init(AVCodecContext *avctx)
> > +{
> > +OSQContext *s = avctx->priv_data;
> > +
> > +if (avctx->extradata_size < 48)
> > +return AVERROR(EINVAL);
> > +
> > +if (avctx->extradata[0] != 1) {
> > +av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
> > +return AVERROR_INVALIDDATA;
> > +}
> > +
> > +avctx->sample_rate = AV_RL32(avctx->extradata + 4);
> > +if (avctx->sample_rate < 1)
> > +return AVERROR_INVALIDDATA;
> > +
> > +avctx->ch_layout.nb_channels = avctx->extradata[3];
>
> You'd need to uninit ch_layout first, as the user may have filled it
> with something (as is the case with the lavf demuxer).
>

Fixed.


>
> > +if (avctx->ch_layout.nb_channels < 1)
> > +return AVERROR_INVALIDDATA;
> > +
> > +switch (avctx->extradata[2]) {
> > +case  8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
> > +case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
> > +case 20:
> > +case 24:
> > +case 28:
> > +case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
> > +default: return AVERROR_INVALIDDATA;
> > +}
> > +
> > +s->nb_samples = AV_RL64(avctx->extradata + 16);
> > +s->frame_samples = AV_RL16(avctx->extradata + 8);
> > +s->max_framesize = (s->frame_samples * 16 + 1024) *
> avctx->ch_layout.nb_channels;
>
> Do you even need to propagate this header using extradata? You can set
> codecpar's sample_fmt and frame_size in the demuxer, much like you're
> doing for sample_rate and ch_layout.
> There doesn't seem to be a value that can't be propagated using the
> proper existing fields here.
>

version is passed via extradata, its more cleaner approach.


>
> > +
> > +s->bitstream = av_calloc(s->max_framesize +
> AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
>
> av_mallocz(). sizeof(*s->bitstream) is 1.
>

nit, i think it changes effectively nothing.


> > +if (!s->bitstream)
> > +return AVERROR(ENOMEM);
> > +
> > +for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
> > +s->decode_buffer[ch] = av_calloc(s->frame_samples + 4,
> > + sizeof(*s->decode_buffer[ch]));
> > +if (!s->decode_buffer[ch])
> > +return AVERROR(ENOMEM);
> > +}
> > +
> > +s->pkt = avctx->internal->in_pkt;
> > +
> > +return 0;
> > +}
> ___
> 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/2] doc/developer: Code pushed without patches on ffmpeg-devel must be announced on the ML

2023-08-24 Thread Andreas Rheinhardt
James Almer:
> On 8/24/2023 4:56 PM, Michael Niedermayer wrote:
>> Signed-off-by: Michael Niedermayer 
>> ---
>>   doc/developer.texi | 9 +
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/doc/developer.texi b/doc/developer.texi
>> index 383120daaa..1c0091fc74 100644
>> --- a/doc/developer.texi
>> +++ b/doc/developer.texi
>> @@ -856,6 +856,15 @@ way to get everyone's patches reviewed sooner.
>>   Reviews must be constructive and when rejecting a patch the reviewer
>> must explain
>>   their reasons and ideally suggest an alternative approach.
>>   +If a change is pushed without being sent to ffmpeg-devel, the
>> developer
>> +pushing it must annouce doing so on the ffmpeg-devel mailing list
>> immedeatly.
> 
> immediately.
> 
> This chunk is ok, but...
> 
>> +@example
>> +forgot a semicolon in this patch, pushed a seperate fix
>> +pushed my new autograd engine and stable diffusion filter. Didnt want to
>> +go through the bikeshed if that belongs in FFmpeg, go to the GA if
>> you want
>> +it removed. Otherwise Just tell me what i should improve and ill look
>> into it.
>> +@end example
> 
> ...this one isn't. It's very passive aggressive and not informative at all.
> This instead should state that patches pushed without passing through
> the ML have to either be trivial, to push fixes to mistakes in recently
> pushed changes that did go through the ML, or for code you maintain.
> 

The maintainer exception has actually been removed in
6a3e174ad1921ba6aec473a2224c71610de3329b.

- Andreas

___
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/2] avformat/rtmpproto: support enhanced rtmp

2023-08-24 Thread Tristan Matthews
Hi,

On Thu, Aug 24, 2023 at 1:32 AM Steven Liu  wrote:
>
> add option named rtmp_enhanced_codec,
> it would support hvc1,av01,vp09 now,
> the fourcc is using Array of strings.
>
> Signed-off-by: Steven Liu 
> ---
>  doc/protocols.texi  |  6 ++
>  libavformat/rtmpproto.c | 38 ++
>  2 files changed, 44 insertions(+)
>
> diff --git a/doc/protocols.texi b/doc/protocols.texi
> index b3fad55591..f2930fb3a2 100644
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -896,6 +896,12 @@ be named, by prefixing the type with 'N' and specifying 
> the name before
>  the value (i.e. @code{NB:myFlag:1}). This option may be used multiple
>  times to construct arbitrary AMF sequences.
>
> +@item rtmp_enhanced_codec
> +Specify that the media is an enhanced rtmp live stream. This option should
> +set a sting like @code{hvc1,av01,vp09} for multiple codecs, or @code{hvc1}

I think this should be more like "Specify the codecs to use in an
enhanced rtmp live stream", the wording here makes it sound more like
a boolean flag.

Also nit: "set a string"

> +for only one codec, set codec fourcc into fourCcLive property into
> +Connect Command Message,
> +
>  @item rtmp_flashver
>  Version of the Flash plugin used to run the SWF player. The default
>  is LNX 9,0,124,2. (When publishing, the default is FMLE/3.0 (compatible;
> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> index f0ef223f05..f7ce04244f 100644
> --- a/libavformat/rtmpproto.c
> +++ b/libavformat/rtmpproto.c
> @@ -127,6 +127,7 @@ typedef struct RTMPContext {
>  int   nb_streamid;///< The next stream id to 
> return on createStream calls
>  doubleduration;   ///< Duration of the stream in 
> seconds as returned by the server (only valid if non-zero)
>  int   tcp_nodelay;///< Use TCP_NODELAY to 
> disable Nagle's algorithm if set to 1
> +char  *enhanced;  ///< codecs list in enhanced 
> rtmp

nit: "codec list"
>  char  username[50];
>  char  password[50];
>  char  auth_params[500];
> @@ -336,6 +337,42 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
>  ff_amf_write_field_name(, "app");
>  ff_amf_write_string2(, rt->app, rt->auth_params);
>
> +if (rt->enhanced) {
> +uint32_t list_len = 0;
> +char *fourcc_data = rt->enhanced;
> +int fourcc_str_len = fourcc_data ? strlen(fourcc_data) : 0;
> +
> +// check the string, fourcc + ',' + ...  + end fourcc correct length 
> should be (4+1)*n+4
> +if ((fourcc_str_len + 1) % 5 != 0)
> +return AVERROR(EINVAL);
> +
> +list_len = (fourcc_str_len + 1) / 5;
> +// write the fourCcList field name
> +ff_amf_write_field_name(, "fourCcList");
> +
> +// write the fourcc array length
> +ff_amf_write_array(, list_len);
> +
> +while(fourcc_data) {
> +unsigned char fourcc[5];
> +switch (*(uint32_t *)fourcc_data) {
> +case MKTAG('h', 'v', 'c', '1'):
> +case MKTAG('a', 'v', '0', '1'):
> +case MKTAG('v', 'p', '0', '9'):
> +strncpy(fourcc, fourcc_data, 4);
> +fourcc[4] = '\0';
> +ff_amf_write_string(, fourcc);
> +break;
> +default:
> +return AVERROR(EINVAL);
> +}
> +
> +fourcc_data += (fourcc_str_len - (fourcc_data - rt->enhanced)) > 
> 4 ? 5 : 4;
> +if (fourcc_data - rt->enhanced >= fourcc_str_len)
> +break;
> +}
> +}
> +
>  if (!rt->is_input) {
>  ff_amf_write_field_name(, "type");
>  ff_amf_write_string(, "nonprivate");
> @@ -3104,6 +3141,7 @@ static const AVOption rtmp_options[] = {
>  {"rtmp_conn", "Append arbitrary AMF data to the Connect message", 
> OFFSET(conn), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC|ENC},
>  {"rtmp_flashver", "Version of the Flash plugin used to run the SWF 
> player.", OFFSET(flashver), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, 
> DEC|ENC},
>  {"rtmp_flush_interval", "Number of packets flushed in the same request 
> (RTMPT only).", OFFSET(flush_interval), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 
> INT_MAX, ENC},
> +{"rtmp_enhanced_codec", "Specify that the codec in enhanced rtmp live 
> stream", OFFSET(enhanced), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, ENC},

I think this should be more like "Specify the codec(s) to use in an
enhanced rtmp live stream" ?

>  {"rtmp_live", "Specify that the media is a live stream.", OFFSET(live), 
> AV_OPT_TYPE_INT, {.i64 = -2}, INT_MIN, INT_MAX, DEC, "rtmp_live"},
>  {"any", "both", 0, AV_OPT_TYPE_CONST, {.i64 = -2}, 0, 0, DEC, 
> "rtmp_live"},
>  {"live", "live stream", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, DEC, 
> "rtmp_live"},
> --
> 2.40.0
>
> 

Re: [FFmpeg-devel] [PATCH] OSQ lossless audio format support

2023-08-24 Thread Andreas Rheinhardt
James Almer:
> On 8/24/2023 6:52 AM, Paul B Mahol wrote:
>> Patches attached.
>>
>> Stereo decoding have some issues with some predictors so not yet
>> bitexact.
>>
>> Please comment.
> 
>> +static av_cold int osq_close(AVCodecContext *avctx)
>> +{
>> +    OSQContext *s = avctx->priv_data;
>> +
>> +    av_freep(>bitstream);
>> +    s->bitstream_size = 0;
>> +
>> +    for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++)
> 
> FFMIN(avctx->ch_layout.nb_channels, 2);
> 

Easier to just use FF_ARRAY_ELEMS(s->decoder_buffer). No harm in freeing
a NULL.

> This being a FF_CODEC_CAP_INIT_CLEANUP decoder, osq_close() could be
> called before osq_init() has a chance to validate nb_channels.
> 
>> +    av_freep(>decode_buffer[ch]);
>> +
>> +    return 0;
>> +}
>> +
>> static av_cold int osq_init(AVCodecContext *avctx)
>> +{
>> +    OSQContext *s = avctx->priv_data;
>> +
>> +    if (avctx->extradata_size < 48)
>> +    return AVERROR(EINVAL);
>> +
>> +    if (avctx->extradata[0] != 1) {
>> +    av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
>> +    return AVERROR_INVALIDDATA;
>> +    }
>> +
>> +    avctx->sample_rate = AV_RL32(avctx->extradata + 4);
>> +    if (avctx->sample_rate < 1)
>> +    return AVERROR_INVALIDDATA;
>> +
>> +    avctx->ch_layout.nb_channels = avctx->extradata[3];
> 
> You'd need to uninit ch_layout first, as the user may have filled it
> with something (as is the case with the lavf demuxer).
> 
>> +    if (avctx->ch_layout.nb_channels < 1)
>> +    return AVERROR_INVALIDDATA;
>> +
>> +    switch (avctx->extradata[2]) {
>> +    case  8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
>> +    case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
>> +    case 20:
>> +    case 24:
>> +    case 28:
>> +    case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
>> +    default: return AVERROR_INVALIDDATA;
>> +    }
>> +
>> +    s->nb_samples = AV_RL64(avctx->extradata + 16);
>> +    s->frame_samples = AV_RL16(avctx->extradata + 8);
>> +    s->max_framesize = (s->frame_samples * 16 + 1024) *
>> avctx->ch_layout.nb_channels;
> 
> Do you even need to propagate this header using extradata? You can set
> codecpar's sample_fmt and frame_size in the demuxer, much like you're
> doing for sample_rate and ch_layout.
> There doesn't seem to be a value that can't be propagated using the
> proper existing fields here.
> 
>> +
>> +    s->bitstream = av_calloc(s->max_framesize +
>> AV_INPUT_BUFFER_PADDING_SIZE, sizeof(*s->bitstream));
> 
> av_mallocz(). sizeof(*s->bitstream) is 1.
> 
>> +    if (!s->bitstream)
>> +    return AVERROR(ENOMEM);
>> +
>> +    for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
>> +    s->decode_buffer[ch] = av_calloc(s->frame_samples + 4,
>> + sizeof(*s->decode_buffer[ch]));
>> +    if (!s->decode_buffer[ch])
>> +    return AVERROR(ENOMEM);
>> +    }
>> +
>> +    s->pkt = avctx->internal->in_pkt;
>> +
>> +    return 0;
>> +}
> ___
> 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/2] doc/developer: Code pushed without patches on ffmpeg-devel must be announced on the ML

2023-08-24 Thread James Almer

On 8/24/2023 4:56 PM, Michael Niedermayer wrote:

Signed-off-by: Michael Niedermayer 
---
  doc/developer.texi | 9 +
  1 file changed, 9 insertions(+)

diff --git a/doc/developer.texi b/doc/developer.texi
index 383120daaa..1c0091fc74 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -856,6 +856,15 @@ way to get everyone's patches reviewed sooner.
  Reviews must be constructive and when rejecting a patch the reviewer must 
explain
  their reasons and ideally suggest an alternative approach.
  
+If a change is pushed without being sent to ffmpeg-devel, the developer

+pushing it must annouce doing so on the ffmpeg-devel mailing list immedeatly.


immediately.

This chunk is ok, but...


+@example
+forgot a semicolon in this patch, pushed a seperate fix
+pushed my new autograd engine and stable diffusion filter. Didnt want to
+go through the bikeshed if that belongs in FFmpeg, go to the GA if you want
+it removed. Otherwise Just tell me what i should improve and ill look into it.
+@end example


...this one isn't. It's very passive aggressive and not informative at all.
This instead should state that patches pushed without passing through 
the ML have to either be trivial, to push fixes to mistakes in recently 
pushed changes that did go through the ML, or for code you maintain.



+
  @anchor{Regression tests}
  @chapter Regression tests
  

___
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/2] doc/developer: Code pushed without patches on ffmpeg-devel must be announced on the ML

2023-08-24 Thread Andreas Rheinhardt
Michael Niedermayer:
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/developer.texi | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/doc/developer.texi b/doc/developer.texi
> index 383120daaa..1c0091fc74 100644
> --- a/doc/developer.texi
> +++ b/doc/developer.texi
> @@ -856,6 +856,15 @@ way to get everyone's patches reviewed sooner.
>  Reviews must be constructive and when rejecting a patch the reviewer must 
> explain
>  their reasons and ideally suggest an alternative approach.
>  
> +If a change is pushed without being sent to ffmpeg-devel, the developer
> +pushing it must annouce doing so on the ffmpeg-devel mailing list immedeatly.
> +@example
> +forgot a semicolon in this patch, pushed a seperate fix
> +pushed my new autograd engine and stable diffusion filter. Didnt want to
> +go through the bikeshed if that belongs in FFmpeg, go to the GA if you want
> +it removed. Otherwise Just tell me what i should improve and ill look into 
> it.
> +@end example

This encourages pushing patches (even completely new filters) without
sending them to the ML.

- Andreas

___
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/2] doc/developer: Code pushed without patches on ffmpeg-devel must be announced on the ML

2023-08-24 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 doc/developer.texi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/doc/developer.texi b/doc/developer.texi
index 383120daaa..1c0091fc74 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -856,6 +856,15 @@ way to get everyone's patches reviewed sooner.
 Reviews must be constructive and when rejecting a patch the reviewer must 
explain
 their reasons and ideally suggest an alternative approach.
 
+If a change is pushed without being sent to ffmpeg-devel, the developer
+pushing it must annouce doing so on the ffmpeg-devel mailing list immedeatly.
+@example
+forgot a semicolon in this patch, pushed a seperate fix
+pushed my new autograd engine and stable diffusion filter. Didnt want to
+go through the bikeshed if that belongs in FFmpeg, go to the GA if you want
+it removed. Otherwise Just tell me what i should improve and ill look into it.
+@end example
+
 @anchor{Regression tests}
 @chapter Regression tests
 
-- 
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 1/2] doc/developer: Reviews must be constructive

2023-08-24 Thread Michael Niedermayer
Suggested text is from Anton

Signed-off-by: Michael Niedermayer 
---
 doc/developer.texi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/doc/developer.texi b/doc/developer.texi
index 0c2f2cd7d1..383120daaa 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -853,6 +853,9 @@ Everyone is welcome to review patches. Also if you are 
waiting for your patch
 to be reviewed, please consider helping to review other patches, that is a 
great
 way to get everyone's patches reviewed sooner.
 
+Reviews must be constructive and when rejecting a patch the reviewer must 
explain
+their reasons and ideally suggest an alternative approach.
+
 @anchor{Regression tests}
 @chapter Regression tests
 
-- 
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 0/2] [RFC] doc/developer patch review improvements

2023-08-24 Thread Michael Niedermayer
This set contains 2 additions to the patch review and commit policy/guidlines


___
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] OSQ lossless audio format support

2023-08-24 Thread James Almer

On 8/24/2023 6:52 AM, Paul B Mahol wrote:

Patches attached.

Stereo decoding have some issues with some predictors so not yet bitexact.

Please comment.



+static av_cold int osq_close(AVCodecContext *avctx)
+{
+OSQContext *s = avctx->priv_data;
+
+av_freep(>bitstream);
+s->bitstream_size = 0;
+
+for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++)


FFMIN(avctx->ch_layout.nb_channels, 2);

This being a FF_CODEC_CAP_INIT_CLEANUP decoder, osq_close() could be 
called before osq_init() has a chance to validate nb_channels.



+av_freep(>decode_buffer[ch]);
+
+return 0;
+}
+
static av_cold int osq_init(AVCodecContext *avctx)
+{
+OSQContext *s = avctx->priv_data;
+
+if (avctx->extradata_size < 48)
+return AVERROR(EINVAL);
+
+if (avctx->extradata[0] != 1) {
+av_log(avctx, AV_LOG_ERROR, "Unsupported version.\n");
+return AVERROR_INVALIDDATA;
+}
+
+avctx->sample_rate = AV_RL32(avctx->extradata + 4);
+if (avctx->sample_rate < 1)
+return AVERROR_INVALIDDATA;
+
+avctx->ch_layout.nb_channels = avctx->extradata[3];


You'd need to uninit ch_layout first, as the user may have filled it 
with something (as is the case with the lavf demuxer).



+if (avctx->ch_layout.nb_channels < 1)
+return AVERROR_INVALIDDATA;
+
+switch (avctx->extradata[2]) {
+case  8: avctx->sample_fmt = AV_SAMPLE_FMT_U8P; break;
+case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16P; break;
+case 20:
+case 24:
+case 28:
+case 32: avctx->sample_fmt = AV_SAMPLE_FMT_S32P; break;
+default: return AVERROR_INVALIDDATA;
+}
+
+s->nb_samples = AV_RL64(avctx->extradata + 16);
+s->frame_samples = AV_RL16(avctx->extradata + 8);
+s->max_framesize = (s->frame_samples * 16 + 1024) * 
avctx->ch_layout.nb_channels;


Do you even need to propagate this header using extradata? You can set 
codecpar's sample_fmt and frame_size in the demuxer, much like you're 
doing for sample_rate and ch_layout.
There doesn't seem to be a value that can't be propagated using the 
proper existing fields here.



+
+s->bitstream = av_calloc(s->max_framesize + AV_INPUT_BUFFER_PADDING_SIZE, 
sizeof(*s->bitstream));


av_mallocz(). sizeof(*s->bitstream) is 1.


+if (!s->bitstream)
+return AVERROR(ENOMEM);
+
+for (int ch = 0; ch < avctx->ch_layout.nb_channels; ch++) {
+s->decode_buffer[ch] = av_calloc(s->frame_samples + 4,
+ sizeof(*s->decode_buffer[ch]));
+if (!s->decode_buffer[ch])
+return AVERROR(ENOMEM);
+}
+
+s->pkt = avctx->internal->in_pkt;
+
+return 0;
+}

___
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] adpcm fixes and improvements

2023-08-24 Thread Paul B Mahol
On Thu, Aug 24, 2023 at 7:39 PM Michael Niedermayer 
wrote:

> On Thu, Aug 24, 2023 at 06:26:36PM +0200, Andreas Rheinhardt wrote:
> > Michael Niedermayer:
> > > On Thu, Aug 24, 2023 at 12:51:28AM +0200, Paul B Mahol wrote:
> > >> On Thu, Aug 24, 2023 at 12:36 AM Michael Niedermayer <
> mich...@niedermayer.cc>
> > >> wrote:
> > >>
> > >>> On Wed, Aug 23, 2023 at 09:04:35PM +0200, Paul B Mahol wrote:
> >  On Wed, Aug 23, 2023 at 9:02 PM Michael Niedermayer <
> > >>> mich...@niedermayer.cc>
> >  wrote:
> > 
> > > On Wed, Aug 16, 2023 at 06:53:42PM +0200, Paul B Mahol wrote:
> > >> On Wed, Aug 16, 2023 at 6:38 PM Michael Niedermayer <
> > > mich...@niedermayer.cc>
> > >> wrote:
> > >>
> > >>> On Tue, Aug 15, 2023 at 04:49:05PM +0200, Paul B Mahol wrote:
> >  Attached
> > >>>
> > >>> [...]
> >   adpcm.c |2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >  3305dbe07ca935958fa213f5cadc339ad3cc3592
> > >>> 0003-avcodec-adpcm-use-already-existing-pointer-for-4xm-d.patch
> >  From c6ad6dc7b8725d897e36399e5c7b8174caeb92e6 Mon Sep 17
> 00:00:00
> > > 2001
> >  From: Paul B Mahol 
> >  Date: Tue, 15 Aug 2023 14:18:47 +0200
> >  Subject: [PATCH 3/4] avcodec/adpcm: use already existing pointer
> > >>> for
> > > 4xm
> >   decoder
> > 
> >  Signed-off-by: Paul B Mahol 
> >  ---
> >   libavcodec/adpcm.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> >  diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> >  index b0c3b91a3b..9993c9e531 100644
> >  --- a/libavcodec/adpcm.c
> >  +++ b/libavcodec/adpcm.c
> >  @@ -1211,7 +1211,7 @@ static int
> > >>> adpcm_decode_frame(AVCodecContext
> > >>> *avctx, AVFrame *frame,
> > 
> >   for (int i = 0; i < channels; i++) {
> >   ADPCMChannelStatus *cs = >status[i];
> >  -samples = (int16_t *)frame->data[i];
> >  +samples = samples_p[i];
> >   for (int n = nb_samples >> 1; n > 0; n--) {
> >   int v = bytestream2_get_byteu();
> >   *samples++ = adpcm_ima_expand_nibble(cs, v &
> > >>> 0x0F,
> > > 4);
> > >>>
> > >>> should be ok if tested
> > >>>
> > >>>
> >  --
> >  2.39.1
> > 
> > >>>
> >   libavcodec/adpcm.c |  388
> > >>> +
> >   tests/ref/fate/adpcm-creative-8-2.6bit |2
> >   tests/ref/fate/adpcm-creative-8-2bit   |2
> >   tests/ref/fate/adpcm-creative-8-4bit   |2
> >   tests/ref/fate/adpcm-ms-mono   |   60 +
> >   5 files changed, 227 insertions(+), 227 deletions(-)
> >  1760df1de66b4227e71ffe942dedcf7d8a33ad48
> > >>> 0004-avcodec-adpcm-consume-all-input-when-decoding.patch
> >  From 19789bca53548d672bff30b88a8838edaa876bdb Mon Sep 17
> 00:00:00
> > > 2001
> >  From: Paul B Mahol 
> >  Date: Tue, 15 Aug 2023 15:25:22 +0200
> >  Subject: [PATCH 4/4] avcodec/adpcm: consume all input when
> > >>> decoding
> > 
> >  Stops multiple decoding calls for single packet.
> >  Also makes decoding faster.
> > >>>
> > >>> This increases latency, which can be problem if packets are
> > >>> sufficiently large
> > >>>
> > >>
> > >> Then reduce size at demuxer level. there is option for it.
> > >
> > > if that is so, then please explain exactly which option should be
> used
> > > in the commit message
> > >
> > >
> >  ffmpeg -h demuxer=wav
> > >>>
> > >>> what about the demuxers that are not named "wav" ?
> > >>>
> > >>>
> > >> I think you are blocking this just for sake of blocking because you
> have
> > >> nothing more constructive to do.
> > >> The delay is always present, unless packet size is exact as block
> align.
> > >> And for ADPCM this is irrelevant.
> > >
> > > IIUC, before this patch if a 1gb sized ADPCM packet comes from a
> demuxer
> > > that is decoded in small kb sized pieces and returned at that
> granularity
> > > to the user.
> > > after this patch (please correct me if iam wrong)
> > > you get a failure as the decoded data is not even addressable with int
> > > but lets assume int is 64bits, you get a 4gb or something like that
> > > audio frame. It maybe faster to decode that in one go but by how much
> is that
> > > faster from lets say decode it in 10-100kb sized chunks ?
> > >
> > > IMHO theres a point where it is too big, and simply returning the data
> > > to the user with some granularity lower than "unlimited" makes sense.
> > > Iam not asking for a new feature, rather your patch removes this
> > >
> >
> > If a user wants his audio in small bits, he should not send 1GB packets.
>
> 

Re: [FFmpeg-devel] [PATCH v7 0/5] JPEG XL Parser (and bug fixes)

2023-08-24 Thread Leo Izen

On 8/2/23 16:33, Leo Izen wrote:

Changes from v6:
- Added dummy stub libavformat/jpegxl_parse.c to fix shared builds

Changes from v5:
- Attached an extra commit to fix existing bug with libjxldec
- Made various changes based on comments by Andreas Reinhardt
-- removed jpegxl_parse.c from avformat, and jpegxl_parse.o from 
avformat/Makefile/OBJS
-- checked for failure in init_vlc_lengths
-- used a macro to initialize VLCElem structs
-- used heap allocations for a buffer of size 250k, instead of stack
-- renamed "code" to "len"
- Fix demuxer to avoid using avio_size, breaking piped input
- Fix some parser bugs discovered during more extensive testing

Changes from v4:
- Added an entropy decoder and full parser, which finds the
 boundaries between files correctly
- Removed unnecessary logging in libjxldec

Changes from v3:

- Don't remove AV_CODEC_CAP_DR1 from libjxldec
- jpegxl_parse.o added to STLIBOBJS in avcodec/Makefile
- add pipe demuxer to avformat/Makefile's SHLIBOBJS

Changes from v2:

- Fix libjxldec to work with packets that are smaller than one frame
- Change how code is shared between libavcodec and libavformat to be more 
sensible.
- Fix the parser to work with large headers that proceed the codestream in a 
container format
 (for example, if several-KB Exif boxes preceed the codestream.)
- Modify the parser to set width/height instead of avctx
   Note: avctx->pix_fmt and s->format are both set, because otherwise the CLI 
tools won't print
 the pixel format without libjxl enabled.
- Update the fate test based on the new parser's packetization

This test relies on FATE samples that haven't been uploaded yet. To test, unzip
the following zipfile[1] in the FATE_SAMPLES directory, placing the test images 
in jxl/.

[1]: https://buzo.us/y.zip

sha256sum: 43a2eeb0dfdf471b47a9fdfb1653974fa156ceceb776891cc137569a8ebf0e75
signature: https://buzo.us/R.asc

Leo Izen (5):
   avcodec/libjxldec: fix errors when decoding grayscale after rgb
   avcodec/libjxldec: use internal AVFrame as buffered space
   avcodec/jpegxl_parser: add JPEG XL parser
   avformat/jpegxl: remove jpegxl_probe, instead call
 avcodec/jpegxl_parse
   fate/jpegxl_anim: add demuxer fate test for jpegxl_anim

  libavcodec/Makefile   |3 +
  libavcodec/jpegxl.h   |   94 ++
  libavcodec/jpegxl_parse.c |  520 ++
  libavcodec/jpegxl_parse.h |   72 +
  libavcodec/jpegxl_parser.c| 1477 +
  libavcodec/libjxldec.c|   41 +-
  libavcodec/parsers.c  |1 +
  libavcodec/version.h  |2 +-
  libavformat/Makefile  |6 +-
  libavformat/img2dec.c |4 +-
  libavformat/jpegxl_anim_dec.c |  132 +-
  .../{jpegxl_probe.h => jpegxl_parse.c}|   21 +-
  libavformat/jpegxl_probe.c|  412 -
  libavformat/version.h |2 +-
  tests/Makefile|1 +
  tests/fate/jxl.mak|   16 +
  tests/ref/fate/jxl-anim-demux-belgium |6 +
  tests/ref/fate/jxl-anim-demux-icos4d  |6 +
  tests/ref/fate/jxl-anim-demux-lenna256|6 +
  tests/ref/fate/jxl-anim-demux-newton  |6 +
  20 files changed, 2273 insertions(+), 555 deletions(-)
  create mode 100644 libavcodec/jpegxl.h
  create mode 100644 libavcodec/jpegxl_parse.c
  create mode 100644 libavcodec/jpegxl_parse.h
  create mode 100644 libavcodec/jpegxl_parser.c
  rename libavformat/{jpegxl_probe.h => jpegxl_parse.c} (55%)
  delete mode 100644 libavformat/jpegxl_probe.c
  create mode 100644 tests/fate/jxl.mak
  create mode 100644 tests/ref/fate/jxl-anim-demux-belgium
  create mode 100644 tests/ref/fate/jxl-anim-demux-icos4d
  create mode 100644 tests/ref/fate/jxl-anim-demux-lenna256
  create mode 100644 tests/ref/fate/jxl-anim-demux-newton



Merging tomorrow as this has been through several review cycles.

- Leo Izen
___
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] checkasm: hevc_sao: Fix a regression in hevc_sao_edge

2023-08-24 Thread Martin Storsjö via ffmpeg-devel

On Thu, 24 Aug 2023, Matthias Dressel wrote:


From: Matthias Dressel 

check_func() might return NULL, in which case the function is not to be
benched. Introduced in cc679054c715acda9438e566b8de3a9eba421ac3.

Signed-off-by: Matthias Dressel 
---
tests/checkasm/hevc_sao.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/hevc_sao.c b/tests/checkasm/hevc_sao.c
index cfee2ddf50..94aa1942e1 100644
--- a/tests/checkasm/hevc_sao.c
+++ b/tests/checkasm/hevc_sao.c
@@ -134,8 +134,8 @@ static void check_sao_edge(HEVCDSPContext *h, int bit_depth)
if (memcmp(dst0 + j*stride, dst1 + j*stride, 
w*SIZEOF_PIXEL))
fail();
}
+bench_new(dst1, src1 + offset, stride, offset_val, eo, 
block_size, block_size);
}
-bench_new(dst1, src1 + offset, stride, offset_val, eo, block_size, 
block_size);
}
}
}
--
2.41.0


LGTM, pushed.

// Martin

___
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] OSQ lossless audio format support

2023-08-24 Thread Paul B Mahol
On Thu, Aug 24, 2023 at 8:06 PM Michael Niedermayer 
wrote:

> On Thu, Aug 24, 2023 at 11:52:45AM +0200, Paul B Mahol wrote:
> > Patches attached.
> >
> > Stereo decoding have some issues with some predictors so not yet
> bitexact.
> >
> > Please comment.
>
>
> [...]
> > diff --git a/libavformat/osq.c b/libavformat/osq.c
> > new file mode 100644
> > index 00..36ce25313f
> > --- /dev/null
> > +++ b/libavformat/osq.c
> > @@ -0,0 +1,117 @@
> > +/*
> > + * OSQ demuxer
> > + * Copyright (c) 2023 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/intreadwrite.h"
> > +#include "avio_internal.h"
> > +#include "avformat.h"
> > +#include "demux.h"
> > +#include "internal.h"
> > +#include "rawdec.h"
> > +
> > +static int osq_probe(const AVProbeData *p)
> > +{
>
> > +if (AV_RL32(p->buf) != MKTAG('O','S','Q',' '))
> > +return 0;
> > +if (AV_RL32(p->buf + 4) != 48)
> > +return 0;
> > +if (AV_RL16(p->buf + 8) != 1)
> > +return 0;
>
> this can be simplified to a single memcmp() with a 10 byte array
>
>
nit



>
> > +if (!p->buf[10])
> > +return 0;
> > +if (!p->buf[11])
> > +return 0;
> > +if (AV_RL32(p->buf + 12) == 0)
> > +return 0;
> > +if (AV_RL16(p->buf + 16) == 0)
> > +return 0;
>
> inconsistant, you mix !x and == 0 for the same kind of check
>
>
nit, changed


>
> > +
> > +return AVPROBE_SCORE_MAX;
> > +}
> > +
> > +static int osq_read_header(AVFormatContext *s)
> > +{
> > +uint32_t t, size;
> > +AVStream *st;
> > +int ret;
> > +
> > +t = avio_rl32(s->pb);
> > +if (t != MKTAG('O','S','Q',' '))
> > +return AVERROR_INVALIDDATA;
> > +
> > +size = avio_rl32(s->pb);
> > +if (size != 48)
> > +return AVERROR_INVALIDDATA;
> > +
> > +st = avformat_new_stream(s, NULL);
> > +if (!st)
> > +return AVERROR(ENOMEM);
> > +if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
> > +return ret;
> > +
>
> > +t = avio_rl32(s->pb);
> > +if (t != MKTAG('R','I','F','F'))
> > +return AVERROR_INVALIDDATA;
> > +avio_skip(s->pb, 8);
> > +
> > +t = avio_rl32(s->pb);
> > +if (t != MKTAG('f','m','t',' '))
> > +return AVERROR_INVALIDDATA;
> > +size = avio_rl32(s->pb);
> > +avio_skip(s->pb, size);
> > +
> > +t = avio_rl32(s->pb);
> > +size = avio_rl32(s->pb);
> > +while (t != MKTAG('d','a','t','a')) {
> > +avio_skip(s->pb, size);
> > +
> > +t = avio_rl32(s->pb);
> > +size = avio_rl32(s->pb);
> > +if (avio_feof(s->pb))
> > +return AVERROR_INVALIDDATA;
> > +}
>
> This looks familiar, can code be shared with other RIFF based formats ?
>
>
If its really critical, maybe later.


>
> > +
> > +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
> > +st->codecpar->codec_id= AV_CODEC_ID_OSQ;
> > +st->codecpar->sample_rate = AV_RL32(st->codecpar->extradata + 4);
> > +if (st->codecpar->sample_rate == 0)
> > +return AVERROR_INVALIDDATA;
>
> missing check for negative numbers
>

fixed


>
>
> [...]
> > diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> > new file mode 100644
> > index 00..b6dc5c1bb4
> > --- /dev/null
> > +++ b/libavcodec/osq.c
> > @@ -0,0 +1,435 @@
> > +/*
> > + * OSQ audio decoder
> > + * Copyright (c) 2023 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, 

Re: [FFmpeg-devel] [PATCH] OSQ lossless audio format support

2023-08-24 Thread Michael Niedermayer
On Thu, Aug 24, 2023 at 11:52:45AM +0200, Paul B Mahol wrote:
> Patches attached.
> 
> Stereo decoding have some issues with some predictors so not yet bitexact.
> 
> Please comment.


[...]
> diff --git a/libavformat/osq.c b/libavformat/osq.c
> new file mode 100644
> index 00..36ce25313f
> --- /dev/null
> +++ b/libavformat/osq.c
> @@ -0,0 +1,117 @@
> +/*
> + * OSQ demuxer
> + * Copyright (c) 2023 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/intreadwrite.h"
> +#include "avio_internal.h"
> +#include "avformat.h"
> +#include "demux.h"
> +#include "internal.h"
> +#include "rawdec.h"
> +
> +static int osq_probe(const AVProbeData *p)
> +{

> +if (AV_RL32(p->buf) != MKTAG('O','S','Q',' '))
> +return 0;
> +if (AV_RL32(p->buf + 4) != 48)
> +return 0;
> +if (AV_RL16(p->buf + 8) != 1)
> +return 0;

this can be simplified to a single memcmp() with a 10 byte array


> +if (!p->buf[10])
> +return 0;
> +if (!p->buf[11])
> +return 0;
> +if (AV_RL32(p->buf + 12) == 0)
> +return 0;
> +if (AV_RL16(p->buf + 16) == 0)
> +return 0;

inconsistant, you mix !x and == 0 for the same kind of check


> +
> +return AVPROBE_SCORE_MAX;
> +}
> +
> +static int osq_read_header(AVFormatContext *s)
> +{
> +uint32_t t, size;
> +AVStream *st;
> +int ret;
> +
> +t = avio_rl32(s->pb);
> +if (t != MKTAG('O','S','Q',' '))
> +return AVERROR_INVALIDDATA;
> +
> +size = avio_rl32(s->pb);
> +if (size != 48)
> +return AVERROR_INVALIDDATA;
> +
> +st = avformat_new_stream(s, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
> +return ret;
> +

> +t = avio_rl32(s->pb);
> +if (t != MKTAG('R','I','F','F'))
> +return AVERROR_INVALIDDATA;
> +avio_skip(s->pb, 8);
> +
> +t = avio_rl32(s->pb);
> +if (t != MKTAG('f','m','t',' '))
> +return AVERROR_INVALIDDATA;
> +size = avio_rl32(s->pb);
> +avio_skip(s->pb, size);
> +
> +t = avio_rl32(s->pb);
> +size = avio_rl32(s->pb);
> +while (t != MKTAG('d','a','t','a')) {
> +avio_skip(s->pb, size);
> +
> +t = avio_rl32(s->pb);
> +size = avio_rl32(s->pb);
> +if (avio_feof(s->pb))
> +return AVERROR_INVALIDDATA;
> +}

This looks familiar, can code be shared with other RIFF based formats ?


> +
> +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
> +st->codecpar->codec_id= AV_CODEC_ID_OSQ;
> +st->codecpar->sample_rate = AV_RL32(st->codecpar->extradata + 4);
> +if (st->codecpar->sample_rate == 0)
> +return AVERROR_INVALIDDATA;

missing check for negative numbers


[...]
> diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> new file mode 100644
> index 00..b6dc5c1bb4
> --- /dev/null
> +++ b/libavcodec/osq.c
> @@ -0,0 +1,435 @@
> +/*
> + * OSQ audio decoder
> + * Copyright (c) 2023 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
> + */
> +

> +#define ASSERT_LEVEL 5

that looks strange
assert level is set by the user building this, also there is no level 5


> +#include "libavutil/avassert.h"
> +#include "libavutil/internal.h"
> +#include "libavutil/intreadwrite.h"
> +#include "avcodec.h"
> +#include "codec_internal.h"
> +#include "decode.h"
> +#include "internal.h"
> +#define BITSTREAM_READER_LE
> +#include 

Re: [FFmpeg-devel] [PATCH] adpcm fixes and improvements

2023-08-24 Thread Michael Niedermayer
On Thu, Aug 24, 2023 at 06:26:36PM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > On Thu, Aug 24, 2023 at 12:51:28AM +0200, Paul B Mahol wrote:
> >> On Thu, Aug 24, 2023 at 12:36 AM Michael Niedermayer 
> >> 
> >> wrote:
> >>
> >>> On Wed, Aug 23, 2023 at 09:04:35PM +0200, Paul B Mahol wrote:
>  On Wed, Aug 23, 2023 at 9:02 PM Michael Niedermayer <
> >>> mich...@niedermayer.cc>
>  wrote:
> 
> > On Wed, Aug 16, 2023 at 06:53:42PM +0200, Paul B Mahol wrote:
> >> On Wed, Aug 16, 2023 at 6:38 PM Michael Niedermayer <
> > mich...@niedermayer.cc>
> >> wrote:
> >>
> >>> On Tue, Aug 15, 2023 at 04:49:05PM +0200, Paul B Mahol wrote:
>  Attached
> >>>
> >>> [...]
>   adpcm.c |2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>  3305dbe07ca935958fa213f5cadc339ad3cc3592
> >>> 0003-avcodec-adpcm-use-already-existing-pointer-for-4xm-d.patch
>  From c6ad6dc7b8725d897e36399e5c7b8174caeb92e6 Mon Sep 17 00:00:00
> > 2001
>  From: Paul B Mahol 
>  Date: Tue, 15 Aug 2023 14:18:47 +0200
>  Subject: [PATCH 3/4] avcodec/adpcm: use already existing pointer
> >>> for
> > 4xm
>   decoder
> 
>  Signed-off-by: Paul B Mahol 
>  ---
>   libavcodec/adpcm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
>  diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
>  index b0c3b91a3b..9993c9e531 100644
>  --- a/libavcodec/adpcm.c
>  +++ b/libavcodec/adpcm.c
>  @@ -1211,7 +1211,7 @@ static int
> >>> adpcm_decode_frame(AVCodecContext
> >>> *avctx, AVFrame *frame,
> 
>   for (int i = 0; i < channels; i++) {
>   ADPCMChannelStatus *cs = >status[i];
>  -samples = (int16_t *)frame->data[i];
>  +samples = samples_p[i];
>   for (int n = nb_samples >> 1; n > 0; n--) {
>   int v = bytestream2_get_byteu();
>   *samples++ = adpcm_ima_expand_nibble(cs, v &
> >>> 0x0F,
> > 4);
> >>>
> >>> should be ok if tested
> >>>
> >>>
>  --
>  2.39.1
> 
> >>>
>   libavcodec/adpcm.c |  388
> >>> +
>   tests/ref/fate/adpcm-creative-8-2.6bit |2
>   tests/ref/fate/adpcm-creative-8-2bit   |2
>   tests/ref/fate/adpcm-creative-8-4bit   |2
>   tests/ref/fate/adpcm-ms-mono   |   60 +
>   5 files changed, 227 insertions(+), 227 deletions(-)
>  1760df1de66b4227e71ffe942dedcf7d8a33ad48
> >>> 0004-avcodec-adpcm-consume-all-input-when-decoding.patch
>  From 19789bca53548d672bff30b88a8838edaa876bdb Mon Sep 17 00:00:00
> > 2001
>  From: Paul B Mahol 
>  Date: Tue, 15 Aug 2023 15:25:22 +0200
>  Subject: [PATCH 4/4] avcodec/adpcm: consume all input when
> >>> decoding
> 
>  Stops multiple decoding calls for single packet.
>  Also makes decoding faster.
> >>>
> >>> This increases latency, which can be problem if packets are
> >>> sufficiently large
> >>>
> >>
> >> Then reduce size at demuxer level. there is option for it.
> >
> > if that is so, then please explain exactly which option should be used
> > in the commit message
> >
> >
>  ffmpeg -h demuxer=wav
> >>>
> >>> what about the demuxers that are not named "wav" ?
> >>>
> >>>
> >> I think you are blocking this just for sake of blocking because you have
> >> nothing more constructive to do.
> >> The delay is always present, unless packet size is exact as block align.
> >> And for ADPCM this is irrelevant.
> > 
> > IIUC, before this patch if a 1gb sized ADPCM packet comes from a demuxer
> > that is decoded in small kb sized pieces and returned at that granularity
> > to the user.
> > after this patch (please correct me if iam wrong)
> > you get a failure as the decoded data is not even addressable with int
> > but lets assume int is 64bits, you get a 4gb or something like that
> > audio frame. It maybe faster to decode that in one go but by how much is 
> > that
> > faster from lets say decode it in 10-100kb sized chunks ?
> > 
> > IMHO theres a point where it is too big, and simply returning the data
> > to the user with some granularity lower than "unlimited" makes sense.
> > Iam not asking for a new feature, rather your patch removes this
> > 
> 
> If a user wants his audio in small bits, he should not send 1GB packets.

Normally most users get their audio packets from a file or stream
they dont choose whats in that and dont choose the size of packets

the wav demuxer has an option to choose the maximum packet size but thats
wav demuxer specific.

am i missing something ?
the 1gb was an extreem example to show the issue, real files would

Re: [FFmpeg-devel] [PATCH] adpcm fixes and improvements

2023-08-24 Thread Andreas Rheinhardt
Michael Niedermayer:
> On Thu, Aug 24, 2023 at 12:51:28AM +0200, Paul B Mahol wrote:
>> On Thu, Aug 24, 2023 at 12:36 AM Michael Niedermayer 
>> wrote:
>>
>>> On Wed, Aug 23, 2023 at 09:04:35PM +0200, Paul B Mahol wrote:
 On Wed, Aug 23, 2023 at 9:02 PM Michael Niedermayer <
>>> mich...@niedermayer.cc>
 wrote:

> On Wed, Aug 16, 2023 at 06:53:42PM +0200, Paul B Mahol wrote:
>> On Wed, Aug 16, 2023 at 6:38 PM Michael Niedermayer <
> mich...@niedermayer.cc>
>> wrote:
>>
>>> On Tue, Aug 15, 2023 at 04:49:05PM +0200, Paul B Mahol wrote:
 Attached
>>>
>>> [...]
  adpcm.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 3305dbe07ca935958fa213f5cadc339ad3cc3592
>>> 0003-avcodec-adpcm-use-already-existing-pointer-for-4xm-d.patch
 From c6ad6dc7b8725d897e36399e5c7b8174caeb92e6 Mon Sep 17 00:00:00
> 2001
 From: Paul B Mahol 
 Date: Tue, 15 Aug 2023 14:18:47 +0200
 Subject: [PATCH 3/4] avcodec/adpcm: use already existing pointer
>>> for
> 4xm
  decoder

 Signed-off-by: Paul B Mahol 
 ---
  libavcodec/adpcm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
 index b0c3b91a3b..9993c9e531 100644
 --- a/libavcodec/adpcm.c
 +++ b/libavcodec/adpcm.c
 @@ -1211,7 +1211,7 @@ static int
>>> adpcm_decode_frame(AVCodecContext
>>> *avctx, AVFrame *frame,

  for (int i = 0; i < channels; i++) {
  ADPCMChannelStatus *cs = >status[i];
 -samples = (int16_t *)frame->data[i];
 +samples = samples_p[i];
  for (int n = nb_samples >> 1; n > 0; n--) {
  int v = bytestream2_get_byteu();
  *samples++ = adpcm_ima_expand_nibble(cs, v &
>>> 0x0F,
> 4);
>>>
>>> should be ok if tested
>>>
>>>
 --
 2.39.1

>>>
  libavcodec/adpcm.c |  388
>>> +
  tests/ref/fate/adpcm-creative-8-2.6bit |2
  tests/ref/fate/adpcm-creative-8-2bit   |2
  tests/ref/fate/adpcm-creative-8-4bit   |2
  tests/ref/fate/adpcm-ms-mono   |   60 +
  5 files changed, 227 insertions(+), 227 deletions(-)
 1760df1de66b4227e71ffe942dedcf7d8a33ad48
>>> 0004-avcodec-adpcm-consume-all-input-when-decoding.patch
 From 19789bca53548d672bff30b88a8838edaa876bdb Mon Sep 17 00:00:00
> 2001
 From: Paul B Mahol 
 Date: Tue, 15 Aug 2023 15:25:22 +0200
 Subject: [PATCH 4/4] avcodec/adpcm: consume all input when
>>> decoding

 Stops multiple decoding calls for single packet.
 Also makes decoding faster.
>>>
>>> This increases latency, which can be problem if packets are
>>> sufficiently large
>>>
>>
>> Then reduce size at demuxer level. there is option for it.
>
> if that is so, then please explain exactly which option should be used
> in the commit message
>
>
 ffmpeg -h demuxer=wav
>>>
>>> what about the demuxers that are not named "wav" ?
>>>
>>>
>> I think you are blocking this just for sake of blocking because you have
>> nothing more constructive to do.
>> The delay is always present, unless packet size is exact as block align.
>> And for ADPCM this is irrelevant.
> 
> IIUC, before this patch if a 1gb sized ADPCM packet comes from a demuxer
> that is decoded in small kb sized pieces and returned at that granularity
> to the user.
> after this patch (please correct me if iam wrong)
> you get a failure as the decoded data is not even addressable with int
> but lets assume int is 64bits, you get a 4gb or something like that
> audio frame. It maybe faster to decode that in one go but by how much is that
> faster from lets say decode it in 10-100kb sized chunks ?
> 
> IMHO theres a point where it is too big, and simply returning the data
> to the user with some granularity lower than "unlimited" makes sense.
> Iam not asking for a new feature, rather your patch removes this
> 

If a user wants his audio in small bits, he should not send 1GB packets.

- Andreas

___
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] adpcm fixes and improvements

2023-08-24 Thread Michael Niedermayer
On Thu, Aug 24, 2023 at 12:51:28AM +0200, Paul B Mahol wrote:
> On Thu, Aug 24, 2023 at 12:36 AM Michael Niedermayer 
> wrote:
> 
> > On Wed, Aug 23, 2023 at 09:04:35PM +0200, Paul B Mahol wrote:
> > > On Wed, Aug 23, 2023 at 9:02 PM Michael Niedermayer <
> > mich...@niedermayer.cc>
> > > wrote:
> > >
> > > > On Wed, Aug 16, 2023 at 06:53:42PM +0200, Paul B Mahol wrote:
> > > > > On Wed, Aug 16, 2023 at 6:38 PM Michael Niedermayer <
> > > > mich...@niedermayer.cc>
> > > > > wrote:
> > > > >
> > > > > > On Tue, Aug 15, 2023 at 04:49:05PM +0200, Paul B Mahol wrote:
> > > > > > > Attached
> > > > > >
> > > > > > [...]
> > > > > > >  adpcm.c |2 +-
> > > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > > > 3305dbe07ca935958fa213f5cadc339ad3cc3592
> > > > > > 0003-avcodec-adpcm-use-already-existing-pointer-for-4xm-d.patch
> > > > > > > From c6ad6dc7b8725d897e36399e5c7b8174caeb92e6 Mon Sep 17 00:00:00
> > > > 2001
> > > > > > > From: Paul B Mahol 
> > > > > > > Date: Tue, 15 Aug 2023 14:18:47 +0200
> > > > > > > Subject: [PATCH 3/4] avcodec/adpcm: use already existing pointer
> > for
> > > > 4xm
> > > > > > >  decoder
> > > > > > >
> > > > > > > Signed-off-by: Paul B Mahol 
> > > > > > > ---
> > > > > > >  libavcodec/adpcm.c | 2 +-
> > > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > > >
> > > > > > > diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> > > > > > > index b0c3b91a3b..9993c9e531 100644
> > > > > > > --- a/libavcodec/adpcm.c
> > > > > > > +++ b/libavcodec/adpcm.c
> > > > > > > @@ -1211,7 +1211,7 @@ static int
> > adpcm_decode_frame(AVCodecContext
> > > > > > *avctx, AVFrame *frame,
> > > > > > >
> > > > > > >  for (int i = 0; i < channels; i++) {
> > > > > > >  ADPCMChannelStatus *cs = >status[i];
> > > > > > > -samples = (int16_t *)frame->data[i];
> > > > > > > +samples = samples_p[i];
> > > > > > >  for (int n = nb_samples >> 1; n > 0; n--) {
> > > > > > >  int v = bytestream2_get_byteu();
> > > > > > >  *samples++ = adpcm_ima_expand_nibble(cs, v &
> > 0x0F,
> > > > 4);
> > > > > >
> > > > > > should be ok if tested
> > > > > >
> > > > > >
> > > > > > > --
> > > > > > > 2.39.1
> > > > > > >
> > > > > >
> > > > > > >  libavcodec/adpcm.c |  388
> > > > > > +
> > > > > > >  tests/ref/fate/adpcm-creative-8-2.6bit |2
> > > > > > >  tests/ref/fate/adpcm-creative-8-2bit   |2
> > > > > > >  tests/ref/fate/adpcm-creative-8-4bit   |2
> > > > > > >  tests/ref/fate/adpcm-ms-mono   |   60 +
> > > > > > >  5 files changed, 227 insertions(+), 227 deletions(-)
> > > > > > > 1760df1de66b4227e71ffe942dedcf7d8a33ad48
> > > > > > 0004-avcodec-adpcm-consume-all-input-when-decoding.patch
> > > > > > > From 19789bca53548d672bff30b88a8838edaa876bdb Mon Sep 17 00:00:00
> > > > 2001
> > > > > > > From: Paul B Mahol 
> > > > > > > Date: Tue, 15 Aug 2023 15:25:22 +0200
> > > > > > > Subject: [PATCH 4/4] avcodec/adpcm: consume all input when
> > decoding
> > > > > > >
> > > > > > > Stops multiple decoding calls for single packet.
> > > > > > > Also makes decoding faster.
> > > > > >
> > > > > > This increases latency, which can be problem if packets are
> > > > > > sufficiently large
> > > > > >
> > > > >
> > > > > Then reduce size at demuxer level. there is option for it.
> > > >
> > > > if that is so, then please explain exactly which option should be used
> > > > in the commit message
> > > >
> > > >
> > > ffmpeg -h demuxer=wav
> >
> > what about the demuxers that are not named "wav" ?
> >
> >
> I think you are blocking this just for sake of blocking because you have
> nothing more constructive to do.
> The delay is always present, unless packet size is exact as block align.
> And for ADPCM this is irrelevant.

IIUC, before this patch if a 1gb sized ADPCM packet comes from a demuxer
that is decoded in small kb sized pieces and returned at that granularity
to the user.
after this patch (please correct me if iam wrong)
you get a failure as the decoded data is not even addressable with int
but lets assume int is 64bits, you get a 4gb or something like that
audio frame. It maybe faster to decode that in one go but by how much is that
faster from lets say decode it in 10-100kb sized chunks ?

IMHO theres a point where it is too big, and simply returning the data
to the user with some granularity lower than "unlimited" makes sense.
Iam not asking for a new feature, rather your patch removes this

thx


> 
> The ADPCM decoders could be transformed to receive frame API if you really
> care.
> 
> 
> git grep  -l ADPCM  libavformat/*c | wc -l
> > 88
> >
> > thx
> >
> > [...]
> > --
> > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> >
> > It is a danger to trust the dream we wish for rather than
> > the science we have, -- Dr. Kenneth Brown
> > ___
> > 

[FFmpeg-devel] [PATCH] checkasm: hevc_sao: Fix a regression in hevc_sao_edge

2023-08-24 Thread Matthias Dressel
From: Matthias Dressel 

check_func() might return NULL, in which case the function is not to be
benched. Introduced in cc679054c715acda9438e566b8de3a9eba421ac3.

Signed-off-by: Matthias Dressel 
---
 tests/checkasm/hevc_sao.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/hevc_sao.c b/tests/checkasm/hevc_sao.c
index cfee2ddf50..94aa1942e1 100644
--- a/tests/checkasm/hevc_sao.c
+++ b/tests/checkasm/hevc_sao.c
@@ -134,8 +134,8 @@ static void check_sao_edge(HEVCDSPContext *h, int bit_depth)
 if (memcmp(dst0 + j*stride, dst1 + j*stride, 
w*SIZEOF_PIXEL))
 fail();
 }
+bench_new(dst1, src1 + offset, stride, offset_val, eo, 
block_size, block_size);
 }
-bench_new(dst1, src1 + offset, stride, offset_val, eo, block_size, 
block_size);
 }
 }
 }
-- 
2.41.0




___
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] OSQ lossless audio format support

2023-08-24 Thread Paul B Mahol
Patches attached.

Stereo decoding have some issues with some predictors so not yet bitexact.

Please comment.
From a90b4fbd4178d4ef434e1255ed20dddebde0ddb8 Mon Sep 17 00:00:00 2001
From: Paul B Mahol 
Date: Tue, 27 Jun 2023 19:51:54 +0200
Subject: [PATCH 2/2] avformat: add OSQ demuxer

Signed-off-by: Paul B Mahol 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/osq.c| 117 +++
 3 files changed, 119 insertions(+)
 create mode 100644 libavformat/osq.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index bd78c206b9..1c8c965a74 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -433,6 +433,7 @@ OBJS-$(CONFIG_OMA_DEMUXER)   += omadec.o pcm.o oma.o
 OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o
 OBJS-$(CONFIG_OPUS_MUXER)+= oggenc.o \
 vorbiscomment.o
+OBJS-$(CONFIG_OSQ_DEMUXER)   += osq.o rawdec.o
 OBJS-$(CONFIG_PAF_DEMUXER)   += paf.o
 OBJS-$(CONFIG_PCM_ALAW_DEMUXER)  += pcmdec.o pcm.o
 OBJS-$(CONFIG_PCM_ALAW_MUXER)+= pcmenc.o rawenc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 6324952bd2..f4210e4932 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -331,6 +331,7 @@ extern const FFOutputFormat ff_ogv_muxer;
 extern const AVInputFormat  ff_oma_demuxer;
 extern const FFOutputFormat ff_oma_muxer;
 extern const FFOutputFormat ff_opus_muxer;
+extern const AVInputFormat  ff_osq_demuxer;
 extern const AVInputFormat  ff_paf_demuxer;
 extern const AVInputFormat  ff_pcm_alaw_demuxer;
 extern const FFOutputFormat ff_pcm_alaw_muxer;
diff --git a/libavformat/osq.c b/libavformat/osq.c
new file mode 100644
index 00..36ce25313f
--- /dev/null
+++ b/libavformat/osq.c
@@ -0,0 +1,117 @@
+/*
+ * OSQ demuxer
+ * Copyright (c) 2023 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/intreadwrite.h"
+#include "avio_internal.h"
+#include "avformat.h"
+#include "demux.h"
+#include "internal.h"
+#include "rawdec.h"
+
+static int osq_probe(const AVProbeData *p)
+{
+if (AV_RL32(p->buf) != MKTAG('O','S','Q',' '))
+return 0;
+if (AV_RL32(p->buf + 4) != 48)
+return 0;
+if (AV_RL16(p->buf + 8) != 1)
+return 0;
+if (!p->buf[10])
+return 0;
+if (!p->buf[11])
+return 0;
+if (AV_RL32(p->buf + 12) == 0)
+return 0;
+if (AV_RL16(p->buf + 16) == 0)
+return 0;
+
+return AVPROBE_SCORE_MAX;
+}
+
+static int osq_read_header(AVFormatContext *s)
+{
+uint32_t t, size;
+AVStream *st;
+int ret;
+
+t = avio_rl32(s->pb);
+if (t != MKTAG('O','S','Q',' '))
+return AVERROR_INVALIDDATA;
+
+size = avio_rl32(s->pb);
+if (size != 48)
+return AVERROR_INVALIDDATA;
+
+st = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+if ((ret = ff_get_extradata(s, st->codecpar, s->pb, size)) < 0)
+return ret;
+
+t = avio_rl32(s->pb);
+if (t != MKTAG('R','I','F','F'))
+return AVERROR_INVALIDDATA;
+avio_skip(s->pb, 8);
+
+t = avio_rl32(s->pb);
+if (t != MKTAG('f','m','t',' '))
+return AVERROR_INVALIDDATA;
+size = avio_rl32(s->pb);
+avio_skip(s->pb, size);
+
+t = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+while (t != MKTAG('d','a','t','a')) {
+avio_skip(s->pb, size);
+
+t = avio_rl32(s->pb);
+size = avio_rl32(s->pb);
+if (avio_feof(s->pb))
+return AVERROR_INVALIDDATA;
+}
+
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= AV_CODEC_ID_OSQ;
+st->codecpar->sample_rate = AV_RL32(st->codecpar->extradata + 4);
+if (st->codecpar->sample_rate == 0)
+return AVERROR_INVALIDDATA;
+st->codecpar->ch_layout.nb_channels = st->codecpar->extradata[3];
+if (st->codecpar->ch_layout.nb_channels == 0)
+return AVERROR_INVALIDDATA;
+st->start_time = 0;
+st->duration = AV_RL32(st->codecpar->extradata + 16);
+avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
+
+return 0;
+}
+
+const