Re: [FFmpeg-devel] [PATCH v5] libavfilter/x86/vf_convolution: add sobel filter optimization and unit test with intel AVX512 VNNI

2022-10-07 Thread Wang, Bin
-Original Message-
From: ffmpeg-devel  On Behalf Of Wang, Bin
Sent: Monday, September 26, 2022 4:56 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v5] libavfilter/x86/vf_convolution: add 
sobel filter optimization and unit test with intel AVX512 VNNI

-Original Message-
From: Wang, Bin 
Sent: Tuesday, September 20, 2022 6:33 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Wang, Bin 
Subject: [FFmpeg-devel] [PATCH v5] libavfilter/x86/vf_convolution: add sobel 
filter optimization and unit test with intel AVX512 VNNI

From: bwang30 

This commit enabled assembly code with intel AVX512 VNNI and added unit test 
for sobel filter

sobel_c: 4537
sobel_avx512icl 2136

Signed-off-by: bwang30 
---
 libavfilter/convolution.h |  74 +
 libavfilter/vf_convolution.c  |  91 +++-
 libavfilter/x86/vf_convolution.asm| 147 ++
 libavfilter/x86/vf_convolution_init.c |  18 
 tests/checkasm/Makefile   |   1 +
 tests/checkasm/checkasm.c |   3 +
 tests/checkasm/checkasm.h |   1 +
 tests/checkasm/vf_convolution.c   | 103 ++
 8 files changed, 360 insertions(+), 78 deletions(-)  create mode 100644 
tests/checkasm/vf_convolution.c

diff --git a/libavfilter/convolution.h b/libavfilter/convolution.h index 
88aabe9a20..e44bfb5da8 100644
--- a/libavfilter/convolution.h
+++ b/libavfilter/convolution.h
@@ -21,6 +21,7 @@
 #ifndef AVFILTER_CONVOLUTION_H
 #define AVFILTER_CONVOLUTION_H
 #include "avfilter.h"
+#include "libavutil/intreadwrite.h"
 
 enum MatrixMode {
 MATRIX_SQUARE,
@@ -61,4 +62,77 @@ typedef struct ConvolutionContext {  } ConvolutionContext;
 
 void ff_convolution_init_x86(ConvolutionContext *s);
+void ff_sobel_init_x86(ConvolutionContext *s, int depth, int 
+nb_planes);
+
+static void setup_3x3(int radius, const uint8_t *c[], const uint8_t *src, int 
stride,
+  int x, int w, int y, int h, int bpc) {
+int i;
+
+for (i = 0; i < 9; i++) {
+int xoff = FFABS(x + ((i % 3) - 1));
+int yoff = FFABS(y + (i / 3) - 1);
+
+xoff = xoff >= w ? 2 * w - 1 - xoff : xoff;
+yoff = yoff >= h ? 2 * h - 1 - yoff : yoff;
+
+c[i] = src + xoff * bpc + yoff * stride;
+}
+}
+
+static void filter_sobel(uint8_t *dst, int width,
+ float scale, float delta, const int *const matrix,
+ const uint8_t *c[], int peak, int radius,
+ int dstride, int stride, int size) {
+const uint8_t *c0 = c[0], *c1 = c[1], *c2 = c[2];
+const uint8_t *c3 = c[3], *c5 = c[5];
+const uint8_t *c6 = c[6], *c7 = c[7], *c8 = c[8];
+int x;
+
+for (x = 0; x < width; x++) {
+float suma = c0[x] * -1 + c1[x] * -2 + c2[x] * -1 +
+ c6[x] *  1 + c7[x] *  2 + c8[x] *  1;
+float sumb = c0[x] * -1 + c2[x] *  1 + c3[x] * -2 +
+ c5[x] *  2 + c6[x] * -1 + c8[x] *  1;
+
+dst[x] = av_clip_uint8(sqrtf(suma*suma + sumb*sumb) * scale + delta);
+}
+}
+
+static void filter16_sobel(uint8_t *dstp, int width,
+   float scale, float delta, const int *const matrix,
+   const uint8_t *c[], int peak, int radius,
+   int dstride, int stride, int size) {
+uint16_t *dst = (uint16_t *)dstp;
+int x;
+
+for (x = 0; x < width; x++) {
+float suma = AV_RN16A([0][2 * x]) * -1 + AV_RN16A([1][2 * x]) * -2 
+ AV_RN16A([2][2 * x]) * -1 +
+ AV_RN16A([6][2 * x]) *  1 + AV_RN16A([7][2 * x]) *  2 
+ AV_RN16A([8][2 * x]) *  1;
+float sumb = AV_RN16A([0][2 * x]) * -1 + AV_RN16A([2][2 * x]) *  1 
+ AV_RN16A([3][2 * x]) * -2 +
+ AV_RN16A([5][2 * x]) *  2 + AV_RN16A([6][2 *
+ x]) * -1 + AV_RN16A([8][2 * x]) *  1;
+
+dst[x] = av_clip(sqrtf(suma*suma + sumb*sumb) * scale + delta, 0, 
peak);
+}
+}
+
+static av_unused void ff_sobel_init(ConvolutionContext *s, int depth, 
+int nb_planes) {
+for (int i = 0; i < 4; i++) {
+s->filter[i] = filter_sobel;
+s->copy[i] = !((1 << i) & s->planes);
+s->size[i] = 3;
+s->setup[i] = setup_3x3;
+s->rdiv[i] = s->scale;
+s->bias[i] = s->delta;
+}
+if (s->depth > 8)
+for (int i = 0; i < 4; i++)
+s->filter[i] = filter16_sobel; #if ARCH_X86_64
+ff_sobel_init_x86(s, depth, nb_planes); #endif }
 #endif
diff --git a/libavfilter/vf_convolution.c b/libavfilter/vf_convolution.c index 
9a9c099e6d..7762fa2a05 100644
--- a/libavfilter/vf_convolution.c
+++ b/libavfilter/vf_convolution.c
@@ -139,24 +139,6 @@ static void filter16_roberts(uint8_t *dstp, int width,
 }
 }
 
-static void filter16_sobel(uint8_t *dstp, int width,
-   float scale, float delta, const int *const matrix,
-   const uint8_t *c[], int peak, int radius,
-   int 

Re: [FFmpeg-devel] [PATCH 1/9] avcodec/opus_rc: Remove write-only waste from OpusRangeCoder

2022-10-07 Thread Lynne
Oct 7, 2022, 22:20 by andreas.rheinha...@outlook.com:

> Write-only since e7d977b446194649aa30f2aacc6c17bce7aeb90b
> (and local to ff_opus_rc_enc_end() before that).
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/opus_rc.c | 2 --
>  libavcodec/opus_rc.h | 3 ---
>  2 files changed, 5 deletions(-)
>
> diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c
> index c432eb90c9..2061418e52 100644
> --- a/libavcodec/opus_rc.c
> +++ b/libavcodec/opus_rc.c
> @@ -383,8 +383,6 @@ void ff_opus_rc_enc_end(OpusRangeCoder *rc, uint8_t *dst, 
> int size)
>  rng_bytes = rc->rng_cur - rc->buf;
>  memcpy(dst, rc->buf, rng_bytes);
>  
> -rc->waste = size*8 - (rc->rb.bytes*8 + rc->rb.cachelen) - rng_bytes*8;
> -
>  /* Put the rawbits part, if any */
>  if (rc->rb.bytes || rc->rb.cachelen) {
>  int i, lap;
> diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h
> index 627f83229e..1b3cb93a15 100644
> --- a/libavcodec/opus_rc.h
> +++ b/libavcodec/opus_rc.h
> @@ -49,9 +49,6 @@ typedef struct OpusRangeCoder {
>  uint8_t *rng_cur;  /* Current range coded byte */
>  int ext;   /* Awaiting propagation */
>  int rem;   /* Carryout flag */
> -
> -/* Encoding stats */
> -int waste;
>  } OpusRangeCoder;
>

Not really to patch 1. The purpose of the waste field was to know how many
bits were spare and usable to put stuff like encoder settings into. It's only a
small field, compilers probably eliminate it anyway, and it's useful for 
debugging,
just leave it there for now. It's not something I'd argue about, so if you'd 
really like
to get rid of it, do tell.

LGTM to patches 2-6. Whatever for the opusenc_psy file, I have a rewrite
I need to finish at some point.

Definite NAK to patch 7. The RC system is very easy to read and well-organized.
I'd like to keep it that way than hunt for spare bytes that any LTO trivially 
removes.
I'd accept a patch that changes the encoder array to heap allocated one (better 
yet
a framepool) if you'd still like to save on the struct size.

LGTM to patches 8-9.
___
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 8/9] checkasm/vp8dsp: Use declare_func_emms only when needed

2022-10-07 Thread Ronald S. Bultje
Hi,

On Fri, Oct 7, 2022 at 9:25 PM Andreas Rheinhardt <
andreas.rheinha...@outlook.com> wrote:

> There is no MMX code for loop filters since commit
> 6a551f14050674fb685920eb1b0640810cacccf9, so use declare_func
> instead of declare_func_emms() to also test that we are not
> in MMX mode after return.
>
> Signed-off-by: Andreas Rheinhardt 
> ---
>  tests/checkasm/vp8dsp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>

LGTM.

Ronald
___
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 9/9] checkasm/idctdsp: Use declare_func_emms only when needed

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for (add|put|put_signed)_pixels_clamped
since commit bfb28b5ce89f3e950214b67ea95b45e3355c2caf, so use
declare_func instead of declare_func_emms() to also test that
we are not in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/idctdsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/idctdsp.c b/tests/checkasm/idctdsp.c
index 02724536a7..c06e607d99 100644
--- a/tests/checkasm/idctdsp.c
+++ b/tests/checkasm/idctdsp.c
@@ -79,7 +79,7 @@ static void check_add_put_clamped(void)
 for (size_t t = 0; t < FF_ARRAY_ELEMS(tests); ++t) {
 void (*func)(const int16_t *, uint8_t * ptrdiff_t) = *(void 
**)((intptr_t)  + tests[t].offset);
 if (check_func(func, "idctdsp.%s", tests[t].name)) {
-declare_func_emms(AV_CPU_FLAG_MMX, void, const int16_t *, uint8_t 
*, ptrdiff_t);
+declare_func(void, const int16_t *, uint8_t *, ptrdiff_t);
 RANDOMIZE_BUFFER16(src, 64);
 RANDOMIZE_BUFFER8(dst, 10 * 24);
 call_ref(src0, dst0 + 24 + 8, 24);
-- 
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 8/9] checkasm/vp8dsp: Use declare_func_emms only when needed

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for loop filters since commit
6a551f14050674fb685920eb1b0640810cacccf9, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/vp8dsp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/vp8dsp.c b/tests/checkasm/vp8dsp.c
index c3af54fbfd..87b03d71d5 100644
--- a/tests/checkasm/vp8dsp.c
+++ b/tests/checkasm/vp8dsp.c
@@ -384,7 +384,7 @@ static void check_loopfilter_16y(void)
 VP8DSPContext d;
 int dir, edge, force_hev;
 int flim_E = 20, flim_I = 10, hev_thresh = 7;
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, int, int, 
int);
+declare_func(void, uint8_t *, ptrdiff_t, int, int, int);
 
 ff_vp8dsp_init();
 
@@ -430,7 +430,7 @@ static void check_loopfilter_8uv(void)
 VP8DSPContext d;
 int dir, edge, force_hev;
 int flim_E = 20, flim_I = 10, hev_thresh = 7;
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, uint8_t *, ptrdiff_t, 
int, int, int);
+declare_func(void, uint8_t *, uint8_t *, ptrdiff_t, int, int, int);
 
 ff_vp8dsp_init();
 
@@ -481,7 +481,7 @@ static void check_loopfilter_simple(void)
 VP8DSPContext d;
 int dir;
 int flim_E = 20, flim_I = 30, hev_thresh = 0;
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t, int);
+declare_func(void, uint8_t *, ptrdiff_t, int);
 
 ff_vp8dsp_init();
 
-- 
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 7/9] checkasm/llviddspenc: Use declare_func_emms only when needed

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for diff_bytes since commit
230ea38de143368729ee1cce47b3a87fbafad8e4, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

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

diff --git a/tests/checkasm/llviddspenc.c b/tests/checkasm/llviddspenc.c
index 4ec46c96bd..e12003aeeb 100644
--- a/tests/checkasm/llviddspenc.c
+++ b/tests/checkasm/llviddspenc.c
@@ -52,8 +52,8 @@ static void check_diff_bytes(LLVidEncDSPContext *c)
 LOCAL_ALIGNED_32(uint8_t, src2, [MAX_STRIDE]);
 LOCAL_ALIGNED_32(uint8_t, src3, [MAX_STRIDE]);
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src1,
-  const uint8_t *src2, intptr_t w);
+declare_func(void, uint8_t *dst, const uint8_t *src1,
+ const uint8_t *src2, intptr_t w);
 
 memset(dst0, 0, MAX_STRIDE);
 memset(dst1, 0, MAX_STRIDE);
-- 
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 6/9] checkasm/huffyuvdsp: Use declare_func_emms only when needed

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for add_int16 since commit
4b6ffc2880e33d05ed1ab6bbc38e5a795f14b504, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/huffyuvdsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/huffyuvdsp.c b/tests/checkasm/huffyuvdsp.c
index 8392022c04..16e6bfb808 100644
--- a/tests/checkasm/huffyuvdsp.c
+++ b/tests/checkasm/huffyuvdsp.c
@@ -42,7 +42,7 @@ static void check_add_int16(HuffYUVDSPContext c, unsigned 
mask, int width, const
 uint16_t *dst0 = av_mallocz(width * sizeof(uint16_t));
 uint16_t *dst1 = av_mallocz(width * sizeof(uint16_t));
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint16_t *dst, uint16_t *src, 
unsigned mask, int w);
+declare_func(void, uint16_t *dst, uint16_t *src, unsigned mask, int w);
 
 if (!src0 || !src1 || !dst0 || !dst1)
 fail();
-- 
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/9] checkasm/llviddsp: Be strict about MMX

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for llviddsp after commit
fed07efcde72824ac1ada80d4af4e91ac4fcfc14, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/llviddsp.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tests/checkasm/llviddsp.c b/tests/checkasm/llviddsp.c
index 66e08c8099..d948a9832d 100644
--- a/tests/checkasm/llviddsp.c
+++ b/tests/checkasm/llviddsp.c
@@ -48,7 +48,7 @@ static void check_add_bytes(LLVidDSPContext c, int width)
 uint8_t *dst1 = av_mallocz(width);
 uint8_t *src0 = av_calloc(width, sizeof(*src0));
 uint8_t *src1 = av_calloc(width, sizeof(*src1));
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, 
ptrdiff_t w);
+declare_func(void, uint8_t *dst, uint8_t *src, ptrdiff_t w);
 
 init_buffer(src0, src1, uint8_t, width);
 
