Re: [FFmpeg-devel] [PATCH] avfilter/vf_curves: add PCHIP interpolator and interp option

2022-10-22 Thread Paul B Mahol
On 10/3/22, Takeshi (Kesh) Ikuma  wrote:
> summary: This patch modifies the `curves` filter with new `interp` option
>  to let user pick the existing natural cubic spline interpolation
>  and the new PCHIP interapolation.
>
> reason:  The natural cubic spline does not impose monotonicity between
>  the keypoints. As such, the fitted curve may vary wildly against
>  user's intension. The PCHIP interpolation is not as smooth as
>  the natural spline but guarantees the monotonicity. Providing
>  both options enhances users experience (e.g., reduces the number
>  of keypoints to realize the desired curve). See the related bug
>  report for the example of an ill-interpolated curve.
>
> alternate solution:
>  Both Photoshop and GIMP appear to use monotonic interpolation in
>  their curve tools, which were the models for this filter. As
>  such, an alternate solution is to drop the natural spline and
>  go without the `interp` option.
>
> related bug report: https://trac.ffmpeg.org/ticket/9947 (filed by myself)
>
> Signed-off-by: Takeshi (Kesh) Ikuma 
>
>   modified:   doc/filters.texi
>   modified:   libavfilter/vf_curves.c
> ---
>  doc/filters.texi|  23 +++-
>  libavfilter/vf_curves.c | 255 
>  2 files changed, 253 insertions(+), 25 deletions(-)
>


Looks like this new interpolator implementationi hangs with 16bit
pixel formats and with some presets:

ffplay input.video -vf format=yuv422p16,curves=vintage:interp=1,format=yuv422p16


> diff --git a/doc/filters.texi b/doc/filters.texi
> index d0f718678c..08a79644e1 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -10389,11 +10389,15 @@ By default, a component curve is defined by the
> two points @var{(0;0)} and
>  "adjusted" to its own value, which means no change to the image.
>
>  The filter allows you to redefine these two points and add some more. A
> new
> -curve (using a natural cubic spline interpolation) will be define to pass
> -smoothly through all these new coordinates. The new defined points needs to
> be
> -strictly increasing over the x-axis, and their @var{x} and @var{y} values
> must
> -be in the @var{[0;1]} interval.  If the computed curves happened to go
> outside
> -the vector spaces, the values will be clipped accordingly.
> +curve will be define to pass smoothly through all these new coordinates.
> The
> +new defined points needs to be strictly increasing over the x-axis, and
> their
> +@var{x} and @var{y} values must be in the @var{[0;1]} interval. The curve
> is
> +formed by using a natural or monotonic cubic spline interpolation,
> depending
> +on the @var{interp} option (default: @code{natural}). The @code{natural}
> +spline produces a smoother curve in general while the monotonic
> (@code{pchip})
> +spline guarantees the transitions between the specified points to be
> +monotonic. If the computed curves happened to go outside the vector
> spaces,
> +the values will be clipped accordingly.
>
>  The filter accepts the following options:
>
> @@ -10437,6 +10441,15 @@ options. In this case, the unset component(s) will
> fallback on this
>  Specify a Photoshop curves file (@code{.acv}) to import the settings from.
>  @item plot
>  Save Gnuplot script of the curves in specified file.
> +@item interp
> +Specify the kind of interpolation. Available algorithms are:
> +@table @samp
> +@item natural
> +Natural cubic spline using a piece-wise cubic polynomial that is twice
> continuously differentiable.
> +@item pchip
> +Monotonic cubic spline using a piecewise cubic Hermite interpolating
> polynomial (PCHIP).
> +@end table
> +
>  @end table
>
>  To avoid some filtergraph syntax conflicts, each key points list need to
> be
> diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c
> index 498b06f6e5..d0efa380e1 100644
> --- a/libavfilter/vf_curves.c
> +++ b/libavfilter/vf_curves.c
> @@ -58,6 +58,12 @@ enum preset {
>  NB_PRESETS,
>  };
>
> +enum interp {
> +INTERP_NATURAL,
> +INTERP_PCHIP,
> +NB_INTERPS,
> +};
> +
>  typedef struct CurvesContext {
>  const AVClass *class;
>  int preset;
> @@ -73,6 +79,7 @@ typedef struct CurvesContext {
>  int is_16bit;
>  int depth;
>  int parsed_psfile;
> +int interp;
>
>  int (*filter_slice)(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs);
>  } CurvesContext;
> @@ -107,6 +114,9 @@ static const AVOption curves_options[] = {
>  { "all",   "set points coordinates for all components",
> OFFSET(comp_points_str_all), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS
> },
>  { "psfile", "set Photoshop curves file name", OFFSET(psfile),
> AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
>  { "plot", "save Gnuplot script of the curves in specified file",
> OFFSET(plot_filename), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
> +{ "interp", "specify the kind of interpolation", OFFSE

[FFmpeg-devel] [PATCH v4 3/4] lavc/tests: add a cached bitstream reader test

2022-10-22 Thread Anton Khirnov
---
 libavcodec/Makefile   |   2 +
 libavcodec/tests/bitstream_be.c   |  19 +++
 libavcodec/tests/bitstream_le.c   |  20 +++
 libavcodec/tests/bitstream_template.c | 183 ++
 tests/fate/libavcodec.mak |  10 ++
 5 files changed, 234 insertions(+)
 create mode 100644 libavcodec/tests/bitstream_be.c
 create mode 100644 libavcodec/tests/bitstream_le.c
 create mode 100644 libavcodec/tests/bitstream_template.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b77fe0db8e..4314b47d65 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1265,6 +1265,8 @@ SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
 
 TESTPROGS = avcodec \
 avpacket\
+bitstream_be\
+bitstream_le\
 celp_math   \
 codec_desc  \
 htmlsubtitles   \
diff --git a/libavcodec/tests/bitstream_be.c b/libavcodec/tests/bitstream_be.c
new file mode 100644
index 00..bc562ed3b1
--- /dev/null
+++ b/libavcodec/tests/bitstream_be.c
@@ -0,0 +1,19 @@
+/*
+ * 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 "bitstream_template.c"
diff --git a/libavcodec/tests/bitstream_le.c b/libavcodec/tests/bitstream_le.c
new file mode 100644
index 00..ba9296c95a
--- /dev/null
+++ b/libavcodec/tests/bitstream_le.c
@@ -0,0 +1,20 @@
+/*
+ * 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 BITSTREAM_LE
+#include "bitstream_template.c"
diff --git a/libavcodec/tests/bitstream_template.c 
b/libavcodec/tests/bitstream_template.c
new file mode 100644
index 00..13e92a31c6
--- /dev/null
+++ b/libavcodec/tests/bitstream_template.c
@@ -0,0 +1,183 @@
+/*
+ * cached bitstream reader test
+ * copyright (c) 2022 Anton Khirnov 
+ *
+ * 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 2
+
+#include "libavutil/avassert.h"
+#include "libavutil/lfg.h"
+#include "libavutil/random_seed.h"
+
+#include "libavcodec/bitstream.h"
+#include "libavcodec/defs.h"
+
+#ifdef BITSTREAM_LE
+#define BITSTREAM_WRITER_LE
+#endif
+#include "libavcodec/put_bits.h"
+
+#define SIZE 157
+
+enum Op {
+OP_READ,
+OP_READ_NZ,
+OP_READ_BIT,
+OP_READ_63,
+OP_READ_64,
+OP_READ_SIGNED,
+OP_APPLY_SIGN,
+OP_ALIGN,
+OP_NB,
+};
+
+int main(int argc, char **argv)
+{
+BitstreamContext bc;
+PutBitContextpb;
+AVLFGlfg;
+
+uint8_t buf[SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
+uint8_t 

[FFmpeg-devel] [PATCH v4 4/4] lavc/get_bits: add a compat wrapper for the cached bitstream reader

2022-10-22 Thread Anton Khirnov
Use that instead of the merged version.
---
 libavcodec/get_bits.h | 309 +-
 1 file changed, 62 insertions(+), 247 deletions(-)

diff --git a/libavcodec/get_bits.h b/libavcodec/get_bits.h
index 992765dc92..a50469b427 100644
--- a/libavcodec/get_bits.h
+++ b/libavcodec/get_bits.h
@@ -1,6 +1,5 @@
 /*
  * Copyright (c) 2004 Michael Niedermayer 
- * Copyright (c) 2016 Alexandra Hájková
  *
  * This file is part of FFmpeg.
  *
@@ -58,12 +57,55 @@
 #define CACHED_BITSTREAM_READER 0
 #endif
 
-typedef struct GetBitContext {
-const uint8_t *buffer, *buffer_end;
 #if CACHED_BITSTREAM_READER
-uint64_t cache;
-unsigned bits_left;
+
+// we always want the LE implementation, to provide get_bits_le()
+#define BITSTREAM_LE
+
+#ifndef BITSTREAM_READER_LE
+# define BITSTREAM_BE
+# define BITSTREAM_DEFAULT_BE
 #endif
+
+#include "bitstream.h"
+
+#undef BITSTREAM_LE
+#undef BITSTREAM_BE
+#undef BITSTREAM_DEFAULT_BE
+
+typedef BitstreamContext GetBitContext;
+
+#define get_bits_count  bits_tell
+#define get_bits_left   bits_left
+#define skip_bits_long  bits_skip
+#define skip_bits   bits_skip
+#define get_bitsbits_read_nz
+#define get_bitsz   bits_read
+#define get_bits_long   bits_read
+#define get_bits1   bits_read_bit
+#define get_bits64  bits_read_64
+#define get_xbits   bits_read_xbits
+#define get_sbits   bits_read_signed
+#define get_sbits_long  bits_read_signed
+#define show_bits   bits_peek
+#define show_bits_long  bits_peek
+#define init_get_bits   bits_init
+#define init_get_bits8  bits_init8
+#define align_get_bits  bits_align
+#define get_vlc2bits_read_vlc
+
+#define init_get_bits8_le(s, buffer, byte_size) 
bits_init8_le((BitstreamContextLE*)s, buffer, byte_size)
+#define get_bits_le(s, n)   
bits_read_le((BitstreamContextLE*)s, n)
+
+#define show_bits1(s)   bits_peek(s, 1)
+#define skip_bits1(s)   bits_skip(s, 1)
+
+#define skip_1stop_8data_bits bits_skip_1stop_8data
+
+#else   // CACHED_BITSTREAM_READER
+
+typedef struct GetBitContext {
+const uint8_t *buffer, *buffer_end;
 int index;
 int size_in_bits;
 int size_in_bits_plus8;
@@ -120,16 +162,12 @@ static inline unsigned int show_bits(GetBitContext *s, 
int n);
  * For examples see get_bits, show_bits, skip_bits, get_vlc.
  */
 
-#if CACHED_BITSTREAM_READER
-#   define MIN_CACHE_BITS 64
-#elif defined LONG_BITSTREAM_READER
+#if defined LONG_BITSTREAM_READER
 #   define MIN_CACHE_BITS 32
 #else
 #   define MIN_CACHE_BITS 25
 #endif
 
-#if !CACHED_BITSTREAM_READER
-
 #define OPEN_READER_NOSIZE(name, gb)\
 unsigned int name ## _index = (gb)->index;  \
 unsigned int av_unused name ## _cache
@@ -214,73 +252,12 @@ static inline unsigned int show_bits(GetBitContext *s, 
int n);
 
 #define GET_CACHE(name, gb) ((uint32_t) name ## _cache)
 
-#endif
 
 static inline int get_bits_count(const GetBitContext *s)
 {
-#if CACHED_BITSTREAM_READER
-return s->index - s->bits_left;
-#else
 return s->index;
-#endif
-}
-
-#if CACHED_BITSTREAM_READER
-static inline void refill_32(GetBitContext *s, int is_le)
-{
-#if !UNCHECKED_BITSTREAM_READER
-if (s->index >> 3 >= s->buffer_end - s->buffer)
-return;
-#endif
-
-if (is_le)
-s->cache = (uint64_t)AV_RL32(s->buffer + (s->index >> 3)) << 
s->bits_left | s->cache;
-else
-s->cache = s->cache | (uint64_t)AV_RB32(s->buffer + (s->index >> 3)) 
<< (32 - s->bits_left);
-s->index += 32;
-s->bits_left += 32;
-}
-
-static inline void refill_64(GetBitContext *s, int is_le)
-{
-#if !UNCHECKED_BITSTREAM_READER
-if (s->index >> 3 >= s->buffer_end - s->buffer)
-return;
-#endif
-
-if (is_le)
-s->cache = AV_RL64(s->buffer + (s->index >> 3));
-else
-s->cache = AV_RB64(s->buffer + (s->index >> 3));
-s->index += 64;
-s->bits_left = 64;
 }
 
-static inline uint64_t get_val(GetBitContext *s, unsigned n, int is_le)
-{
-uint64_t ret;
-av_assert2(n>0 && n<=63);
-if (is_le) {
-ret = s->cache & ((UINT64_C(1) << n) - 1);
-s->cache >>= n;
-} else {
-ret = s->cache >> (64 - n);
-s->cache <<= n;
-}
-s->bits_left -= n;
-return ret;
-}
-
-static inline unsigned show_val(const GetBitContext *s, unsigned n)
-{
-#ifdef BITSTREAM_READER_LE
-return s->cache & ((UINT64_C(1) << n) - 1);
-#else
-return s->cache >> (64 - n);
-#endif
-}
-#endif
-
 /**
  * Skips the specified number of bits.
  * @param n the number of bits to skip,
@@ -290,28 +267,12 @@ static inline unsigned show_val(const GetBitContext *s, 
unsigned n)
  */
 static inline void skip_bits_long(GetBitContext *s, int n)
 {
-#if CACHED_BITSTREAM_READER
-skip_bits(s, n);
-#else
 #if UNCHECKED_BITSTREAM_READER
 s->index += n;
 #else
 s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
 #endif
-#end

[FFmpeg-devel] [PATCH v4 1/4] lavc: add standalone cached bitstream reader

2022-10-22 Thread Anton Khirnov
From: Alexandra Hájková 

The cached bitstream reader was originally written by Alexandra Hájková
for Libav, with significant input from Kostya Shishkov and Luca Barbato.
It was then committed to FFmpeg in ca079b09549, by merging it with the
implementation of the current bitstream reader.

This merge makes the code of get_bits.h significantly harder to read,
since it now contains two different bitstream readers interleaved with
 #ifdefs. Additionally, the code was committed without proper authorship
attribution.

This commit re-adds the cached bitstream reader as a standalone header,
as it was originally developed. It will be made useful in following
commits.

Integration by Anton Khirnov.

Signed-off-by: Anton Khirnov 
---
 libavcodec/bitstream.h | 529 +
 1 file changed, 529 insertions(+)
 create mode 100644 libavcodec/bitstream.h

diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
new file mode 100644
index 00..6fd321dba5
--- /dev/null
+++ b/libavcodec/bitstream.h
@@ -0,0 +1,529 @@
+/*
+ * Copyright (c) 2016 Alexandra Hájková
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * bitstream reader API header.
+ */
+
+#ifndef AVCODEC_BITSTREAM_H
+#define AVCODEC_BITSTREAM_H
+
+#include 
+
+#include "config.h"
+
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/log.h"
+
+#include "mathops.h"
+#include "vlc.h"
+
+#ifndef UNCHECKED_BITSTREAM_READER
+#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
+#endif
+
+typedef struct BitstreamContext {
+uint64_t bits;   // stores bits read from the buffer
+const uint8_t *buffer, *buffer_end;
+const uint8_t *ptr;  // pointer to the position inside a buffer
+unsigned bits_valid; // number of bits left in bits field
+unsigned size_in_bits;
+} BitstreamContext;
+
+/**
+ * @return
+ * - 0 on successful refill
+ * - a negative number when bitstream end is hit
+ *
+ * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
+ */
+static inline int bits_priv_refill_64(BitstreamContext *bc)
+{
+#if !UNCHECKED_BITSTREAM_READER
+if (bc->ptr >= bc->buffer_end)
+return -1;
+#endif
+
+#ifdef BITSTREAM_READER_LE
+bc->bits   = AV_RL64(bc->ptr);
+#else
+bc->bits   = AV_RB64(bc->ptr);
+#endif
+bc->ptr   += 8;
+bc->bits_valid = 64;
+
+return 0;
+}
+
+/**
+ * @return
+ * - 0 on successful refill
+ * - a negative number when bitstream end is hit
+ *
+ * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
+ */
+static inline int bits_priv_refill_32(BitstreamContext *bc)
+{
+#if !UNCHECKED_BITSTREAM_READER
+if (bc->ptr >= bc->buffer_end)
+return -1;
+#endif
+
+#ifdef BITSTREAM_READER_LE
+bc->bits  |= (uint64_t)AV_RL32(bc->ptr) << bc->bits_valid;
+#else
+bc->bits  |= (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_valid);
+#endif
+bc->ptr+= 4;
+bc->bits_valid += 32;
+
+return 0;
+}
+
+/**
+ * Initialize BitstreamContext.
+ * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
+ *larger than the actual read bits because some optimized bitstream
+ *readers read 32 or 64 bits at once and could read over the end
+ * @param bit_size the size of the buffer in bits
+ * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
+ */
+static inline int bits_init(BitstreamContext *bc, const uint8_t *buffer,
+unsigned int bit_size)
+{
+unsigned int buffer_size;
+
+if (bit_size > INT_MAX - 7 || !buffer) {
+bc->buffer = NULL;
+bc->ptr= NULL;
+bc->bits_valid = 0;
+return AVERROR_INVALIDDATA;
+}
+
+buffer_size = (bit_size + 7) >> 3;
+
+bc->buffer   = buffer;
+bc->buffer_end   = buffer + buffer_size;
+bc->ptr  = bc->buffer;
+bc->size_in_bits = bit_size;
+bc->bits_valid   = 0;
+bc->bits = 0;
+
+bits_priv_refill_64(bc);
+
+return 0;
+}
+
+/**
+ * Initialize BitstreamContext.
+ * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
+ *larger than the actual read bits because some optimized bit

[FFmpeg-devel] [PATCH v4 2/4] lavc/bitstream: templatize for BE/LE

2022-10-22 Thread Anton Khirnov
Allows using both BE and LE bitstream readers in the same file.
---
 libavcodec/Makefile   |   1 +
 libavcodec/bitstream.h| 563 --
 .../{bitstream.h => bitstream_template.h} | 243 
 tests/ref/fate/source |   1 +
 4 files changed, 220 insertions(+), 588 deletions(-)
 copy libavcodec/{bitstream.h => bitstream_template.h} (54%)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8fa83c72b2..b77fe0db8e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1238,6 +1238,7 @@ SKIPHEADERS+= %_tablegen.h
  \
   aaccoder_trellis.h\
   aacenc_quantization.h \
   aacenc_quantization_misc.h\
+  bitstream_template.h  \
   $(ARCH)/vpx_arith.h  \
 
 SKIPHEADERS-$(CONFIG_AMF)  += amfenc.h
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
index 6fd321dba5..ef7d8d55c2 100644
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -23,6 +23,21 @@
  * bitstream reader API header.
  */
 
+/*
+ * Bit order (endianness) is controlled by #defining BITSTREAM_BE and/or
+ * BITSTREAM_LE before #including this header. The corresponding bitreading
+ * functions are provided as bits_*_be()/bits_*_le() respectively.
+ *
+ * If neither or only BITSTREAM_BE is defined, then the default (unsuffixed)
+ * bits_*() will resolve to the big-endian implementation. If only BITSTREAM_LE
+ * is defined, little-endian will be the default.
+ *
+ * If both are defined, then the default can be controlled by defining at most
+ * one of BITSTREAM_DEFAULT_LE/BE. When BITSTREAM_DEFAULT_* is not defined, no
+ * default is provided and you must always explicitly use the _be() or _le()
+ * variants.
+ */
+
 #ifndef AVCODEC_BITSTREAM_H
 #define AVCODEC_BITSTREAM_H
 
@@ -42,461 +57,80 @@
 #define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
 #endif
 
-typedef struct BitstreamContext {
-uint64_t bits;   // stores bits read from the buffer
-const uint8_t *buffer, *buffer_end;
-const uint8_t *ptr;  // pointer to the position inside a buffer
-unsigned bits_valid; // number of bits left in bits field
-unsigned size_in_bits;
-} BitstreamContext;
-
-/**
- * @return
- * - 0 on successful refill
- * - a negative number when bitstream end is hit
- *
- * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
- */
-static inline int bits_priv_refill_64(BitstreamContext *bc)
-{
-#if !UNCHECKED_BITSTREAM_READER
-if (bc->ptr >= bc->buffer_end)
-return -1;
-#endif
-
-#ifdef BITSTREAM_READER_LE
-bc->bits   = AV_RL64(bc->ptr);
-#else
-bc->bits   = AV_RB64(bc->ptr);
-#endif
-bc->ptr   += 8;
-bc->bits_valid = 64;
-
-return 0;
-}
-
-/**
- * @return
- * - 0 on successful refill
- * - a negative number when bitstream end is hit
- *
- * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
- */
-static inline int bits_priv_refill_32(BitstreamContext *bc)
-{
-#if !UNCHECKED_BITSTREAM_READER
-if (bc->ptr >= bc->buffer_end)
-return -1;
-#endif
-
-#ifdef BITSTREAM_READER_LE
-bc->bits  |= (uint64_t)AV_RL32(bc->ptr) << bc->bits_valid;
-#else
-bc->bits  |= (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_valid);
-#endif
-bc->ptr+= 4;
-bc->bits_valid += 32;
-
-return 0;
-}
-
-/**
- * Initialize BitstreamContext.
- * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
- *larger than the actual read bits because some optimized bitstream
- *readers read 32 or 64 bits at once and could read over the end
- * @param bit_size the size of the buffer in bits
- * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
- */
-static inline int bits_init(BitstreamContext *bc, const uint8_t *buffer,
-unsigned int bit_size)
-{
-unsigned int buffer_size;
-
-if (bit_size > INT_MAX - 7 || !buffer) {
-bc->buffer = NULL;
-bc->ptr= NULL;
-bc->bits_valid = 0;
-return AVERROR_INVALIDDATA;
-}
-
-buffer_size = (bit_size + 7) >> 3;
-
-bc->buffer   = buffer;
-bc->buffer_end   = buffer + buffer_size;
-bc->ptr  = bc->buffer;
-bc->size_in_bits = bit_size;
-bc->bits_valid   = 0;
-bc->bits = 0;
-
-bits_priv_refill_64(bc);
-
-return 0;
-}
-
-/**
- * Initialize BitstreamContext.
- * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes
- *larger than the actual read bits because some optimized bitstream
- *readers read 32 or 64 bits at once and could read over the end
- * @param byte_size the size of the buffer in bytes
- * @return 0 on su

Re: [FFmpeg-devel] [PATCH v4 1/4] lavc: add standalone cached bitstream reader

2022-10-22 Thread Paul B Mahol
On 10/22/22, Anton Khirnov  wrote:
> From: Alexandra Hájková 
>
> The cached bitstream reader was originally written by Alexandra Hájková
> for Libav, with significant input from Kostya Shishkov and Luca Barbato.
> It was then committed to FFmpeg in ca079b09549, by merging it with the
> implementation of the current bitstream reader.
>
> This merge makes the code of get_bits.h significantly harder to read,
> since it now contains two different bitstream readers interleaved with
>  #ifdefs. Additionally, the code was committed without proper authorship
> attribution.
>
> This commit re-adds the cached bitstream reader as a standalone header,
> as it was originally developed. It will be made useful in following
> commits.
>
> Integration by Anton Khirnov.
>
> Signed-off-by: Anton Khirnov 
> ---
>  libavcodec/bitstream.h | 529 +
>  1 file changed, 529 insertions(+)
>  create mode 100644 libavcodec/bitstream.h
>
> diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
> new file mode 100644
> index 00..6fd321dba5
> --- /dev/null
> +++ b/libavcodec/bitstream.h
> @@ -0,0 +1,529 @@
> +/*
> + * Copyright (c) 2016 Alexandra Hájková
> + *
> + * 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
> + */
> +
> +/**
> + * @file
> + * bitstream reader API header.
> + */
> +
> +#ifndef AVCODEC_BITSTREAM_H
> +#define AVCODEC_BITSTREAM_H
> +
> +#include 
> +
> +#include "config.h"
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/common.h"
> +#include "libavutil/intreadwrite.h"
> +#include "libavutil/log.h"
> +
> +#include "mathops.h"
> +#include "vlc.h"
> +
> +#ifndef UNCHECKED_BITSTREAM_READER
> +#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
> +#endif
> +
> +typedef struct BitstreamContext {
> +uint64_t bits;   // stores bits read from the buffer
> +const uint8_t *buffer, *buffer_end;
> +const uint8_t *ptr;  // pointer to the position inside a buffer
> +unsigned bits_valid; // number of bits left in bits field
> +unsigned size_in_bits;
> +} BitstreamContext;
> +
> +/**
> + * @return
> + * - 0 on successful refill
> + * - a negative number when bitstream end is hit
> + *
> + * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
> + */
> +static inline int bits_priv_refill_64(BitstreamContext *bc)
> +{
> +#if !UNCHECKED_BITSTREAM_READER
> +if (bc->ptr >= bc->buffer_end)
> +return -1;
> +#endif
> +
> +#ifdef BITSTREAM_READER_LE
> +bc->bits   = AV_RL64(bc->ptr);
> +#else
> +bc->bits   = AV_RB64(bc->ptr);
> +#endif
> +bc->ptr   += 8;
> +bc->bits_valid = 64;
> +
> +return 0;
> +}
> +
> +/**
> + * @return
> + * - 0 on successful refill
> + * - a negative number when bitstream end is hit
> + *
> + * Always succeeds when UNCHECKED_BITSTREAM_READER is enabled.
> + */
> +static inline int bits_priv_refill_32(BitstreamContext *bc)
> +{
> +#if !UNCHECKED_BITSTREAM_READER
> +if (bc->ptr >= bc->buffer_end)
> +return -1;
> +#endif
> +
> +#ifdef BITSTREAM_READER_LE
> +bc->bits  |= (uint64_t)AV_RL32(bc->ptr) << bc->bits_valid;
> +#else
> +bc->bits  |= (uint64_t)AV_RB32(bc->ptr) << (32 - bc->bits_valid);
> +#endif
> +bc->ptr+= 4;
> +bc->bits_valid += 32;
> +
> +return 0;
> +}
> +
> +/**
> + * Initialize BitstreamContext.
> + * @param buffer bitstream buffer, must be AV_INPUT_BUFFER_PADDING_SIZE
> bytes
> + *larger than the actual read bits because some optimized bitstream
> + *readers read 32 or 64 bits at once and could read over the end
> + * @param bit_size the size of the buffer in bits
> + * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would
> overflow.
> + */
> +static inline int bits_init(BitstreamContext *bc, const uint8_t *buffer,
> +unsigned int bit_size)
> +{
> +unsigned int buffer_size;
> +
> +if (bit_size > INT_MAX - 7 || !buffer) {
> +bc->buffer = NULL;
> +bc->ptr= NULL;
> +bc->bits_valid = 0;
> +return AVERROR_INVALIDDATA;
> +}
> +
> +buffer_size = (bit_size + 7) >> 3;
> +
> +bc->buffer   = buffer;
> +bc->buffer_end   = buffer + buffer_size;
> +bc->ptr

[FFmpeg-devel] [PATCH 1/2] doc/examples/muxing: Remove unnecessary ret

2022-10-22 Thread Jun Zhao
From: Jun Zhao 

Remove unnecessary ret and make the code more compact

Signed-off-by: Jun Zhao 
---
 doc/examples/muxing.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index 3acb778322..cd997d5431 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -219,8 +219,6 @@ static AVFrame *alloc_audio_frame(enum AVSampleFormat 
sample_fmt,
   int sample_rate, int nb_samples)
 {
 AVFrame *frame = av_frame_alloc();
-int ret;
-
 if (!frame) {
 fprintf(stderr, "Error allocating an audio frame\n");
 exit(1);
@@ -232,8 +230,7 @@ static AVFrame *alloc_audio_frame(enum AVSampleFormat 
sample_fmt,
 frame->nb_samples = nb_samples;
 
 if (nb_samples) {
-ret = av_frame_get_buffer(frame, 0);
-if (ret < 0) {
+if (av_frame_get_buffer(frame, 0) < 0) {
 fprintf(stderr, "Error allocating an audio buffer\n");
 exit(1);
 }
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 2/2] doc/protocols: update rtsp options

2022-10-22 Thread Jun Zhao
From: Jun Zhao 

Split the rtsp options to muxer/demuxer, and update the options.

Signed-off-by: Jun Zhao 
---
 doc/protocols.texi | 64 ++
 1 file changed, 64 insertions(+)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 0df38d790c..5e9198e67c 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -1178,6 +1178,59 @@ Options can be set on the 
@command{ffmpeg}/@command{ffplay} command
 line, or set in code via @code{AVOption}s or in
 @code{avformat_open_input}.
 
+@subsection Muxer
+The following options are supported.
+
+@table @option
+@item rtsp_transport
+Set RTSP transport protocols.
+
+It accepts the following values:
+@table @samp
+@item udp
+Use UDP as lower transport protocol.
+
+@item tcp
+Use TCP (interleaving within the RTSP control channel) as lower
+transport protocol.
+@end table
+
+Default value is @samp{0}.
+
+@item rtsp_flags
+Set RTSP flags.
+
+The following values are accepted:
+@table @samp
+@item latm
+Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC.
+@item rfc2190
+Use RFC 2190 packetization instead of RFC 4629 for H.263.
+@item skip_rtcp
+Don't send RTCP sender reports.
+@item h264_mode0
+Use mode 0 for H.264 in RTP.
+@item send_bye
+Send RTCP BYE packets when finishing.
+@end table
+
+Default value is @samp{0}.
+
+
+@item min_port
+Set minimum local UDP port. Default value is 5000.
+
+@item max_port
+Set maximum local UDP port. Default value is 65000.
+
+@item buffer_size
+Set the maximum socket buffer size in bytes.
+
+@item pkt_size
+Set max send packet size (in bytes). Default value is 1472.
+@end table
+
+@subsection Demuxer
 The following options are supported.
 
 @table @option
@@ -1203,6 +1256,10 @@ Use UDP multicast as lower transport protocol.
 @item http
 Use HTTP tunneling as lower transport protocol, which is useful for
 passing proxies.
+
+@item https
+Use HTTPs tunneling as lower transport protocol, which is useful for
+passing proxies and widely used for security consideration.
 @end table
 
 Multiple lower transport protocols may be specified, in that case they are
@@ -1220,6 +1277,9 @@ Accept packets only from negotiated peer address and port.
 Act as a server, listening for an incoming connection.
 @item prefer_tcp
 Try TCP for RTP transport first, if TCP is available as RTSP RTP transport.
+@item satip_raw
+Export raw MPEG-TS stream instead of demuxing. The flag will simply write out
+the raw stream, with the original PAT/PMT/PIDs intact.
 @end table
 
 Default value is @samp{none}.
@@ -1232,6 +1292,7 @@ The following flags are accepted:
 @item video
 @item audio
 @item data
+@item subtitle
 @end table
 
 By default it accepts all media types.
@@ -1256,6 +1317,9 @@ Set socket TCP I/O timeout in microseconds.
 @item user_agent
 Override User-Agent header. If not specified, it defaults to the
 libavformat identifier string.
+
+@item buffer_size
+Set the maximum socket buffer size in bytes.
 @end table
 
 When receiving data over UDP, the demuxer tries to reorder received packets
-- 
2.25.1

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

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


[FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const

2022-10-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavformat/argo_cvg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index edf75c905e..aedc7c4a32 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -70,7 +70,7 @@ typedef struct ArgoCVGMuxContext {
 
 #if CONFIG_ARGO_CVG_DEMUXER
 /* "Special" files that are played at a different rate. */
-static ArgoCVGOverride overrides[] = {
+static const ArgoCVGOverride overrides[] = {
 { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */
 { "REDCRY88.CVG", { 38280, 0, 1 }, 4134848, 88200 }, /* Beta */
 { "DANLOOP1.CVG", { 54744, 1, 0 }, 5684641, 37800 }, /* Beta */
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 2/5] avcodec/aaccoder: Mark function pointer arrays as const

2022-10-22 Thread Andreas Rheinhardt
Forgotten in 57d305207a30131172e1c07c99e2cba833c1add1.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/aaccoder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index e3b6b2f02c..6291c16123 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -226,7 +226,7 @@ QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC_RTZ, 0, 1, 1, 1, 0, 
0, ROUND_TO_ZERO)
 QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NOISE, 0, 0, 0, 0, 1, 0, ROUND_STANDARD)
 QUANTIZE_AND_ENCODE_BAND_COST_FUNC(STEREO,0, 0, 0, 0, 0, 1, ROUND_STANDARD)
 
-static quantize_and_encode_band_func quantize_and_encode_band_cost_arr[] =
+static const quantize_and_encode_band_func quantize_and_encode_band_cost_arr[] 
=
 {
 quantize_and_encode_band_cost_ZERO,
 quantize_and_encode_band_cost_SQUAD,
@@ -246,7 +246,7 @@ static quantize_and_encode_band_func 
quantize_and_encode_band_cost_arr[] =
 quantize_and_encode_band_cost_STEREO,
 };
 
-static quantize_and_encode_band_func quantize_and_encode_band_cost_rtz_arr[] =
+static const quantize_and_encode_band_func 
quantize_and_encode_band_cost_rtz_arr[] =
 {
 quantize_and_encode_band_cost_ZERO,
 quantize_and_encode_band_cost_SQUAD,
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 3/5] avutil/tx_template: Don't waste space for inexistent factors

2022-10-22 Thread Andreas Rheinhardt
It is possible to avoid the factors array for the power-of-two
tables for which said array is unused by using a different
structure for initialization the same structure for power-of-two
tables as for non-power-of-two-tables. This saves 3*15*16B
from .data.

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/tx_template.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 6b63cc575f..b44a6189cc 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -55,9 +55,14 @@ TABLE_DEF( 9,  8);
 typedef struct FFSRTabsInitOnce {
 void (*func)(void);
 AVOnce control;
-int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
 } FFSRTabsInitOnce;
 
+typedef struct FFSRTabsInitOnceExt {
+void (*func)(void);
+AVOnce control;
+int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
+} FFSRTabsInitOnceExt;
+
 #define INIT_FF_SR_TAB(len)\
 static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)\
 {  \
@@ -145,7 +150,7 @@ static av_cold void TX_TAB(ff_tx_init_tab_9)(void)
 TX_TAB(ff_tx_tab_9)[7] = TX_TAB(ff_tx_tab_9)[3] - TX_TAB(ff_tx_tab_9)[4];
 }
 
-static FFSRTabsInitOnce nptwo_tabs_init_once[] = {
+static FFSRTabsInitOnceExt nptwo_tabs_init_once[] = {
 { TX_TAB(ff_tx_init_tab_53),  AV_ONCE_INIT, { 15, 5, 3 } },
 { TX_TAB(ff_tx_init_tab_9),   AV_ONCE_INIT, {  9 }   },
 { TX_TAB(ff_tx_init_tab_7),   AV_ONCE_INIT, {  7 }   },
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 4/5] avutil/tx_template: Avoid code duplication

2022-10-22 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavutil/tx_template.c | 76 +++--
 1 file changed, 27 insertions(+), 49 deletions(-)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index b44a6189cc..c15dc2ea27 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -27,25 +27,28 @@
 #define TABLE_DEF(name, size) \
 DECLARE_ALIGNED(32, TXSample, TX_TAB(ff_tx_tab_ ##name))[size]
 
-#define SR_TABLE(len) \
-TABLE_DEF(len, len/4 + 1)
+#define SR_POW2_TABLES \
+SR_TABLE(8)\
+SR_TABLE(16)   \
+SR_TABLE(32)   \
+SR_TABLE(64)   \
+SR_TABLE(128)  \
+SR_TABLE(256)  \
+SR_TABLE(512)  \
+SR_TABLE(1024) \
+SR_TABLE(2048) \
+SR_TABLE(4096) \
+SR_TABLE(8192) \
+SR_TABLE(16384)\
+SR_TABLE(32768)\
+SR_TABLE(65536)\
+SR_TABLE(131072)   \
 
+#define SR_TABLE(len) \
+TABLE_DEF(len, len/4 + 1);
 /* Power of two tables */
-SR_TABLE(8);
-SR_TABLE(16);
-SR_TABLE(32);
-SR_TABLE(64);
-SR_TABLE(128);
-SR_TABLE(256);
-SR_TABLE(512);
-SR_TABLE(1024);
-SR_TABLE(2048);
-SR_TABLE(4096);
-SR_TABLE(8192);
-SR_TABLE(16384);
-SR_TABLE(32768);
-SR_TABLE(65536);
-SR_TABLE(131072);
+SR_POW2_TABLES
+#undef SR_TABLE
 
 /* Other factors' tables */
 TABLE_DEF(53, 12);
@@ -63,7 +66,7 @@ typedef struct FFSRTabsInitOnceExt {
 int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
 } FFSRTabsInitOnceExt;
 
-#define INIT_FF_SR_TAB(len)\
+#define SR_TABLE(len)  \
 static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)\
 {  \
 double freq = 2*M_PI/len;  \
@@ -74,39 +77,14 @@ static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) 
   \
\
 *tab = 0;  \
 }
-
-INIT_FF_SR_TAB(8)
-INIT_FF_SR_TAB(16)
-INIT_FF_SR_TAB(32)
-INIT_FF_SR_TAB(64)
-INIT_FF_SR_TAB(128)
-INIT_FF_SR_TAB(256)
-INIT_FF_SR_TAB(512)
-INIT_FF_SR_TAB(1024)
-INIT_FF_SR_TAB(2048)
-INIT_FF_SR_TAB(4096)
-INIT_FF_SR_TAB(8192)
-INIT_FF_SR_TAB(16384)
-INIT_FF_SR_TAB(32768)
-INIT_FF_SR_TAB(65536)
-INIT_FF_SR_TAB(131072)
+SR_POW2_TABLES
+#undef SR_TABLE
 
 static FFSRTabsInitOnce sr_tabs_init_once[] = {
-{ TX_TAB(ff_tx_init_tab_8),  AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_16), AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_32), AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_64), AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_128),AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_256),AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_512),AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_1024),   AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_2048),   AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_4096),   AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_8192),   AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_16384),  AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_32768),  AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_65536),  AV_ONCE_INIT },
-{ TX_TAB(ff_tx_init_tab_131072), AV_ONCE_INIT },
+#define SR_TABLE(len) \
+{ TX_TAB(ff_tx_init_tab_ ## len), AV_ONCE_INIT },
+SR_POW2_TABLES
+#undef SR_TABLE
 };
 
 static av_cold void TX_TAB(ff_tx_init_tab_53)(void)
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 5/5] avutil/tx_template: Move function pointers to const memory

2022-10-22 Thread Andreas Rheinhardt
This can be achieved by moving the AVOnce out of the structure
containing the function pointers; the latter can then be made
const.
This also has the advantage of eliminating padding in the structure
(sizeof(AVOnce) is four here) and allowing the AVOnces to be put
into .bss (dependening upon the implementation).

Signed-off-by: Andreas Rheinhardt 
---
 libavutil/tx_template.c | 47 +++--
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index c15dc2ea27..56e9a6aa98 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -55,16 +55,10 @@ TABLE_DEF(53, 12);
 TABLE_DEF( 7,  6);
 TABLE_DEF( 9,  8);
 
-typedef struct FFSRTabsInitOnce {
+typedef struct FFSRTabsInitData {
 void (*func)(void);
-AVOnce control;
-} FFSRTabsInitOnce;
-
-typedef struct FFSRTabsInitOnceExt {
-void (*func)(void);
-AVOnce control;
 int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
-} FFSRTabsInitOnceExt;
+} FFSRTabsInitData;
 
 #define SR_TABLE(len)  \
 static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)\