@@ -78,9 +78,9 @@ static void check_add_median_pred(LLVidDSPContext c, int 
width) {
 uint8_t *src1  = av_calloc(width, sizeof(*src1));
 uint8_t *diff0 = av_calloc(width, sizeof(*diff0));
 uint8_t *diff1 = av_calloc(width, sizeof(*diff1));
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, const uint8_t *src1,
-  const uint8_t *diff, ptrdiff_t w,
-  int *left, int *left_top);
+declare_func(void, uint8_t *dst, const uint8_t *src1,
+ const uint8_t *diff, ptrdiff_t w,
+ int *left, int *left_top);
 
 init_buffer(src0, src1, uint8_t, width);
 init_buffer(diff0, diff1, uint8_t, width);
@@ -114,7 +114,7 @@ static void check_add_left_pred(LLVidDSPContext c, int 
width, int acc, const cha
 uint8_t *dst1 = av_mallocz(width);
 uint8_t *src0 = av_calloc(width, sizeof(*src0));
 uint8_t *src1 = av_calloc(width, sizeof(*src1));
-declare_func_emms(AV_CPU_FLAG_MMX, int, uint8_t *dst, uint8_t *src, 
ptrdiff_t w, int acc);
+declare_func(int, uint8_t *dst, uint8_t *src, ptrdiff_t w, int acc);
 
 init_buffer(src0, src1, uint8_t, width);
 
@@ -143,7 +143,7 @@ static void check_add_left_pred_16(LLVidDSPContext c, 
unsigned mask, int width,
 uint16_t *dst1 = av_calloc(width, sizeof(*dst1));
 uint16_t *src0 = av_calloc(width, sizeof(*src0));
 uint16_t *src1 = av_calloc(width, sizeof(*src1));
-declare_func_emms(AV_CPU_FLAG_MMX, int, uint16_t *dst, uint16_t *src, 
unsigned mask, ptrdiff_t w, unsigned acc);
+declare_func(int, uint16_t *dst, uint16_t *src, unsigned mask, ptrdiff_t 
w, unsigned acc);
 
 init_buffer(src0, src1, uint16_t, width);
 
@@ -168,8 +168,8 @@ static void check_add_left_pred_16(LLVidDSPContext c, 
unsigned mask, int width,
 static void check_add_gradient_pred(LLVidDSPContext c, int w) {
 int src_size, stride;
 uint8_t *src0, *src1;
-declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *src, const ptrdiff_t 
stride,
-  const ptrdiff_t width);
+declare_func(void, uint8_t *src, const ptrdiff_t stride,
+ const ptrdiff_t width);
 
 stride = w + 32;
 src_size = (stride + 32) * 2; /* dsp need previous line, and ignore the 
start of the line */
-- 
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/9] checkasm/pixblockdsp: Be strict about MMX

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for pixblockdsp after commit
92b58002776edd3a3df03c90e8a3ab24b8f987de, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

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

diff --git a/tests/checkasm/pixblockdsp.c b/tests/checkasm/pixblockdsp.c
index 9a7865aa5f..3c8599db36 100644
--- a/tests/checkasm/pixblockdsp.c
+++ b/tests/checkasm/pixblockdsp.c
@@ -48,7 +48,7 @@
 #define check_get_pixels(type, aligned)
\
 do {   
\
 int i; 
\
-declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block, const uint8_t 
*pixels, ptrdiff_t line_size);\
+declare_func(void, int16_t *block, const uint8_t *pixels, ptrdiff_t 
line_size);\

\
 for (i = 0; i < BUF_UNITS; i++) {  
\
 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i;
\
@@ -65,7 +65,7 @@
 #define check_diff_pixels(type, aligned)   
\
 do {   
\
 int i; 
\
-declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *av_restrict block, 
const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride); \
+declare_func(void, int16_t *av_restrict block, const uint8_t *s1, 
const uint8_t *s2, ptrdiff_t stride); \

\
 for (i = 0; i < BUF_UNITS; i++) {  
\
 int src_offset = i * 64 * sizeof(type) + (aligned ? 8 : 1) * i;
\
-- 
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/9] checkasm/audiodsp: Be strict about MMX

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for audiodsp after commit
3d716d38abdae1982e84e30becb57458244656bd, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/audiodsp.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tests/checkasm/audiodsp.c b/tests/checkasm/audiodsp.c
index d3a5604299..7980b550d2 100644
--- a/tests/checkasm/audiodsp.c
+++ b/tests/checkasm/audiodsp.c
@@ -61,7 +61,7 @@ void checkasm_check_audiodsp(void)
 unsigned int len_bits_minus4, v1_bits, v2_bits, len;
 int32_t res0, res1;
 
-declare_func_emms(AV_CPU_FLAG_MMX, int32_t, const int16_t *v1, const 
int16_t *v2, int len);
+declare_func(int32_t, const int16_t *v1, const int16_t *v2, int len);
 
 // generate random 5-12bit vector length
 len_bits_minus4 = rnd() % 8;
@@ -90,8 +90,8 @@ void checkasm_check_audiodsp(void)
 int32_t val1, val2, min, max;
 int len;
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, int32_t *dst, const int32_t 
*src,
-  int32_t min, int32_t max, unsigned int len);
+declare_func(void, int32_t *dst, const int32_t *src,
+ int32_t min, int32_t max, unsigned int len);
 
 val1 = ((int32_t)rnd());
 val1 = FFSIGN(val1) * (val1 & ((1 << 24) - 1));
@@ -120,8 +120,8 @@ void checkasm_check_audiodsp(void)
 float val1, val2, min, max;
 int i, len;
 
-declare_func_emms(AV_CPU_FLAG_MMX, void, float *dst, const float *src,
-  int len, float min, float max);
+declare_func(void, float *dst, const float *src,
+ int len, float min, float max);
 
 val1 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
 val2 = (float)rnd() / (UINT_MAX >> 1) - 1.0f;
-- 
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/9] checkasm/blockdsp: Be strict about MMX

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for blockdsp after commit
ee551a21ddcbf81afe183d9489c534ee80f263a0, so use declare_func
instead of declare_func_emms() to also test that we are not
in MMX mode after return.

Signed-off-by: Andreas Rheinhardt 
---
 tests/checkasm/blockdsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/blockdsp.c b/tests/checkasm/blockdsp.c
index 99d79209e4..22a2f79455 100644
--- a/tests/checkasm/blockdsp.c
+++ b/tests/checkasm/blockdsp.c
@@ -42,7 +42,7 @@
 #define check_clear(func, size) \
 do {\
 if (check_func(h.func, "blockdsp." #func)) {\
-declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *block);   \
+declare_func(void, int16_t *block); \
 randomize_buffers(size);\
 call_ref(buf0); \
 call_new(buf1); \
-- 
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/9] checkasm/vc1dsp: Use declare_func_emms only when needed

2022-10-07 Thread Andreas Rheinhardt
There is no MMX code for vc1_inv_trans_8x8 or
vc1_unescape_buffer, so use declare_func instead of
declare_func_emms() to also test that we are not in MMX
mode after return.

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

diff --git a/tests/checkasm/vc1dsp.c b/tests/checkasm/vc1dsp.c
index 52628d15e4..570785776f 100644
--- a/tests/checkasm/vc1dsp.c
+++ b/tests/checkasm/vc1dsp.c
@@ -261,7 +261,7 @@ static void check_inv_trans_inplace(void)
 
 if (check_func(h.vc1_inv_trans_8x8, "vc1dsp.vc1_inv_trans_8x8")) {
 matrix *coeffs;
-declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t *);
+declare_func(void, int16_t *);
 RANDOMIZE_BUFFER16(inv_trans_in, 10 * 8);
 coeffs = generate_inverse_quantized_transform_coefficients(8, 8);
 for (int j = 0; j < 8; ++j)
@@ -404,7 +404,7 @@ static void check_unescape(void)
 
 if (check_func(h.vc1_unescape_buffer, "vc1dsp.vc1_unescape_buffer")) {
 int len0, len1, escaped_offset, unescaped_offset, escaped_len;
-declare_func_emms(AV_CPU_FLAG_MMX, int, const uint8_t *, int, uint8_t 
*);
+declare_func(int, const uint8_t *, int, uint8_t *);
 
 /* Test data which consists of escapes sequences packed as tightly as 
possible */
 for (int x = 0; x < UNESCAPE_BUF_SIZE; ++x)
-- 
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] avformat/dashdec: Differentiate unassigned and zero attributes

2022-10-07 Thread Gregor Riepl

This fixes an issue where a timestamp attribute may have a valid zero
value (the UNIX epoch 1970-01-01T00:00:00), but is misinterpreted by
dashdec as being unassigned. This changes the logic that calculates
segment numbers and makes the stream undecodable by dashdec.

The fix originally posted to the issue tracker was incorrect and
changed other parts of the segment calculation logic. With this
patch, only the interpretation of the attributes is changed.
Some warnings are added to account for potential errors in manifests.

Fixes: #8522
Signed-off-by: Gregor Riepl 
---
 libavformat/dashdec.c | 210 --
 1 file changed, 162 insertions(+), 48 deletions(-)

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index 29d4680c68..f25d1a2bdf 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -20,6 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include 
+#include 
 #include "libavutil/bprint.h"
 #include "libavutil/opt.h"
 #include "libavutil/time.h"
@@ -129,21 +130,34 @@ typedef struct DASHContext {
 struct representation **subtitles;
 
 /* MediaPresentationDescription Attribute */

-uint64_t media_presentation_duration;
-uint64_t suggested_presentation_delay;
-uint64_t availability_start_time;
-uint64_t availability_end_time;
-uint64_t publish_time;
-uint64_t minimum_update_period;
-uint64_t time_shift_buffer_depth;
-uint64_t min_buffer_time;
+uint64_t media_presentation_duration_value;
+uint64_t suggested_presentation_delay_value;
+uint64_t availability_start_time_value;
+uint64_t availability_end_time_value;
+uint64_t publish_time_value;
+uint64_t minimum_update_period_value;
+uint64_t time_shift_buffer_depth_value;
+uint64_t min_buffer_time_value;
 
 /* Period Attribute */

-uint64_t period_duration;
-uint64_t period_start;
+uint64_t period_duration_value;
+uint64_t period_start_value;
 
 /* AdaptationSet Attribute */

-char *adaptionset_lang;
+char *adaptionset_lang_value;
+
+/* Attribute valid flags (true if the attribute exists in the XML 
manifest) */
+bool media_presentation_duration_assigned;
+bool suggested_presentation_delay_assigned;
+bool availability_start_time_assigned;
+bool availability_end_time_assigned;
+bool publish_time_assigned;
+bool minimum_update_period_assigned;
+bool time_shift_buffer_depth_assigned;
+bool min_buffer_time_assigned;
+bool period_duration_assigned;
+bool period_start_assigned;
+bool adaptionset_lang_assigned;
 
 int is_live;

 AVIOInterruptCB *interrupt_callback;
@@ -867,8 +881,8 @@ static int parse_manifest_representation(AVFormatContext 
*s, const char *url,
 rep = av_mallocz(sizeof(struct representation));
 if (!rep)
 return AVERROR(ENOMEM);
-if (c->adaptionset_lang) {
-rep->lang = av_strdup(c->adaptionset_lang);
+if (c->adaptionset_lang_assigned) {
+rep->lang = av_strdup(c->adaptionset_lang_value);
 if (!rep->lang) {
 av_log(s, AV_LOG_ERROR, "alloc language memory failure\n");
 av_freep();
@@ -1106,7 +1120,10 @@ static int 
parse_manifest_adaptationset_attr(AVFormatContext *s, xmlNodePtr adap
 av_log(s, AV_LOG_WARNING, "Cannot get AdaptionSet\n");
 return AVERROR(EINVAL);
 }
-c->adaptionset_lang = xmlGetProp(adaptionset_node, "lang");
+c->adaptionset_lang_value = xmlGetProp(adaptionset_node, "lang");
+if (c->adaptionset_lang_value) {
+c->adaptionset_lang_assigned = true;
+}
 
 return 0;

 }
@@ -1162,8 +1179,9 @@ static int parse_manifest_adaptationset(AVFormatContext 
*s, const char *url,
 }
 
 err:

-xmlFree(c->adaptionset_lang);
-c->adaptionset_lang = NULL;
+xmlFree(c->adaptionset_lang_value);
+c->adaptionset_lang_value = NULL;
+c->adaptionset_lang_assigned = false;
 return ret;
 }
 
@@ -1273,29 +1291,37 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)

 val = xmlGetProp(node, attr->name);
 
 if (!av_strcasecmp(attr->name, "availabilityStartTime")) {

-c->availability_start_time = get_utc_date_time_insec(s, val);
-av_log(s, AV_LOG_TRACE, "c->availability_start_time = 
[%"PRId64"]\n", c->availability_start_time);
+c->availability_start_time_value = get_utc_date_time_insec(s, 
val);
+c->availability_start_time_assigned = true;
+av_log(s, AV_LOG_TRACE, "c->availability_start_time = 
[%"PRId64"]\n", c->availability_start_time_value);
 } else if (!av_strcasecmp(attr->name, "availabilityEndTime")) {
-c->availability_end_time = get_utc_date_time_insec(s, val);
-av_log(s, AV_LOG_TRACE, "c->availability_end_time = 
[%"PRId64"]\n", c->availability_end_time);
+

[FFmpeg-devel] [PATCH 9/9] avcodec/opus_pvq: Avoid indirection when possible

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opus_pvq.c  |  4 ++--
 libavcodec/opus_pvq.h  |  3 +++
 libavcodec/opus_pvq_template.c | 35 ++
 libavcodec/opusenc_psy.c   | 12 ++--
 4 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 8ef0f85a81..26d4e436e1 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -511,9 +511,9 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
 
 #if CONFIG_OPUS_ENCODER
 #if CONFIG_OPUS_DECODER
-s->quant_band = encode ? pvq_quant_band_enc : pvq_quant_band_dec;
+s->quant_band = encode ? ff_pvq_quant_band_enc : pvq_quant_band_dec;
 #else
-s->quant_band = pvq_quant_band_enc;
+s->quant_band = ff_pvq_quant_band_enc;
 #endif
 s->pvq_search = ppp_pvq_search_c;
 #if ARCH_X86
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index b71bc49034..4907025125 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -26,6 +26,7 @@
 #include "libavutil/mem_internal.h"
 
 #include "opus_celt.h"
+#include "opus_rc.h"
 
 #define QUANT_FN(name) uint32_t (name)(struct CeltPVQ *pvq, CeltFrame *f,  
  \
OpusRangeCoder *rc, const int band, 
float *X, \
@@ -47,4 +48,6 @@ void ff_celt_pvq_init_x86(struct CeltPVQ *s);
 int  ff_celt_pvq_init(struct CeltPVQ **pvq, int encode);
 void ff_celt_pvq_uninit(struct CeltPVQ **pvq);
 
+QUANT_FN(ff_pvq_quant_band_enc);
+
 #endif /* AVCODEC_OPUS_PVQ_H */
diff --git a/libavcodec/opus_pvq_template.c b/libavcodec/opus_pvq_template.c
index 5f03f3d415..79e8e4ca52 100644
--- a/libavcodec/opus_pvq_template.c
+++ b/libavcodec/opus_pvq_template.c
@@ -24,14 +24,17 @@
  */
 
 #undef FUNC
+#undef STATIC
 
 #if ENCODING
-#define FUNC(name) name ## _enc
+#define STATIC
+#define FUNC(name) ff_ ## name ## _enc
 #else
+#define STATIC static
 #define FUNC(name) name ## _dec
 #endif
 
-static
+STATIC
 uint32_t FUNC(pvq_quant_band)(CeltPVQ *const pvq, CeltFrame *const f,
   OpusRangeCoder *const rc,
   const int band, float *X,
@@ -256,8 +259,8 @@ uint32_t FUNC(pvq_quant_band)(CeltPVQ *const pvq, CeltFrame 
*const f,
 sign = 1 - 2 * sign;
 /* We use orig_fill here because we want to fold the side, but if
 itheta==16384, we'll have cleared the low bits of fill. */
-cm = pvq->quant_band(pvq, f, rc, band, x2, NULL, N, mbits, blocks, 
lowband, duration,
- lowband_out, level, gain, lowband_scratch, 
orig_fill);
+cm = FUNC(pvq_quant_band)(pvq, f, rc, band, x2, NULL, N, mbits, 
blocks, lowband, duration,
+  lowband_out, level, gain, 
lowband_scratch, orig_fill);
 /* We don't split N=2 bands, so cm is either 1 or 0 (for a 
fold-collapse),
 and there's no need to worry about mixing with the other channel. 
*/
 y2[0] = -sign * x2[1];
@@ -309,25 +312,25 @@ uint32_t FUNC(pvq_quant_band)(CeltPVQ *const pvq, 
CeltFrame *const f,
 if (mbits >= sbits) {
 /* In stereo mode, we do not apply a scaling to the mid
  * because we need the normalized mid for folding later */
-cm = pvq->quant_band(pvq, f, rc, band, X, NULL, N, mbits, 
blocks,
- lowband, duration, next_lowband_out1, 
next_level,
- stereo ? 1.0f : (gain * mid), 
lowband_scratch, fill);
+cm = FUNC(pvq_quant_band)(pvq, f, rc, band, X, NULL, N, mbits, 
blocks,
+  lowband, duration, 
next_lowband_out1, next_level,
+  stereo ? 1.0f : (gain * mid), 
lowband_scratch, fill);
 rebalance = mbits - (rebalance - f->remaining2);
 if (rebalance > 3 << 3 && itheta != 0)
 sbits += rebalance - (3 << 3);
 
 /* For a stereo split, the high bits of fill are always zero,
  * so no folding will be done to the side. */
-cmt = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, 
blocks,
-  next_lowband2, duration, NULL, 
next_level,
-  gain * side, NULL, fill >> blocks);
+cmt = FUNC(pvq_quant_band)(pvq, f, rc, band, Y, NULL, N, 
sbits, blocks,
+   next_lowband2, duration, NULL, 
next_level,
+   gain * side, NULL, fill >> blocks);
 cm |= cmt << ((B0 >> 1) & (stereo - 1));
 } else {
 /* For a stereo split, the high bits of fill are always zero,
  * so no folding will be done to the side. */
-cm = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, 
blocks,
- 

[FFmpeg-devel] [PATCH 8/9] avcodec/opus: Rename opus.c->opus_celt.c, opus_celt.c->opusdec_celt.c

2022-10-07 Thread Andreas Rheinhardt
Since commit 4fc2531fff112836026aad2bdaf128c9d15a72e3 opus.c
contains only the celt stuff shared between decoder and encoder.
meanwhile, opus_celt.c is decoder-only. So the new names
reflect the actual content better than the current ones.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile   |   4 +-
 libavcodec/opus.c | 522 --
 libavcodec/opus_celt.c| 899 ++
 libavcodec/opusdec_celt.c | 587 +
 4 files changed, 1006 insertions(+), 1006 deletions(-)
 delete mode 100644 libavcodec/opus.c
 create mode 100644 libavcodec/opusdec_celt.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b7eb3b1e48..949c65a0e3 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -554,10 +554,10 @@ OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o 
nellymoser.o
 OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
 OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
 OBJS-$(CONFIG_ON2AVC_DECODER)  += on2avc.o on2avcdata.o
-OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o \
+OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opusdec_celt.o opus_celt.o 
\
   opus_pvq.o opus_silk.o opustab.o 
vorbis_data.o \
   opusdec_rc.o opusdsp.o opus_parse.o
-OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus.o opusenc_psy.o \
+OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus_celt.o opusenc_psy.o \
   opusenc_rc.o opustab.o opus_pvq.o
 OBJS-$(CONFIG_PAF_AUDIO_DECODER)   += pafaudio.o
 OBJS-$(CONFIG_PAF_VIDEO_DECODER)   += pafvideo.o
diff --git a/libavcodec/opus.c b/libavcodec/opus.c
deleted file mode 100644
index 8def5e6e34..00
--- a/libavcodec/opus.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*
- * Copyright (c) 2012 Andrew D'Addesio
- * Copyright (c) 2013-2014 Mozilla Corporation
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include 
-
-#include "config_components.h"
-#include "opus_celt.h"
-#include "opus_pvq.h"
-#include "opustab.h"
-#include "opus_rc.h"
-#include "opusdec_rc.h"
-#include "opusenc_rc.h"
-
-#if !CONFIG_OPUS_ENCODER
-#define ff_opus_rc_enc_log(...)
-#define ff_opus_rc_enc_cdf(...)
-#define ff_opus_rc_enc_uint(...)
-#endif
-
-#if !CONFIG_OPUS_DECODER
-#define ff_opus_rc_dec_log(...) 0
-#define ff_opus_rc_dec_cdf(...) 0
-#define ff_opus_rc_dec_uint(...) 0
-#endif
-
-static inline void opus_rc_enc_log(OpusRangeCoder *rc, int val, uint32_t bits)
-{
-ff_opus_rc_enc_log((OpusEncRangeCoder*)rc, val, bits);
-}
-
-static inline uint32_t opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
-{
-return ff_opus_rc_dec_log((OpusDecRangeCoder*)rc, bits);
-}
-
-static inline void opus_rc_enc_cdf(OpusRangeCoder *rc, int val, const uint16_t 
*cdf)
-{
-ff_opus_rc_enc_cdf((OpusEncRangeCoder*)rc, val, cdf);
-}
-
-static inline uint32_t opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
-{
-return ff_opus_rc_dec_cdf((OpusDecRangeCoder*)rc, cdf);
-}
-
-void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
-{
-float lowband_scratch[8 * 22];
-float norm1[2 * 8 * 100];
-float *norm2 = norm1 + 8 * 100;
-
-int totalbits = (f->framebits << 3) - f->anticollapse_needed;
-
-int update_lowband = 1;
-int lowband_offset = 0;
-
-int i, j;
-
-for (i = f->start_band; i < f->end_band; i++) {
-uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 };
-int band_offset = ff_celt_freq_bands[i] << f->size;
-int band_size   = ff_celt_freq_range[i] << f->size;
-float *X = f->block[0].coeffs + band_offset;
-float *Y = (f->channels == 2) ? f->block[1].coeffs + band_offset : 
NULL;
-float *norm_loc1, *norm_loc2;
-
-int consumed = opus_rc_tell_frac(rc);
-int effective_lowband = -1;
-int b = 0;
-
-/* Compute how many bits we want to allocate to this band */
-if (i != f->start_band)
-f->remaining -= consumed;
-f->remaining2 = totalbits - consumed - 1;
-if (i <= f->coded_bands - 1) {
-int curr_balance = f->remaining / FFMIN(3, f->coded_bands-i);
-b = 

[FFmpeg-devel] [PATCH 7/9] avcodec/opus_rc: Split de/encoder-only parts off OpusRangeContext

2022-10-07 Thread Andreas Rheinhardt
The decoder currently only uses 72 bytes of 1376; furthermore,
the GetBitContext in OpusRangeCoder is unused by the encoder,
but its existence adds an unnecessary inclusion of get_bits.h
to the encoder-only files. So split OpusRangeContext;
also split opus_rc.c into an encoder- and a decoder-only part.

This necessitated trivial changes in several other files.
The only part where the changes where these changes were involved
was opus_pvq.c, where the quant_band functions are now defined
in a template file instead of being created via an av_always_inline
function.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/Makefile|   8 +-
 libavcodec/opus.c  |  62 -
 libavcodec/opus_celt.c |  39 +--
 libavcodec/opus_celt.h |   3 +-
 libavcodec/opus_pvq.c  | 456 +++--
 libavcodec/opus_pvq_template.c | 432 +++
 libavcodec/opus_rc.c   | 409 -
 libavcodec/opus_rc.h   |  66 ++---
 libavcodec/opus_silk.c |  11 +-
 libavcodec/opus_silk.h |   4 +-
 libavcodec/opusdec.c   |  11 +-
 libavcodec/opusdec_rc.c| 214 
 libavcodec/opusdec_rc.h|  53 
 libavcodec/opusenc.c   |  39 +--
 libavcodec/opusenc_psy.c   |  14 +-
 libavcodec/opusenc_psy.h   |   1 +
 libavcodec/opusenc_rc.c| 210 +++
 libavcodec/opusenc_rc.h|  64 +
 18 files changed, 1139 insertions(+), 957 deletions(-)
 create mode 100644 libavcodec/opus_pvq_template.c
 delete mode 100644 libavcodec/opus_rc.c
 create mode 100644 libavcodec/opusdec_rc.c
 create mode 100644 libavcodec/opusdec_rc.h
 create mode 100644 libavcodec/opusenc_rc.c
 create mode 100644 libavcodec/opusenc_rc.h

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 592d9347f6..b7eb3b1e48 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -554,11 +554,11 @@ OBJS-$(CONFIG_NELLYMOSER_ENCODER)  += nellymoserenc.o 
nellymoser.o
 OBJS-$(CONFIG_NOTCHLC_DECODER) += notchlc.o
 OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o
 OBJS-$(CONFIG_ON2AVC_DECODER)  += on2avc.o on2avcdata.o
-OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o 
opus_rc.o \
+OBJS-$(CONFIG_OPUS_DECODER)+= opusdec.o opus.o opus_celt.o \
   opus_pvq.o opus_silk.o opustab.o 
vorbis_data.o \
-  opusdsp.o opus_parse.o
-OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus.o opus_rc.o opustab.o 
opus_pvq.o \
-  opusenc_psy.o
+  opusdec_rc.o opusdsp.o opus_parse.o
+OBJS-$(CONFIG_OPUS_ENCODER)+= opusenc.o opus.o opusenc_psy.o \
+  opusenc_rc.o opustab.o opus_pvq.o
 OBJS-$(CONFIG_PAF_AUDIO_DECODER)   += pafaudio.o
 OBJS-$(CONFIG_PAF_VIDEO_DECODER)   += pafvideo.o
 OBJS-$(CONFIG_PAM_DECODER) += pnmdec.o pnm.o
diff --git a/libavcodec/opus.c b/libavcodec/opus.c
index a24c38be52..8def5e6e34 100644
--- a/libavcodec/opus.c
+++ b/libavcodec/opus.c
@@ -21,9 +21,45 @@
 
 #include 
 
+#include "config_components.h"
 #include "opus_celt.h"
 #include "opus_pvq.h"
 #include "opustab.h"
+#include "opus_rc.h"
+#include "opusdec_rc.h"
+#include "opusenc_rc.h"
+
+#if !CONFIG_OPUS_ENCODER
+#define ff_opus_rc_enc_log(...)
+#define ff_opus_rc_enc_cdf(...)
+#define ff_opus_rc_enc_uint(...)
+#endif
+
+#if !CONFIG_OPUS_DECODER
+#define ff_opus_rc_dec_log(...) 0
+#define ff_opus_rc_dec_cdf(...) 0
+#define ff_opus_rc_dec_uint(...) 0
+#endif
+
+static inline void opus_rc_enc_log(OpusRangeCoder *rc, int val, uint32_t bits)
+{
+ff_opus_rc_enc_log((OpusEncRangeCoder*)rc, val, bits);
+}
+
+static inline uint32_t opus_rc_dec_log(OpusRangeCoder *rc, uint32_t bits)
+{
+return ff_opus_rc_dec_log((OpusDecRangeCoder*)rc, bits);
+}
+
+static inline void opus_rc_enc_cdf(OpusRangeCoder *rc, int val, const uint16_t 
*cdf)
+{
+ff_opus_rc_enc_cdf((OpusEncRangeCoder*)rc, val, cdf);
+}
+
+static inline uint32_t opus_rc_dec_cdf(OpusRangeCoder *rc, const uint16_t *cdf)
+{
+return ff_opus_rc_dec_cdf((OpusDecRangeCoder*)rc, cdf);
+}
 
 void ff_celt_quant_bands(CeltFrame *f, OpusRangeCoder *rc)
 {
@@ -150,12 +186,14 @@ void ff_celt_bitalloc(CeltFrame *f, OpusRangeCoder *rc, 
int encode)
 int bits1[CELT_MAX_BANDS];
 int bits2[CELT_MAX_BANDS];
 
+if (!CONFIG_OPUS_DECODER || !CONFIG_OPUS_ENCODER)
+encode = CONFIG_OPUS_ENCODER;
 /* Spread */
 if (opus_rc_tell(rc) + 4 <= f->framebits) {
 if (encode)
-ff_opus_rc_enc_cdf(rc, f->spread, ff_celt_model_spread);
+opus_rc_enc_cdf(rc, f->spread, ff_celt_model_spread);
 else
-f->spread = ff_opus_rc_dec_cdf(rc, ff_celt_model_spread);
+f->spread = opus_rc_dec_cdf(rc, ff_celt_model_spread);
 } 

[FFmpeg-devel] [PATCH 6/9] avcodec/opus_pvq: Don't build ppp_pvq_search_c when unused

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opus_pvq.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index 79101847af..d08dcd7413 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -366,6 +366,7 @@ static inline float celt_decode_pulses(OpusRangeCoder *rc, 
int *y, uint32_t N, u
 return celt_cwrsi(N, K, idx, y);
 }
 
+#if CONFIG_OPUS_ENCODER
 /*
  * Faster than libopus's search, operates entirely in the signed domain.
  * Slightly worse/better depending on N, K and the input vector.
@@ -418,6 +419,7 @@ static float ppp_pvq_search_c(float *X, int *y, int K, int 
N)
 
 return (float)y_norm;
 }
+#endif
 
 static uint32_t celt_alg_quant(OpusRangeCoder *rc, float *X, uint32_t N, 
uint32_t K,
enum CeltSpread spread, uint32_t blocks, float 
gain,
@@ -907,11 +909,13 @@ int av_cold ff_celt_pvq_init(CeltPVQ **pvq, int encode)
 if (!s)
 return AVERROR(ENOMEM);
 
-s->pvq_search = ppp_pvq_search_c;
 s->quant_band = encode ? pvq_encode_band : pvq_decode_band;
 
-#if CONFIG_OPUS_ENCODER && ARCH_X86
+#if CONFIG_OPUS_ENCODER
+s->pvq_search = ppp_pvq_search_c;
+#if ARCH_X86
 ff_celt_pvq_init_x86(s);
+#endif
 #endif
 
 *pvq = s;
-- 
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/9] avcodec/opus_rc: Don't duplicate define

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opus_rc.c | 4 ++--
 libavcodec/opus_rc.h | 5 ++---
 libavcodec/opusenc_psy.c | 2 +-
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c
index 2061418e52..1a26d889b7 100644
--- a/libavcodec/opus_rc.c
+++ b/libavcodec/opus_rc.c
@@ -388,7 +388,7 @@ void ff_opus_rc_enc_end(OpusRangeCoder *rc, uint8_t *dst, 
int size)
 int i, lap;
 uint8_t *rb_src, *rb_dst;
 ff_opus_rc_put_raw(rc, 0, 32 - rc->rb.cachelen);
-rb_src = rc->buf + OPUS_MAX_PACKET_SIZE + 12 - rc->rb.bytes;
+rb_src = rc->buf + OPUS_MAX_FRAME_SIZE + 12 - rc->rb.bytes;
 rb_dst = dst + FFMAX(size - rc->rb.bytes, 0);
 lap = [rng_bytes] - rb_dst;
 for (i = 0; i < lap; i++)
@@ -405,5 +405,5 @@ void ff_opus_rc_enc_init(OpusRangeCoder *rc)
 rc->rem = -1;
 rc->ext =  0;
 rc->rng_cur = rc->buf;
-ff_opus_rc_dec_raw_init(rc, rc->buf + OPUS_MAX_PACKET_SIZE + 8, 0);
+ff_opus_rc_dec_raw_init(rc, rc->buf + OPUS_MAX_FRAME_SIZE + 8, 0);
 }
diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h
index 1b3cb93a15..72e683b075 100644
--- a/libavcodec/opus_rc.h
+++ b/libavcodec/opus_rc.h
@@ -25,8 +25,7 @@
 
 #include 
 #include "get_bits.h"
-
-#define OPUS_MAX_PACKET_SIZE 1275
+#include "opus.h"
 
 #define opus_ilog(i) (av_log2(i) + !!(i))
 
@@ -45,7 +44,7 @@ typedef struct OpusRangeCoder {
 uint32_t total_bits;
 
 /* Encoder */
-uint8_t buf[OPUS_MAX_PACKET_SIZE + 12]; /* memcpy vs (memmove + 
overreading) */
+uint8_t buf[OPUS_MAX_FRAME_SIZE + 12]; /* memcpy vs (memmove + 
overreading) */
 uint8_t *rng_cur;  /* Current range coded byte */
 int ext;   /* Awaiting propagation */
 int rem;   /* Carryout flag */
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
index 5c768ae68e..48ccd2ebd0 100644
--- a/libavcodec/opusenc_psy.c
+++ b/libavcodec/opusenc_psy.c
@@ -359,7 +359,7 @@ static void celt_gauge_psy_weight(OpusPsyContext *s, 
OpusPsyStep **start,
 rate /= s->avctx->sample_rate/frame_size;
 
 f_out->framebits = lrintf(rate);
-f_out->framebits = FFMIN(f_out->framebits, OPUS_MAX_PACKET_SIZE*8);
+f_out->framebits = FFMIN(f_out->framebits, OPUS_MAX_FRAME_SIZE * 8);
 f_out->framebits = FFALIGN(f_out->framebits, 8);
 }
 
-- 
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/9] avcodec/opus: Use prefix for defines

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opus.h   |  6 +++---
 libavcodec/opus_parse.c | 12 ++--
 libavcodec/opus_parse.h |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavcodec/opus.h b/libavcodec/opus.h
index 4d061cf5f8..f87b63aaca 100644
--- a/libavcodec/opus.h
+++ b/libavcodec/opus.h
@@ -25,9 +25,9 @@
 
 #include 
 
-#define MAX_FRAME_SIZE   1275
-#define MAX_FRAMES   48
-#define MAX_PACKET_DUR   5760
+#define OPUS_MAX_FRAME_SIZE  1275
+#define OPUS_MAX_FRAMES48
+#define OPUS_MAX_PACKET_DUR  5760
 
 #define OPUS_TS_HEADER 0x7FE0// 0x3ff (11 bits)
 #define OPUS_TS_MASK   0xFFE0// top 11 bits
diff --git a/libavcodec/opus_parse.c b/libavcodec/opus_parse.c
index 39765c5b79..e922d1f304 100644
--- a/libavcodec/opus_parse.c
+++ b/libavcodec/opus_parse.c
@@ -128,7 +128,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 }
 
 frame_bytes = end - ptr;
-if (frame_bytes > MAX_FRAME_SIZE)
+if (frame_bytes > OPUS_MAX_FRAME_SIZE)
 goto fail;
 pkt->frame_offset[0] = ptr - buf;
 pkt->frame_size[0]   = frame_bytes;
@@ -147,7 +147,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 }
 
 frame_bytes = end - ptr;
-if (frame_bytes & 1 || frame_bytes >> 1 > MAX_FRAME_SIZE)
+if (frame_bytes & 1 || frame_bytes >> 1 > OPUS_MAX_FRAME_SIZE)
 goto fail;
 pkt->frame_offset[0] = ptr - buf;
 pkt->frame_size[0]   = frame_bytes >> 1;
@@ -177,7 +177,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 
 /* calculate 2nd frame size */
 frame_bytes = end - ptr - pkt->frame_size[0];
-if (frame_bytes < 0 || frame_bytes > MAX_FRAME_SIZE)
+if (frame_bytes < 0 || frame_bytes > OPUS_MAX_FRAME_SIZE)
 goto fail;
 pkt->frame_offset[1] = pkt->frame_offset[0] + pkt->frame_size[0];
 pkt->frame_size[1]   = frame_bytes;
@@ -189,7 +189,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 padding  = (i >> 6) & 0x01;
 pkt->vbr = (i >> 7) & 0x01;
 
-if (pkt->frame_count == 0 || pkt->frame_count > MAX_FRAMES)
+if (pkt->frame_count == 0 || pkt->frame_count > OPUS_MAX_FRAMES)
 goto fail;
 
 /* read padding size */
@@ -239,7 +239,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 } else {
 frame_bytes = end - ptr - padding;
 if (frame_bytes % pkt->frame_count ||
-frame_bytes / pkt->frame_count > MAX_FRAME_SIZE)
+frame_bytes / pkt->frame_count > OPUS_MAX_FRAME_SIZE)
 goto fail;
 frame_bytes /= pkt->frame_count;
 }
@@ -258,7 +258,7 @@ int ff_opus_parse_packet(OpusPacket *pkt, const uint8_t 
*buf, int buf_size,
 
 /* total packet duration cannot be larger than 120ms */
 pkt->frame_duration = opus_frame_duration[pkt->config];
-if (pkt->frame_duration * pkt->frame_count > MAX_PACKET_DUR)
+if (pkt->frame_duration * pkt->frame_count > OPUS_MAX_PACKET_DUR)
 goto fail;
 
 /* set mode and bandwidth */
diff --git a/libavcodec/opus_parse.h b/libavcodec/opus_parse.h
index 8e5c6a880c..83ed3c7887 100644
--- a/libavcodec/opus_parse.h
+++ b/libavcodec/opus_parse.h
@@ -37,8 +37,8 @@ typedef struct OpusPacket {
 int config; /**< configuration: tells the audio mode,
  **bandwidth, and frame 
duration */
 int frame_count;/**< frame count */
-int frame_offset[MAX_FRAMES];   /**< frame offsets */
-int frame_size[MAX_FRAMES]; /**< frame sizes */
+int frame_offset[OPUS_MAX_FRAMES]; /**< frame offsets */
+int frame_size[OPUS_MAX_FRAMES]; /**< frame sizes */
 int frame_duration; /**< frame duration, in samples @ 48kHz */
 enum OpusMode mode; /**< mode */
 enum OpusBandwidth bandwidth;   /**< bandwidth */
-- 
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/9] avcodec/opusenc_psy: Remove unused/write-only context members

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opusenc_psy.c |  5 -
 libavcodec/opusenc_psy.h | 11 ---
 2 files changed, 16 deletions(-)

diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
index 94c37fb8b1..5c768ae68e 100644
--- a/libavcodec/opusenc_psy.c
+++ b/libavcodec/opusenc_psy.c
@@ -470,12 +470,9 @@ int ff_opus_psy_celt_frame_process(OpusPsyContext *s, 
CeltFrame *f, int index)
 
 if (f->transient != start_transient_flag) {
 f->blocks = f->transient ? 
OPUS_BLOCK_SIZE(s->p.framesize)/CELT_OVERLAP : 1;
-s->redo_analysis = 1;
 return 1;
 }
 
-s->redo_analysis = 0;
-
 return 0;
 }
 
@@ -509,7 +506,6 @@ void ff_opus_psy_postencode_update(OpusPsyContext *s, 
CeltFrame *f)
 
 s->avg_is_band /= (s->p.frames + 1);
 
-s->cs_num = 0;
 s->steps_to_process = 0;
 s->buffered_steps -= steps_out;
 s->total_packets_out += s->p.frames;
@@ -521,7 +517,6 @@ av_cold int ff_opus_psy_init(OpusPsyContext *s, 
AVCodecContext *avctx,
 {
 int i, ch, ret;
 
-s->redo_analysis = 0;
 s->lambda = 1.0f;
 s->options = options;
 s->avctx = avctx;
diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h
index ee58b0cdf9..bc1a88c03d 100644
--- a/libavcodec/opusenc_psy.h
+++ b/libavcodec/opusenc_psy.h
@@ -49,20 +49,12 @@ typedef struct OpusBandExcitation {
 float excitation_init;
 } OpusBandExcitation;
 
-typedef struct PsyChain {
-int start;
-int end;
-} PsyChain;
-
 typedef struct OpusPsyContext {
 AVCodecContext *avctx;
 AVFloatDSPContext *dsp;
 struct FFBufQueue *bufqueue;
 OpusEncOptions *options;
 
-PsyChain cs[128];
-int cs_num;
-
 OpusBandExcitation ex[OPUS_MAX_CHANNELS][CELT_MAX_BANDS];
 FFBesselFilter bfilter_lo[OPUS_MAX_CHANNELS][CELT_MAX_BANDS];
 FFBesselFilter bfilter_hi[OPUS_MAX_CHANNELS][CELT_MAX_BANDS];
@@ -78,15 +70,12 @@ typedef struct OpusPsyContext {
 DECLARE_ALIGNED(32, float, scratch)[2048];
 
 /* Stats */
-float rc_waste;
 float avg_is_band;
 int64_t dual_stereo_used;
 int64_t total_packets_out;
 
 /* State */
-FFBesselFilter lambda_lp;
 OpusPacketInfo p;
-int redo_analysis;
 int buffered_steps;
 int steps_to_process;
 int eof;
-- 
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/9] avcodec/opusenc_psy: Remove unused function parameter

2022-10-07 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opusenc.c | 2 +-
 libavcodec/opusenc_psy.c | 2 +-
 libavcodec/opusenc_psy.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 7695e95884..280425c74f 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -594,7 +594,7 @@ static int opus_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 opus_packet_assembler(s, avpkt);
 
 /* Update the psychoacoustic system */
-ff_opus_psy_postencode_update(>psyctx, s->frame, s->rc);
+ff_opus_psy_postencode_update(>psyctx, s->frame);
 
 /* Remove samples from queue and skip if needed */
 ff_af_queue_remove(>afq, s->packet.frames*frame_size, >pts, 
>duration);
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
index 9b11651dbe..94c37fb8b1 100644
--- a/libavcodec/opusenc_psy.c
+++ b/libavcodec/opusenc_psy.c
@@ -479,7 +479,7 @@ int ff_opus_psy_celt_frame_process(OpusPsyContext *s, 
CeltFrame *f, int index)
 return 0;
 }
 
-void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f, 
OpusRangeCoder *rc)
+void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f)
 {
 int i, frame_size = OPUS_BLOCK_SIZE(s->p.framesize);
 int steps_out = s->p.frames*(frame_size/120);
diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h
index 67e96b2fa5..ee58b0cdf9 100644
--- a/libavcodec/opusenc_psy.h
+++ b/libavcodec/opusenc_psy.h
@@ -98,7 +98,7 @@ typedef struct OpusPsyContext {
 int  ff_opus_psy_process   (OpusPsyContext *s, OpusPacketInfo *p);
 void ff_opus_psy_celt_frame_init   (OpusPsyContext *s, CeltFrame *f, int 
index);
 int  ff_opus_psy_celt_frame_process(OpusPsyContext *s, CeltFrame *f, int 
index);
-void ff_opus_psy_postencode_update (OpusPsyContext *s, CeltFrame *f, 
OpusRangeCoder *rc);
+void ff_opus_psy_postencode_update (OpusPsyContext *s, CeltFrame *f);
 
 int  ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx,
   struct FFBufQueue *bufqueue, OpusEncOptions *options);
-- 
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/9] avcodec/opus_rc: Remove write-only waste from OpusRangeCoder

2022-10-07 Thread Andreas Rheinhardt
Write-only since e7d977b446194649aa30f2aacc6c17bce7aeb90b
(and local to ff_opus_rc_enc_end() before that).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/opus_rc.c | 2 --
 libavcodec/opus_rc.h | 3 ---
 2 files changed, 5 deletions(-)

diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c
index c432eb90c9..2061418e52 100644
--- a/libavcodec/opus_rc.c
+++ b/libavcodec/opus_rc.c
@@ -383,8 +383,6 @@ void ff_opus_rc_enc_end(OpusRangeCoder *rc, uint8_t *dst, 
int size)
 rng_bytes = rc->rng_cur - rc->buf;
 memcpy(dst, rc->buf, rng_bytes);
 
-rc->waste = size*8 - (rc->rb.bytes*8 + rc->rb.cachelen) - rng_bytes*8;
-
 /* Put the rawbits part, if any */
 if (rc->rb.bytes || rc->rb.cachelen) {
 int i, lap;
diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h
index 627f83229e..1b3cb93a15 100644
--- a/libavcodec/opus_rc.h
+++ b/libavcodec/opus_rc.h
@@ -49,9 +49,6 @@ typedef struct OpusRangeCoder {
 uint8_t *rng_cur;  /* Current range coded byte */
 int ext;   /* Awaiting propagation */
 int rem;   /* Carryout flag */
-
-/* Encoding stats */
-int waste;
 } OpusRangeCoder;
 
 /**
-- 
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] [crop support for matroska demuxer 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-10-07 Thread Dmitrii Ovchinnikov
Sent an updated version:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7707.
1)
>>All of these should be size_t
The field type is still "int" according to James Almer's comment.
2) I placed the fields at the very end, according to a message from Timo
Rothenpieler.
3)
>>The semantics of these new fields definitely need to be defined more
precisely
Added a flag responsible for the behavior(enum
CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;).
When set to 1 (the default), libavcodec will apply container cropping
to codec cropping additionally.
When set to 2, libavcodec will use container cropping to overwrite
codec cropping (the final cropping uses container cropping parameters)
When set to 0, libavcodec will ignore container cropping parameters
(the final cropping uses codec cropping parameters)This field works with
"apply_cropping".
Only if apply_cropping is 1, this field works
___
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] [crop support for matroska demuxer, V3 3/3] libavformat\matroskadec.c: crop support for matroska demuxer.

2022-10-07 Thread OvchinnikovDmitrii
In webm specification, it supports cropping information. 
(https://www.webmproject.org/docs/container/)
In ffmpeg, the implementation of webm is a subset of matroska. In 
matroskadec.c, those cropping related four fields are forced to 0.

for the sample file with crop (crop_bottom =8, crop_top=crop_left=crop_right=0.)
ffmpeg.exe -i  test_with_container_crop.webm -pix_fmt yuv420p -y output.yuv

original ffmpeg code - the output.yuv resolution is 1920x1088
changed code - the output.yuv resolution is 1920x1080

Previous discussion 
:https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=7668
---
 libavformat/matroskadec.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d582f566a2..2023fd4977 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -210,6 +210,10 @@ typedef struct MatroskaTrackVideo {
 uint64_t pixel_width;
 uint64_t pixel_height;
 EbmlBin  color_space;
+uint64_t pixel_cropt;
+uint64_t pixel_cropl;
+uint64_t pixel_cropb;
+uint64_t pixel_cropr;
 uint64_t display_unit;
 uint64_t interlaced;
 uint64_t field_order;
@@ -517,10 +521,10 @@ static EbmlSyntax matroska_track_video[] = {
 { MATROSKA_ID_VIDEOALPHAMODE,  EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, alpha_mode), { .u = 0 } },
 { MATROSKA_ID_VIDEOCOLOR,  EBML_NEST,  0, 
sizeof(MatroskaTrackVideoColor), offsetof(MatroskaTrackVideo, color), { .n = 
matroska_track_video_color } },
 { MATROSKA_ID_VIDEOPROJECTION, EBML_NEST,  0, 0, 
offsetof(MatroskaTrackVideo, projection), { .n = 
matroska_track_video_projection } },
-{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_NONE },
-{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_NONE },
+{ MATROSKA_ID_VIDEOPIXELCROPT, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropt), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPL, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropl), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPB, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropb), {.u = 0 } },
+{ MATROSKA_ID_VIDEOPIXELCROPR, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, pixel_cropr), {.u = 0 } },
 { MATROSKA_ID_VIDEODISPLAYUNIT,EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, display_unit), { .u= 
MATROSKA_VIDEO_DISPLAYUNIT_PIXELS } },
 { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, interlaced),  { .u = 
MATROSKA_VIDEO_INTERLACE_FLAG_UNDETERMINED } },
 { MATROSKA_ID_VIDEOFIELDORDER, EBML_UINT,  0, 0, 
offsetof(MatroskaTrackVideo, field_order), { .u = 
MATROSKA_VIDEO_FIELDORDER_UNDETERMINED } },
@@ -2879,6 +2883,11 @@ static int matroska_parse_tracks(AVFormatContext *s)
 st->codecpar->width  = track->video.pixel_width;
 st->codecpar->height = track->video.pixel_height;
 
+st->codecpar->container_crop_top= track->video.pixel_cropt;
+st->codecpar->container_crop_left   = track->video.pixel_cropl;
+st->codecpar->container_crop_bottom = track->video.pixel_cropb;
+st->codecpar->container_crop_right  = track->video.pixel_cropr;
+
 if (track->video.interlaced == 
MATROSKA_VIDEO_INTERLACE_FLAG_INTERLACED)
 st->codecpar->field_order = mkv_field_order(matroska, 
track->video.field_order);
 else if (track->video.interlaced == 
MATROSKA_VIDEO_INTERLACE_FLAG_PROGRESSIVE)
-- 
2.30.0.windows.2

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

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


[FFmpeg-devel] [crop support for matroska demuxer, V3 2/3] libavcodec: Public code to support container crop

2022-10-07 Thread OvchinnikovDmitrii
Support both simple and receive_frame api
The container crop information is applied additional to frame crop information
---
 libavcodec/codec_par.c | 30 +++---
 libavcodec/decode.c| 14 ++
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/libavcodec/codec_par.c b/libavcodec/codec_par.c
index abda649aa8..9738402434 100644
--- a/libavcodec/codec_par.c
+++ b/libavcodec/codec_par.c
@@ -115,17 +115,21 @@ int avcodec_parameters_from_context(AVCodecParameters 
*par,
 
 switch (par->codec_type) {
 case AVMEDIA_TYPE_VIDEO:
-par->format  = codec->pix_fmt;
-par->width   = codec->width;
-par->height  = codec->height;
-par->field_order = codec->field_order;
-par->color_range = codec->color_range;
-par->color_primaries = codec->color_primaries;
-par->color_trc   = codec->color_trc;
-par->color_space = codec->colorspace;
-par->chroma_location = codec->chroma_sample_location;
-par->sample_aspect_ratio = codec->sample_aspect_ratio;
-par->video_delay = codec->has_b_frames;
+par->format= codec->pix_fmt;
+par->width = codec->width;
+par->height= codec->height;
+par->container_crop_top= codec->container_crop_top;
+par->container_crop_left   = codec->container_crop_left;
+par->container_crop_bottom = codec->container_crop_bottom;
+par->container_crop_right  = codec->container_crop_right;
+par->field_order   = codec->field_order;
+par->color_range   = codec->color_range;
+par->color_primaries   = codec->color_primaries;
+par->color_trc = codec->color_trc;
+par->color_space   = codec->colorspace;
+par->chroma_location   = codec->chroma_sample_location;
+par->sample_aspect_ratio   = codec->sample_aspect_ratio;
+par->video_delay   = codec->has_b_frames;
 break;
 case AVMEDIA_TYPE_AUDIO:
 par->format   = codec->sample_fmt;
@@ -199,6 +203,10 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 codec->pix_fmt= par->format;
 codec->width  = par->width;
 codec->height = par->height;
+codec->container_crop_top = par->container_crop_top;
+codec->container_crop_left= par->container_crop_left;
+codec->container_crop_bottom  = par->container_crop_bottom;
+codec->container_crop_right   = par->container_crop_right;
 codec->field_order= par->field_order;
 codec->color_range= par->color_range;
 codec->color_primaries= par->color_primaries;
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 6be2d3d6ed..412c7cc2f4 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -693,6 +693,20 @@ static int apply_cropping(AVCodecContext *avctx, AVFrame 
*frame)
 if (!avctx->apply_cropping)
 return 0;
 
+if (avctx->container_apply_cropping == FF_CONTAINER_CROPPING_ADDITION)
+{
+frame->crop_top+= avctx->container_crop_top;
+frame->crop_left   += avctx->container_crop_left;
+frame->crop_bottom += avctx->container_crop_bottom;
+frame->crop_right  += avctx->container_crop_right;
+}
+else if (avctx->container_apply_cropping == 
FF_CONTAINER_CROPPING_OVERWRITE) {
+frame->crop_top= avctx->container_crop_top;
+frame->crop_left   = avctx->container_crop_left;
+frame->crop_bottom = avctx->container_crop_bottom;
+frame->crop_right  = avctx->container_crop_right;
+}
+
 return av_frame_apply_cropping(frame, avctx->flags & 
AV_CODEC_FLAG_UNALIGNED ?
   AV_FRAME_CROP_UNALIGNED : 0);
 }
-- 
2.30.0.windows.2

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

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


[FFmpeg-devel] [crop support for matroska demuxer, V3 1/3] libavcodec: Add crop related fields to structure AVCodecContext and AVCodecParameters.

2022-10-07 Thread OvchinnikovDmitrii
---
 libavcodec/avcodec.h   | 35 +++
 libavcodec/codec_par.h |  8 
 libavcodec/options_table.h |  4 
 3 files changed, 47 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7365eb5cc0..d28a7cc022 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -380,6 +380,19 @@ typedef struct RcOverride{
  */
 #define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0)
 
+/**
+* Video decoding only. Certain container support cropping, meaning that
+* only a sub-rectangle of the decoded frame is intended for display.
+* Certain codec supports cropping as well.This option controls how
+* cropping is handled by libavcodec when  container cropping and
+* codec cropping exist.
+*/
+enum CONTAINER_CROPPING_POLICY_TYPE {
+FF_CONTAINER_CROPPING_IGNORE = 0,
+FF_CONTAINER_CROPPING_ADDITION,
+FF_CONTAINER_CROPPING_OVERWRITE
+};
+
 struct AVCodecInternal;
 
 /**
@@ -2057,6 +2070,28 @@ typedef struct AVCodecContext {
  * The decoder can then override during decoding as needed.
  */
 AVChannelLayout ch_layout;
+
+/* When set to 1 (the default), libavcodec will apply container cropping
+ * to codec cropping additionally.
+ *
+ * When set to 2, libavcodec will use container cropping to overwrite
+ * codec cropping (the final cropping uses container cropping parameters)
+ *
+ * When set to 0, libavcodec will ignore container cropping parameters
+ * (the final cropping uses codec cropping parameters)
+ *
+ * This field works with "apply_cropping". Only if apply_cropping is 1, 
this
+ * field works
+ */
+enum CONTAINER_CROPPING_POLICY_TYPE container_apply_cropping;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/codec_par.h b/libavcodec/codec_par.h
index 7660791a12..12d8ceb521 100644
--- a/libavcodec/codec_par.h
+++ b/libavcodec/codec_par.h
@@ -210,6 +210,14 @@ typedef struct AVCodecParameters {
  * Audio only. The channel layout and number of channels.
  */
 AVChannelLayout ch_layout;
+
+/**
+ * The cropping parameters from container.
+ */
+int container_crop_top;
+int container_crop_left;
+int container_crop_bottom;
+int container_crop_right;
 } AVCodecParameters;
 
 /**
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cd02f5096f..fd1ef21f90 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -401,6 +401,10 @@ static const AVOption avcodec_options[] = {
 {"allow_profile_mismatch", "attempt to decode anyway if HW accelerated 
decoder's supported profiles do not exactly match the stream", 0, 
AV_OPT_TYPE_CONST, {.i64 = AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH }, INT_MIN, 
INT_MAX, V | D, "hwaccel_flags"},
 {"extra_hw_frames", "Number of extra hardware frames to allocate for the 
user", OFFSET(extra_hw_frames), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, 
V|D },
 {"discard_damaged_percentage", "Percentage of damaged samples to discard a 
frame", OFFSET(discard_damaged_percentage), AV_OPT_TYPE_INT, {.i64 = 95 }, 0, 
100, V|D },
+{ "container_apply_cropping", "ploicy using container cropping parameters", 
OFFSET(container_apply_cropping), AV_OPT_TYPE_INT64, {.i64 = 
FF_CONTAINER_CROPPING_ADDITION }, 0, 2, V | D, "container_apply_cropping" },
+{ "ignore","ignore container cropping",
   0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_IGNORE },0, 0, V 
| D, "container_apply_cropping" },
+{ "addition",  "apply container cropping additionally to elementary stream 
cropping", 0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_ADDITION },  0, 
0, V | D, "container_apply_cropping" },
+{ "overwrite", "use container cropping to overwrite elementary stream 
cropping",  0, AV_OPT_TYPE_CONST, {.i64 = FF_CONTAINER_CROPPING_OVERWRITE 
}, 0, 0, V | D, "container_apply_cropping" },
 {NULL},
 };
 
-- 
2.30.0.windows.2

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

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


Re: [FFmpeg-devel] [PATCH] avcodec: ViewQuest VQC decoder

2022-10-07 Thread Tomas Härdin
fre 2022-10-07 klockan 14:33 +0200 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > fre 2022-10-07 klockan 12:38 +0200 skrev Andreas Rheinhardt:
> > > Tomas Härdin:
> > > > tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:
> > > > > 
> > > > > +static av_cold int vqc_decode_init(AVCodecContext * avctx)
> > > > > +{
> > > > > +    static AVOnce init_static_once = AV_ONCE_INIT;
> > > > > +    VqcContext *s = avctx->priv_data;
> > > > > +
> > > > > +    s->vectors = av_malloc((avctx->width * avctx->height *
> > > > > 3) /
> > > > > 2);
> > > > > +    if (!s->vectors)
> > > > > +    return AVERROR(ENOMEM);
> > > > > +
> > > > > +    s->coeff = av_malloc(2 * avctx->width *
> > > > > sizeof(int16_t));
> > > > > +    if (!s->coeff)
> > > > > +    return AVERROR(ENOMEM);
> > > > > +
> > > > > +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> > > > > +    if (!s->tmp1)
> > > > > +    return AVERROR(ENOMEM);
> > > > > +
> > > > > +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> > > > 
> > > > av_malloc_array() perhaps? Not that these are likely to
> > > > overflow
> > > > since
> > > > max pixels is usually far away from INT_MAX
> > > > 
> > > 
> > > Actually, sizeof(int16_t) is guaranteed to be two, so that
> > > sizeof(int16_t) / 2 is always one.
> > 
> > Not on machines where CHAR_BIT >= 16. But we could enforce that
> > during
> > configuration
> > 
> 
> The fixed-wide integers are required by the spec to have no padding.
> We
> rely on uint8_t/int8_t to be present and so CHAR_BIT divides 8, but
> it
> has to be >= 8, too, so it is eight. (Apart from that, we probably
> rely
> on CHAR_BIT to be eight in thousands of other places, too.)

Right, the presence of (u)int8_t together with ISO/IEC 9899:1999 saying
CHAR_BIT >= 8 does imply CHAR_BIT == 8.

/Tomas

___
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] avcodec: ViewQuest VQC decoder

2022-10-07 Thread Andreas Rheinhardt
Tomas Härdin:
> fre 2022-10-07 klockan 12:38 +0200 skrev Andreas Rheinhardt:
>> Tomas Härdin:
>>> tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:

 +static av_cold int vqc_decode_init(AVCodecContext * avctx)
 +{
 +    static AVOnce init_static_once = AV_ONCE_INIT;
 +    VqcContext *s = avctx->priv_data;
 +
 +    s->vectors = av_malloc((avctx->width * avctx->height * 3) /
 2);
 +    if (!s->vectors)
 +    return AVERROR(ENOMEM);
 +
 +    s->coeff = av_malloc(2 * avctx->width * sizeof(int16_t));
 +    if (!s->coeff)
 +    return AVERROR(ENOMEM);
 +
 +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
 +    if (!s->tmp1)
 +    return AVERROR(ENOMEM);
 +
 +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);
>>>
>>> av_malloc_array() perhaps? Not that these are likely to overflow
>>> since
>>> max pixels is usually far away from INT_MAX
>>>
>>
>> Actually, sizeof(int16_t) is guaranteed to be two, so that
>> sizeof(int16_t) / 2 is always one.
> 
> Not on machines where CHAR_BIT >= 16. But we could enforce that during
> configuration
> 

The fixed-wide integers are required by the spec to have no padding. We
rely on uint8_t/int8_t to be present and so CHAR_BIT divides 8, but it
has to be >= 8, too, so it is eight. (Apart from that, we probably rely
on CHAR_BIT to be eight in thousands of other places, too.)

- 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] avcodec: ViewQuest VQC decoder

2022-10-07 Thread Tomas Härdin
fre 2022-10-07 klockan 12:38 +0200 skrev Andreas Rheinhardt:
> Tomas Härdin:
> > tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:
> > > 
> > > +static av_cold int vqc_decode_init(AVCodecContext * avctx)
> > > +{
> > > +    static AVOnce init_static_once = AV_ONCE_INIT;
> > > +    VqcContext *s = avctx->priv_data;
> > > +
> > > +    s->vectors = av_malloc((avctx->width * avctx->height * 3) /
> > > 2);
> > > +    if (!s->vectors)
> > > +    return AVERROR(ENOMEM);
> > > +
> > > +    s->coeff = av_malloc(2 * avctx->width * sizeof(int16_t));
> > > +    if (!s->coeff)
> > > +    return AVERROR(ENOMEM);
> > > +
> > > +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> > > +    if (!s->tmp1)
> > > +    return AVERROR(ENOMEM);
> > > +
> > > +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> > 
> > av_malloc_array() perhaps? Not that these are likely to overflow
> > since
> > max pixels is usually far away from INT_MAX
> > 
> 
> Actually, sizeof(int16_t) is guaranteed to be two, so that
> sizeof(int16_t) / 2 is always one.

Not on machines where CHAR_BIT >= 16. But we could enforce that during
configuration

/Tomas

___
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 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h

2022-10-07 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Also improve the other headers a bit.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/ylc.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
> index 3ea6749ffe..29c10f05da 100644
> --- a/libavcodec/ylc.c
> +++ b/libavcodec/ylc.c
> @@ -18,21 +18,17 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> -#include 
> -#include 
>  #include 
>  
>  #define YLC_VLC_BITS 10
>  
> -#include "libavutil/imgutils.h"
> -#include "libavutil/internal.h"
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/mem.h"
> +#include "libavutil/pixfmt.h"
>  #include "avcodec.h"
>  #include "bswapdsp.h"
>  #include "codec_internal.h"
>  #include "get_bits.h"
> -#include "huffyuvdsp.h"
>  #include "thread.h"
>  #include "unary.h"
>  

Will apply this patchset tomorrow unless there are objections.

- 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 1/2] avcodec/msmpeg4enc: Fix indentation

2022-10-07 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Forgotten after 2b9ab1d54a35f7d689b2396cfc59f9dbdcae391f.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/msmpeg4enc.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/msmpeg4enc.c b/libavcodec/msmpeg4enc.c
> index e40acdf3fc..f0d0045e69 100644
> --- a/libavcodec/msmpeg4enc.c
> +++ b/libavcodec/msmpeg4enc.c
> @@ -279,15 +279,15 @@ void ff_msmpeg4_encode_picture_header(MpegEncContext * 
> s, int picture_number)
>  
>  void ff_msmpeg4_encode_ext_header(MpegEncContext * s)
>  {
> -unsigned fps = s->avctx->time_base.den / s->avctx->time_base.num / 
> FFMAX(s->avctx->ticks_per_frame, 1);
> -put_bits(>pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
> +unsigned fps = s->avctx->time_base.den / s->avctx->time_base.num / 
> FFMAX(s->avctx->ticks_per_frame, 1);
> +put_bits(>pb, 5, FFMIN(fps, 31)); //yes 29.97 -> 29
>  
> -put_bits(>pb, 11, FFMIN(s->bit_rate/1024, 2047));
> +put_bits(>pb, 11, FFMIN(s->bit_rate / 1024, 2047));
>  
> -if(s->msmpeg4_version>=3)
> -put_bits(>pb, 1, s->flipflop_rounding);
> -else
> -av_assert0(s->flipflop_rounding==0);
> +if (s->msmpeg4_version >= 3)
> +put_bits(>pb, 1, s->flipflop_rounding);
> +else
> +av_assert0(!s->flipflop_rounding);
>  }
>  
>  void ff_msmpeg4_encode_motion(MpegEncContext * s,

Will apply these trivialities tonight unless there are objections.

- 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 2/2] avcodec/asvenc: Remove unnecessary emms_c()

2022-10-07 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> PixblockDSP does not use MMX functions any more since
> 92b58002776edd3a3df03c90e8a3ab24b8f987de and FDCTDSP
> since d402ec6be99dc82e263bad883e7c1c3d957343db.
> BswapDSP never used MMX, so that the emms_c() here
> is unnecessary.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavcodec/asvenc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavcodec/asvenc.c b/libavcodec/asvenc.c
> index e185d501b3..9da7cbb986 100644
> --- a/libavcodec/asvenc.c
> +++ b/libavcodec/asvenc.c
> @@ -300,7 +300,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
> *pkt,
>  encode_mb(a, a->block);
>  }
>  }
> -emms_c();
>  
>  if (avctx->codec_id == AV_CODEC_ID_ASV1)
>  flush_put_bits(>pb);

Will apply tomorrow unless there are objections.

- 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] avcodec: ViewQuest VQC decoder

2022-10-07 Thread Andreas Rheinhardt
Tomas Härdin:
> tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:
>>
>> +static av_cold int vqc_decode_init(AVCodecContext * avctx)
>> +{
>> +    static AVOnce init_static_once = AV_ONCE_INIT;
>> +    VqcContext *s = avctx->priv_data;
>> +
>> +    s->vectors = av_malloc((avctx->width * avctx->height * 3) / 2);
>> +    if (!s->vectors)
>> +    return AVERROR(ENOMEM);
>> +
>> +    s->coeff = av_malloc(2 * avctx->width * sizeof(int16_t));
>> +    if (!s->coeff)
>> +    return AVERROR(ENOMEM);
>> +
>> +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
>> +    if (!s->tmp1)
>> +    return AVERROR(ENOMEM);
>> +
>> +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> 
> av_malloc_array() perhaps? Not that these are likely to overflow since
> max pixels is usually far away from INT_MAX
> 

Actually, sizeof(int16_t) is guaranteed to be two, so that
sizeof(int16_t) / 2 is always one.

- 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] avcodec: ViewQuest VQC decoder

2022-10-07 Thread Tomas Härdin
tor 2022-10-06 klockan 21:45 +1100 skrev Peter Ross:
> 
> +static av_cold int vqc_decode_init(AVCodecContext * avctx)
> +{
> +    static AVOnce init_static_once = AV_ONCE_INIT;
> +    VqcContext *s = avctx->priv_data;
> +
> +    s->vectors = av_malloc((avctx->width * avctx->height * 3) / 2);
> +    if (!s->vectors)
> +    return AVERROR(ENOMEM);
> +
> +    s->coeff = av_malloc(2 * avctx->width * sizeof(int16_t));
> +    if (!s->coeff)
> +    return AVERROR(ENOMEM);
> +
> +    s->tmp1 = av_malloc(avctx->width * sizeof(int16_t) / 2);
> +    if (!s->tmp1)
> +    return AVERROR(ENOMEM);
> +
> +    s->tmp2 = av_malloc(avctx->width * sizeof(int16_t) / 2);

av_malloc_array() perhaps? Not that these are likely to overflow since
max pixels is usually far away from INT_MAX

> +static uint8_t sat1(int x)
> +{
> +    return x >= -128 ? x <= 127 ? x + 0x80 : 0xFF : 0x00;
> +}

Use av_clip*()

> +static uint8_t sat2(int x)
> +{
> +    return x >= -128 ? x <= 127 ? x + 0x80 : 0x00 : 0xFF;
> +}

Doesn't look like av_clip() will work here. Or?

> +static int vqc_decode_frame(AVCodecContext *avctx, AVFrame * rframe,
> +    int * got_frame, AVPacket * avpkt)
> +{
> +    VqcContext *s = avctx->priv_data;
> +    int ret;
> +    uint8_t * buf = avpkt->data;
> +    int cache, seed[7], gamma, contrast;
> +
> +    if (avpkt->size < 7)
> +    return AVERROR_INVALIDDATA;
> +
> +    if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
> +    return ret;
> +
> +    av_log(avctx, AV_LOG_DEBUG, "VQC%d format\n", (buf[2] & 1) + 1);
> +
> +    if (((buf[0] >> 1) & 7) != 5) {
> +    avpriv_request_sample(avctx, "subversion != 5\n");
> +    return AVERROR_PATCHWELCOME;
> +    }
> +
> +    cache = buf[4] | (AV_RL16(buf + 5) << 8);

AV_RL24()

No tests? Looks like samp.avi would make a fine addition to FATE

/Tomas

___
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 v13 9/9] avcodec/evc: Changes in Changelog and MAINTAINERS files

2022-10-07 Thread Dawid Kozinski
- Changelog update
- MAINTAINERS update

Signed-off-by: Dawid Kozinski 
---
 Changelog   | 3 ++-
 MAINTAINERS | 5 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 14ba8ac874..ff3b9aebf1 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,8 @@ version 5.1:
 - remap_opencl filter
 - added chromakey_cuda filter
 - added bilateral_cuda filter
+- eXtra-fast Essential Video Encoder (XEVE)
+- eXtra-fast Essential Video Decoder (XEVD)
 
 
 version 5.0:
@@ -91,7 +93,6 @@ version 5.0:
 - anlmf audio filter
 - IMF demuxer (experimental)
 
-
 version 4.4:
 - AudioToolbox output device
 - MacCaption demuxer
diff --git a/MAINTAINERS b/MAINTAINERS
index eebfa5cfb7..df8d8eca73 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -200,6 +200,8 @@ Codecs:
   libvpx*   James Zern
   libxavs.c Stefan Gehrer
   libxavs2.cHuiwen Ren
+  libxevd.c Dawid Kozinski
+  libxeve.c,Dawid Kozinski
   libzvbi-teletextdec.c Marton Balint
   lzo.h, lzo.c  Reimar Doeffinger
   mdec.cMichael Niedermayer
@@ -420,6 +422,9 @@ Muxers/Demuxers:
   dv.c  Roman Shaposhnik
   electronicarts.c  Peter Ross
   epafdec.c Paul B Mahol
+  evc.c, evc.h  Dawid Kozinski
+  evcdec.c  Dawid Kozinski
+  evc_parser.c  Dawid Kozinski
   ffm*  Baptiste Coudurier
   flic.cMike Melanson
   flvdec.c  Michael Niedermayer
-- 
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 v13 8/9] avformat/mov_demuxer: Extended MOV demuxer to handle EVC video content

2022-10-07 Thread Dawid Kozinski
- Added evc extension to the list of extensions for ff_mov_demuxer

Signed-off-by: Dawid Kozinski 
---
 libavformat/demux.c | 1 +
 libavformat/mov.c   | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 2dfd82a63c..f3ebe4d09b 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -120,6 +120,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, 
AVStream *st,
 { "mp3",AV_CODEC_ID_MP3,  AVMEDIA_TYPE_AUDIO},
 { "mpegvideo",  AV_CODEC_ID_MPEG2VIDEO,   AVMEDIA_TYPE_VIDEO},
 { "truehd", AV_CODEC_ID_TRUEHD,   AVMEDIA_TYPE_AUDIO},
+{ "evc",AV_CODEC_ID_EVC,  AVMEDIA_TYPE_VIDEO},
 { 0 }
 };
 int score;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1f436e21d6..435c9d905e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2502,6 +2502,7 @@ static int mov_finalize_stsd_codec(MOVContext *c, 
AVIOContext *pb,
 case AV_CODEC_ID_VP9:
 sti->need_parsing = AVSTREAM_PARSE_FULL;
 break;
+case AV_CODEC_ID_EVC:
 case AV_CODEC_ID_AV1:
 /* field_order detection of H264 requires parsing */
 case AV_CODEC_ID_H264:
@@ -9130,7 +9131,7 @@ const AVInputFormat ff_mov_demuxer = {
 .long_name  = NULL_IF_CONFIG_SMALL("QuickTime / MOV"),
 .priv_class = _class,
 .priv_data_size = sizeof(MOVContext),
-.extensions = "mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif",
+.extensions = 
"mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif,evc",
 .flags_internal = FF_FMT_INIT_CLEANUP,
 .read_probe = mov_probe,
 .read_header= mov_read_header,
-- 
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 v13 7/9] avformat/mov_muxer: Extended MOV muxer to handle EVC video content

2022-10-07 Thread Dawid Kozinski
- Changes in mov_write_video_tag function to handle EVC elementary stream
- Provided structure EVCDecoderConfigurationRecord that specifies the decoder 
configuration information for ISO/IEC 23094-1 video content

Signed-off-by: Dawid Kozinski 
---
 libavformat/Makefile|   2 +-
 libavformat/evc.c   | 455 
 libavformat/evc.h   |  44 
 libavformat/isom_tags.c |   2 +
 libavformat/movenc.c|  35 +++-
 5 files changed, 536 insertions(+), 2 deletions(-)
 create mode 100644 libavformat/evc.c
 create mode 100644 libavformat/evc.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index af175d2097..6ae5056c61 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -363,7 +363,7 @@ OBJS-$(CONFIG_MOV_DEMUXER)   += mov.o 
mov_chan.o mov_esds.o \
 OBJS-$(CONFIG_MOV_MUXER) += movenc.o av1.o avc.o hevc.o vpcc.o 
\
 movenchint.o mov_chan.o rtp.o \
 movenccenc.o movenc_ttml.o 
rawutils.o \
-dovi_isom.o
+dovi_isom.o evc.o
 OBJS-$(CONFIG_MP2_MUXER) += rawenc.o
 OBJS-$(CONFIG_MP3_DEMUXER)   += mp3dec.o replaygain.o
 OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o
diff --git a/libavformat/evc.c b/libavformat/evc.c
new file mode 100644
index 00..72c2759924
--- /dev/null
+++ b/libavformat/evc.c
@@ -0,0 +1,455 @@
+/*
+ * EVC helper functions for muxers
+ * Copyright (c) 2022 Dawid Kozinski 
+ *
+ * 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 "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/evc.h"
+#include "avformat.h"
+#include "avio.h"
+#include "evc.h"
+#include "avio_internal.h"
+
+// The length field that indicates the length in bytes of the following NAL 
unit is configured to be of 4 bytes
+#define EVC_NAL_UNIT_LENGTH_BYTE(4)  /* byte */
+#define EVC_NAL_HEADER_SIZE (2)  /* byte */
+
+// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: 
section 12.3.3.1
+enum {
+SPS_INDEX,
+PPS_INDEX,
+APS_INDEX,
+SEI_INDEX,
+NB_ARRAYS
+};
+
+// rpl structure
+typedef struct RefPicListStruct {
+int poc;
+int tid;
+int ref_pic_num;
+int ref_pic_active_num;
+int ref_pics[EVC_MAX_NUM_REF_PICS];
+char pic_type;
+
+} RefPicListStruct;
+
+// The sturcture reflects SPS RBSP(raw byte sequence payload) layout
+// @see ISO_IEC_23094-1 section 7.3.2.1
+//
+// The following descriptors specify the parsing process of each element
+// u(n) - unsigned integer using n bits
+// ue(v) - unsigned integer 0-th order Exp_Golomb-coded syntax element with 
the left bit first
+typedef struct EVCSPS {
+int sps_seq_parameter_set_id;   // ue(v)
+int profile_idc;// u(8)
+int level_idc;  // u(8)
+int toolset_idc_h;  // u(32)
+int toolset_idc_l;  // u(32)
+int chroma_format_idc;  // ue(v)
+int pic_width_in_luma_samples;  // ue(v)
+int pic_height_in_luma_samples; // ue(v)
+int bit_depth_luma_minus8;  // ue(v)
+int bit_depth_chroma_minus8;// ue(v)
+
+// @note
+// Currently the structure does not reflect the entire SPS RBSP layout.
+// It contains only the fields that are necessary to read from the NAL 
unit all the values
+// necessary for the correct initialization of 
EVCDecoderConfigurationRecord
+
+// @note
+// If necessary, add the missing fields to the structure to reflect
+// the contents of the entire NAL unit of the SPS type
+
+} EVCSPS;
+
+// @see ISO/IEC 14496-15:2021 Coding of audio-visual objects - Part 15: 
section 12.3.3.3
+typedef struct EVCNALUnitArray {
+uint8_t  array_completeness; // when equal to 1 indicates that all NAL 
units of the given type are in the following array
+uint8_t  NAL_unit_type;  // indicates the type of the NAL units in the 
following array
+uint16_t numNalus;   // indicates the number of NAL units of the 
indicated type
+uint16_t *nalUnitLength; // 

[FFmpeg-devel] [PATCH v13 6/9] avcodec/evc_decoder: Provided support for EVC decoder

2022-10-07 Thread Dawid Kozinski
- Added EVC decoder wrapper
- Changes in project configuration file and libavcodec Makefile
- Added documentation for xevd wrapper

Signed-off-by: Dawid Kozinski 
---
 configure |   4 +
 doc/decoders.texi |  24 +++
 doc/general_contents.texi |  10 +-
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libxevd.c  | 423 ++
 6 files changed, 462 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/libxevd.c

diff --git a/configure b/configure
index 7f430995a6..0adbd4291e 100755
--- a/configure
+++ b/configure
@@ -292,6 +292,7 @@ External library support:
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
   --enable-libxeve enable EVC encoding via libxeve [no]
+  --enable-libxevd enable EVC decoding via libxevd [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1877,6 +1878,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libwebp
+libxevd
 libxeve
 libxml2
 libzimg
@@ -3409,6 +3411,7 @@ libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
+libxevd_decoder_deps="libxevd"
 libxeve_encoder_deps="libxeve"
 libxvid_encoder_deps="libxvid"
 libzvbi_teletext_decoder_deps="libzvbi"
@@ -6742,6 +6745,7 @@ enabled libx265   && require_pkg_config libx265 
x265 x265.h x265_api_get
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
+enabled libxevd   && require_pkg_config libxevd "xevd >= 0.4.0" 
"xevd.h" xevd_decode
 enabled libxeve   && require_pkg_config libxeve "xeve >= 0.4.0" 
"xeve.h" xeve_encode
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h 
zimg_get_api_version
diff --git a/doc/decoders.texi b/doc/decoders.texi
index e2fcbf5dc9..0bd9096114 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -126,6 +126,30 @@ Set amount of frame threads to use during decoding. The 
default value is 0 (auto
 
 @end table
 
+@section libxevd
+
+eXtra-fast Essential Video Decoder (XEVD) MPEG-5 EVC decoder wrapper.
+
+This decoder requires the presence of the libxevd headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxevd}.
+
+The xevd project website is at @url{https://github.com/mpeg5/xevd}.
+
+@subsection Options
+
+The following options are supported by the libxevd wrapper.
+The xevd-equivalent options or values are listed in parentheses for easy 
migration.
+
+To get a more accurate and extensive documentation of the libxevd options,
+invoke the command  @code{xevd_app --help} or consult the libxevd 
documentation.
+
+@table @option
+@item threads (@emph{threads})
+Force to use a specific number of threads
+
+@end table
+
 @section QSV Decoders
 
 The family of Intel QuickSync Video decoders (VC1, MPEG-2, H.264, HEVC,
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 417f0ab64f..0d9daf43a7 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -351,6 +351,14 @@ Go to @url{https://github.com/mpeg5/xeve} and follow the 
instructions for
 installing the XEVE library. Then pass @code{--enable-libxeve} to configure to
 enable it.
 
+@section eXtra-fast Essential Video Decoder (XEVD)
+
+FFmpeg can make use of the XEVD library for EVC video decoding.
+
+Go to @url{https://github.com/mpeg5/xevd} and follow the instructions for
+installing the XEVD library. Then pass @code{--enable-libxevd} to configure to
+enable it.
+
 @section ZVBI
 
 ZVBI is a VBI decoding library which can be used by FFmpeg to decode DVB
@@ -944,7 +952,7 @@ following image formats are supported:
 @item Escape 124 @tab @tab  X
 @item Escape 130 @tab @tab  X
 @item EVC / MPEG-5 Part 1@tab  X  @tab  X
-@tab encoding supported through external library libxeve
+@tab encoding and decoding supported through external libraries libxeve 
and libxevd
 @item FFmpeg video codec #1  @tab  X  @tab  X
 @tab lossless codec (fourcc: FFV1)
 @item Flash Screen Video v1  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8944e2a0d6..f2799ae19b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1107,6 +1107,7 @@ OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 

[FFmpeg-devel] [PATCH v13 5/9] avcodec/evc_encoder: Provided support for EVC encoder

2022-10-07 Thread Dawid Kozinski
- Added EVC encoder wrapper
- Changes in project configuration file and libavcodec Makefile
- Added documentation for xeve wrapper

Signed-off-by: Dawid Kozinski 
---
 configure |   4 +
 doc/encoders.texi |  69 +
 doc/general_contents.texi |  11 +
 libavcodec/Makefile   |   1 +
 libavcodec/allcodecs.c|   1 +
 libavcodec/libxeve.c  | 615 ++
 6 files changed, 701 insertions(+)
 create mode 100644 libavcodec/libxeve.c

diff --git a/configure b/configure
index 957b7fe13e..7f430995a6 100755
--- a/configure
+++ b/configure
@@ -291,6 +291,7 @@ External library support:
   --enable-libwebp enable WebP encoding via libwebp [no]
   --enable-libx264 enable H.264 encoding via x264 [no]
   --enable-libx265 enable HEVC encoding via x265 [no]
+  --enable-libxeve enable EVC encoding via libxeve [no]
   --enable-libxavs enable AVS encoding via xavs [no]
   --enable-libxavs2enable AVS2 encoding via xavs2 [no]
   --enable-libxcb  enable X11 grabbing using XCB [autodetect]
@@ -1876,6 +1877,7 @@ EXTERNAL_LIBRARY_LIST="
 libvorbis
 libvpx
 libwebp
+libxeve
 libxml2
 libzimg
 libzmq
@@ -3407,6 +3409,7 @@ libx264rgb_encoder_select="libx264_encoder"
 libx265_encoder_deps="libx265"
 libxavs_encoder_deps="libxavs"
 libxavs2_encoder_deps="libxavs2"
+libxeve_encoder_deps="libxeve"
 libxvid_encoder_deps="libxvid"
 libzvbi_teletext_decoder_deps="libzvbi"
 vapoursynth_demuxer_deps="vapoursynth"
@@ -6739,6 +6742,7 @@ enabled libx265   && require_pkg_config libx265 
x265 x265.h x265_api_get
  require_cpp_condition libx265 x265.h "X265_BUILD 
>= 70"
 enabled libxavs   && require libxavs "stdint.h xavs.h" 
xavs_encoder_encode "-lxavs $pthreads_extralibs $libm_extralibs"
 enabled libxavs2  && require_pkg_config libxavs2 "xavs2 >= 1.3.0" 
"stdint.h xavs2.h" xavs2_api_get
+enabled libxeve   && require_pkg_config libxeve "xeve >= 0.4.0" 
"xeve.h" xeve_encode
 enabled libxvid   && require libxvid xvid.h xvid_global -lxvidcore
 enabled libzimg   && require_pkg_config libzimg "zimg >= 2.7.0" zimg.h 
zimg_get_api_version
 enabled libzmq&& require_pkg_config libzmq "libzmq >= 4.2.1" zmq.h 
zmq_ctx_new
diff --git a/doc/encoders.texi b/doc/encoders.texi
index 1a5216f8eb..4c8c2871ec 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -2894,6 +2894,75 @@ ffmpeg -i input -c:v libxavs2 -xavs2-params RdoqLevel=0 
output.avs2
 @end example
 @end table
 
+@section libxeve
+
+eXtra-fast Essential Video Encoder (XEVE) MPEG-5 EVC encoder wrapper.
+The xeve-equivalent options or values are listed in parentheses for easy 
migration.
+
+This encoder requires the presence of the libxeve headers and library
+during configuration. You need to explicitly configure the build with
+@option{--enable-libxeve}.
+
+@float NOTE
+Many libxeve encoder options are mapped to FFmpeg global codec options,
+while unique encoder options are provided through private options.
+Additionally the xeve-params private options allows one to pass a list
+of key=value tuples as accepted by the libxeve @code{parse_xeve_params} 
function.
+@end float
+
+The xeve project website is at @url{https://github.com/mpeg5/xeve}.
+
+@subsection Options
+
+The following options are supported by the libxeve wrapper.
+The xeve-equivalent options or values are listed in parentheses for easy 
migration.
+
+@float NOTE
+To reduce the duplication of documentation, only the private options
+and some others requiring special attention are documented here. For
+the documentation of the undocumented generic options, see
+@ref{codec-options,,the Codec Options chapter}.
+@end float
+
+@float NOTE
+To get a more accurate and extensive documentation of the libxeve options,
+invoke the command  @code{xeve_app --help} or consult the libxeve 
documentation.
+@end float
+
+@table @option
+@item b (@emph{bitrate})
+Set target video bitrate in bits/s.
+Note that FFmpeg's b option is expressed in bits/s, while xeve's bitrate is in 
kilobits/s.
+
+@item bf (@emph{bframes})
+Set the maximum number of B frames (1,3,7,15).
+
+@item g (@emph{keyint})
+Set the GOP size (I-picture period).
+
+@item preset (@emph{preset})
+Set the xeve preset.
+Set the encoder preset value to determine encoding speed [fast, medium, slow, 
placebo]
+
+@item tune (@emph{tune})
+Set the encoder tune parameter [psnr, zerolatency]
+
+@item profile (@emph{profile})
+Set the encoder profile [0: baselie; 1: main]
+
+@item crf (@emph{crf})
+Set the quality for constant quality mode.
+Constant rate factor <10..49> [default: 32]
+
+@item qp (@emph{qp})
+Set constant quantization rate control method parameter.
+Quantization parameter qp <0..51> [default: 32]
+
+@item threads (@emph{threads})
+Force to use a specific number of threads
+
+@end table
+
 @section libxvid
 
 Xvid MPEG-4 Part 2 encoder wrapper.
diff 

[FFmpeg-devel] [PATCH v13 4/9] avformat/evc_demuxer: Added demuxer to handle reading EVC video files

2022-10-07 Thread Dawid Kozinski
- Provided AVInputFormat structure describing EVC input format (ff_evc_demuxer)

Signed-off-by: Dawid Kozinski 
---
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/evcdec.c | 124 +++
 3 files changed, 126 insertions(+)
 create mode 100644 libavformat/evcdec.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index a14a759c1f..af175d2097 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -251,6 +251,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_DEMUXER)   += evcdec.o rawdec.o
 OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 615d2bc3b1..e4cc112b90 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -150,6 +150,7 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVInputFormat  ff_evc_demuxer;
 extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
diff --git a/libavformat/evcdec.c b/libavformat/evcdec.c
new file mode 100644
index 00..ffb7449c4d
--- /dev/null
+++ b/libavformat/evcdec.c
@@ -0,0 +1,124 @@
+/*
+ * RAW EVC video demuxer
+ *
+ * Copyright (c) 2021 Dawid Kozinski 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/internal.h"
+#include "libavcodec/evc.h"
+
+#include "rawdec.h"
+#include "avformat.h"
+
+typedef struct EVCParserContext {
+int got_sps;
+int got_pps;
+int got_idr;
+int got_nonidr;
+} EVCParserContext;
+
+static int get_nalu_type(const uint8_t *bits, int bits_size)
+{
+int unit_type_plus1 = 0;
+
+if(bits_size >= EVC_NAL_HEADER_SIZE) {
+unsigned char *p = (unsigned char *)bits;
+// forbidden_zero_bit
+if ((p[0] & 0x80) != 0) { // Cannot get bitstream information. 
Malformed bitstream.
+return -1;
+}
+
+// nal_unit_type
+unit_type_plus1 = (p[0] >> 1) & 0x3F;
+}
+
+return unit_type_plus1 - 1;
+}
+
+static uint32_t read_nal_unit_length(const uint8_t *bits, int bits_size)
+{
+uint32_t nalu_len = 0;
+
+if(bits_size >= EVC_NAL_UNIT_LENGTH_BYTE) {
+
+int t = 0;
+unsigned char *p = (unsigned char *)bits;
+
+for(int i=0; ibuf;
+int bytes_to_read = p->buf_size;
+
+while(bytes_to_read > EVC_NAL_UNIT_LENGTH_BYTE) {
+
+nalu_size = read_nal_unit_length(bits, EVC_NAL_UNIT_LENGTH_BYTE);
+if(nalu_size == 0) break;
+
+bits += EVC_NAL_UNIT_LENGTH_BYTE;
+bytes_to_read -= EVC_NAL_UNIT_LENGTH_BYTE;
+
+if(bytes_to_read < nalu_size) break;
+
+nalu_type = get_nalu_type(bits, bytes_to_read);
+
+bits += nalu_size;
+bytes_to_read -= nalu_size;
+
+if (nalu_type == EVC_SPS_NUT)
+ev->got_sps++;
+else if (nalu_type == EVC_PPS_NUT)
+ev->got_pps++;
+else if (nalu_type == EVC_IDR_NUT )
+ev->got_idr++;
+else if (nalu_type == EVC_NOIDR_NUT)
+ev->got_nonidr++;
+}
+
+return 0;
+}
+
+static int evc_probe(const AVProbeData *p)
+{
+EVCParserContext ev = {0};
+int ret = parse_nal_units(p, );
+
+if (ret == 0 && ev.got_sps && ev.got_pps && (ev.got_idr || ev.got_nonidr > 
3))
+return AVPROBE_SCORE_EXTENSION + 1;  // 1 more than .mpg
+
+return 0;
+}
+
+FF_DEF_RAWVIDEO_DEMUXER(evc, "raw EVC video", evc_probe, "evc", 
AV_CODEC_ID_EVC)
-- 
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] [PATCH v13 3/9] avformat/evc_muxer: Added muxer to handle writing EVC encoded data into file or output bytestream

2022-10-07 Thread Dawid Kozinski
- Provided AVOutputFormat structure describing EVC output format (ff_evc_muxer)
- Added documentation for EVC muxer

Signed-off-by: Dawid Kozinski 
---
 doc/muxers.texi  |  6 ++
 libavformat/Makefile |  1 +
 libavformat/allformats.c |  1 +
 libavformat/rawenc.c | 13 +
 4 files changed, 21 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index b2f4326aae..08ab20c09e 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -2124,6 +2124,12 @@ DTS Coherent Acoustics (DCA) audio.
 
 Dolby Digital Plus, also known as Enhanced AC-3, audio.
 
+@subsection evc
+
+MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video.
+
+Extensions: evc
+
 @subsection g722
 
 ITU-T G.722 audio.
diff --git a/libavformat/Makefile b/libavformat/Makefile
index d7f198bf39..a14a759c1f 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -251,6 +251,7 @@ OBJS-$(CONFIG_HCOM_DEMUXER)  += hcom.o pcm.o
 OBJS-$(CONFIG_HDS_MUXER) += hdsenc.o
 OBJS-$(CONFIG_HEVC_DEMUXER)  += hevcdec.o rawdec.o
 OBJS-$(CONFIG_HEVC_MUXER)+= rawenc.o
+OBJS-$(CONFIG_EVC_MUXER) += rawenc.o
 OBJS-$(CONFIG_HLS_DEMUXER)   += hls.o hls_sample_encryption.o
 OBJS-$(CONFIG_HLS_MUXER) += hlsenc.o hlsplaylist.o avc.o
 OBJS-$(CONFIG_HNM_DEMUXER)   += hnm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 47c419a009..615d2bc3b1 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -150,6 +150,7 @@ extern const AVInputFormat  ff_ea_cdata_demuxer;
 extern const AVInputFormat  ff_eac3_demuxer;
 extern const AVOutputFormat ff_eac3_muxer;
 extern const AVInputFormat  ff_epaf_demuxer;
+extern const AVOutputFormat ff_evc_muxer;
 extern const AVOutputFormat ff_f4v_muxer;
 extern const AVInputFormat  ff_ffmetadata_demuxer;
 extern const AVOutputFormat ff_ffmetadata_muxer;
diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index 267fce252d..b7b2aff453 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -401,6 +401,19 @@ const AVOutputFormat ff_hevc_muxer = {
 };
 #endif
 
+#if CONFIG_EVC_MUXER
+AVOutputFormat ff_evc_muxer = {
+.name  = "evc",
+.long_name = NULL_IF_CONFIG_SMALL("raw EVC video"),
+.extensions= "evc",
+.audio_codec   = AV_CODEC_ID_NONE,
+.video_codec   = AV_CODEC_ID_EVC,
+.write_header  = force_one_stream,
+.write_packet  = ff_raw_write_packet,
+.flags = AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_M4V_MUXER
 const AVOutputFormat ff_m4v_muxer = {
 .name  = "m4v",
-- 
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 v13 2/9] avcodec/evc_parser: Added parser implementaion for EVC format

2022-10-07 Thread Dawid Kozinski
Signed-off-by: Dawid Kozinski 
---
 libavcodec/Makefile |   1 +
 libavcodec/evc.h| 155 +
 libavcodec/evc_parser.c | 725 
 libavcodec/parsers.c|   1 +
 4 files changed, 882 insertions(+)
 create mode 100644 libavcodec/evc.h
 create mode 100644 libavcodec/evc_parser.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 592d9347f6..0fdf141d54 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1134,6 +1134,7 @@ OBJS-$(CONFIG_DVAUDIO_PARSER)  += dvaudio_parser.o
 OBJS-$(CONFIG_DVBSUB_PARSER)   += dvbsub_parser.o
 OBJS-$(CONFIG_DVD_NAV_PARSER)  += dvd_nav_parser.o
 OBJS-$(CONFIG_DVDSUB_PARSER)   += dvdsub_parser.o
+OBJS-$(CONFIG_EVC_PARSER)  += evc_parser.o
 OBJS-$(CONFIG_FLAC_PARSER) += flac_parser.o flacdata.o flac.o
 OBJS-$(CONFIG_FTR_PARSER)  += ftr_parser.o
 OBJS-$(CONFIG_G723_1_PARSER)   += g723_1_parser.o
diff --git a/libavcodec/evc.h b/libavcodec/evc.h
new file mode 100644
index 00..b3e648796c
--- /dev/null
+++ b/libavcodec/evc.h
@@ -0,0 +1,155 @@
+/*
+ * EVC definitions and enums
+ * Copyright (c) 2022 Dawid Kozinski 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_EVC_H
+#define AVCODEC_EVC_H
+
+// The length field that indicates the length in bytes of the following NAL 
unit is configured to be of 4 bytes
+#define EVC_NAL_UNIT_LENGTH_BYTE(4)  /* byte */
+#define EVC_NAL_HEADER_SIZE (2)  /* byte */
+
+/**
+ * @see ISO_IEC_23094-1_2020, 7.4.2.2 NAL unit header semantic
+ *  Table 4 - NAL unit type codes and NAL unit type classes
+ */
+enum EVCNALUnitType {
+EVC_NOIDR_NUT= 0,   /* Coded slice of a non-IDR picture */
+EVC_IDR_NUT  = 1,   /* Coded slice of an IDR picture */
+EVC_RSV_VCL_NUT02= 2,
+EVC_RSV_VCL_NUT03= 3,
+EVC_RSV_VCL_NUT04= 4,
+EVC_RSV_VCL_NUT05= 5,
+EVC_RSV_VCL_NUT06= 6,
+EVC_RSV_VCL_NUT07= 7,
+EVC_RSV_VCL_NUT08= 8,
+EVC_RSV_VCL_NUT09= 9,
+EVC_RSV_VCL_NUT10= 10,
+EVC_RSV_VCL_NUT11= 11,
+EVC_RSV_VCL_NUT12= 12,
+EVC_RSV_VCL_NUT13= 13,
+EVC_RSV_VCL_NUT14= 14,
+EVC_RSV_VCL_NUT15= 15,
+EVC_RSV_VCL_NUT16= 16,
+EVC_RSV_VCL_NUT17= 17,
+EVC_RSV_VCL_NUT18= 18,
+EVC_RSV_VCL_NUT19= 19,
+EVC_RSV_VCL_NUT20= 20,
+EVC_RSV_VCL_NUT21= 21,
+EVC_RSV_VCL_NUT22= 22,
+EVC_RSV_VCL_NUT23= 23,
+EVC_SPS_NUT  = 24,  /* Sequence parameter set */
+EVC_PPS_NUT  = 25,  /* Picture paremeter set */
+EVC_APS_NUT  = 26,  /* Adaptation parameter set */
+EVC_FD_NUT   = 27,  /* Filler data */
+EVC_SEI_NUT  = 28,  /* Supplemental enhancement information */
+EVC_RSV_NONVCL29 = 29,
+EVC_RSV_NONVCL30 = 30,
+EVC_RSV_NONVCL31 = 31,
+EVC_RSV_NONVCL32 = 32,
+EVC_RSV_NONVCL33 = 33,
+EVC_RSV_NONVCL34 = 34,
+EVC_RSV_NONVCL35 = 35,
+EVC_RSV_NONVCL36 = 36,
+EVC_RSV_NONVCL37 = 37,
+EVC_RSV_NONVCL38 = 38,
+EVC_RSV_NONVCL39 = 39,
+EVC_RSV_NONVCL40 = 40,
+EVC_RSV_NONVCL41 = 41,
+EVC_RSV_NONVCL42 = 42,
+EVC_RSV_NONVCL43 = 43,
+EVC_RSV_NONVCL44 = 44,
+EVC_RSV_NONVCL45 = 45,
+EVC_RSV_NONVCL46 = 46,
+EVC_RSV_NONVCL47 = 47,
+EVC_RSV_NONVCL48 = 48,
+EVC_RSV_NONVCL49 = 49,
+EVC_RSV_NONVCL50 = 50,
+EVC_RSV_NONVCL51 = 51,
+EVC_RSV_NONVCL52 = 52,
+EVC_RSV_NONVCL53 = 53,
+EVC_RSV_NONVCL54 = 54,
+EVC_RSV_NONVCL55 = 55,
+EVC_UNSPEC_NUT56 = 56,
+EVC_UNSPEC_NUT57 = 57,
+EVC_UNSPEC_NUT58 = 58,
+EVC_UNSPEC_NUT59 = 59,
+EVC_UNSPEC_NUT60 = 60,
+EVC_UNSPEC_NUT61 = 61,
+EVC_UNSPEC_NUT62 = 62
+};
+
+// slice type
+// @see ISO_IEC_23094-1_2020 7.4.5 Slice header semantics

[FFmpeg-devel] [PATCH v13 1/9] avcodec/evc: MPEG-5 EVC codec registration

2022-10-07 Thread Dawid Kozinski
Added prerequisites that must be met before providing support for the MPEG-5 
EVC codec
- Added new entry to codec IDs list
- Added new entry to the codec descriptor list
- Bumped libavcodec minor version
- Added profiles for EVC codec

Signed-off-by: Dawid Kozinski 
---
 libavcodec/avcodec.h| 3 +++
 libavcodec/codec_desc.c | 8 
 libavcodec/codec_id.h   | 1 +
 libavcodec/profiles.c   | 6 ++
 libavcodec/profiles.h   | 1 +
 libavcodec/version.h| 2 +-
 6 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7365eb5cc0..43f3732b58 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1668,6 +1668,9 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_KLVA_SYNC 0
 #define FF_PROFILE_KLVA_ASYNC 1
 
+#define FF_PROFILE_EVC_BASELINE 0
+#define FF_PROFILE_EVC_MAIN 1
+
 /**
  * level
  * - encoding: Set by user.
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 93b18f9072..6f745e5499 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1916,6 +1916,14 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("Media 100i"),
 .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY,
 },
+{
+.id= AV_CODEC_ID_EVC,
+.type  = AVMEDIA_TYPE_VIDEO,
+.name  = "evc",
+.long_name = NULL_IF_CONFIG_SMALL("MPEG-5 EVC (Essential Video 
Coding)"),
+.props = AV_CODEC_PROP_LOSSY | AV_CODEC_PROP_REORDER,
+.profiles  = NULL_IF_CONFIG_SMALL(ff_evc_profiles),
+},
 
 /* various PCM "codecs" */
 {
diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h
index 82874daaa3..84cb9edc0b 100644
--- a/libavcodec/codec_id.h
+++ b/libavcodec/codec_id.h
@@ -319,6 +319,7 @@ enum AVCodecID {
 AV_CODEC_ID_RADIANCE_HDR,
 AV_CODEC_ID_WBMP,
 AV_CODEC_ID_MEDIA100,
+AV_CODEC_ID_EVC,
 
 /* various PCM "codecs" */
 AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the 
start of audio codecs
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 7af7fbeb13..a31244e0db 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -181,4 +181,10 @@ const AVProfile ff_arib_caption_profiles[] = {
 { FF_PROFILE_UNKNOWN }
 };
 
+const AVProfile ff_evc_profiles[] = {
+{ FF_PROFILE_EVC_BASELINE, "Baseline"  },
+{ FF_PROFILE_EVC_MAIN, "Main"  },
+{ FF_PROFILE_UNKNOWN },
+};
+
 #endif /* !CONFIG_SMALL */
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 41a19aa9ad..cf92b5f126 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -72,5 +72,6 @@ extern const AVProfile ff_sbc_profiles[];
 extern const AVProfile ff_prores_profiles[];
 extern const AVProfile ff_mjpeg_profiles[];
 extern const AVProfile ff_arib_caption_profiles[];
+extern const AVProfile ff_evc_profiles[];
 
 #endif /* AVCODEC_PROFILES_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ade18cddcd..f8abc803b6 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #include "version_major.h"
 
-#define LIBAVCODEC_VERSION_MINOR  50
+#define LIBAVCODEC_VERSION_MINOR  51
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
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".