@@ -80,9 +74,14 @@ static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)  
  \
 SR_POW2_TABLES
 #undef SR_TABLE
 
-static FFSRTabsInitOnce sr_tabs_init_once[] = {
-#define SR_TABLE(len) \
-{ TX_TAB(ff_tx_init_tab_ ## len), AV_ONCE_INIT },
+static void (*const sr_tabs_init_funcs[])(void) = {
+#define SR_TABLE(len) TX_TAB(ff_tx_init_tab_ ##len),
+SR_POW2_TABLES
+#undef SR_TABLE
+};
+
+static AVOnce sr_tabs_init_once[] = {
+#define SR_TABLE(len) AV_ONCE_INIT,
 SR_POW2_TABLES
 #undef SR_TABLE
 };
@@ -128,10 +127,16 @@ static av_cold void TX_TAB(ff_tx_init_tab_9)(void)
 TX_TAB(ff_tx_tab_9)[7] = TX_TAB(ff_tx_tab_9)[3] - TX_TAB(ff_tx_tab_9)[4];
 }
 
-static FFSRTabsInitOnceExt nptwo_tabs_init_once[] = {
-{ TX_TAB(ff_tx_init_tab_53),  AV_ONCE_INIT, { 15, 5, 3 } },
-{ TX_TAB(ff_tx_init_tab_9),   AV_ONCE_INIT, {  9 }   },
-{ TX_TAB(ff_tx_init_tab_7),   AV_ONCE_INIT, {  7 }   },
+static const FFSRTabsInitData nptwo_tabs_init_data[] = {
+{ TX_TAB(ff_tx_init_tab_53),  { 15, 5, 3 } },
+{ TX_TAB(ff_tx_init_tab_9),   {  9 }   },
+{ TX_TAB(ff_tx_init_tab_7),   {  7 }   },
+};
+
+static AVOnce nptwo_tabs_init_once[] = {
+AV_ONCE_INIT,
+AV_ONCE_INIT,
+AV_ONCE_INIT,
 };
 
 av_cold void TX_TAB(ff_tx_init_tabs)(int len)
@@ -140,23 +145,23 @@ av_cold void TX_TAB(ff_tx_init_tabs)(int len)
 if (factor_2) {
 int idx = factor_2 - 3;
 for (int i = 0; i <= idx; i++)
-ff_thread_once(&sr_tabs_init_once[i].control,
-sr_tabs_init_once[i].func);
+ff_thread_once(&sr_tabs_init_once[i],
+sr_tabs_init_funcs[i]);
 len >>= factor_2;
 }
 
-for (int i = 0; i < FF_ARRAY_ELEMS(nptwo_tabs_init_once); i++) {
+for (int i = 0; i < FF_ARRAY_ELEMS(nptwo_tabs_init_data); i++) {
 int f, f_idx = 0;
 
 if (len <= 1)
 return;
 
-while ((f = nptwo_tabs_init_once[i].factors[f_idx++])) {
+while ((f = nptwo_tabs_init_data[i].factors[f_idx++])) {
 if (f % len)
 continue;
 
-ff_thread_once(&nptwo_tabs_init_once[i].control,
-nptwo_tabs_init_once[i].func);
+ff_thread_once(&nptwo_tabs_init_once[i],
+nptwo_tabs_init_data[i].func);
 len /= f;
 break;
 }
-- 
2.34.1

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

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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_curves: add PCHIP interpolator and interp option

2022-10-22 Thread Takeshi Ikuma


0001-avfilter-vf_curves-add-PCHIP-interpolator-and-interp-v2.patch
Description: Binary data
___
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] libavformat/aea EOF Patch

2022-10-22 Thread asivery
Hello,
This patch aims to fix a problem I've noticed while working with AEA (Sony 
ATRAC1 comtainer) files.
Right now FFmpeg always exits with an "Input/Output error" when dealing with 
AEA files.
This patch solves that issue by returning AVERROR_EOF once the end of file is 
encountered, instead of always returning AVERROR(EIO).

I am sending this patch again because of an incorrect mime type of the first 
one.

Best regards,AsiveryFrom cc127ff24d82a04611fac14cf4114a2262f87111 Mon Sep 17 00:00:00 2001
From: asivery 
Date: Tue, 27 Sep 2022 00:13:10 +0200
Subject: [PATCH] avformat/aea: Make it so the AEA demuxer returns EOF at the
 end of file instead of EIO

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

diff --git a/libavformat/aea.c b/libavformat/aea.c
index f4b39e4f9e..d721398cf5 100644
--- a/libavformat/aea.c
+++ b/libavformat/aea.c
@@ -93,8 +93,11 @@ static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
 int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
 
 pkt->stream_index = 0;
-if (ret <= 0)
-return AVERROR(EIO);
+if (ret <= 0){
+if(ret < 0)
+return ret;
+return AVERROR_EOF;
+}
 
 return ret;
 }
-- 
2.34.1

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

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


[FFmpeg-devel] [PATCH 1/5 v2] avcodec/ac3dec: split off code discarding garbage at the beginning of a packet

2022-10-22 Thread James Almer
Signed-off-by: James Almer 
---
No changes since v1.

 libavcodec/ac3_parser.c  | 19 +++
 libavcodec/ac3_parser_internal.h |  2 ++
 libavcodec/ac3dec.c  | 15 ++-
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 4f154bb7c4..425e1b4742 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -53,6 +53,25 @@ static const uint8_t center_levels[4] = { 4, 5, 6, 5 };
  */
 static const uint8_t surround_levels[4] = { 4, 6, 7, 6 };
 
+int ff_ac3_find_syncword(const uint8_t *buf, int buf_size)
+{
+int i;
+
+for (i = 1; i < buf_size; i += 2) {
+if (buf[i] == 0x77 || buf[i] == 0x0B) {
+if ((buf[i] ^ buf[i-1]) == (0x77 ^ 0x0B)) {
+i--;
+break;
+} else if ((buf[i] ^ buf[i+1]) == (0x77 ^ 0x0B)) {
+break;
+}
+}
+}
+if (i >= buf_size)
+return AVERROR_INVALIDDATA;
+
+return i;
+}
 
 int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr)
 {
diff --git a/libavcodec/ac3_parser_internal.h b/libavcodec/ac3_parser_internal.h
index bd4e1bbffb..2ac0e67ec2 100644
--- a/libavcodec/ac3_parser_internal.h
+++ b/libavcodec/ac3_parser_internal.h
@@ -79,4 +79,6 @@ int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo 
*hdr);
 int avpriv_ac3_parse_header(AC3HeaderInfo **hdr, const uint8_t *buf,
 size_t size);
 
+int ff_ac3_find_syncword(const uint8_t *buf, int buf_size);
+
 #endif /* AVCODEC_AC3_PARSER_INTERNAL_H */
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 340f6e1e37..8e40587ff1 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -1508,19 +1508,8 @@ static int ac3_decode_frame(AVCodecContext *avctx, 
AVFrame *frame,
 s->superframe_size = 0;
 
 buf_size = full_buf_size;
-for (i = 1; i < buf_size; i += 2) {
-if (buf[i] == 0x77 || buf[i] == 0x0B) {
-if ((buf[i] ^ buf[i-1]) == (0x77 ^ 0x0B)) {
-i--;
-break;
-} else if ((buf[i] ^ buf[i+1]) == (0x77 ^ 0x0B)) {
-break;
-}
-}
-}
-if (i >= buf_size)
-return AVERROR_INVALIDDATA;
-if (i > 10)
+i = ff_ac3_find_syncword(buf, buf_size);
+if (i < 0 || i > 10)
 return i;
 buf += i;
 buf_size -= i;
-- 
2.37.3

___
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/5] avcodec/aac_ac3_parser: don't fill stream info in the sync function

2022-10-22 Thread James Almer
Have it only find frame boundaries. The stream props will then be filled once
we have an assembled frame.

Signed-off-by: James Almer 
---
 libavcodec/aac_ac3_parser.c | 63 +
 libavcodec/aac_ac3_parser.h | 12 +--
 libavcodec/aac_parser.c |  7 +
 libavcodec/ac3_parser.c | 16 +-
 4 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index b14b1e31f9..6df064e28d 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -26,6 +26,8 @@
 #include "libavutil/common.h"
 #include "parser.h"
 #include "aac_ac3_parser.h"
+#include "ac3_parser_internal.h"
+#include "adts_header.h"
 
 int ff_aac_ac3_parse(AVCodecParserContext *s1,
  AVCodecContext *avctx,
@@ -48,7 +50,7 @@ get_next:
 len=0;
 for(i=s->remaining_size; istate = (s->state<<8) + buf[i];
-if((len=s->sync(s->state, s, &s->need_next_header, 
&new_frame_start)))
+if((len=s->sync(s->state, &s->need_next_header, 
&new_frame_start)))
 break;
 }
 if(len<=0){
@@ -79,42 +81,77 @@ get_next:
 *poutbuf = buf;
 *poutbuf_size = buf_size;
 
-/* update codec info */
-if(s->codec_id)
-avctx->codec_id = s->codec_id;
-
 if (got_frame) {
+int bit_rate;
+
 /* Due to backwards compatible HE-AAC the sample rate, channel count,
and total number of samples found in an AAC ADTS header are not
reliable. Bit rate is still accurate because the total frame
duration in seconds is still correct (as is the number of bits in
the frame). */
 if (avctx->codec_id != AV_CODEC_ID_AAC) {
-avctx->sample_rate = s->sample_rate;
+AC3HeaderInfo hdr, *phrd = &hdr;
+int offset = ff_ac3_find_syncword(buf, buf_size);
+
+if (offset < 0)
+return i;
+
+buf += offset;
+buf_size -= offset;
+while (buf_size > 0) {
+int ret = avpriv_ac3_parse_header(&phrd, buf, buf_size);
+
+if (ret < 0 || hdr.frame_size > buf_size)
+return i;
+
+if (buf_size > hdr.frame_size) {
+buf += hdr.frame_size;
+buf_size -= hdr.frame_size;
+continue;
+}
+break;
+}
+
+avctx->sample_rate = hdr.sample_rate;
+
+if (hdr.bitstream_id > 10)
+avctx->codec_id = AV_CODEC_ID_EAC3;
+
 if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
 av_channel_layout_uninit(&avctx->ch_layout);
-if (s->channel_layout) {
-av_channel_layout_from_mask(&avctx->ch_layout, 
s->channel_layout);
+if (hdr.channel_layout) {
+av_channel_layout_from_mask(&avctx->ch_layout, 
hdr.channel_layout);
 } else {
 avctx->ch_layout.order   = AV_CHANNEL_ORDER_UNSPEC;
-avctx->ch_layout.nb_channels = s->channels;
+avctx->ch_layout.nb_channels = hdr.channels;
 }
 #if FF_API_OLD_CHANNEL_LAYOUT
 FF_DISABLE_DEPRECATION_WARNINGS
 avctx->channels = avctx->ch_layout.nb_channels;
-avctx->channel_layout = s->channel_layout;
+avctx->channel_layout = hdr.channel_layout;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
 }
-s1->duration = s->samples;
-avctx->audio_service_type = s->service_type;
+s1->duration = hdr.num_blocks * 256;
+avctx->audio_service_type = hdr.bitstream_mode;
+if (hdr.bitstream_mode == 0x7 && hdr.channels > 1)
+avctx->audio_service_type = AV_AUDIO_SERVICE_TYPE_KARAOKE;
+bit_rate = hdr.bit_rate;
+} else {
+AACADTSHeaderInfo hdr, *phrd = &hdr;
+int ret = avpriv_adts_header_parse(&phrd, buf, buf_size);
+
+if (ret < 0)
+return i;
+
+bit_rate = hdr.bit_rate;
 }
 
 /* Calculate the average bit rate */
 s->frame_number++;
 if (!CONFIG_EAC3_DECODER || avctx->codec_id != AV_CODEC_ID_EAC3) {
 avctx->bit_rate +=
-(s->bit_rate - avctx->bit_rate) / s->frame_number;
+(bit_rate - avctx->bit_rate) / s->frame_number;
 }
 }
 
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index 8b93cbf84f..560bba54f5 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -39,24 +39,14 @@ typedef enum {
 
 typedef struct AACAC3ParseContext {
 ParseContext pc;
-int frame_size;
 int header_size;
-int (*sync)(uint64_t state, struct AACAC3ParseContext *hdr_info,
-int *need_next

[FFmpeg-devel] [PATCH 4/5] avcodec/aac_ac3_parser: reindent after previous commit

2022-10-22 Thread James Almer
Signed-off-by: James Almer 
---
 libavcodec/aac_ac3_parser.c | 62 ++---
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index bfbb55d68e..e89b12baf9 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -44,42 +44,42 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
 i = buf_size;
 } else {
 get_next:
-i=END_NOT_FOUND;
-if(s->remaining_size <= buf_size){
-if(s->remaining_size && !s->need_next_header){
-i= s->remaining_size;
-s->remaining_size = 0;
-}else{ //we need a header first
-len=0;
-for(i=s->remaining_size; istate = (s->state<<8) + buf[i];
-if((len=s->sync(s->state, &s->need_next_header, 
&new_frame_start)))
-break;
-}
-if(len<=0){
-i=END_NOT_FOUND;
-}else{
-got_frame = 1;
-s->state=0;
-i-= s->header_size -1;
-s->remaining_size = len;
-if(!new_frame_start || pc->index+i<=0){
-s->remaining_size += i;
-goto get_next;
+i=END_NOT_FOUND;
+if(s->remaining_size <= buf_size){
+if(s->remaining_size && !s->need_next_header){
+i= s->remaining_size;
+s->remaining_size = 0;
+}else{ //we need a header first
+len=0;
+for(i=s->remaining_size; istate = (s->state<<8) + buf[i];
+if((len=s->sync(s->state, &s->need_next_header, 
&new_frame_start)))
+break;
 }
-else if (i < 0) {
-s->remaining_size += i;
+if(len<=0){
+i=END_NOT_FOUND;
+}else{
+got_frame = 1;
+s->state=0;
+i-= s->header_size -1;
+s->remaining_size = len;
+if(!new_frame_start || pc->index+i<=0){
+s->remaining_size += i;
+goto get_next;
+}
+else if (i < 0) {
+s->remaining_size += i;
+}
 }
 }
 }
-}
 
-if(ff_combine_frame(pc, i, &buf, &buf_size)<0){
-s->remaining_size -= FFMIN(s->remaining_size, buf_size);
-*poutbuf = NULL;
-*poutbuf_size = 0;
-return buf_size;
-}
+if(ff_combine_frame(pc, i, &buf, &buf_size)<0){
+s->remaining_size -= FFMIN(s->remaining_size, buf_size);
+*poutbuf = NULL;
+*poutbuf_size = 0;
+return buf_size;
+}
 }
 
 *poutbuf = buf;
-- 
2.37.3

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

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


[FFmpeg-devel] [PATCH 3/5] avcodec/aac_ac3_parser: don't try to sync when the parser is configured to handle complete frames

2022-10-22 Thread James Almer
Should speed up parsing when the frames come from non raw containers.

Signed-off-by: James Almer 
---
 libavcodec/aac_ac3_parser.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 6df064e28d..bfbb55d68e 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -40,6 +40,9 @@ int ff_aac_ac3_parse(AVCodecParserContext *s1,
 int new_frame_start;
 int got_frame = 0;
 
+if (s1->flags & PARSER_FLAG_COMPLETE_FRAMES) {
+i = buf_size;
+} else {
 get_next:
 i=END_NOT_FOUND;
 if(s->remaining_size <= buf_size){
@@ -77,6 +80,7 @@ get_next:
 *poutbuf_size = 0;
 return buf_size;
 }
+}
 
 *poutbuf = buf;
 *poutbuf_size = buf_size;
-- 
2.37.3

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

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


[FFmpeg-devel] [PATCH 5/5 v2] avcodec/ac3_parser: improve false positive detection when parsing sync frames

2022-10-22 Thread James Almer
A two byte sync word is not enough to ensure we got a real syncframe, nor are
all the range checks we do in the first seven bytes. Do therefore an integrity
check for the sync frame in order to prevent the parser from filling avctx with
bogus information.

Signed-off-by: James Almer 
---
 libavcodec/aac_ac3_parser.c | 4 
 libavcodec/aac_ac3_parser.h | 2 ++
 libavcodec/ac3_parser.c | 1 +
 3 files changed, 7 insertions(+)

diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index e89b12baf9..2b0ee61b6d 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -113,6 +113,10 @@ get_next:
 buf_size -= hdr.frame_size;
 continue;
 }
+/* Check for false positives since the syncword is not enough.
+   See section 6.1.2 of A/52. */
+if (av_crc(s->crc_ctx, 0, buf + 2, hdr.frame_size - 2))
+return i;
 break;
 }
 
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index 560bba54f5..bc16181a19 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -24,6 +24,7 @@
 #define AVCODEC_AAC_AC3_PARSER_H
 
 #include 
+#include "libavutil/crc.h"
 #include "avcodec.h"
 #include "parser.h"
 
@@ -42,6 +43,7 @@ typedef struct AACAC3ParseContext {
 int header_size;
 int (*sync)(uint64_t state, int *need_next_header, int *new_frame_start);
 
+const AVCRC *crc_ctx;
 int remaining_size;
 uint64_t state;
 
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index 8885e1c72e..13b8d3b7d8 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -246,6 +246,7 @@ static av_cold int ac3_parse_init(AVCodecParserContext *s1)
 {
 AACAC3ParseContext *s = s1->priv_data;
 s->header_size = AC3_HEADER_SIZE;
+s->crc_ctx = av_crc_get_table(AV_CRC_16_ANSI);
 s->sync = ac3_sync;
 return 0;
 }
-- 
2.37.3

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