[FFmpeg-devel] [PATCH v3 10/10] fate: add tests for xHE-AAC

2024-05-24 Thread Lynne via ffmpeg-devel
Starting off small with a few features.
Samples and reference decoded files copied from the official ISO
reference suite.

FATE files: https://files.lynne.ee/xhe_refs/
---
 tests/fate/aac.mak | 8 
 1 file changed, 8 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 817944773d..ff58392ad9 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -62,6 +62,14 @@ FATE_AAC += fate-aac-ap05_48
 fate-aac-ap05_48: CMD = pcm -i $(TARGET_SAMPLES)/aac/ap05_48.mp4
 fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16
 
+FATE_AAC += fate-aac-fd_2_c1_ms_0x01
+fate-aac-fd_2_c1_ms_0x01: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x01.mp4
+fate-aac-fd_2_c1_ms_0x01: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x01.s16
+
+FATE_AAC += fate-aac-fd_2_c1_ms_0x04
+fate-aac-fd_2_c1_ms_0x04: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/Fd_2_c1_Ms_0x04.mp4
+fate-aac-fd_2_c1_ms_0x04: REF = $(SAMPLES)/aac/Fd_2_c1_Ms_0x04.s16
+
 FATE_AAC += fate-aac-er_ad6000np_44_ep0
 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4
 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16
-- 
2.43.0.381.gb435a96ce8
___
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 v3 09/10] aacdec: add a decoder for AAC USAC (xHE-AAC)

2024-05-24 Thread Lynne via ffmpeg-devel
This commit adds a decoder for the frequency-domain part of USAC.

What works:
 - Mono
 - Stereo (no prediction)
 - Stereo (mid/side coding)
 - Stereo (complex prediction)

What's left:
 - Speech coding

Known issues:
 - Desync with certain sequences
 - Preroll crossover missing (shouldn't matter, bitrate adaptation only)
---
 libavcodec/aac/Makefile  |3 +-
 libavcodec/aac/aacdec.c  |  188 +--
 libavcodec/aac/aacdec.h  |  187 +++
 libavcodec/aac/aacdec_ac.c   |  208 
 libavcodec/aac/aacdec_ac.h   |   54 +
 libavcodec/aac/aacdec_dsp_template.c |4 +-
 libavcodec/aac/aacdec_latm.h |   14 +-
 libavcodec/aac/aacdec_lpd.c  |  198 
 libavcodec/aac/aacdec_lpd.h  |   33 +
 libavcodec/aac/aacdec_usac.c | 1592 ++
 libavcodec/aac/aacdec_usac.h |   37 +
 libavcodec/aactab.c  |   42 +
 libavcodec/aactab.h  |   10 +
 13 files changed, 2494 insertions(+), 76 deletions(-)
 create mode 100644 libavcodec/aac/aacdec_ac.c
 create mode 100644 libavcodec/aac/aacdec_ac.h
 create mode 100644 libavcodec/aac/aacdec_lpd.c
 create mode 100644 libavcodec/aac/aacdec_lpd.h
 create mode 100644 libavcodec/aac/aacdec_usac.c
 create mode 100644 libavcodec/aac/aacdec_usac.h

diff --git a/libavcodec/aac/Makefile b/libavcodec/aac/Makefile
index c3e525d373..70b1dca274 100644
--- a/libavcodec/aac/Makefile
+++ b/libavcodec/aac/Makefile
@@ -2,6 +2,7 @@ clean::
$(RM) $(CLEANSUFFIXES:%=libavcodec/aac/%)
 
 OBJS-$(CONFIG_AAC_DECODER)  +=  aac/aacdec.o aac/aacdec_tab.o \
-aac/aacdec_float.o
+aac/aacdec_float.o aac/aacdec_usac.o \
+aac/aacdec_ac.o aac/aacdec_lpd.o
 OBJS-$(CONFIG_AAC_FIXED_DECODER)+=  aac/aacdec.o aac/aacdec_tab.o \
 aac/aacdec_fixed.o
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 6f37ac5361..2b8322fc68 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -40,6 +40,7 @@
 
 #include "aacdec.h"
 #include "aacdec_tab.h"
+#include "aacdec_usac.h"
 
 #include "libavcodec/aac.h"
 #include "libavcodec/aac_defines.h"
@@ -535,6 +536,8 @@ static av_cold void flush(AVCodecContext *avctx)
 }
 }
 }
+
+ff_aac_usac_reset_state(ac, >oc[1]);
 }
 
 /**
@@ -993,13 +996,14 @@ static int decode_eld_specific_config(AACDecContext *ac, 
AVCodecContext *avctx,
  */
 static int decode_audio_specific_config_gb(AACDecContext *ac,
AVCodecContext *avctx,
-   MPEG4AudioConfig *m4ac,
+   OutputConfiguration *oc,
GetBitContext *gb,
int get_bit_alignment,
int sync_extension)
 {
 int i, ret;
 GetBitContext gbc = *gb;
+MPEG4AudioConfig *m4ac = >m4ac;
 MPEG4AudioConfig m4ac_bak = *m4ac;
 
 if ((i = ff_mpeg4audio_get_config_gb(m4ac, , sync_extension, avctx)) < 
0) {
@@ -1033,14 +1037,22 @@ static int 
decode_audio_specific_config_gb(AACDecContext *ac,
 case AOT_ER_AAC_LC:
 case AOT_ER_AAC_LD:
 if ((ret = decode_ga_specific_config(ac, avctx, gb, get_bit_alignment,
-m4ac, m4ac->chan_config)) < 0)
+ >m4ac, m4ac->chan_config)) < 
0)
 return ret;
 break;
 case AOT_ER_AAC_ELD:
 if ((ret = decode_eld_specific_config(ac, avctx, gb,
-  m4ac, m4ac->chan_config)) < 0)
+  >m4ac, m4ac->chan_config)) < 
0)
+return ret;
+break;
+#if CONFIG_AAC_DECODER
+case AOT_USAC_NOSBR: /* fallthrough */
+case AOT_USAC:
+if ((ret = ff_aac_usac_config_decode(ac, avctx, gb,
+ oc, m4ac->chan_config)) < 0)
 return ret;
 break;
+#endif
 default:
 avpriv_report_missing_feature(avctx,
   "Audio object type %s%d",
@@ -1060,7 +1072,7 @@ static int decode_audio_specific_config_gb(AACDecContext 
*ac,
 
 static int decode_audio_specific_config(AACDecContext *ac,
 AVCodecContext *avctx,
-MPEG4AudioConfig *m4ac,
+OutputConfiguration *oc,
 const uint8_t *data, int64_t bit_size,
 int sync_extension)
 {
@@ -1080,7 +1092,7 @@ static int decode_audio_specific_config(AACDecContext *ac,
 if ((ret = init_get_bits(, data, bit_size)) < 0)
 return ret;
 
-return 

[FFmpeg-devel] [PATCH v3 08/10] aactab: add new scalefactor offset tables for 96/768pt windows

2024-05-24 Thread Lynne via ffmpeg-devel
---
 libavcodec/aactab.c | 117 
 libavcodec/aactab.h |   4 ++
 2 files changed, 121 insertions(+)

diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index dfb2dfd98d..18afa69bad 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -154,6 +154,10 @@ const uint8_t ff_aac_num_swb_960[] = {
 40, 40, 46, 49, 49, 49, 46, 46, 42, 42, 42, 40, 40
 };
 
+const uint8_t ff_aac_num_swb_768[] = {
+37, 37, 41, 43, 43, 43, 43, 43, 39, 39, 39, 37, 37
+};
+
 const uint8_t ff_aac_num_swb_512[] = {
  0,  0,  0, 36, 36, 37, 31, 31,  0,  0,  0,  0,  0
 };
@@ -170,6 +174,10 @@ const uint8_t ff_aac_num_swb_120[] = {
 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
 };
 
+const uint8_t ff_aac_num_swb_96[] = {
+12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14
+};
+
 const uint8_t ff_aac_pred_sfb_max[] = {
 33, 33, 38, 40, 40, 40, 41, 41, 37, 37, 37, 34, 34
 };
@@ -1806,6 +1814,99 @@ static const uint16_t swb_offset_120_8[] =
 0, 4, 8, 12, 16,  20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 120
 };
 
+static const uint16_t swb_offset_768_96[] =
+{
+0,   4,   8,   12,  16,  20,  24,  28,  32,  36,
+40,  44,  48,  52,  56,  64,  72,  80,  88,  96,
+108, 120, 132, 144, 156, 172, 188, 212, 240, 276,
+320, 384, 448, 512, 576, 640, 704, 768
+};
+
+static const uint16_t swb_offset_768_64[] =
+{
+0,   4,   8,   12,  16,  20,  24,  28,  32,  36,  40,
+44,  48,  52,  56,  64,  72,  80,  88,  100, 112, 124,
+140, 156, 172, 192, 216, 240, 268, 304, 344, 384, 424,
+464, 504, 544, 584, 624, 664, 704, 744, 768
+};
+
+static const uint16_t swb_offset_768_48[] =
+{
+0,   4,   8,   12,  16,  20,  24,  28,  32,  36,  40,  48,
+56,  64,  72,  80,  88,  96,  108, 120, 132, 144, 160, 176,
+196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512,
+544, 576, 608, 640, 672, 704, 736, 768
+};
+
+static const uint16_t swb_offset_768_32[] =
+{
+0,   4,   8,   12,  16,  20,  24,  28,  32,  36,  40,  48,
+56,  64,  72,  80,  88,  96,  108, 120, 132, 144, 160, 176,
+196, 216, 240, 264, 292, 320, 352, 384, 416, 448, 480, 512,
+544, 576, 608, 640, 672, 704, 736, 768
+};
+
+static const uint16_t swb_offset_768_24[] =
+{
+0,   4,   8,   12,  16,  20,  24,  28,  32,  36,  40,  44,
+52,  60,  68,  76,  84,  92,  100, 108, 116, 124, 136, 148,
+160, 172, 188, 204, 220, 240, 260, 284, 308, 336, 364, 396,
+432, 468, 508, 552, 600, 652, 704, 768
+};
+
+static const uint16_t swb_offset_768_16[] =
+{
+0,   8,   16,  24,  32,  40,  48,  56,  64,
+72,  80,  88,  100, 112, 124, 136, 148, 160,
+172, 184, 196, 212, 228, 244, 260, 280, 300,
+320, 344, 368, 396, 424, 456, 492, 532, 572,
+616, 664, 716, 768
+};
+
+static const uint16_t swb_offset_768_8[] =
+{
+0,   12,  24,  36,  48,  60,  72,  84,  96,  108,
+120, 132, 144, 156, 172, 188, 204, 220, 236, 252,
+268, 288, 308, 328, 348, 372, 396, 420, 448, 476,
+508, 544, 580, 620, 664, 712, 764, 768
+};
+
+static const uint16_t swb_offset_96_96[] =
+{
+0,  4,  8,  12, 16, 20, 24,
+32, 40, 48, 64, 92, 96
+};
+
+static const uint16_t swb_offset_96_64[] =
+{
+0,  4,  8,  12, 16, 20, 24,
+32, 40, 48, 64, 92, 96
+};
+
+static const uint16_t swb_offset_96_48[] =
+{
+0,  4,  8,  12, 16, 20, 28,
+36, 44, 56, 68, 80, 96
+};
+
+static const uint16_t swb_offset_96_24[] =
+{
+0,  4,  8,  12, 16, 20, 24, 28,
+36, 44, 52, 64, 76, 92, 96
+};
+
+static const uint16_t swb_offset_96_16[] =
+{
+0,  4,  8,  12, 16, 20, 24, 28,
+32, 40, 48, 60, 72, 88, 96
+};
+
+static const uint16_t swb_offset_96_8[] =
+{
+0,  4,  8,  12, 16, 20, 24, 28,
+36, 44, 52, 60, 72, 88, 96
+};
+
 const uint16_t * const ff_swb_offset_1024[] = {
 swb_offset_1024_96, swb_offset_1024_96, swb_offset_1024_64,
 swb_offset_1024_48, swb_offset_1024_48, swb_offset_1024_32,
@@ -1822,6 +1923,14 @@ const uint16_t * const ff_swb_offset_960[] = {
 swb_offset_960_8
 };
 
+const uint16_t * const ff_swb_offset_768[] = {
+swb_offset_768_96, swb_offset_768_96, swb_offset_768_64,
+swb_offset_768_48, swb_offset_768_48, swb_offset_768_32,
+swb_offset_768_24, swb_offset_768_24, swb_offset_768_16,
+swb_offset_768_16, swb_offset_768_16, swb_offset_768_8,
+swb_offset_768_8
+};
+
 const uint16_t * const ff_swb_offset_512[] = {
 NULL,   NULL,   NULL,
 swb_offset_512_48,  swb_offset_512_48,  swb_offset_512_32,
@@ -1856,6 +1965,14 @@ const uint16_t * const ff_swb_offset_120[] = {
 swb_offset_120_8
 };
 
+const uint16_t * const ff_swb_offset_96[] = {
+swb_offset_96_96, swb_offset_96_96, swb_offset_96_96,
+swb_offset_96_48, swb_offset_96_48, swb_offset_96_48,
+swb_offset_96_24, swb_offset_96_24, swb_offset_96_16,
+swb_offset_96_16, swb_offset_96_16, swb_offset_96_8,
+swb_offset_96_8
+};
+
 // @}
 
 /* @name ff_tns_max_bands
diff --git a/libavcodec/aactab.h 

[FFmpeg-devel] [PATCH v3 06/10] aactab: add deemphasis tables for USAC

2024-05-24 Thread Lynne via ffmpeg-devel
---
 libavcodec/aactab.c | 25 +
 libavcodec/aactab.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 3718b81a07..8ce5e43974 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -3377,3 +3377,28 @@ const DECLARE_ALIGNED(32, int, 
ff_aac_eld_window_480_fixed)[1800] = {
 0xffecff1c, 0xffed391e, 0xffed740c, 0xffedafb1,
 0xffedebe1, 0xffee287d, 0xffee654e, 0xffeea23f,
 };
+
+/* As specified by ISO/IEC 23003 */
+#define USAC_EMPH_COEFF 0.68
+
+DECLARE_ALIGNED(16, const float, ff_aac_deemph_weights)[16] = {
+USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+
+0,
+USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+
+0,
+0,
+USAC_EMPH_COEFF,
+USAC_EMPH_COEFF*USAC_EMPH_COEFF,
+
+0,
+0,
+0,
+USAC_EMPH_COEFF,
+};
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index e1a2d8b9a1..91262380d4 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -64,6 +64,8 @@ DECLARE_ALIGNED(32, extern const float, 
ff_aac_eld_window_480)[1800];
 DECLARE_ALIGNED(32, extern const int,   ff_aac_eld_window_480_fixed)[1800];
 // @}
 
+extern const float ff_aac_deemph_weights[16];
+
 /* Initializes data shared between float decoder and encoder. */
 void ff_aac_float_common_init(void);
 
-- 
2.43.0.381.gb435a96ce8
___
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 v3 05/10] aacdec_dsp: implement 768-point transform and windowing

2024-05-24 Thread Lynne via ffmpeg-devel
Required for USAC
---
 libavcodec/aac/aacdec.c  |  4 ++
 libavcodec/aac/aacdec.h  |  5 +++
 libavcodec/aac/aacdec_dsp_template.c | 67 
 libavcodec/aac/aacdec_fixed.c|  2 +
 libavcodec/aac/aacdec_float.c|  4 ++
 libavcodec/sinewin_fixed_tablegen.c  |  2 +
 libavcodec/sinewin_fixed_tablegen.h  |  4 ++
 7 files changed, 88 insertions(+)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index a7e5b2a369..6f37ac5361 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1113,10 +1113,12 @@ static av_cold int decode_close(AVCodecContext *avctx)
 }
 }
 
+av_tx_uninit(>mdct96);
 av_tx_uninit(>mdct120);
 av_tx_uninit(>mdct128);
 av_tx_uninit(>mdct480);
 av_tx_uninit(>mdct512);
+av_tx_uninit(>mdct768);
 av_tx_uninit(>mdct960);
 av_tx_uninit(>mdct1024);
 av_tx_uninit(>mdct_ltp);
@@ -1145,10 +1147,12 @@ static av_cold int init_dsp(AVCodecContext *avctx)
 if (ret < 0) \
 return ret
 
+MDCT_INIT(ac->mdct96,   ac->mdct96_fn, 96, 1.0/96);
 MDCT_INIT(ac->mdct120,  ac->mdct120_fn,   120, 1.0/120);
 MDCT_INIT(ac->mdct128,  ac->mdct128_fn,   128, 1.0/128);
 MDCT_INIT(ac->mdct480,  ac->mdct480_fn,   480, 1.0/480);
 MDCT_INIT(ac->mdct512,  ac->mdct512_fn,   512, 1.0/512);
+MDCT_INIT(ac->mdct768,  ac->mdct768_fn,   768, 1.0/768);
 MDCT_INIT(ac->mdct960,  ac->mdct960_fn,   960, 1.0/960);
 MDCT_INIT(ac->mdct1024, ac->mdct1024_fn, 1024, 1.0/1024);
 #undef MDCT_INIT
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index 499bd8eefc..8d1eb74066 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -245,6 +245,7 @@ typedef struct AACDecDSP {
ChannelElement *cce, int index);
 
 void (*imdct_and_windowing)(AACDecContext *ac, SingleChannelElement *sce);
+void (*imdct_and_windowing_768)(AACDecContext *ac, SingleChannelElement 
*sce);
 void (*imdct_and_windowing_960)(AACDecContext *ac, SingleChannelElement 
*sce);
 void (*imdct_and_windowing_ld)(AACDecContext *ac, SingleChannelElement 
*sce);
 void (*imdct_and_windowing_eld)(AACDecContext *ac, SingleChannelElement 
*sce);
@@ -290,18 +291,22 @@ struct AACDecContext {
  * @name Computed / set up during initialization
  * @{
  */
+AVTXContext *mdct96;
 AVTXContext *mdct120;
 AVTXContext *mdct128;
 AVTXContext *mdct480;
 AVTXContext *mdct512;
+AVTXContext *mdct768;
 AVTXContext *mdct960;
 AVTXContext *mdct1024;
 AVTXContext *mdct_ltp;
 
+av_tx_fn mdct96_fn;
 av_tx_fn mdct120_fn;
 av_tx_fn mdct128_fn;
 av_tx_fn mdct480_fn;
 av_tx_fn mdct512_fn;
+av_tx_fn mdct768_fn;
 av_tx_fn mdct960_fn;
 av_tx_fn mdct1024_fn;
 av_tx_fn mdct_ltp_fn;
diff --git a/libavcodec/aac/aacdec_dsp_template.c 
b/libavcodec/aac/aacdec_dsp_template.c
index e69970472c..59a69d88f3 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -383,6 +383,71 @@ static void AAC_RENAME(imdct_and_windowing)(AACDecContext 
*ac, SingleChannelElem
 }
 }
 
+/**
+ * Conduct IMDCT and windowing for 768-point frames.
+ */
+static void AAC_RENAME(imdct_and_windowing_768)(AACDecContext *ac, 
SingleChannelElement *sce)
+{
+IndividualChannelStream *ics = >ics;
+INTFLOAT *in= sce->AAC_RENAME(coeffs);
+INTFLOAT *out   = sce->AAC_RENAME(output);
+INTFLOAT *saved = sce->AAC_RENAME(saved);
+const INTFLOAT *swindow  = ics->use_kb_window[0] ? 
AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96);
+const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? 
AAC_RENAME(aac_kbd_long_768) : AAC_RENAME(sine_768);
+const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? 
AAC_RENAME(aac_kbd_short_96) : AAC_RENAME(sine_96);
+INTFLOAT *buf  = ac->AAC_RENAME(buf_mdct);
+INTFLOAT *temp = ac->AAC_RENAME(temp);
+int i;
+
+// imdct
+if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
+for (i = 0; i < 8; i++)
+ac->mdct96_fn(ac->mdct96, buf + i * 96, in + i * 96, 
sizeof(INTFLOAT));
+} else {
+ac->mdct768_fn(ac->mdct768, buf, in, sizeof(INTFLOAT));
+}
+
+/* window overlapping
+ * NOTE: To simplify the overlapping code, all 'meaningless' short to long
+ * and long to short transitions are considered to be short to short
+ * transitions. This leaves just two cases (long to long and short to 
short)
+ * with a little special sauce for EIGHT_SHORT_SEQUENCE.
+ */
+
+if ((ics->window_sequence[1] == ONLY_LONG_SEQUENCE || 
ics->window_sequence[1] == LONG_STOP_SEQUENCE) &&
+(ics->window_sequence[0] == ONLY_LONG_SEQUENCE || 
ics->window_sequence[0] == LONG_START_SEQUENCE)) {
+ac->fdsp->vector_fmul_window(out,   saved,
buf, lwindow_prev, 384);
+} 

[FFmpeg-devel] [PATCH v3 07/10] aactab: add tables for the new USAC arithmetic coder

2024-05-24 Thread Lynne via ffmpeg-devel
---
 libavcodec/aactab.c | 376 
 libavcodec/aactab.h |   6 +
 2 files changed, 382 insertions(+)

diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 8ce5e43974..dfb2dfd98d 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -1193,6 +1193,382 @@ const uint16_t *const ff_aac_codebook_vector_idx[] = {
 codebook_vector10_idx,
 };
 
+const uint16_t ff_aac_ac_msb_cdfs[64][17] = {
+{   708,   706,   579,   569,   568,   567,   479,   469,
+297,   138,97,91,72,52,38,34, 0, },
+{  7619,  6917,  6519,  6412,  5514,  5003,  4683,  4563,
+   3907,  3297,  3125,  3060,  2904,  2718,  2631,  2590, 0, },
+{  7263,  4888,  4810,  4803,  1889,   415,   335,   327,
+195,72,52,49,36,20,15,14, 0, },
+{  3626,  2197,  2188,  2187,   582,57,47,46,
+ 30,12, 9, 8, 6, 4, 3, 2, 0, },
+{  7806,  5541,  5451,  5441,  2720,   834,   691,   674,
+487,   243,   179,   167,   139,98,77,70, 0, },
+{  6684,  4101,  4058,  4055,  1748,   426,   368,   364,
+322,   257,   235,   232,   228,   222,   217,   215, 0, },
+{  9162,  5964,  5831,  5819,  3269,   866,   658,   638,
+535,   348,   258,   244,   234,   214,   195,   186, 0, },
+{ 10638,  8491,  8365,  8351,  4418,  2067,  1859,  1834,
+   1190,   601,   495,   478,   356,   217,   174,   164, 0, },
+{ 13389, 10514, 10032,  9961,  7166,  3488,  2655,  2524,
+   2015,  1140,   760,   672,   585,   426,   325,   283, 0, },
+{ 14861, 12788, 12115, 11952,  9987,  6657,  5323,  4984,
+   4324,  3001,  2205,  1943,  1764,  1394,  1115,   978, 0, },
+{ 12876, 10004,  9661,  9610,  7107,  3435,  2711,  2595,
+   2257,  1508,  1059,   952,   893,   753,   609,   538, 0, },
+{ 15125, 13591, 13049, 12874, 11192,  8543,  7406,  7023,
+   6291,  4922,  4104,  3769,  3465,  2890,  2486,  2275, 0, },
+{ 14574, 13106, 12731, 12638, 10453,  7947,  7233,  7037,
+   6031,  4618,  4081,  3906,  3465,  2802,  2476,  2349, 0, },
+{ 15070, 13179, 12517, 12351, 10742,  7657,  6200,  5825,
+   5264,  3998,  3014,  2662,  2510,  2153,  1799,  1564, 0, },
+{ 15542, 14466, 14007, 13844, 12489, 10409,  9481,  9132,
+   8305,  6940,  6193,  5867,  5458,  4743,  4291,  4047, 0, },
+{ 15165, 14384, 14084, 13934, 12911, 11485, 10844, 10513,
+  10002,  8993,  8380,  8051,  7711,  7036,  6514,  6233, 0, },
+{ 15642, 14279, 13625, 13393, 12348,  9971,  8405,  7858,
+   7335,  6119,  4918,  4376,  4185,  3719,  3231,  2860, 0, },
+{ 13408, 13407, 11471, 11218, 11217, 11216,  9473,  9216,
+   6480,  3689,  2857,  2690,  2256,  1732,  1405,  1302, 0, },
+{ 16098, 15584, 15191, 14931, 14514, 13578, 12703, 12103,
+  11830, 11172, 10475,  9867,  9695,  9281,  8825,  8389, 0, },
+{ 15844, 14873, 14277, 13996, 13230, 11535, 10205,  9543,
+   9107,  8086,  7085,  6419,  6214,  5713,  5195,  4731, 0, },
+{ 16131, 15720, 15443, 15276, 14848, 13971, 13314, 12910,
+  12591, 11874, 11225, 10788, 10573, 10077,  9585,  9209, 0, },
+{ 16331, 16330, 12283, 11435, 11434, 11433,  8725,  8049,
+   6065,  4138,  3187,  2842,  2529,  2171,  1907,  1745, 0, },
+{ 16011, 15292, 14782, 14528, 14008, 12767, 11556, 10921,
+  10591,  9759,  8813,  8043,  7855,  7383,  6863,  6282, 0, },
+{ 16380, 16379, 15159, 14610, 14609, 14608, 12859, 12111,
+  11046,  9536,  8348,  7713,  7216,  6533,  5964,  5546, 0, },
+{ 16367, 16333, 16294, 16253, 16222, 16143, 16048, 15947,
+  15915, 15832, 15731, 15619, 15589, 15512, 15416, 15310, 0, },
+{ 15967, 15319, 14937, 14753, 14010, 12638, 11787, 11360,
+  10805,  9706,  8934,  8515,  8166,  7456,  6911,  6575, 0, },
+{  4906,  3005,  2985,  2984,   875,   102,83,81,
+ 47,17,12,11, 8, 5, 4, 3, 0, },
+{  7217,  4346,  4269,  4264,  1924,   428,   340,   332,
+280,   203,   179,   175,   171,   164,   159,   157, 0, },
+{ 16010, 15415, 15032, 14805, 14228, 13043, 12168, 11634,
+  11265, 10419,  9645,  9110,  8892,  8378,  7850,  7437, 0, },
+{  8573,  5218,  5046,  5032,  2787,   771,   555,   533,
+443,   286,   218,   205,   197,   181,   168,   162, 0, },
+{ 11474,  8095,  7822,  7796,  4632,  1443,  1046,  1004,
+748,   351,   218,   194,   167,   121,93,83, 0, },
+{ 16152, 15764, 15463, 15264, 14925, 14189, 13536, 13070,
+  12846, 12314, 11763, 11277, 11131, 10777, 10383, 10011, 0, },
+{ 14187, 11654, 11043, 10919,  8498,  4885,  3778,  3552,
+   2947,  1835,  1283,  1134,   998,   749,   585,   514, 0, },
+{ 14162, 11527, 10759, 10557,  8601,  5417,  4105,  3753,
+   3286,  2353,  1708,  1473,  1370,  1148,   959,   840, 0, },
+{ 16205, 15902, 15669, 15498, 15213, 14601, 14068, 13674,
+  

[FFmpeg-devel] [PATCH v3 01/10] channel_layout: add new channel positions supported by xHE-AAC

2024-05-24 Thread Lynne via ffmpeg-devel
apichanges will be updated upon merging, as well as a version bump.
---
 libavutil/channel_layout.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavutil/channel_layout.h b/libavutil/channel_layout.h
index 8a078d1601..4e19bbbd9e 100644
--- a/libavutil/channel_layout.h
+++ b/libavutil/channel_layout.h
@@ -79,6 +79,10 @@ enum AVChannel {
 AV_CHAN_BOTTOM_FRONT_CENTER,
 AV_CHAN_BOTTOM_FRONT_LEFT,
 AV_CHAN_BOTTOM_FRONT_RIGHT,
+AV_CHAN_SURROUND_LEFT,
+AV_CHAN_SURROUND_RIGHT,
+AV_CHAN_TOP_SURROUND_LEFT,
+AV_CHAN_TOP_SURROUND_RIGHT,
 
 /** Channel is empty can be safely skipped. */
 AV_CHAN_UNUSED = 0x200,
-- 
2.43.0.381.gb435a96ce8
___
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 v3 04/10] aacdec: expose decode_tns

2024-05-24 Thread Lynne via ffmpeg-devel
USAC has the same syntax, with one minor change we can check for.
---
 libavcodec/aac/aacdec.c | 6 +++---
 libavcodec/aac/aacdec.h | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 40554ff9e4..a7e5b2a369 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1542,7 +1542,7 @@ static int decode_pulses(Pulse *pulse, GetBitContext *gb,
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns,
+int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns,
   GetBitContext *gb, const IndividualChannelStream *ics)
 {
 int w, filt, i, coef_len, coef_res, coef_compress;
@@ -1690,7 +1690,7 @@ int ff_aac_decode_ics(AACDecContext *ac, 
SingleChannelElement *sce,
 }
 tns->present = get_bits1(gb);
 if (tns->present && !er_syntax) {
-ret = decode_tns(ac, tns, gb, ics);
+ret = ff_aac_decode_tns(ac, tns, gb, ics);
 if (ret < 0)
 goto fail;
 }
@@ -1704,7 +1704,7 @@ int ff_aac_decode_ics(AACDecContext *ac, 
SingleChannelElement *sce,
 // I see no textual basis in the spec for this occurring after SSR gain
 // control, but this is what both reference and real implmentations do
 if (tns->present && er_syntax) {
-ret = decode_tns(ac, tns, gb, ics);
+ret = ff_aac_decode_tns(ac, tns, gb, ics);
 if (ret < 0)
 goto fail;
 }
diff --git a/libavcodec/aac/aacdec.h b/libavcodec/aac/aacdec.h
index bea0578e92..499bd8eefc 100644
--- a/libavcodec/aac/aacdec.h
+++ b/libavcodec/aac/aacdec.h
@@ -351,6 +351,9 @@ int ff_aac_decode_init_fixed(AVCodecContext *avctx);
 int ff_aac_decode_ics(AACDecContext *ac, SingleChannelElement *sce,
   GetBitContext *gb, int common_window, int scale_flag);
 
+int ff_aac_decode_tns(AACDecContext *ac, TemporalNoiseShaping *tns,
+  GetBitContext *gb, const IndividualChannelStream *ics);
+
 int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx,
   uint8_t (*layout_map)[3],
   int *tags,
-- 
2.43.0.381.gb435a96ce8
___
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 v3 03/10] aacdec: expose channel layout related functions

2024-05-24 Thread Lynne via ffmpeg-devel
---
 libavcodec/aac/aacdec.c | 73 -
 libavcodec/aac/aacdec.h | 19 +--
 2 files changed, 51 insertions(+), 41 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 35722f9b9b..40554ff9e4 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -111,10 +111,6 @@
Parametric Stereo.
  */
 
-static int output_configure(AACDecContext *ac,
-uint8_t layout_map[MAX_ELEM_ID*4][3], int tags,
-enum OCStatus oc_type, int get_new_frame);
-
 #define overread_err "Input buffer exhausted before END element found\n"
 
 static int count_channels(uint8_t (*layout)[3], int tags)
@@ -447,8 +443,8 @@ static void pop_output_configuration(AACDecContext *ac)
 if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) {
 ac->oc[1] = ac->oc[0];
 ac->avctx->ch_layout = ac->oc[1].ch_layout;
-output_configure(ac, ac->oc[1].layout_map, ac->oc[1].layout_map_tags,
- ac->oc[1].status, 0);
+ff_aac_output_configure(ac, ac->oc[1].layout_map, 
ac->oc[1].layout_map_tags,
+ac->oc[1].status, 0);
 }
 }
 
@@ -458,7 +454,7 @@ static void pop_output_configuration(AACDecContext *ac)
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int output_configure(AACDecContext *ac,
+int ff_aac_output_configure(AACDecContext *ac,
 uint8_t layout_map[MAX_ELEM_ID * 4][3], int tags,
 enum OCStatus oc_type, int get_new_frame)
 {
@@ -547,7 +543,7 @@ static av_cold void flush(AVCodecContext *avctx)
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx,
+int ff_aac_set_default_channel_config(AACDecContext *ac, AVCodecContext *avctx,
   uint8_t (*layout_map)[3],
   int *tags,
   int channel_config)
@@ -587,7 +583,7 @@ static int set_default_channel_config(AACDecContext *ac, 
AVCodecContext *avctx,
 return 0;
 }
 
-static ChannelElement *get_che(AACDecContext *ac, int type, int elem_id)
+ChannelElement *ff_aac_get_che(AACDecContext *ac, int type, int elem_id)
 {
 /* For PCE based channel configurations map the channels solely based
  * on tags. */
@@ -603,11 +599,11 @@ static ChannelElement *get_che(AACDecContext *ac, int 
type, int elem_id)
 
 av_log(ac->avctx, AV_LOG_DEBUG, "mono with CPE\n");
 
-if (set_default_channel_config(ac, ac->avctx, layout_map,
-   _map_tags, 2) < 0)
+if (ff_aac_set_default_channel_config(ac, ac->avctx, layout_map,
+  _map_tags, 2) < 0)
 return NULL;
-if (output_configure(ac, layout_map, layout_map_tags,
- OC_TRIAL_FRAME, 1) < 0)
+if (ff_aac_output_configure(ac, layout_map, layout_map_tags,
+OC_TRIAL_FRAME, 1) < 0)
 return NULL;
 
 ac->oc[1].m4ac.chan_config = 2;
@@ -627,8 +623,8 @@ static ChannelElement *get_che(AACDecContext *ac, int type, 
int elem_id)
 layout_map[0][2] = layout_map[1][2] = AAC_CHANNEL_FRONT;
 layout_map[0][1] = 0;
 layout_map[1][1] = 1;
-if (output_configure(ac, layout_map, layout_map_tags,
- OC_TRIAL_FRAME, 1) < 0)
+if (ff_aac_output_configure(ac, layout_map, layout_map_tags,
+OC_TRIAL_FRAME, 1) < 0)
 return NULL;
 
 if (ac->oc[1].m4ac.sbr)
@@ -877,8 +873,8 @@ static int decode_ga_specific_config(AACDecContext *ac, 
AVCodecContext *avctx,
 if (tags < 0)
 return tags;
 } else {
-if ((ret = set_default_channel_config(ac, avctx, layout_map,
-  , channel_config)))
+if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
+ , channel_config)))
 return ret;
 }
 
@@ -887,7 +883,7 @@ static int decode_ga_specific_config(AACDecContext *ac, 
AVCodecContext *avctx,
 } else if (m4ac->sbr == 1 && m4ac->ps == -1)
 m4ac->ps = 1;
 
-if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0)))
+if (ac && (ret = ff_aac_output_configure(ac, layout_map, tags, 
OC_GLOBAL_HDR, 0)))
 return ret;
 
 if (extension_flag) {
@@ -967,11 +963,11 @@ static int decode_eld_specific_config(AACDecContext *ac, 
AVCodecContext *avctx,
 skip_bits_long(gb, 8 * len);
 }
 
-if ((ret = set_default_channel_config(ac, avctx, layout_map,
-  , channel_config)))
+if ((ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
+

[FFmpeg-devel] [PATCH v3 00/10] aacdec: add a native xHE-AAC decoder

2024-05-24 Thread Lynne via ffmpeg-devel
This commit adds a decoder for the frequency-domain part of USAC.
SBR is as of now not yet supported, will be added with a future
patch.

A known issue is that preroll frames (usually present quite often
within the file, as xHE-AAC has real keyframes and I-frames) can
cause artifacts.

Lynne (10):
  channel_layout: add new channel positions supported by xHE-AAC
  aacdec: move from scalefactor ranged arrays to flat arrays
  aacdec: expose channel layout related functions
  aacdec: expose decode_tns
  aacdec_dsp: implement 768-point transform and windowing
  aactab: add deemphasis tables for USAC
  aactab: add tables for the new USAC arithmetic coder
  aactab: add new scalefactor offset tables for 96/768pt windows
  aacdec: add a decoder for AAC USAC (xHE-AAC)
  fate: add tests for xHE-AAC

 libavcodec/aac/Makefile  |3 +-
 libavcodec/aac/aacdec.c  |  371 +++---
 libavcodec/aac/aacdec.h  |  219 +++-
 libavcodec/aac/aacdec_ac.c   |  208 
 libavcodec/aac/aacdec_ac.h   |   54 +
 libavcodec/aac/aacdec_dsp_template.c |  162 ++-
 libavcodec/aac/aacdec_fixed.c|2 +
 libavcodec/aac/aacdec_float.c|4 +
 libavcodec/aac/aacdec_latm.h |   14 +-
 libavcodec/aac/aacdec_lpd.c  |  198 
 libavcodec/aac/aacdec_lpd.h  |   33 +
 libavcodec/aac/aacdec_usac.c | 1592 ++
 libavcodec/aac/aacdec_usac.h |   37 +
 libavcodec/aactab.c  |  560 +
 libavcodec/aactab.h  |   22 +
 libavcodec/sinewin_fixed_tablegen.c  |2 +
 libavcodec/sinewin_fixed_tablegen.h  |4 +
 libavutil/channel_layout.h   |4 +
 tests/fate/aac.mak   |8 +
 19 files changed, 3262 insertions(+), 235 deletions(-)
 create mode 100644 libavcodec/aac/aacdec_ac.c
 create mode 100644 libavcodec/aac/aacdec_ac.h
 create mode 100644 libavcodec/aac/aacdec_lpd.c
 create mode 100644 libavcodec/aac/aacdec_lpd.h
 create mode 100644 libavcodec/aac/aacdec_usac.c
 create mode 100644 libavcodec/aac/aacdec_usac.h

-- 
2.43.0.381.gb435a96ce8
___
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 v3 02/10] aacdec: move from scalefactor ranged arrays to flat arrays

2024-05-24 Thread Lynne via ffmpeg-devel
AAC uses an unconventional system to send scalefactors
(the volume+quantization value for each band).
Each window is split into either 1 or 8 blocks (long vs short),
and transformed separately from one another, with the coefficients
for each being also completely independent. The scalefactors
slightly increase from 64 (long) to 128 (short) to accomodate
better per-block-per-band volume for each window.

To reduce overhead, the codec signals scalefactor sizes in an obtuse way,
where each group's scalefactor types are sent via a variable length decoding,
with a range.
But our decoder was written in a way where those ranges were carried through
the entire decoder, and to actually read them you had to use the range.

Instead of having a dedicated array with a range for each scalefactor,
just let the decoder directly index each scalefactor.

This also switches the form of quantized scalefactors to the format
the spec uses, where for intensity stereo and regular, scalefactors
are stored in a scalefactor - 100 form, rather than as-is.

USAC gets rid of the complex scalefactor handling. This commit permits
for code sharing between both.
---
 libavcodec/aac/aacdec.c  | 100 ---
 libavcodec/aac/aacdec.h  |   5 +-
 libavcodec/aac/aacdec_dsp_template.c |  95 ++---
 3 files changed, 83 insertions(+), 117 deletions(-)

diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 7457fe6c97..35722f9b9b 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1412,13 +1412,13 @@ fail:
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int decode_band_types(AACDecContext *ac, enum BandType band_type[120],
- int band_type_run_end[120], GetBitContext *gb,
- IndividualChannelStream *ics)
+static int decode_band_types(AACDecContext *ac, SingleChannelElement *sce,
+ GetBitContext *gb)
 {
-int g, idx = 0;
+IndividualChannelStream *ics = >ics;
 const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5;
-for (g = 0; g < ics->num_window_groups; g++) {
+
+for (int g = 0; g < ics->num_window_groups; g++) {
 int k = 0;
 while (k < ics->max_sfb) {
 uint8_t sect_end = k;
@@ -1442,10 +1442,8 @@ static int decode_band_types(AACDecContext *ac, enum 
BandType band_type[120],
 return AVERROR_INVALIDDATA;
 }
 } while (sect_len_incr == (1 << bits) - 1);
-for (; k < sect_end; k++) {
-band_type[idx]   = sect_band_type;
-band_type_run_end[idx++] = sect_end;
-}
+for (; k < sect_end; k++)
+sce->band_type[g*ics->max_sfb + k] = sect_band_type;
 }
 }
 return 0;
@@ -1461,69 +1459,59 @@ static int decode_band_types(AACDecContext *ac, enum 
BandType band_type[120],
  *
  * @return  Returns error status. 0 - OK, !0 - error
  */
-static int decode_scalefactors(AACDecContext *ac, int sfo[120],
-   GetBitContext *gb,
-   unsigned int global_gain,
-   IndividualChannelStream *ics,
-   enum BandType band_type[120],
-   int band_type_run_end[120])
+static int decode_scalefactors(AACDecContext *ac, SingleChannelElement *sce,
+   GetBitContext *gb, unsigned int global_gain)
 {
-int g, i, idx = 0;
+IndividualChannelStream *ics = >ics;
 int offset[3] = { global_gain, global_gain - NOISE_OFFSET, 0 };
 int clipped_offset;
 int noise_flag = 1;
-for (g = 0; g < ics->num_window_groups; g++) {
-for (i = 0; i < ics->max_sfb;) {
-int run_end = band_type_run_end[idx];
-switch (band_type[idx]) {
+
+for (int g = 0; g < ics->num_window_groups; g++) {
+for (int sfb = 0; sfb < ics->max_sfb; sfb++) {
+switch (sce->band_type[g*ics->max_sfb + sfb]) {
 case ZERO_BT:
-for (; i < run_end; i++, idx++)
-sfo[idx] = 0;
+sce->sfo[g*ics->max_sfb + sfb] = 0;
 break;
 case INTENSITY_BT: /* fallthrough */
 case INTENSITY_BT2:
-for (; i < run_end; i++, idx++) {
-offset[2] += get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 
SCALE_DIFF_ZERO;
-clipped_offset = av_clip(offset[2], -155, 100);
-if (offset[2] != clipped_offset) {
-avpriv_request_sample(ac->avctx,
-  "If you heard an audible 
artifact, there may be a bug in the decoder. "
-  "Clipped intensity stereo 
position (%d -> %d)",
-  offset[2], clipped_offset);
-

[FFmpeg-devel] [PATCH 16/16] avcodec/wmaenc: Don't unnecessarily reset AVPacket.size

2024-05-24 Thread Andreas Rheinhardt
The packet is unreferenced generically lateron anyway.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wmaenc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index b4650d42b3..73ce0876c9 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -418,7 +418,6 @@ static int encode_superframe(AVCodecContext *avctx, 
AVPacket *avpkt,
 error = encode_frame(s, s->coefs, avpkt->data, avpkt->size, 
total_gain++);
 if (error > 0) {
 av_log(avctx, AV_LOG_ERROR, "Invalid input data or requested bitrate 
too low, cannot encode\n");
-avpkt->size = 0;
 return AVERROR(EINVAL);
 }
 remaining = -error;
-- 
2.40.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 15/16] avcodec/wmaenc: Use av_unreachable to mark unreachable codepath

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wmaenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 7240c0895c..b4650d42b3 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -80,7 +80,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
 AV_WL32(extradata, flags1);
 AV_WL16(extradata + 4, flags2);
 } else {
-av_assert0(0);
+av_unreachable;
 }
 avctx->extradata  = extradata;
 s->use_exp_vlc= flags2 & 0x0001;
-- 
2.40.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 14/16] avcodec/wma: Mark ff_wma_end() as av_cold

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index da9c914b57..257184c0d8 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -364,7 +364,7 @@ int ff_wma_total_gain_to_bits(int total_gain)
 return  9;
 }
 
-int ff_wma_end(AVCodecContext *avctx)
+av_cold int ff_wma_end(AVCodecContext *avctx)
 {
 WMACodecContext *s = avctx->priv_data;
 int i;
-- 
2.40.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 13/16] avcodec/wmaenc: Move transient PutBitContext from Context to stack

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/wma.h|  2 --
 libavcodec/wmaenc.c | 58 ++---
 2 files changed, 28 insertions(+), 32 deletions(-)

diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 3d0d872ea3..a909f5baa7 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -28,7 +28,6 @@
 
 #include "avcodec.h"
 #include "get_bits.h"
-#include "put_bits.h"
 
 /* size of blocks */
 #define BLOCK_MIN_BITS 7
@@ -68,7 +67,6 @@ typedef struct CoefVLCTable {
 typedef struct WMACodecContext {
 AVCodecContext *avctx;
 GetBitContext gb;
-PutBitContext pb;
 int version;///< 1 = 0x160 (WMAV1), 2 = 0x161 
(WMAV2)
 int use_bit_reservoir;
 int use_variable_block_len;
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index eaf0498ea2..7240c0895c 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -28,6 +28,7 @@
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "encode.h"
+#include "put_bits.h"
 #include "wma.h"
 #include "libavutil/avassert.h"
 
@@ -161,7 +162,7 @@ static void init_exp(WMACodecContext *s, int ch, const int 
*exp_param)
 s->max_exponent[ch] = max_scale;
 }
 
-static void encode_exp_vlc(WMACodecContext *s, int ch, const int *exp_param)
+static void encode_exp_vlc(WMACodecContext *s, PutBitContext *pb, int ch, 
const int *exp_param)
 {
 int last_exp;
 const uint16_t *ptr;
@@ -173,7 +174,7 @@ static void encode_exp_vlc(WMACodecContext *s, int ch, 
const int *exp_param)
 if (s->version == 1) {
 last_exp = *exp_param++;
 av_assert0(last_exp - 10 >= 0 && last_exp - 10 < 32);
-put_bits(>pb, 5, last_exp - 10);
+put_bits(pb, 5, last_exp - 10);
 q += *ptr++;
 } else
 last_exp = 36;
@@ -181,7 +182,7 @@ static void encode_exp_vlc(WMACodecContext *s, int ch, 
const int *exp_param)
 int exp  = *exp_param++;
 int code = exp - last_exp + 60;
 av_assert1(code >= 0 && code < 120);
-put_bits(>pb, ff_aac_scalefactor_bits[code],
+put_bits(pb, ff_aac_scalefactor_bits[code],
  ff_aac_scalefactor_code[code]);
 /* XXX: use a table */
 q   += *ptr++;
@@ -189,7 +190,8 @@ static void encode_exp_vlc(WMACodecContext *s, int ch, 
const int *exp_param)
 }
 }
 
-static int encode_block(WMACodecContext *s, float (*src_coefs)[BLOCK_MAX_SIZE],
+static int encode_block(WMACodecContext *s, PutBitContext *pb,
+float (*src_coefs)[BLOCK_MAX_SIZE],
 int total_gain)
 {
 int channels = s->avctx->ch_layout.nb_channels;
@@ -230,7 +232,7 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 }
 
 if (channels == 2)
-put_bits(>pb, 1, !!s->ms_stereo);
+put_bits(pb, 1, !!s->ms_stereo);
 
 for (ch = 0; ch < channels; ch++) {
 // FIXME only set channel_coded when needed, instead of always
@@ -269,7 +271,7 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 v = 0;
 for (ch = 0; ch < channels; ch++) {
 int a = s->channel_coded[ch];
-put_bits(>pb, 1, a);
+put_bits(pb, 1, a);
 v |= a;
 }
 
@@ -277,8 +279,8 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 return 1;
 
 for (v = total_gain - 1; v >= 127; v -= 127)
-put_bits(>pb, 7, 127);
-put_bits(>pb, 7, v);
+put_bits(pb, 7, 127);
+put_bits(pb, 7, v);
 
 coef_nb_bits = ff_wma_total_gain_to_bits(total_gain);
 
@@ -288,7 +290,7 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 int i, n;
 n = s->exponent_high_sizes[bsize];
 for (i = 0; i < n; i++) {
-put_bits(>pb, 1, s->high_band_coded[ch][i] = 0);
+put_bits(pb, 1, s->high_band_coded[ch][i] = 0);
 if (0)
 nb_coefs[ch] -= s->exponent_high_bands[bsize][i];
 }
@@ -298,13 +300,13 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 
 parse_exponents = 1;
 if (s->block_len_bits != s->frame_len_bits)
-put_bits(>pb, 1, parse_exponents);
+put_bits(pb, 1, parse_exponents);
 
 if (parse_exponents) {
 for (ch = 0; ch < channels; ch++) {
 if (s->channel_coded[ch]) {
 if (s->use_exp_vlc) {
-encode_exp_vlc(s, ch, fixed_exp);
+encode_exp_vlc(s, pb, ch, fixed_exp);
 } else {
 av_assert0(0); // FIXME not implemented
 //encode_exp_lsp(s, ch);
@@ -333,28 +335,28 @@ static int encode_block(WMACodecContext *s, float 
(*src_coefs)[BLOCK_MAX_SIZE],
 code = run + s->int_table[tindex][abs_level - 1];
 
 av_assert2(code < 

Re: [FFmpeg-devel] FFmpeg 7.0.1

2024-05-24 Thread Michael Niedermayer
On Fri, Apr 05, 2024 at 02:15:58AM +0200, Michael Niedermayer wrote:
> Hi all
> 
> i intend to make a 7.0.1 in a few weeks for all the bug fixes that didnt
> make it in 7.0

i intend to make 7.0.1 in the next days (maybe tomorrow)
and 6.1.2 soon after that

thx

[..]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH 11/12] avcodec/e?ac3enc: Inform compiler about PutBitContext being blank

2024-05-24 Thread Andreas Rheinhardt
This turned out to be very beneficial: For GCC 13, the codesize
of ac3_output_frame_header went down from 4522B to 1247B and
from 10762B to 9298B for eac3_output_frame_header. For Clang 17,
the numbers went down from 3923B to 2477B and from 8338B to 6548B
(always with -O3).

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ac3enc.c  | 2 ++
 libavcodec/eac3enc.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 3649289865..a1783577c5 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1638,6 +1638,8 @@ static void ac3_output_frame_header(AC3EncodeContext *s, 
PutBitContext *pb)
 {
 AC3EncOptions *opt = >options;
 
+put_bits_assume_flushed(pb);
+
 put_bits(pb, 16, 0x0b77);   /* frame header */
 put_bits(pb, 16, 0);/* crc1: will be filled later */
 put_bits(pb, 2,  s->bit_alloc.sr_code);
diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c
index 8ef3e7e773..1c522dae2e 100644
--- a/libavcodec/eac3enc.c
+++ b/libavcodec/eac3enc.c
@@ -135,6 +135,8 @@ static void eac3_output_frame_header(AC3EncodeContext *s, 
PutBitContext *pb)
 int blk, ch;
 AC3EncOptions *opt = >options;
 
+put_bits_assume_flushed(pb);
+
 put_bits(pb, 16, 0x0b77);   /* sync word */
 
 /* BSI header */
-- 
2.40.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 12/12] avcodec/speedhqenc: Use av_unreachable for unreachable condition

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/speedhqenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 5b4ff4c139..29d603c729 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -128,7 +128,8 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
 s->avctx->codec_tag = MKTAG('S','H','Q','4');
 break;
 default:
-av_assert0(0);
+/* Already checked via AVCodec.pix_fmts. */
+av_unreachable;
 }
 
 return 0;
-- 
2.40.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 10/12] avcodec/put_bits: Allow to mark places where PutBitContext is flushed

2024-05-24 Thread Andreas Rheinhardt
This will allow the compiler to optimize the "is the cache full?"
branches away from some put_bits().

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/put_bits.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libavcodec/put_bits.h b/libavcodec/put_bits.h
index 4561dc131a..79bad1c214 100644
--- a/libavcodec/put_bits.h
+++ b/libavcodec/put_bits.h
@@ -74,6 +74,16 @@ static inline void init_put_bits(PutBitContext *s, uint8_t 
*buffer,
 s->bit_buf  = 0;
 }
 
+/**
+ * Inform the compiler that a PutBitContext is flushed (i.e. if it has just
+ * been initialized or flushed). Undefined behaviour occurs if this is used
+ * with a PutBitContext for which this is not true.
+ */
+static inline void put_bits_assume_flushed(const PutBitContext *s)
+{
+av_assume(s->bit_left == BUF_BITS);
+}
+
 /**
  * @return the total number of bits written to the bitstream.
  */
-- 
2.40.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 09/12] avcodec/dolby_e_parse: Use av_unreachable instead of av_assert0(0)

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/dolby_e_parse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/dolby_e_parse.c b/libavcodec/dolby_e_parse.c
index ffedcd99a4..62d38ab3a3 100644
--- a/libavcodec/dolby_e_parse.c
+++ b/libavcodec/dolby_e_parse.c
@@ -88,7 +88,8 @@ int ff_dolby_e_convert_input(DBEContext *s, int nb_words, int 
key)
 AV_WB24(dst, AV_RB24(src) ^ key);
 break;
 default:
-av_assert0(0);
+av_unreachable;
+break;
 }
 
 return init_get_bits(>gb, s->buffer, nb_words * s->word_bits);
-- 
2.40.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 08/12] avcodec/utvideoenc: Remove always-false pixel format check

2024-05-24 Thread Andreas Rheinhardt
Mark it as unreachable instead.

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

diff --git a/libavcodec/utvideoenc.c b/libavcodec/utvideoenc.c
index 59e198458b..f347a33e6e 100644
--- a/libavcodec/utvideoenc.c
+++ b/libavcodec/utvideoenc.c
@@ -143,9 +143,9 @@ static av_cold int utvideo_encode_init(AVCodecContext 
*avctx)
 original_format  = UTVIDEO_444;
 break;
 default:
-av_log(avctx, AV_LOG_ERROR, "Unknown pixel format: %d\n",
-   avctx->pix_fmt);
-return AVERROR_INVALIDDATA;
+/* Already checked via AVCodec.pix_fmts. */
+av_unreachable;
+break;
 }
 
 ff_bswapdsp_init(>bdsp);
-- 
2.40.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 07/12] avcodec/vlc: Make code more readable with av_unreachable

2024-05-24 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/vlc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index ee09d96fd6..f869c19650 100644
--- a/libavcodec/vlc.c
+++ b/libavcodec/vlc.c
@@ -49,10 +49,11 @@
 v = *(const uint16_t *)ptr; \
 break;  \
 case 4: \
-default:\
-av_assert1(size == 4);  \
 v = *(const uint32_t *)ptr; \
 break;  \
+default:\
+av_unreachable; \
+break;  \
 }   \
 }
 
-- 
2.40.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 05/12] avcodec/mpeg4videodec: Mark impossible switch case as unreachable

2024-05-24 Thread Andreas Rheinhardt
Alternative to 8fc649b931a3cbc3a2dd9b50b75a9261a2fb4b49.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/mpeg4videodec.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index df1e22207d..724ca202f5 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -24,6 +24,7 @@
 
 #include "config_components.h"
 
+#include "libavutil/avassert.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/thread.h"
@@ -598,7 +599,10 @@ static int mpeg4_decode_sprite_trajectory(Mpeg4DecContext 
*ctx, GetBitContext *g
 ctx->sprite_shift[1]  = alpha + beta + rho - min_ab + 2;
 break;
 default:
-av_assert0(0);
+/* num_sprite_warping_points outside of 0..3 results in an error
+ * in which num_sprite_warping_points is reset to zero. */
+av_unreachable;
+break;
 }
 /* try to simplify the situation */
 if (sprite_delta[0][0] == a << ctx->sprite_shift[0] &&
-- 
2.40.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 06/12] avcodec/pcm-dvdenc: Mark unreachable default cases as unreachable

2024-05-24 Thread Andreas Rheinhardt
Fixes a Clang warning when asserts are disabled:
"variable 'quant' is used uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]"

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/pcm-dvdenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c
index 1e7ee644f6..c3e853ed6a 100644
--- a/libavcodec/pcm-dvdenc.c
+++ b/libavcodec/pcm-dvdenc.c
@@ -45,7 +45,9 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx)
 freq = 1;
 break;
 default:
-av_assert1(0);
+/* Already checked via AVCodec.supported_samplerates. */
+av_unreachable;
+break;
 }
 
 switch (avctx->sample_fmt) {
@@ -58,7 +60,9 @@ static av_cold int pcm_dvd_encode_init(AVCodecContext *avctx)
 quant = 2;
 break;
 default:
-av_assert1(0);
+/* Already checked via AVCodec.sample_fmts. */
+av_unreachable;
+break;
 }
 
 avctx->bits_per_coded_sample = 16 + quant * 4;
-- 
2.40.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 04/12] all: Use put_bytes_output() instead of put_bits_ptr - pb->buf

2024-05-24 Thread Andreas Rheinhardt
Avoids accessing internals of PutBitContext.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/ljpegenc.c   | 2 +-
 libavcodec/proresenc_anatoliy.c | 2 +-
 libavcodec/wmaenc.c | 2 +-
 libavformat/mpegenc.c   | 4 ++--
 libavformat/swfenc.c| 6 +++---
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 46546e2160..3443951af5 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -252,7 +252,7 @@ static int ljpeg_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 ff_mjpeg_encode_picture_trailer(, header_bits);
 
 flush_put_bits();
-pkt->size   = put_bits_ptr() - pb.buf;
+pkt->size   = put_bytes_output();
 *got_packet = 1;
 
 return 0;
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 7b7618af9b..6ddb799297 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -382,7 +382,7 @@ static int encode_slice_plane(int16_t *blocks, int 
mb_count, uint8_t *buf, unsig
 encode_acs(, blocks, blocks_per_slice, qmat, scan);
 
 flush_put_bits();
-return put_bits_ptr() - pb.buf;
+return put_bytes_output();
 }
 
 static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx,
diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c
index 6949f08fb6..eaf0498ea2 100644
--- a/libavcodec/wmaenc.c
+++ b/libavcodec/wmaenc.c
@@ -425,7 +425,7 @@ static int encode_superframe(AVCodecContext *avctx, 
AVPacket *avpkt,
 put_bits(>pb, 8, 'N');
 
 flush_put_bits(>pb);
-av_assert0(put_bits_ptr(>pb) - s->pb.buf == avctx->block_align);
+av_assert0(put_bytes_output(>pb) == avctx->block_align);
 
 if (frame->pts != AV_NOPTS_VALUE)
 avpkt->pts = frame->pts - ff_samples_to_time_base(avctx, 
avctx->initial_padding);
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 6b6763c30f..068bc9d71e 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -124,7 +124,7 @@ static int put_pack_header(AVFormatContext *ctx, uint8_t 
*buf,
 put_bits(, 3, 0); /* stuffing length */
 }
 flush_put_bits();
-return put_bits_ptr() - pb.buf;
+return put_bytes_output();
 }
 
 static int put_system_header(AVFormatContext *ctx, uint8_t *buf,
@@ -269,7 +269,7 @@ static int put_system_header(AVFormatContext *ctx, uint8_t 
*buf,
 }
 
 flush_put_bits();
-size = put_bits_ptr() - pb.buf;
+size = put_bytes_output();
 /* patch packet size */
 AV_WB16(buf + 4, size - 6);
 
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index d106e16d19..fc883b8023 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -124,7 +124,7 @@ static void put_swf_rect(AVIOContext *pb,
 put_bits(, nbits, ymax & mask);
 
 flush_put_bits();
-avio_write(pb, buf, put_bits_ptr() - p.buf);
+avio_write(pb, buf, put_bytes_output());
 }
 
 static void put_swf_line_edge(PutBitContext *pb, int dx, int dy)
@@ -189,7 +189,7 @@ static void put_swf_matrix(AVIOContext *pb,
 put_bits(, nbits, ty);
 
 flush_put_bits();
-avio_write(pb, buf, put_bits_ptr() - p.buf);
+avio_write(pb, buf, put_bytes_output());
 }
 
 static int swf_write_header(AVFormatContext *s)
@@ -323,7 +323,7 @@ static int swf_write_header(AVFormatContext *s)
 put_bits(, 5, 0);
 
 flush_put_bits();
-avio_write(pb, buf1, put_bits_ptr() - p.buf);
+avio_write(pb, buf1, put_bytes_output());
 
 put_swf_end_tag(s);
 }
-- 
2.40.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 03/12] avcodec/proresenc_anatoliy: Mark impossible case as unreachable

2024-05-24 Thread Andreas Rheinhardt
Should fix Coverity issue 1440385.

Signed-off-by: Andreas Rheinhardt 
---
Alternative to https://ffmpeg.org/pipermail/ffmpeg-devel/2024-May/327293.html

 libavcodec/proresenc_anatoliy.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index 2fb96e9cf5..7b7618af9b 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -845,18 +845,25 @@ static av_cold int prores_encode_init(AVCodecContext 
*avctx)
 }
 
 if (avctx->profile == AV_PROFILE_UNKNOWN) {
-if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) {
+switch (avctx->pix_fmt) {
+case AV_PIX_FMT_YUV422P10:
 avctx->profile = AV_PROFILE_PRORES_STANDARD;
 av_log(avctx, AV_LOG_INFO,
 "encoding with ProRes standard (apcn) profile\n");
-} else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10) {
+break;
+case AV_PIX_FMT_YUV444P10:
 avctx->profile = AV_PROFILE_PRORES_;
 av_log(avctx, AV_LOG_INFO,
"encoding with ProRes  (ap4h) profile\n");
-} else if (avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) {
+break;
+case AV_PIX_FMT_YUVA444P10:
 avctx->profile = AV_PROFILE_PRORES_;
 av_log(avctx, AV_LOG_INFO,
"encoding with ProRes + (ap4h) profile\n");
+break;
+default:
+/* Already checked via AVCodec.pix_fmts. */
+av_unreachable;
 }
 } else if (avctx->profile < AV_PROFILE_PRORES_PROXY
 || avctx->profile > AV_PROFILE_PRORES_XQ) {
-- 
2.40.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 02/12] avcodec/amrwbdec: Mark default switch as unreachable

2024-05-24 Thread Andreas Rheinhardt
Alternative fix for Coverity issue #1473499
instead of a3bb269db92601e2dc0e99352468d02f7b26c7c2.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/amrwbdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 21a730b835..de1e661f2f 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -556,7 +556,9 @@ static void decode_fixed_vector(float *fixed_vector, const 
uint16_t *pulse_hi,
((int) pulse_hi[i] << 11), 4, 1);
 break;
 default:
-av_assert2(0);
+/* Everything >= MODE_SIM is impossible: MODE_SIM is patchwelcome,
+ * > MODE_SIM is invalid. */
+av_unreachable;
 }
 
 memset(fixed_vector, 0, sizeof(float) * AMRWB_SFR_SIZE);
-- 
2.40.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 01/12] avutil/avassert: Add av_unreachable and av_assume() macros

2024-05-24 Thread Andreas Rheinhardt
Useful to let the compiler and static analyzers know that
something is unreachable without adding an av_assert
(which would be either dead for the compiler or add runtime
overhead) for this.

Signed-off-by: Andreas Rheinhardt 
---
I can add more macros if it is desired to differentiate between
ASSERT_LEVEL == 1 and ASSERT_LEVEL > 1.

 doc/APIchanges   |  3 +++
 libavutil/avassert.h | 33 +
 2 files changed, 36 insertions(+)

diff --git a/doc/APIchanges b/doc/APIchanges
index 60f056b863..5a3ae37999 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
 
 API changes, most recent first:
 
+2024-05-24 - xx - lavu 59.xx.100 - avassert.h
+  Add av_unreachable and av_assume() macros.
+
 2024-05-23 - xx - lavu 59.20.100 - channel_layout.h
   Add av_channel_layout_ambisonic_order().
 
diff --git a/libavutil/avassert.h b/libavutil/avassert.h
index 1895fb7551..41e29c7687 100644
--- a/libavutil/avassert.h
+++ b/libavutil/avassert.h
@@ -31,6 +31,7 @@
 #ifdef HAVE_AV_CONFIG_H
 #   include "config.h"
 #endif
+#include "attributes.h"
 #include "log.h"
 #include "macros.h"
 
@@ -68,6 +69,38 @@
 #define av_assert2_fpu() ((void)0)
 #endif
 
+/**
+ * Asserts that are used as compiler optimization hints depending
+ * upon ASSERT_LEVEL and NBDEBUG.
+ *
+ * Undefined behaviour occurs if execution reaches a point marked
+ * with av_unreachable or if a condition used with av_assume()
+ * is false.
+ *
+ * The condition used with av_assume() should not have side-effects
+ * and should be visible to the compiler.
+ */
+#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0 || !defined(HAVE_AV_CONFIG_H) && 
!defined(NDEBUG)
+#define av_unreachable  av_assert0(0)
+#define av_assume(cond) av_assert0(cond)
+#elif AV_GCC_VERSION_AT_LEAST(4, 5) || AV_HAS_BUILTIN(__builtin_unreachable)
+#define av_unreachable __builtin_unreachable()
+#if AV_HAS_BUILTIN(__builtin_assume)
+#define av_assume(cond) __builtin_assume(cond)
+#else
+#define av_assume(cond) do {  \
+if (!(cond))  \
+__builtin_unreachable();  \
+} while (0)
+#endif
+#elif  defined(_MSC_VER)
+#define av_unreachable  __assume(0)
+#define av_assume(cond) __assume(cond)
+#else
+#define av_unreachable
+#define av_assume(cond)
+#endif
+
 /**
  * Assert that floating point operations can be executed.
  *
-- 
2.40.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] [RFC] STF 2025

2024-05-24 Thread Michael Niedermayer
Hi

On Mon, May 20, 2024 at 09:51:25PM +0300, Rémi Denis-Courmont wrote:
> Le sunnuntaina 19. toukokuuta 2024, 14.29.43 EEST Thilo Borgmann via ffmpeg-
> devel a écrit :
> > [...]
> > 
> > >> * Fund administrative / maintainance work (one example is the mailman
> > >> upgrade that is needed>> 
> > >>   with the next OS upgrade on one of our servers (this is not as trivial
> > >>   as one might expect). Another example here may be some git related
> > >>   tools if we find something that theres a broad consensus about.
> > > 
> > > I agree that this should be paid but I would expect that STF would not be
> > > too keen on it, not that I'd know really.
> > We should absolutely pay for such activity and STF is very well willing
> > to fund such things.
> 
> Again, I don't know but that seems to stray from their stated goals. Also 
> this 
> is most certainly not a full-time job, and it requires a very high level of 
> trust. In practice, what this really means is paying Michael.

I did not and do not intend to do the mailman or OS upgrade work. I hope
someone else will.

thx

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/2] libavfilter/signature_lookup: fix possible division by zero

2024-05-24 Thread Michael Niedermayer
On Fri, May 24, 2024 at 12:33:11PM +0200, Gerion Entrup wrote:
> Am Dienstag, 7. Mai 2024, 19:46:28 MESZ schrieb Michael Niedermayer:
> > On Mon, May 06, 2024 at 12:30:39AM +0200, Gerion Entrup wrote:
> > > ---
> > >  libavfilter/signature_lookup.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/libavfilter/signature_lookup.c 
> > > b/libavfilter/signature_lookup.c
> > > index a0ca818a9b..b39a3e225b 100644
> > > --- a/libavfilter/signature_lookup.c
> > > +++ b/libavfilter/signature_lookup.c
> > > @@ -128,7 +128,7 @@ static int get_jaccarddist(SignatureContext *sc, 
> > > CoarseSignature *first, CoarseS
> > >  int jaccarddist, i, composdist = 0, cwthcount = 0;
> > >  for (i = 0; i < 5; i++) {
> > >  if ((jaccarddist = intersection_word(first->data[i], 
> > > second->data[i])) > 0) {
> > > -jaccarddist /= union_word(first->data[i], second->data[i]);
> > > +jaccarddist /= FFMAX(union_word(first->data[i], 
> > > second->data[i]), 1);
> > >  }
> > 
> > for which input data does this cause a division by 0 ?
> 
> Sorry for the late answer. I missed your mail somehow.
> union_word counts the amount of one bits that are created when you are "or"ing
> the course signatures. So, when the underlying videos are so different that 
> all
> bits of the created signatures are different, the "or"-operator will always
> return 0 and so also its sum (I have not tested this).

the division only occurs if jaccarddist > 0

basically what iam asking is for which A and B do we have
(A) != 0 && (A|B) == 0
or am i misreading the code ?

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] avformat/demux: Remove dead stores

2024-05-24 Thread Michael Niedermayer
On Fri, May 24, 2024 at 08:21:05AM +0200, Andreas Rheinhardt wrote:
> Michael Niedermayer:
> > Fixes: CID1473512 Unused value
> > Fixes: CID1529228 Unused value
> > 
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavformat/demux.c | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/libavformat/demux.c b/libavformat/demux.c
> > index ecefe7e0a74..d0a5a39d052 100644
> > --- a/libavformat/demux.c
> > +++ b/libavformat/demux.c
> > @@ -2998,9 +2998,6 @@ int avformat_find_stream_info(AVFormatContext *ic, 
> > AVDictionary **options)
> >  
> >  av_opt_set_int(ic, "skip_clear", 0, AV_OPT_SEARCH_CHILDREN);
> >  
> > -if (ret >= 0 && ic->nb_streams)
> > -/* We could not have all the codec parameters before EOF. */
> > -ret = -1;
> >  for (unsigned i = 0; i < ic->nb_streams; i++) {
> >  AVStream *const st  = ic->streams[i];
> >  FFStream *const sti = ffstream(st);
> > @@ -3022,8 +3019,6 @@ int avformat_find_stream_info(AVFormatContext *ic, 
> > AVDictionary **options)
> > "Could not find codec parameters for stream %d (%s): 
> > %s\n"
> > "Consider increasing the value for the 
> > 'analyzeduration' (%"PRId64") and 'probesize' (%"PRId64") options\n",
> > i, buf, errmsg, ic->max_analyze_duration, 
> > ic->probesize);
> > -} else {
> > -ret = 0;
> >  }
> >  }
> >  
> 
> IIRC these stores are only dead since
> ac5a568e6dff8162a2e982f3571b925f1b207e2c; and it doesn't seem as if this
> was intended.

replaced by:

@@ -3027,9 +3027,11 @@ int avformat_find_stream_info(AVFormatContext *ic, 
AVDictionary **options)
 }
 }

-ret = compute_chapters_end(ic);
-if (ret < 0)
+err = compute_chapters_end(ic);
+if (err < 0) {
+ret = err;
 goto find_stream_info_err;
+}

 /* update the stream parameters from the internal codec contexts */
 for (unsigned i = 0; i < ic->nb_streams; i++) {

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH] WIP: lavc/flacdsp: R-V Zvl256b lpc33

2024-05-24 Thread Rémi Denis-Courmont
Le perjantaina 24. toukokuuta 2024, 23.04.40 EEST Rémi Denis-Courmont a écrit 
:
> flac_lpc_33_13_c: 499.7
> flac_lpc_33_13_rvv_i64: 197.7
> flac_lpc_33_16_c: 601.5
> flac_lpc_33_16_rvv_i64: 195.2
> flac_lpc_33_29_c: 1011.5
> flac_lpc_33_29_rvv_i64: 300.7
> flac_lpc_33_32_c: 1099.0
> flac_lpc_33_32_rvv_i64: 296.7

Ignore the "WIP: " in the subject.

> ---
>  libavcodec/riscv/flacdsp_init.c |  7 +--
>  libavcodec/riscv/flacdsp_rvv.S  | 27 +++
>  2 files changed, 32 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/riscv/flacdsp_init.c
> b/libavcodec/riscv/flacdsp_init.c index 830ae36534..861276be28 100644
> --- a/libavcodec/riscv/flacdsp_init.c
> +++ b/libavcodec/riscv/flacdsp_init.c
> @@ -31,6 +31,8 @@ void ff_flac_lpc32_rvv(int32_t *decoded, const int
> coeffs[32], int pred_order, int qlevel, int len);
>  void ff_flac_lpc32_rvv_simple(int32_t *decoded, const int coeffs[32],
>int pred_order, int qlevel, int len);
> +void ff_flac_lpc33_rvv(int64_t *, const int32_t *, const int coeffs[32],
> +   int pred_order, int qlevel, int len);
>  void ff_flac_wasted32_rvv(int32_t *, int shift, int len);
>  void ff_flac_wasted33_rvv(int64_t *, const int32_t *, int shift, int len);
>  void ff_flac_decorrelate_indep2_16_rvv(uint8_t **out, int32_t **in,
> @@ -76,9 +78,10 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c,
> enum AVSampleFormat fmt,
> 
>  # if (__riscv_xlen >= 64)
>  if (flags & AV_CPU_FLAG_RVV_I64) {
> -if (vlenb > 16)
> +if (vlenb > 16) {
>  c->lpc32 = ff_flac_lpc32_rvv_simple;
> -else
> +c->lpc33 = ff_flac_lpc33_rvv;
> +} else
>  c->lpc32 = ff_flac_lpc32_rvv;
>  }
>  # endif
> diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
> index 0e10940f74..ea42f8bea4 100644
> --- a/libavcodec/riscv/flacdsp_rvv.S
> +++ b/libavcodec/riscv/flacdsp_rvv.S
> @@ -103,6 +103,33 @@ func ff_flac_lpc32_rvv_simple, zve64x, zbb
> 
>  ret
>  endfunc
> +
> +func ff_flac_lpc33_rvv, zve64x, zbb
> +vtype_vli t0, a3, t1, e64, ta, ma
> +vsetvl  zero, a3, t0
> +vmv.s.x v0, zero
> +sh2add  a1, a3, a1
> +vle32.v v24, (a2)
> +sub a5, a5, a3
> +vle64.v v16, (a0)
> +sh3add  a0, a3, a0
> +vsext.vf2 v8, v24
> +1:
> +vmul.vv v24, v8, v16
> +lw  t0, (a1)
> +addia1, a1, 4
> +vredsum.vs v24, v24, v0
> +addia5, a5, -1
> +vmv.x.s t1, v24
> +sra t1, t1, a4
> +add t0, t0, t1
> +vslide1down.vx v16, v16, t0
> +sd  t0, (a0)
> +addia0, a0, 8
> +bneza5, 1b
> +
> +ret
> +endfunc
>  #endif
> 
>  func ff_flac_wasted32_rvv, zve32x


-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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] WIP: lavc/flacdsp: R-V Zvl256b lpc33

2024-05-24 Thread Rémi Denis-Courmont
flac_lpc_33_13_c: 499.7
flac_lpc_33_13_rvv_i64: 197.7
flac_lpc_33_16_c: 601.5
flac_lpc_33_16_rvv_i64: 195.2
flac_lpc_33_29_c: 1011.5
flac_lpc_33_29_rvv_i64: 300.7
flac_lpc_33_32_c: 1099.0
flac_lpc_33_32_rvv_i64: 296.7
---
 libavcodec/riscv/flacdsp_init.c |  7 +--
 libavcodec/riscv/flacdsp_rvv.S  | 27 +++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/libavcodec/riscv/flacdsp_init.c b/libavcodec/riscv/flacdsp_init.c
index 830ae36534..861276be28 100644
--- a/libavcodec/riscv/flacdsp_init.c
+++ b/libavcodec/riscv/flacdsp_init.c
@@ -31,6 +31,8 @@ void ff_flac_lpc32_rvv(int32_t *decoded, const int coeffs[32],
int pred_order, int qlevel, int len);
 void ff_flac_lpc32_rvv_simple(int32_t *decoded, const int coeffs[32],
   int pred_order, int qlevel, int len);
+void ff_flac_lpc33_rvv(int64_t *, const int32_t *, const int coeffs[32],
+   int pred_order, int qlevel, int len);
 void ff_flac_wasted32_rvv(int32_t *, int shift, int len);
 void ff_flac_wasted33_rvv(int64_t *, const int32_t *, int shift, int len);
 void ff_flac_decorrelate_indep2_16_rvv(uint8_t **out, int32_t **in,
@@ -76,9 +78,10 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum 
AVSampleFormat fmt,
 
 # if (__riscv_xlen >= 64)
 if (flags & AV_CPU_FLAG_RVV_I64) {
-if (vlenb > 16)
+if (vlenb > 16) {
 c->lpc32 = ff_flac_lpc32_rvv_simple;
-else
+c->lpc33 = ff_flac_lpc33_rvv;
+} else
 c->lpc32 = ff_flac_lpc32_rvv;
 }
 # endif
diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
index 0e10940f74..ea42f8bea4 100644
--- a/libavcodec/riscv/flacdsp_rvv.S
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -103,6 +103,33 @@ func ff_flac_lpc32_rvv_simple, zve64x, zbb
 
 ret
 endfunc
+
+func ff_flac_lpc33_rvv, zve64x, zbb
+vtype_vli t0, a3, t1, e64, ta, ma
+vsetvl  zero, a3, t0
+vmv.s.x v0, zero
+sh2add  a1, a3, a1
+vle32.v v24, (a2)
+sub a5, a5, a3
+vle64.v v16, (a0)
+sh3add  a0, a3, a0
+vsext.vf2 v8, v24
+1:
+vmul.vv v24, v8, v16
+lw  t0, (a1)
+addia1, a1, 4
+vredsum.vs v24, v24, v0
+addia5, a5, -1
+vmv.x.s t1, v24
+sra t1, t1, a4
+add t0, t0, t1
+vslide1down.vx v16, v16, t0
+sd  t0, (a0)
+addia0, a0, 8
+bneza5, 1b
+
+ret
+endfunc
 #endif
 
 func ff_flac_wasted32_rvv, zve32x
-- 
2.45.1

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

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


Re: [FFmpeg-devel] [PATCH 2/4] fftools/ffmpeg: rewrite checking whether codec AVOptions have been used

2024-05-24 Thread Michael Niedermayer
On Thu, May 23, 2024 at 11:03:37AM +0200, Anton Khirnov wrote:
> Share the code between encoding and decoding. Instead of checking every
> stream's options dictionary (which is also used for other purposes),
> track all used options in a dedicated dictionary.
> ---
>  fftools/cmdutils.c| 17 
>  fftools/cmdutils.h|  4 ++-
>  fftools/ffmpeg.c  | 49 ++
>  fftools/ffmpeg.h  |  3 ++-
>  fftools/ffmpeg_demux.c| 50 ---
>  fftools/ffmpeg_mux.c  |  1 +
>  fftools/ffmpeg_mux.h  |  3 +++
>  fftools/ffmpeg_mux_init.c | 55 +--
>  fftools/ffmpeg_opt.c  | 18 -
>  fftools/ffplay.c  |  2 +-
>  fftools/ffprobe.c |  2 +-
>  11 files changed, 89 insertions(+), 115 deletions(-)

breaks https://samples.ffmpeg.org/image-samples/exr/sub.0030.exr

./ffmpeg -layer RenderLayer.Color -gamma 2.2  -i sub.0030.exr -bitexact  
/tmp/test-color2.2.jpg

Input #0, exr_pipe, from 'sub.0030.exr':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: exr, gbrapf32le, 960x540 [SAR 1:1 DAR 16:9], 25 fps, 25 
tbr, 25 tbn
[in#0/exr_pipe @ 0x55c06b88b7c0] Codec AVOption gamma (set gamma) is not a 
decoding option.
Error opening input file sub.0030.exr.
Error opening input files: Invalid argument

thx

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

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH v5 1/2] lavu/hashtable: create generic robin hood hash table

2024-05-24 Thread Michael Niedermayer
On Thu, May 23, 2024 at 03:10:04PM -0700, Connor Worley wrote:
> Signed-off-by: Connor Worley 
> ---
>  libavutil/Makefile  |   2 +
>  libavutil/hashtable.c   | 192 
>  libavutil/hashtable.h   |  91 +
>  libavutil/tests/hashtable.c | 108 
>  4 files changed, 393 insertions(+)
>  create mode 100644 libavutil/hashtable.c
>  create mode 100644 libavutil/hashtable.h
>  create mode 100644 libavutil/tests/hashtable.c

breaks build

 make testprogs -j32 -k
CC  libavutil/tests/hashtable.o
libavutil/tests/hashtable.c: In function ‘main’:
libavutil/tests/hashtable.c:28:5: error: unknown type name ‘uint8_t’; did you 
mean ‘u_int8_t’?
   28 | uint8_t k;
  | ^~~
  | u_int8_t
libavutil/tests/hashtable.c:29:5: error: unknown type name ‘uint64_t’; did you 
mean ‘u_int64_t’?
   29 | uint64_t v;
  | ^~~~
  | u_int64_t
make: *** [ffbuild/common.mak:81: libavutil/tests/hashtable.o] Error 1
make: Target 'testprogs' not remade because of errors.



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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] [PATCH] web/contact: relink code of conduct

2024-05-24 Thread Michael Niedermayer
Found-by: John Hawkinson

Signed-off-by: Michael Niedermayer 
---
 src/contact | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/contact b/src/contact
index 982e9da..537ca9d 100644
--- a/src/contact
+++ b/src/contact
@@ -11,7 +11,7 @@
   avoid https://en.wikipedia.org/wiki/Top-posting;>top-posting and
   thread hijacking (that is, replying to a thread and changing the 
subject line to
   something completely unrelated that was not being discussed within 
the original
-  thread) and please read the Code of conduct.
+  thread) and please read the Code of conduct.
 
 
   Configuring your mail client to break lines after 70 or so 
characters is a plus.
@@ -106,7 +106,7 @@
   have voice in the channels.
   https://kiwiirc.com/nextclient/irc.libera.chat/?channels=#ffmpeg,#ffmpeg-devel;>kiwiirc
 webchat is a web
   client for these channels.
-  Please read and follow the Code of conduct.
+  Please read and follow the Code of conduct.
 
   
   
-- 
2.45.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] lavc/flacdsp: do not assume maximum R-V VL

2024-05-24 Thread Rémi Denis-Courmont
This loop correctly assumes that VLMAX=16 (4x128-bit vectors
with 32-bit elements) and 32 >= pred_order > 16. We need to alternate
between VL=16 and VL=t2=pred_order-16 elements to add up to pred_order.

The current code requests AVL=a2=pred_order elements. In QEMU and on
thte K230 hardware, this sets VL=16 as we need. But the specification
merely guarantees that we get: ceil(AVL / 2) <= VL <= VLMAX. For
instance, if pred_order equals 27, we could end up with VL=14 or VL=15
instead of VL=16. So instead, request literally VLMAX=16.
---
 libavcodec/riscv/flacdsp_rvv.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/riscv/flacdsp_rvv.S b/libavcodec/riscv/flacdsp_rvv.S
index 60c9d03344..da8756a2f9 100644
--- a/libavcodec/riscv/flacdsp_rvv.S
+++ b/libavcodec/riscv/flacdsp_rvv.S
@@ -56,11 +56,11 @@ func ff_flac_lpc32_rvv, zve64x
 vle32.v v16, (a0)
 sh2add  a0, a2, a0
 1:
-vsetvli zero, a2, e32, m4, ta, ma
+vsetvli t1, zero, e32, m4, ta, ma
 vwmul.vv v24, v8, v16
 vsetvli zero, t2, e32, m4, tu, ma
 vwmacc.vv v24, v12, v20
-vsetvli zero, a2, e64, m8, ta, ma
+vsetvli t1, zero, e64, m8, ta, ma
 vredsum.vs v24, v24, v0
 lw  t0, (a0)
 addia4, a4, -1
-- 
2.45.1

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

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


Re: [FFmpeg-devel] [PATCH] avcodec/flacdec: Remove unused variable

2024-05-24 Thread James Almer

On 5/24/2024 12:37 PM, Andreas Rheinhardt wrote:

Forgotten in 0380a03f1f9d55e5690bb92bfa4897f2c728c1e5.


LGTM. And sorry, i was sure i had amended it locally when you pointed it 
out.




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

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 460d3bc01e..ad921a1bd1 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -481,7 +481,7 @@ static int decode_subframe_lpc(FLACContext *s, int32_t 
*decoded, int pred_order,
  static int decode_subframe_lpc_33bps(FLACContext *s, int64_t *decoded,
   int32_t *residual, int pred_order)
  {
-int i, j, ret;
+int i, ret;
  int coeff_prec, qlevel;
  int coeffs[32];
  

___
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 v9 01/13] avcodec/vaapi_encode: introduce a base layer for vaapi encode

2024-05-24 Thread Lynne via ffmpeg-devel

On 24/05/2024 17:39, Wu, Tong1 wrote:

-Original Message-
From: ffmpeg-devel  On Behalf Of Lynne
via ffmpeg-devel
Sent: Friday, May 24, 2024 12:11 AM
To: ffmpeg-devel@ffmpeg.org
Cc: Lynne 
Subject: Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode:
introduce a base layer for vaapi encode

On 20/05/2024 16:52, tong1.wu-at-intel@ffmpeg.org wrote:

From: Tong Wu 

Since VAAPI and future D3D12VA implementation may share some common

parameters,

a base layer encode context is introduced as vaapi context's base.

Signed-off-by: Tong Wu 
---
   libavcodec/hw_base_encode.h | 56

+

   libavcodec/vaapi_encode.h   | 39 +-
   2 files changed, 63 insertions(+), 32 deletions(-)
   create mode 100644 libavcodec/hw_base_encode.h

diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h
new file mode 100644
index 00..1996179456
--- /dev/null
+++ b/libavcodec/hw_base_encode.h
@@ -0,0 +1,56 @@
+/*
+ * 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_HW_BASE_ENCODE_H
+#define AVCODEC_HW_BASE_ENCODE_H
+
+#define MAX_DPB_SIZE 16
+#define MAX_PICTURE_REFERENCES 2
+#define MAX_REORDER_DELAY 16
+#define MAX_ASYNC_DEPTH 64
+#define MAX_REFERENCE_LIST_NUM 2
+
+enum {
+PICTURE_TYPE_IDR = 0,
+PICTURE_TYPE_I   = 1,
+PICTURE_TYPE_P   = 2,
+PICTURE_TYPE_B   = 3,
+};
+
+enum {
+// Codec supports controlling the subdivision of pictures into slices.
+FLAG_SLICE_CONTROL = 1 << 0,
+// Codec only supports constant quality (no rate control).
+FLAG_CONSTANT_QUALITY_ONLY = 1 << 1,
+// Codec is intra-only.
+FLAG_INTRA_ONLY= 1 << 2,
+// Codec supports B-pictures.
+FLAG_B_PICTURES= 1 << 3,
+// Codec supports referencing B-pictures.
+FLAG_B_PICTURE_REFERENCES  = 1 << 4,
+// Codec supports non-IDR key pictures (that is, key pictures do
+// not necessarily empty the DPB).
+FLAG_NON_IDR_KEY_PICTURES  = 1 << 5,
+};
+
+typedef struct HWBaseEncodeContext {
+const AVClass *class;
+} HWBaseEncodeContext;
+
+#endif /* AVCODEC_HW_BASE_ENCODE_H */
+
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index 0eed9691ca..f5c9be8973 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -33,34 +33,27 @@

   #include "avcodec.h"
   #include "hwconfig.h"
+#include "hw_base_encode.h"

   struct VAAPIEncodeType;
   struct VAAPIEncodePicture;

+// Codec output packet without timestamp delay, which means the
+// output packet has same PTS and DTS.
+#define FLAG_TIMESTAMP_NO_DELAY 1 << 6
+
   enum {
   MAX_CONFIG_ATTRIBUTES  = 4,
   MAX_GLOBAL_PARAMS  = 4,
-MAX_DPB_SIZE   = 16,
-MAX_PICTURE_REFERENCES = 2,
-MAX_REORDER_DELAY  = 16,
   MAX_PARAM_BUFFER_SIZE  = 1024,
   // A.4.1: table A.6 allows at most 22 tile rows for any level.
   MAX_TILE_ROWS  = 22,
   // A.4.1: table A.6 allows at most 20 tile columns for any level.
   MAX_TILE_COLS  = 20,
-MAX_ASYNC_DEPTH= 64,
-MAX_REFERENCE_LIST_NUM = 2,
   };

   extern const AVCodecHWConfigInternal *const

ff_vaapi_encode_hw_configs[];


-enum {
-PICTURE_TYPE_IDR = 0,
-PICTURE_TYPE_I   = 1,
-PICTURE_TYPE_P   = 2,
-PICTURE_TYPE_B   = 3,
-};
-
   typedef struct VAAPIEncodeSlice {
   int index;
   int row_start;
@@ -193,7 +186,8 @@ typedef struct VAAPIEncodeRCMode {
   } VAAPIEncodeRCMode;

   typedef struct VAAPIEncodeContext {
-const AVClass *class;
+// Base context.
+HWBaseEncodeContext base;

   // Codec-specific hooks.
   const struct VAAPIEncodeType *codec;
@@ -397,25 +391,6 @@ typedef struct VAAPIEncodeContext {
   AVPacket*tail_pkt;
   } VAAPIEncodeContext;

-enum {
-// Codec supports controlling the subdivision of pictures into slices.
-FLAG_SLICE_CONTROL = 1 << 0,
-// Codec only supports constant quality (no rate control).
-FLAG_CONSTANT_QUALITY_ONLY = 1 << 1,
-// Codec is intra-only.
-FLAG_INTRA_ONLY= 1 << 2,
-// Codec supports B-pictures.
-FLAG_B_PICTURES= 1 << 3,
-// Codec supports referencing B-pictures.
-

[FFmpeg-devel] [PATCH 2/2] checkasm/vp8dsp: add VP7 tests

2024-05-24 Thread Rémi Denis-Courmont
---
 tests/checkasm/vp8dsp.c | 57 ++---
 1 file changed, 36 insertions(+), 21 deletions(-)

diff --git a/tests/checkasm/vp8dsp.c b/tests/checkasm/vp8dsp.c
index 12d2f62f2d..e448fe89fc 100644
--- a/tests/checkasm/vp8dsp.c
+++ b/tests/checkasm/vp8dsp.c
@@ -18,8 +18,10 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include 
 #include 
 
+#include "config_components.h"
 #include "libavcodec/vp8dsp.h"
 
 #include "libavutil/common.h"
@@ -108,7 +110,7 @@ static void wht4x4(int16_t *coef)
 }
 }
 
-static void check_idct(VP8DSPContext *d)
+static void check_idct(VP8DSPContext *d, bool is_vp7)
 {
 LOCAL_ALIGNED_16(uint8_t, src,  [4 * 4]);
 LOCAL_ALIGNED_16(uint8_t, dst,  [4 * 4]);
@@ -127,7 +129,7 @@ static void check_idct(VP8DSPContext *d)
 for (dc = 0; dc <= 1; dc++) {
 void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? 
d->vp8_idct_dc_add : d->vp8_idct_add;
 
-if (check_func(idct, "vp8_idct_%sadd", dc ? "dc_" : "")) {
+if (check_func(idct, "vp%d_idct_%sadd", 8 - is_vp7, dc ? "dc_" : "")) {
 if (dc) {
 memset(subcoef0, 0, 4 * 4 * sizeof(int16_t));
 subcoef0[0] = coef[0];
@@ -151,7 +153,7 @@ static void check_idct(VP8DSPContext *d)
 }
 }
 
-static void check_idct_dc4(VP8DSPContext *d)
+static void check_idct_dc4(VP8DSPContext *d, bool is_vp7)
 {
 LOCAL_ALIGNED_16(uint8_t, src,  [4 * 4 * 4]);
 LOCAL_ALIGNED_16(uint8_t, dst,  [4 * 4 * 4]);
@@ -165,7 +167,7 @@ static void check_idct_dc4(VP8DSPContext *d)
 
 for (chroma = 0; chroma <= 1; chroma++) {
 void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? 
d->vp8_idct_dc_add4uv : d->vp8_idct_dc_add4y;
-if (check_func(idct4dc, "vp8_idct_dc_add4%s", chroma ? "uv" : "y")) {
+if (check_func(idct4dc, "vp%d_idct_dc_add4%s", 8 - is_vp7, chroma ? 
"uv" : "y")) {
 ptrdiff_t stride = chroma ? 8 : 16;
 int w  = chroma ? 2 : 4;
 for (i = 0; i < 4; i++) {
@@ -191,7 +193,7 @@ static void check_idct_dc4(VP8DSPContext *d)
 
 }
 
-static void check_luma_dc_wht(VP8DSPContext *d)
+static void check_luma_dc_wht(VP8DSPContext *d, bool is_vp7)
 {
 LOCAL_ALIGNED_16(int16_t, dc, [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, dc0, [4 * 4]);
@@ -218,7 +220,7 @@ static void check_luma_dc_wht(VP8DSPContext *d)
 for (dc_only = 0; dc_only <= 1; dc_only++) {
 void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? 
d->vp8_luma_dc_wht_dc : d->vp8_luma_dc_wht;
 
-if (check_func(idct, "vp8_luma_dc_wht%s", dc_only ? "_dc" : "")) {
+if (check_func(idct, "vp%d_luma_dc_wht%s", 8 - is_vp7, dc_only ? "_dc" 
: "")) {
 if (dc_only) {
 memset(dc0, 0, 16 * sizeof(int16_t));
 dc0[0] = dc[0];
@@ -368,7 +370,7 @@ static void fill_loopfilter_buffers(uint8_t *buf, ptrdiff_t 
stride, int w, int h
 #define randomize_buffers(buf, lineoff, str, force_hev) \
 randomize_loopfilter_buffers(lineoff, str, dir, flim_E, flim_I, 
hev_thresh, buf, force_hev)
 
-static void check_loopfilter_16y(VP8DSPContext *d)
+static void check_loopfilter_16y(VP8DSPContext *d, bool is_vp7)
 {
 LOCAL_ALIGNED_16(uint8_t, base0, [32 + 16 * 16]);
 LOCAL_ALIGNED_16(uint8_t, base1, [32 + 16 * 16]);
@@ -389,7 +391,7 @@ static void check_loopfilter_16y(VP8DSPContext *d)
 case (0 << 1) | 1: func = d->vp8_h_loop_filter16y_inner; break;
 case (1 << 1) | 1: func = d->vp8_v_loop_filter16y_inner; break;
 }
-if (check_func(func, "vp8_loop_filter16y%s_%s", edge ? "_inner" : 
"", dir ? "v" : "h")) {
+if (check_func(func, "vp%d_loop_filter16y%s_%s", 8 - is_vp7, edge 
? "_inner" : "", dir ? "v" : "h")) {
 for (force_hev = -1; force_hev <= 1; force_hev++) {
 fill_loopfilter_buffers(buf0 - midoff, 16, 16, 16);
 randomize_buffers(buf0, 0, 16, force_hev);
@@ -409,7 +411,7 @@ static void check_loopfilter_16y(VP8DSPContext *d)
 }
 }
 
-static void check_loopfilter_8uv(VP8DSPContext *d)
+static void check_loopfilter_8uv(VP8DSPContext *d, bool is_vp7)
 {
 LOCAL_ALIGNED_16(uint8_t, base0u, [32 + 16 * 16]);
 LOCAL_ALIGNED_16(uint8_t, base0v, [32 + 16 * 16]);
@@ -434,7 +436,7 @@ static void check_loopfilter_8uv(VP8DSPContext *d)
 case (0 << 1) | 1: func = d->vp8_h_loop_filter8uv_inner; break;
 case (1 << 1) | 1: func = d->vp8_v_loop_filter8uv_inner; break;
 }
-if (check_func(func, "vp8_loop_filter8uv%s_%s", edge ? "_inner" : 
"", dir ? "v" : "h")) {
+if (check_func(func, "vp%d_loop_filter8uv%s_%s", 8 - is_vp7, edge 
? "_inner" : "", dir ? "v" : "h")) {
 for (force_hev = -1; force_hev <= 1; force_hev++) {
 fill_loopfilter_buffers(buf0u - midoff, 16, 16, 16);
 fill_loopfilter_buffers(buf0v - midoff, 16, 16, 16);
@@ 

[FFmpeg-devel] [PATCH 1/2] checkasm/vp8dsp: share DSP context across tests

2024-05-24 Thread Rémi Denis-Courmont
This will simplify later changes.
---
 tests/checkasm/vp8dsp.c | 82 +
 1 file changed, 34 insertions(+), 48 deletions(-)

diff --git a/tests/checkasm/vp8dsp.c b/tests/checkasm/vp8dsp.c
index 6e989819ef..12d2f62f2d 100644
--- a/tests/checkasm/vp8dsp.c
+++ b/tests/checkasm/vp8dsp.c
@@ -108,7 +108,7 @@ static void wht4x4(int16_t *coef)
 }
 }
 
-static void check_idct(void)
+static void check_idct(VP8DSPContext *d)
 {
 LOCAL_ALIGNED_16(uint8_t, src,  [4 * 4]);
 LOCAL_ALIGNED_16(uint8_t, dst,  [4 * 4]);
@@ -117,17 +117,15 @@ static void check_idct(void)
 LOCAL_ALIGNED_16(int16_t, coef, [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, subcoef0, [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, subcoef1, [4 * 4]);
-VP8DSPContext d;
 int dc;
 declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t *block, 
ptrdiff_t stride);
 
-ff_vp8dsp_init();
 randomize_buffers(src, dst, 4, coef);
 
 dct4x4(coef);
 
 for (dc = 0; dc <= 1; dc++) {
-void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? d.vp8_idct_dc_add 
: d.vp8_idct_add;
+void (*idct)(uint8_t *, int16_t *, ptrdiff_t) = dc ? 
d->vp8_idct_dc_add : d->vp8_idct_add;
 
 if (check_func(idct, "vp8_idct_%sadd", dc ? "dc_" : "")) {
 if (dc) {
@@ -153,7 +151,7 @@ static void check_idct(void)
 }
 }
 
-static void check_idct_dc4(void)
+static void check_idct_dc4(VP8DSPContext *d)
 {
 LOCAL_ALIGNED_16(uint8_t, src,  [4 * 4 * 4]);
 LOCAL_ALIGNED_16(uint8_t, dst,  [4 * 4 * 4]);
@@ -162,14 +160,11 @@ static void check_idct_dc4(void)
 LOCAL_ALIGNED_16(int16_t, coef, [4], [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, subcoef0, [4], [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, subcoef1, [4], [4 * 4]);
-VP8DSPContext d;
 int i, chroma;
 declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, int16_t 
block[4][16], ptrdiff_t stride);
 
-ff_vp8dsp_init();
-
 for (chroma = 0; chroma <= 1; chroma++) {
-void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? 
d.vp8_idct_dc_add4uv : d.vp8_idct_dc_add4y;
+void (*idct4dc)(uint8_t *, int16_t[4][16], ptrdiff_t) = chroma ? 
d->vp8_idct_dc_add4uv : d->vp8_idct_dc_add4y;
 if (check_func(idct4dc, "vp8_idct_dc_add4%s", chroma ? "uv" : "y")) {
 ptrdiff_t stride = chroma ? 8 : 16;
 int w  = chroma ? 2 : 4;
@@ -196,7 +191,7 @@ static void check_idct_dc4(void)
 
 }
 
-static void check_luma_dc_wht(void)
+static void check_luma_dc_wht(VP8DSPContext *d)
 {
 LOCAL_ALIGNED_16(int16_t, dc, [4 * 4]);
 LOCAL_ALIGNED_16(int16_t, dc0, [4 * 4]);
@@ -204,13 +199,10 @@ static void check_luma_dc_wht(void)
 int16_t block[4][4][16];
 LOCAL_ALIGNED_16(int16_t, block0, [4], [4][16]);
 LOCAL_ALIGNED_16(int16_t, block1, [4], [4][16]);
-VP8DSPContext d;
 int dc_only;
 int blockx, blocky;
 declare_func_emms(AV_CPU_FLAG_MMX, void, int16_t block[4][4][16], int16_t 
dc[16]);
 
-ff_vp8dsp_init();
-
 for (blocky = 0; blocky < 4; blocky++) {
 for (blockx = 0; blockx < 4; blockx++) {
 uint8_t src[16], dst[16];
@@ -224,7 +216,7 @@ static void check_luma_dc_wht(void)
 wht4x4(dc);
 
 for (dc_only = 0; dc_only <= 1; dc_only++) {
-void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? 
d.vp8_luma_dc_wht_dc : d.vp8_luma_dc_wht;
+void (*idct)(int16_t [4][4][16], int16_t [16]) = dc_only ? 
d->vp8_luma_dc_wht_dc : d->vp8_luma_dc_wht;
 
 if (check_func(idct, "vp8_luma_dc_wht%s", dc_only ? "_dc" : "")) {
 if (dc_only) {
@@ -262,20 +254,16 @@ static void check_luma_dc_wht(void)
 } \
 } while (0)
 
-static void check_mc(void)
+static void check_mc(VP8DSPContext *d)
 {
 LOCAL_ALIGNED_16(uint8_t, buf, [32 * 32]);
 LOCAL_ALIGNED_16(uint8_t, dst0, [16 * 16]);
 LOCAL_ALIGNED_16(uint8_t, dst1, [16 * 16]);
-VP8DSPContext d;
 int type, k, dx, dy;
 declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *, ptrdiff_t,
   const uint8_t *, ptrdiff_t, int, int, int);
 
-ff_vp78dsp_init();
-
 for (type = 0; type < 2; type++) {
-vp8_mc_func (*tab)[3][3] = type ? d.put_vp8_bilinear_pixels_tab : 
d.put_vp8_epel_pixels_tab;
 for (k = 1; k < 8; k++) {
 int hsize  = k / 3;
 int size   = 16 >> hsize;
@@ -283,6 +271,8 @@ static void check_mc(void)
 for (dy = 0; dy < 3; dy++) {
 for (dx = 0; dx < 3; dx++) {
 char str[100];
+vp8_mc_func func = (type ? d->put_vp8_bilinear_pixels_tab 
: d->put_vp8_epel_pixels_tab)[hsize][dy][dx];
+
 if (dx || dy) {
 if (type == 0) {
 static const char *dx_names[] = { "", "h4", "h6" };
@@ -294,7 +284,8 @@ static void check_mc(void)
 } else {
 snprintf(str, 

Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode: introduce a base layer for vaapi encode

2024-05-24 Thread Wu, Tong1
>-Original Message-
>From: ffmpeg-devel  On Behalf Of Lynne
>via ffmpeg-devel
>Sent: Friday, May 24, 2024 12:11 AM
>To: ffmpeg-devel@ffmpeg.org
>Cc: Lynne 
>Subject: Re: [FFmpeg-devel] [PATCH v9 01/13] avcodec/vaapi_encode:
>introduce a base layer for vaapi encode
>
>On 20/05/2024 16:52, tong1.wu-at-intel@ffmpeg.org wrote:
>> From: Tong Wu 
>>
>> Since VAAPI and future D3D12VA implementation may share some common
>parameters,
>> a base layer encode context is introduced as vaapi context's base.
>>
>> Signed-off-by: Tong Wu 
>> ---
>>   libavcodec/hw_base_encode.h | 56
>+
>>   libavcodec/vaapi_encode.h   | 39 +-
>>   2 files changed, 63 insertions(+), 32 deletions(-)
>>   create mode 100644 libavcodec/hw_base_encode.h
>>
>> diff --git a/libavcodec/hw_base_encode.h b/libavcodec/hw_base_encode.h
>> new file mode 100644
>> index 00..1996179456
>> --- /dev/null
>> +++ b/libavcodec/hw_base_encode.h
>> @@ -0,0 +1,56 @@
>> +/*
>> + * 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_HW_BASE_ENCODE_H
>> +#define AVCODEC_HW_BASE_ENCODE_H
>> +
>> +#define MAX_DPB_SIZE 16
>> +#define MAX_PICTURE_REFERENCES 2
>> +#define MAX_REORDER_DELAY 16
>> +#define MAX_ASYNC_DEPTH 64
>> +#define MAX_REFERENCE_LIST_NUM 2
>> +
>> +enum {
>> +PICTURE_TYPE_IDR = 0,
>> +PICTURE_TYPE_I   = 1,
>> +PICTURE_TYPE_P   = 2,
>> +PICTURE_TYPE_B   = 3,
>> +};
>> +
>> +enum {
>> +// Codec supports controlling the subdivision of pictures into slices.
>> +FLAG_SLICE_CONTROL = 1 << 0,
>> +// Codec only supports constant quality (no rate control).
>> +FLAG_CONSTANT_QUALITY_ONLY = 1 << 1,
>> +// Codec is intra-only.
>> +FLAG_INTRA_ONLY= 1 << 2,
>> +// Codec supports B-pictures.
>> +FLAG_B_PICTURES= 1 << 3,
>> +// Codec supports referencing B-pictures.
>> +FLAG_B_PICTURE_REFERENCES  = 1 << 4,
>> +// Codec supports non-IDR key pictures (that is, key pictures do
>> +// not necessarily empty the DPB).
>> +FLAG_NON_IDR_KEY_PICTURES  = 1 << 5,
>> +};
>> +
>> +typedef struct HWBaseEncodeContext {
>> +const AVClass *class;
>> +} HWBaseEncodeContext;
>> +
>> +#endif /* AVCODEC_HW_BASE_ENCODE_H */
>> +
>> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
>> index 0eed9691ca..f5c9be8973 100644
>> --- a/libavcodec/vaapi_encode.h
>> +++ b/libavcodec/vaapi_encode.h
>> @@ -33,34 +33,27 @@
>>
>>   #include "avcodec.h"
>>   #include "hwconfig.h"
>> +#include "hw_base_encode.h"
>>
>>   struct VAAPIEncodeType;
>>   struct VAAPIEncodePicture;
>>
>> +// Codec output packet without timestamp delay, which means the
>> +// output packet has same PTS and DTS.
>> +#define FLAG_TIMESTAMP_NO_DELAY 1 << 6
>> +
>>   enum {
>>   MAX_CONFIG_ATTRIBUTES  = 4,
>>   MAX_GLOBAL_PARAMS  = 4,
>> -MAX_DPB_SIZE   = 16,
>> -MAX_PICTURE_REFERENCES = 2,
>> -MAX_REORDER_DELAY  = 16,
>>   MAX_PARAM_BUFFER_SIZE  = 1024,
>>   // A.4.1: table A.6 allows at most 22 tile rows for any level.
>>   MAX_TILE_ROWS  = 22,
>>   // A.4.1: table A.6 allows at most 20 tile columns for any level.
>>   MAX_TILE_COLS  = 20,
>> -MAX_ASYNC_DEPTH= 64,
>> -MAX_REFERENCE_LIST_NUM = 2,
>>   };
>>
>>   extern const AVCodecHWConfigInternal *const
>ff_vaapi_encode_hw_configs[];
>>
>> -enum {
>> -PICTURE_TYPE_IDR = 0,
>> -PICTURE_TYPE_I   = 1,
>> -PICTURE_TYPE_P   = 2,
>> -PICTURE_TYPE_B   = 3,
>> -};
>> -
>>   typedef struct VAAPIEncodeSlice {
>>   int index;
>>   int row_start;
>> @@ -193,7 +186,8 @@ typedef struct VAAPIEncodeRCMode {
>>   } VAAPIEncodeRCMode;
>>
>>   typedef struct VAAPIEncodeContext {
>> -const AVClass *class;
>> +// Base context.
>> +HWBaseEncodeContext base;
>>
>>   // Codec-specific hooks.
>>   const struct VAAPIEncodeType *codec;
>> @@ -397,25 +391,6 @@ typedef struct VAAPIEncodeContext {
>>   AVPacket*tail_pkt;
>>   } VAAPIEncodeContext;
>>
>> -enum {
>> -// Codec supports controlling the subdivision of pictures into slices.
>> -FLAG_SLICE_CONTROL   

[FFmpeg-devel] [PATCH] avcodec/flacdec: Remove unused variable

2024-05-24 Thread Andreas Rheinhardt
Forgotten in 0380a03f1f9d55e5690bb92bfa4897f2c728c1e5.

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

diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 460d3bc01e..ad921a1bd1 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -481,7 +481,7 @@ static int decode_subframe_lpc(FLACContext *s, int32_t 
*decoded, int pred_order,
 static int decode_subframe_lpc_33bps(FLACContext *s, int64_t *decoded,
  int32_t *residual, int pred_order)
 {
-int i, j, ret;
+int i, ret;
 int coeff_prec, qlevel;
 int coeffs[32];
 
-- 
2.40.1

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

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


Re: [FFmpeg-devel] [PATCH 0/1] avcodec/h264_parser: fix start of packet for some broken

2024-05-24 Thread Nicolas Gaullier
>Envoyé : mardi 26 mars 2024 16:10
>
>This is a patch from my patch serie 
>https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=10999
>Maybe it is easier to review it this way, independantly.
>This patch shows some benefits by itself, but most importantly, it is required 
>for my patch serie to avoid any regression with some invalid streams.
>
>This patch is active in mpegts/h264 when the NAL Access Unit Delimiter is 
>missing the zero_byte (= a invalid stream case).
>In such a case, if it happens that the last data byte from the previous frame 
>is a null byte, this byte is "kidnaped" to form the full NAL_AUD...
>This is not good, but even worser, with my patch serie above applied, it means 
>that the start of the editunit is in the previous frame, which means the pts 
>has to be taken in it, which is not the expected behaviour in such a 
>missleading >scenario.
>
>Michael sent me a sample from the wild but it can't be shared, so here it is:
>I have another sample of my own with NAL_AUD missing zero_byte similarly, but 
>it is missing the ending null byte, so I have patched/inserted the null byte 
>(I shrinked the adaptation field) to show how the code behave.
>
>Sample original (invalid NAL_AUDs):
>https://0x0.st/Xs9Q.ts
>Same sample modified to exhibit the issue (invalid NAL_AUDs + an available 
>null ending byte at 0x291F):
>https://0x0.st/Xs9j.ts
>
>I use this simple command line and then compare the xml, it seems quite clear:
>ffprobe xxx.ts -show_packets -show_data -print_format xml
>
>Nicolas Gaullier (1):
>  avcodec/h264_parser: fix start of packet for some broken streams
>
> libavcodec/h264_parser.c | 11 ++-
> 1 file changed, 10 insertions(+), 1 deletion(-)

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

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


Re: [FFmpeg-devel] [PATCH v3 0/1] avformat/demux: fix accurate probing of durations in mpegts/ps

2024-05-24 Thread Nicolas Gaullier
>Envoyé : lundi 29 avril 2024 19:35
>À : FFmpeg development discussions and patches 
>Objet : Re: [FFmpeg-devel] [PATCH v3 0/1] avformat/demux: fix accurate probing 
>of durations in mpegts/ps
>
>>Envoyé : lundi 22 avril 2024 14:32
>>À : ffmpeg-devel@ffmpeg.org
>>Objet : Re: [FFmpeg-devel] [PATCH v3 0/1] avformat/demux: fix accurate 
>>probing of durations in mpegts/ps
>>
>>>De : Nicolas Gaullier  Envoyé : mardi 2 
>>>avril 2024 23:26 Objet : [PATCH v3 0/1] avformat/demux: fix accurate 
>>>probing of durations in mpegts/ps
>>>
>>>v3: rebased after ed9363052f4b8b8 applied tonight (add 
>>>duration_probesize AVOption)
>>>
>>>Note: I have no other plan for demux/probing; with these two patches, I can 
>>>cover my use cases, especially mpegts-concats.
>>>
>>>For remembering, previous cover-letters:
>>>
>>>v1
>>>ff_read_packet() is more lightweight, but it leads to important issues when 
>>>looking for accurate durations.
>>>As a side effect, the code looks also simpler with regular av_read_frame() 
>>>calls.
>>>1)Updates in the fate tests do exhibit most of the results.
>>>
>>>2)See also more directly the case of an audio PES containing many frames:
ffprobe tests/data/lavf/lavf.ts -select_streams a -show_entries 
stream=duration -of flat
>>>Before patch:
>>>  streams.stream.0.duration="0.757556"
>>>After patch:
>>>  streams.stream.0.duration="1.018778"
>>>
>>>3)Here is an additional (commonplace) sample to demonstrate the benefit for 
>>>twofields-encoded video:
https://0x0.st/HFbm.ts (say h264-50i_mp2.ts)
>>>
ffprobe h264-50i_mp2.ts -show_entries stream=duration -of flat
>>>Before patch:
>>>  streams.stream.0.duration="2.06"
>>>  streams.stream.1.duration="1.176000"
>>>After patch:
>>>  streams.stream.0.duration="2.08"
>>>  streams.stream.1.duration="1.20"
>>>
>>>
>>>v2
>>>v1: There was an issue with teletext where resolution is set just once at 
>>>decoder init (teletext resolution is fixed/hard coded), so it is somewhat 
>>>fragile: when a demuxer context update occurs, it is lost/overriden by 
>>avcodec_parameters_to_context(sti->avctx, st->codecpar) in 
>>>read_frame_internal.
>>>They could have been other scenario besides teletext, I don't know.
>>>v2: So now at estimate_timings_from_pts, with one or more seeking involved 
>>>(seeking is detected by the mpegts demuxer and set last_vn=-1, so pmt is 
>>>forced/updated and results in demuxer context update), it is required to 
>>preserve the info in codecpar at first.
>>>Thanks to Michael for reporting the issue.
>>>
>>>
>>>Nicolas Gaullier (1):
>>>  avformat/demux: Fix accurate probing of durations in mpegts/ps
>>>
>>> libavformat/demux.c   |  36 ++--
>>> tests/ref/fate/concat-demuxer-simple2-lavf-ts | 170 +-
>>> tests/ref/fate/ts-opus-demux  |   4 +-
>>> 3 files changed, 100 insertions(+), 110 deletions(-)
>>
>>Ping for review ?
>>The patch (https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=11386) 
>>still applies on current master.
>>Thanks.

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

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


Re: [FFmpeg-devel] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Andreas Rheinhardt
Michael Henrik Bodenhoff via ffmpeg-devel:
> Hi Andrey ,
> 
> "when the decoder is set up to ignore B frames"
> 
> How do you do that ? 
> 
> We must have missed something while we tried using FFmpeg, because we 
> couldn't find a way of telling the decoder to ignore B frames, we actually 
> got so desperate that we considered if it was possible to modify the incoming 
> encoded stream to make FFmpeg believe that the stream doesn't contain B 
> frames ☹
> 

There is AVCodecContext.skip_frame; some decoders (not all, but e.g.
H.264) will skip frames based upon this value. But it does not affect
the decoder delay.
(There is also AV_CODEC_FLAG_LOW_DELAY, but this is honored by even less
decoders (only some old ones).)

- 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] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Michael Henrik Bodenhoff via ffmpeg-devel
Hi Andrey ,

"when the decoder is set up to ignore B frames"

How do you do that ? 

We must have missed something while we tried using FFmpeg, because we couldn't 
find a way of telling the decoder to ignore B frames, we actually got so 
desperate that we considered if it was possible to modify the incoming encoded 
stream to make FFmpeg believe that the stream doesn't contain B frames ☹

Michael Bodenhoff
Principal Software Engineer

FT01

Email: m...@milestone.dk
-Original Message-
From: ffmpeg-devel  On Behalf Of Andrey Turkin
Sent: 24. maj 2024 13:39
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] Flushing while decoding , but need already decoded 
frames

[You don't often get email from andrey.tur...@gmail.com. Learn why this is 
important at https://aka.ms/LearnAboutSenderIdentification ]

Have to say, this issue has been a long grievance of mine. There is no reason 
to delay frames when the decoder is set up to ignore B frames as there is no 
reordering to be done; ideally this should be zero-delay case (packet goes in, 
frame goes out) yet the most common decoders delay frames anyway, as if to 
decode B frames. Moreover, with the "new" send/receive API I think there is no 
reason to delay frames at all - a single send_packet could decode and queue 
multiple frames to be received, so it makes sense to send frames as soon as 
possible - yet that is not the case as well.

пт, 24 мая 2024 г. в 13:17, Andreas Rheinhardt :
>
> Michael Henrik Bodenhoff via ffmpeg-devel:
> > Hi ,
> >
> > my team recently had to abandon switching to using FFmpeg from
> > specific decoder implementations (NvDEC, Intel Media SDK , IPP and
> > quite a few codec specific decoders) because of big performance
> > issues because of the way FFmpeg works….. or at least we think it is
> > (we’re FFmpeg noobs   )
> >
> > It's actually an issue we also had with Intel Media SDK,  leading us to pay 
> > Intel to extend Media SDK to do what we needed.
> >
> > Our product is a video surveillance system, and that means we have to 
> > decode a LOT of video streams simultaneously.
> >
> > For motion detection we want to only decode keyframes, and skip P and B 
> > frames , and that works fine with FFmpeg most of the time, except for when 
> > the video stream contains B frames.
> > Without B-Frames it’s really simple (simplified pseudocode) :
> >
> > while(true)
> > {
> >   receiveStreamCompleteFrame();
> >   If(KeyFrame)
> >   {
> > avcodec_send_packet();
> > if(avcodec_receive_frame()==0)
> > {
> >// do motion detection
> > }
> >   }
> > }
> >
> > But! with B Frames FFmpeg doesn’t return keyframes when they are decoded, 
> > they are kept, and we can’t seem to flush them out. avcodec_flush_buffers 
> > allow us to continue to next keyframe, but it doesn’t seem to give us the 
> > keyframe we just gave to FFmpeg with avcodec_send_packet.
> >
> > while(true)
> > {
> >   receiveStreamCompleteFrame();
> >   If(KeyFrame)
> >   {
> > avcodec_send_packet();
> > if(avcodec_receive_frame()==0)
> > {
> >// do motion detection
> > }
> > Else
> > {
> >   avcodec_flush_buffers();
> >   if(avcodec_receive_frame()==0)
> >   {
> >  // do motion detection
> >   }
> > }
> >   }
> > }
> >
> > Calling avcodec_receive_frame after calling avcodec_flush_buffer
> > results in -11 and no frame
> >
> > is there anyway around this ? And if not, could FFmpeg be made to have this 
> > functionality ?
> >
> > I tried contacting one of the FFmpeg consultants from
> > https://ff/
> > mpeg.org%2Fconsulting.html=05%7C02%7Cmibo%40milestone.dk%7C46bc
> > b557d2194eb8b76d08dc7be63528%7C4744e4b2072d4754be71250b45e049fe%7C0%
> > 7C0%7C638521475866379714%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDA
> > iLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C=H
> > V8bPZyvDklo5iGs%2BnrW4uEJ6m%2B9tOExcyvt8W3VxyQ%3D=0 but
> > never got a response
> >
>
> Send your packet with the keyframe, send a NULL packet (to signal
> EOF), then the internally stored frames should be output by
> avcodec_receive_frame(). Then flush the decoder (to be able to send
> new packets to it).
>
> - Andreas
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmp/
> eg.org%2Fmailman%2Flistinfo%2Fffmpeg-devel=05%7C02%7Cmibo%40miles
> tone.dk%7C46bcb557d2194eb8b76d08dc7be63528%7C4744e4b2072d4754be71250b4
> 5e049fe%7C0%7C0%7C638521475866388265%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM
> C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C
> =vxzy9fFGqhTghbquG0O9zUE1e%2FoPrkaJbsPAfkN7NtE%3D=0
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email 

Re: [FFmpeg-devel] [PATCH v3 1/2] avcodec: add external enc libvvenc for H266/VVC

2024-05-24 Thread Nuo Mi
Hi @Andreas,
Thank you for the review.
Seems Christian still needs some guidance from you, see 1, 2, 3
On Thu, May 16, 2024 at 11:22 PM Christian  wrote:

>
>
> > On 14. May 2024, at 18:49, Andreas Rheinhardt <
> andreas.rheinha...@outlook.com> wrote:
> >
> > Christian Bartnik:
> >> From: Thomas Siedel 
> >>
> >> Add external encoder VVenC for H266/VVC encoding.
> >> Register new encoder libvvenc.
> >> Add libvvenc to wrap the vvenc interface.
> >> libvvenc implements encoder option: preset,qp,period,subjopt,
> >> vvenc-params,levelidc,tier.
> >> Enable encoder by adding --enable-libvvenc in configure step.
> >>
> >> Co-authored-by: Christian Bartnik chris1031...@gmail.com
> >> Signed-off-by: Christian Bartnik 
> >> ---
> >> configure  |   4 +
> >> doc/encoders.texi  |  65 +
> >> libavcodec/Makefile|   1 +
> >> libavcodec/allcodecs.c |   1 +
> >> libavcodec/libvvenc.c  | 566 +
> >> 5 files changed, 637 insertions(+)
> >> create mode 100644 libavcodec/libvvenc.c
> >>
> >> diff --git a/configure b/configure
> >> index a909b0689c..5d9a14821b 100755
> >> --- a/configure
> >> +++ b/configure
> >> @@ -293,6 +293,7 @@ External library support:
> >>   --enable-libvorbis   enable Vorbis en/decoding via libvorbis,
> >>native implementation exists [no]
> >>   --enable-libvpx  enable VP8 and VP9 de/encoding via libvpx
> [no]
> >> +  --enable-libvvencenable H.266/VVC encoding via vvenc [no]
> >>   --enable-libwebp enable WebP encoding via libwebp [no]
> >>   --enable-libx264 enable H.264 encoding via x264 [no]
> >>   --enable-libx265 enable HEVC encoding via x265 [no]
> >> @@ -1966,6 +1967,7 @@ EXTERNAL_LIBRARY_LIST="
> >> libvmaf
> >> libvorbis
> >> libvpx
> >> +libvvenc
> >> libwebp
> >> libxevd
> >> libxeve
> >> @@ -3558,6 +3560,7 @@ libvpx_vp8_decoder_deps="libvpx"
> >> libvpx_vp8_encoder_deps="libvpx"
> >> libvpx_vp9_decoder_deps="libvpx"
> >> libvpx_vp9_encoder_deps="libvpx"
> >> +libvvenc_encoder_deps="libvvenc"
> >> libwebp_encoder_deps="libwebp"
> >> libwebp_anim_encoder_deps="libwebp"
> >> libx262_encoder_deps="libx262"
> >> @@ -7025,6 +7028,7 @@ enabled libvpx&& {
> >> die "libvpx enabled but no supported decoders found"
> >> fi
> >> }
> >> +enabled libvvenc  && require_pkg_config libvvenc "libvvenc >=
> 1.6.1" "vvenc/vvenc.h" vvenc_get_version
> >>
> >> enabled libwebp   && {
> >> enabled libwebp_encoder  && require_pkg_config libwebp "libwebp
> >= 0.2.0" webp/encode.h WebPGetEncoderVersion
> >> diff --git a/doc/encoders.texi b/doc/encoders.texi
> >> index c82f316f94..92aab17c49 100644
> >> --- a/doc/encoders.texi
> >> +++ b/doc/encoders.texi
> >> @@ -2378,6 +2378,71 @@ Indicates frame duration
> >> For more information about libvpx see:
> >> @url{http://www.webmproject.org/}
> >>
> >> +@section libvvenc
> >> +
> >> +VVenC H.266/VVC encoder wrapper.
> >> +
> >> +This encoder requires the presence of the libvvenc headers and library
> >> +during configuration. You need to explicitly configure the build with
> >> +@option{--enable-libvvenc}.
> >> +
> >> +The VVenC project website is at
> >> +@url{https://github.com/fraunhoferhhi/vvenc}.
> >> +
> >> +@subsection Supported Pixel Formats
> >> +
> >> +VVenC supports only 10-bit color spaces as input. But the internal
> (encoded)
> >> +bit depth can be set to 8-bit or 10-bit at runtime.
> >> +
> >> +@subsection Options
> >> +
> >> +@table @option
> >> +@item b
> >> +Sets target video bitrate.
> >> +
> >> +@item g
> >> +Set the GOP size. Currently support for g=1 (Intra only) or default.
> >> +
> >> +@item preset
> >> +Set the VVenC preset.
> >> +
> >> +@item levelidc
> >> +Set level idc.
> >> +
> >> +@item tier
> >> +Set vvc tier.
> >> +
> >> +@item qp
> >> +Set constant quantization parameter.
> >> +
> >> +@item subopt @var{boolean}
> >> +Set subjective (perceptually motivated) optimization. Default is 1
> (on).
> >> +
> >> +@item bitdepth8 @var{boolean}
> >> +Set 8bit coding mode instead of using 10bit. Default is 0 (off).
> >> +
> >> +@item period
> >> +set (intra) refresh period in seconds.
> >> +
> >> +@item vvenc-params
> >> +Set vvenc options using a list of @var{key}=@var{value} couples
> separated
> >> +by ":". See @command{vvencapp --fullhelp} or @command{vvencFFapp
> --fullhelp} for a list of options.
> >> +
> >> +For example, the options might be provided as:
> >> +
> >> +@example
> >> +intraperiod=64:decodingrefreshtype=idr:poc0idr=1:internalbitdepth=8
> >> +@end example
> >> +
> >> +For example the encoding options for 2-pass encoding might be provided
> with @option{-vvenc-params}:
> >> +
> >> +@example
> >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> passes=2:pass=1:rcstatsfile=stats.json output.mp4
> >> +ffmpeg -i input -c:v libvvenc -b 1M -vvenc-params
> passes=2:pass=2:rcstatsfile=stats.json output.mp4
> >> +@end example
> >> +

Re: [FFmpeg-devel] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Anton Khirnov
Quoting Andrey Turkin (2024-05-24 13:39:15)
> Have to say, this issue has been a long grievance of mine. There is no
> reason to delay frames when the decoder is set up to ignore B frames
> as there is no reordering to be done;

This only holds for pre-h264 codecs.

-- 
Anton Khirnov
___
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] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Ronald S. Bultje
Hi,

On Fri, May 24, 2024 at 7:39 AM Andrey Turkin 
wrote:

> Have to say, this issue has been a long grievance of mine. There is no
> reason to delay frames when the decoder is set up to ignore B frames
> as there is no reordering to be done
>

Frame threading?

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


Re: [FFmpeg-devel] [PATCH 09/10] lavc/hevc_ps: reduce the size of ShortTermRPS.used

2024-05-24 Thread James Almer

On 5/24/2024 6:11 AM, Anton Khirnov wrote:

Quoting James Almer (2024-04-10 15:42:51)



On 4/10/2024 10:31 AM, Anton Khirnov wrote:

diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
index 5d7c6b1b64..c2b65fc201 100644
--- a/libavcodec/vulkan_hevc.c
+++ b/libavcodec/vulkan_hevc.c
@@ -374,17 +374,17 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
   /* NOTE: This is the predicted, and *reordered* version.
* Probably incorrect, but the spec doesn't say which version to 
use. */
   for (int j = 0; j < sps->st_rps[i].num_delta_pocs; j++)
-str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j;
+str[i].used_by_curr_pic_flag |= st_rps->used;
   
   for (int j = 0; j < str[i].num_negative_pics; j++) {

-str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? 
st_rps->delta_poc[j - 1] : 0) - 1;
-str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j;
+str[i].delta_poc_s0_minus1[j]= st_rps->delta_poc[j] - (j ? 
st_rps->delta_poc[j - 1] : 0) - 1;
+str[i].used_by_curr_pic_s0_flag |= st_rps->used & ((1 << 
str[i].num_negative_pics) - 1);


av_mod_uintp2(st_rps->used, str[i].num_negative_pics).


unrelated change


It's a nit, but not unrelated. You're adding a "i & ((1 << j) - 1)" 
line, which can be simplified (and optimized) by using av_mod_uintp2() 
instead.

___
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] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Andrey Turkin
Have to say, this issue has been a long grievance of mine. There is no
reason to delay frames when the decoder is set up to ignore B frames
as there is no reordering to be done; ideally this should be
zero-delay case (packet goes in, frame goes out) yet the most common
decoders delay frames anyway, as if to decode B frames. Moreover, with
the "new" send/receive API I think there is no reason to delay frames
at all - a single send_packet could decode and queue multiple frames
to be received, so it makes sense to send frames as soon as possible -
yet that is not the case as well.

пт, 24 мая 2024 г. в 13:17, Andreas Rheinhardt :
>
> Michael Henrik Bodenhoff via ffmpeg-devel:
> > Hi ,
> >
> > my team recently had to abandon switching to using FFmpeg from specific 
> > decoder implementations (NvDEC, Intel Media SDK , IPP and quite a few codec 
> > specific decoders) because of big performance issues because of the way 
> > FFmpeg works….. or at least we think it is (we’re FFmpeg noobs   )
> >
> > It's actually an issue we also had with Intel Media SDK,  leading us to pay 
> > Intel to extend Media SDK to do what we needed.
> >
> > Our product is a video surveillance system, and that means we have to 
> > decode a LOT of video streams simultaneously.
> >
> > For motion detection we want to only decode keyframes, and skip P and B 
> > frames , and that works fine with FFmpeg most of the time, except for when 
> > the video stream contains B frames.
> > Without B-Frames it’s really simple (simplified pseudocode) :
> >
> > while(true)
> > {
> >   receiveStreamCompleteFrame();
> >   If(KeyFrame)
> >   {
> > avcodec_send_packet();
> > if(avcodec_receive_frame()==0)
> > {
> >// do motion detection
> > }
> >   }
> > }
> >
> > But! with B Frames FFmpeg doesn’t return keyframes when they are decoded, 
> > they are kept, and we can’t seem to flush them out. avcodec_flush_buffers 
> > allow us to continue to next keyframe, but it doesn’t seem to give us the 
> > keyframe we just gave to FFmpeg with avcodec_send_packet.
> >
> > while(true)
> > {
> >   receiveStreamCompleteFrame();
> >   If(KeyFrame)
> >   {
> > avcodec_send_packet();
> > if(avcodec_receive_frame()==0)
> > {
> >// do motion detection
> > }
> > Else
> > {
> >   avcodec_flush_buffers();
> >   if(avcodec_receive_frame()==0)
> >   {
> >  // do motion detection
> >   }
> > }
> >   }
> > }
> >
> > Calling avcodec_receive_frame after calling avcodec_flush_buffer results in 
> > -11 and no frame
> >
> > is there anyway around this ? And if not, could FFmpeg be made to have this 
> > functionality ?
> >
> > I tried contacting one of the FFmpeg consultants from 
> > https://ffmpeg.org/consulting.html but never got a response
> >
>
> Send your packet with the keyframe, send a NULL packet (to signal EOF),
> then the internally stored frames should be output by
> avcodec_receive_frame(). Then flush the decoder (to be able to send new
> packets to it).
>
> - Andreas
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel 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] [RFC] STF 2025

2024-05-24 Thread Thilo Borgmann via ffmpeg-devel




On 24.05.24 11:56, Andrew Sayers wrote:

On Fri, May 17, 2024 at 03:49:58PM +0200, Michael Niedermayer wrote:

Hi all

Before this is forgotten again, better start some dicsussion too early than too 
late


This comment is inspired by the other subthread, but not directly in reply to 
it.
I'm replying to this post rather than get in the middle of all that...


Thanks :)



What happens if someone is hired to do a job that requires access to the ML,
then gets involved in a situation where there's talk of a ban?

If they're banned, does that translate to suspension without pay?  With pay?

Banning such a person would jeopardise future funding - if they aren't banned,
will people be concerned about the apparent conflict of interest?


Interesting and something we should think about.
I think the project's well-being should be the priority - meaning if we 
vote for a ban of someone that was trusted enough to get a contact from 
us in the first place, the ban should be executed - or any other measure 
the CC or GA sees fit. Giving a work contact to someone shall not make 
us dependent on that person to such an extent.




In a wider sense, hiring a single person to do a job we come to rely on (like
code review) gives the project a bus number of 1.  How would the STF react to
a proposal like "we plan to do XYZ in 2025, but if we don't get funding for
2026, we'll drop Z and spend the time on a transition plan instead"?


Speaking as an idealist, we should uphold our procedures independently 
of what another entity (except the applicable law) thinks about our 
decisions.


Realisticly speaking, we already got some feedback from STF about such 
potential break aways on our end. Though these are of course never good 
in any such business relation, these things do happen. So up to a 
certain extend, it won't remove us from the program. Problems arise if 
such things are getting frequent.


We also got another layer of protection vie the SPI linked in between.
If we sanction someone severely who is in current posession of a 
contract to do some FFmpeg work, we might stop funding that and give 
another contract to someone who can take over.


Not saying that this could work with any kind of work but can be an option.

That brings me to the idea that we need to check the contracts for 
potential fail-safe clauses for such extreme cases like these.


Thanks,
Thnilo
___
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] libavfilter/signature_lookup: fix possible division by zero

2024-05-24 Thread Gerion Entrup
Am Dienstag, 7. Mai 2024, 19:46:28 MESZ schrieb Michael Niedermayer:
> On Mon, May 06, 2024 at 12:30:39AM +0200, Gerion Entrup wrote:
> > ---
> >  libavfilter/signature_lookup.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavfilter/signature_lookup.c b/libavfilter/signature_lookup.c
> > index a0ca818a9b..b39a3e225b 100644
> > --- a/libavfilter/signature_lookup.c
> > +++ b/libavfilter/signature_lookup.c
> > @@ -128,7 +128,7 @@ static int get_jaccarddist(SignatureContext *sc, 
> > CoarseSignature *first, CoarseS
> >  int jaccarddist, i, composdist = 0, cwthcount = 0;
> >  for (i = 0; i < 5; i++) {
> >  if ((jaccarddist = intersection_word(first->data[i], 
> > second->data[i])) > 0) {
> > -jaccarddist /= union_word(first->data[i], second->data[i]);
> > +jaccarddist /= FFMAX(union_word(first->data[i], 
> > second->data[i]), 1);
> >  }
> 
> for which input data does this cause a division by 0 ?

Sorry for the late answer. I missed your mail somehow.
union_word counts the amount of one bits that are created when you are "or"ing
the course signatures. So, when the underlying videos are so different that all
bits of the created signatures are different, the "or"-operator will always
return 0 and so also its sum (I have not tested this).

Gerion



signature.asc
Description: This is a digitally signed message part.
___
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] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Andreas Rheinhardt
Michael Henrik Bodenhoff via ffmpeg-devel:
> Hi ,
> 
> my team recently had to abandon switching to using FFmpeg from specific 
> decoder implementations (NvDEC, Intel Media SDK , IPP and quite a few codec 
> specific decoders) because of big performance issues because of the way 
> FFmpeg works….. or at least we think it is (we’re FFmpeg noobs   )
> 
> It's actually an issue we also had with Intel Media SDK,  leading us to pay 
> Intel to extend Media SDK to do what we needed.
> 
> Our product is a video surveillance system, and that means we have to decode 
> a LOT of video streams simultaneously.
> 
> For motion detection we want to only decode keyframes, and skip P and B 
> frames , and that works fine with FFmpeg most of the time, except for when 
> the video stream contains B frames.
> Without B-Frames it’s really simple (simplified pseudocode) :
> 
> while(true)
> {
>   receiveStreamCompleteFrame();
>   If(KeyFrame)
>   {
> avcodec_send_packet();
> if(avcodec_receive_frame()==0)
> {
>// do motion detection
> }
>   }
> }
> 
> But! with B Frames FFmpeg doesn’t return keyframes when they are decoded, 
> they are kept, and we can’t seem to flush them out. avcodec_flush_buffers 
> allow us to continue to next keyframe, but it doesn’t seem to give us the 
> keyframe we just gave to FFmpeg with avcodec_send_packet.
> 
> while(true)
> {
>   receiveStreamCompleteFrame();
>   If(KeyFrame)
>   {
> avcodec_send_packet();
> if(avcodec_receive_frame()==0)
> {
>// do motion detection
> }
> Else
> {
>   avcodec_flush_buffers();
>   if(avcodec_receive_frame()==0)
>   {
>  // do motion detection
>   }
> }
>   }
> }
> 
> Calling avcodec_receive_frame after calling avcodec_flush_buffer results in 
> -11 and no frame
> 
> is there anyway around this ? And if not, could FFmpeg be made to have this 
> functionality ?
> 
> I tried contacting one of the FFmpeg consultants from 
> https://ffmpeg.org/consulting.html but never got a response
> 

Send your packet with the keyframe, send a NULL packet (to signal EOF),
then the internally stored frames should be output by
avcodec_receive_frame(). Then flush the decoder (to be able to send new
packets to it).

- 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] [RFC] STF 2025

2024-05-24 Thread Andrew Sayers
On Fri, May 17, 2024 at 03:49:58PM +0200, Michael Niedermayer wrote:
> Hi all
> 
> Before this is forgotten again, better start some dicsussion too early than 
> too late

This comment is inspired by the other subthread, but not directly in reply to 
it.
I'm replying to this post rather than get in the middle of all that...

What happens if someone is hired to do a job that requires access to the ML,
then gets involved in a situation where there's talk of a ban?

If they're banned, does that translate to suspension without pay?  With pay?

Banning such a person would jeopardise future funding - if they aren't banned,
will people be concerned about the apparent conflict of interest?

In a wider sense, hiring a single person to do a job we come to rely on (like
code review) gives the project a bus number of 1.  How would the STF react to
a proposal like "we plan to do XYZ in 2025, but if we don't get funding for
2026, we'll drop Z and spend the time on a transition plan instead"?
___
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 v5 0/4] Explain what "context" means

2024-05-24 Thread Andrew Sayers
On Fri, May 24, 2024 at 03:50:52AM +0200, Michael Niedermayer wrote:
> On Thu, May 23, 2024 at 09:00:39PM +0100, Andrew Sayers wrote:

> > Imagine you wanted to write a system that nudged people to try new codecs.
> > It might say e.g. "you seem to be using H.264, would you like to try H.265?"
> > Implementing that would probably involve a struct like:
> > 
> > struct AVOldNew {
> >   AVClass* old;
> >   AVClass* new;
> > };
> 
> AVClass would describe the internal decoder structures. This would not be
> correct at all in this example.
> Thats like handing a man 2 CAD documents about 2 engines of 2 cars
> 
> If you wanted to suggest to get a tesla instead of a ford. One would have to
> describe the 2 cars and their differences
> thats 2 AVCodecDescriptor maybe

Hmm, yes fair point.  A better example might be a simple linked list:

struct AVClassList {
AVClass* cur;
AVClassList* next;
};

Again, that clearly is a struct that begins with AVClass*, but clearly isn't an
AVClass context structure.

I realise it's a bit of an academic distinction, but IMHO these hypotheticals
suggest it's more accurate to define the term "AVClass context structure"
in terms of usage rather than layout.
___
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] lavc/rv32dsp: remove stray load immediate

2024-05-24 Thread Rémi Denis-Courmont


Le 24 mai 2024 09:44:50 GMT+03:00, Andreas Rheinhardt 
 a écrit :
>Rémi Denis-Courmont:
>> ---
>>  libavcodec/riscv/rv34dsp_rvv.S | 1 -
>>  1 file changed, 1 deletion(-)
>> 
>> diff --git a/libavcodec/riscv/rv34dsp_rvv.S b/libavcodec/riscv/rv34dsp_rvv.S
>> index f1f6345012..8eda01665d 100644
>> --- a/libavcodec/riscv/rv34dsp_rvv.S
>> +++ b/libavcodec/riscv/rv34dsp_rvv.S
>> @@ -37,7 +37,6 @@ func ff_rv34_idct_dc_add_rvv, zve32x
>>  vlse32.v  v0, (a0), a1
>>  lit1, 169
>>  mul   t1, t1, a2
>> -lia2, 255
>>  addi  t1, t1, 512
>>  srai  t1, t1, 10
>>  vsetivli  zero, 4*4, e16, m2, ta, ma
>
>s/rv32dsp/rv34dsp/

Good catch, will amend locally.
___
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/4] avformat/matroskadec: Add assert to silence Coverity false positive

2024-05-24 Thread Andreas Rheinhardt
Helps with Coverity issue #1452453.

Signed-off-by: Andreas Rheinhardt 
---
 libavformat/matroskadec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 2f07e11d87..13959f8b3d 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1315,6 +1315,8 @@ static int ebml_parse(MatroskaDemuxContext *matroska,
 matroska->num_levels--;
 return LEVEL_ENDED;
 }
+// We have not encountered a known element; syntax is a 
sentinel.
+av_assert1(syntax->type == EBML_NONE);
 };
 }
 
-- 
2.40.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] Flushing while decoding , but need already decoded frames

2024-05-24 Thread Michael Henrik Bodenhoff via ffmpeg-devel
Hi ,

my team recently had to abandon switching to using FFmpeg from specific decoder 
implementations (NvDEC, Intel Media SDK , IPP and quite a few codec specific 
decoders) because of big performance issues because of the way FFmpeg works….. 
or at least we think it is (we’re FFmpeg noobs   )

It's actually an issue we also had with Intel Media SDK,  leading us to pay 
Intel to extend Media SDK to do what we needed.

Our product is a video surveillance system, and that means we have to decode a 
LOT of video streams simultaneously.

For motion detection we want to only decode keyframes, and skip P and B frames 
, and that works fine with FFmpeg most of the time, except for when the video 
stream contains B frames.
Without B-Frames it’s really simple (simplified pseudocode) :

while(true)
{
  receiveStreamCompleteFrame();
  If(KeyFrame)
  {
avcodec_send_packet();
if(avcodec_receive_frame()==0)
{
   // do motion detection
}
  }
}

But! with B Frames FFmpeg doesn’t return keyframes when they are decoded, they 
are kept, and we can’t seem to flush them out. avcodec_flush_buffers allow us 
to continue to next keyframe, but it doesn’t seem to give us the keyframe we 
just gave to FFmpeg with avcodec_send_packet.

while(true)
{
  receiveStreamCompleteFrame();
  If(KeyFrame)
  {
avcodec_send_packet();
if(avcodec_receive_frame()==0)
{
   // do motion detection
}
Else
{
  avcodec_flush_buffers();
  if(avcodec_receive_frame()==0)
  {
 // do motion detection
  }
}
  }
}

Calling avcodec_receive_frame after calling avcodec_flush_buffer results in -11 
and no frame

is there anyway around this ? And if not, could FFmpeg be made to have this 
functionality ?

I tried contacting one of the FFmpeg consultants from 
https://ffmpeg.org/consulting.html but never got a response

Michael Bodenhoff
Principal Software Engineer
FT01
Email: m...@milestone.dk

[Linkedin Logo][Twitter 
Logo][Youtube 
Logo][Facebook 
Logo][Instagram 
Logo]

[Milestone Logo]

___
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 10/10] lavc/hevc_ps: compactify ShortTermRPS

2024-05-24 Thread Anton Khirnov
Quoting James Almer (2024-04-11 14:35:37)
> > diff --git a/libavcodec/hevc_ps.h b/libavcodec/hevc_ps.h
> > index 92b85115f7..a8d07aa1b2 100644
> > --- a/libavcodec/hevc_ps.h
> > +++ b/libavcodec/hevc_ps.h
> > @@ -70,16 +70,19 @@ typedef struct HEVCHdrParams {
> >   } HEVCHdrParams;
> >   
> >   typedef struct ShortTermRPS {
> > -uint8_t rps_predict;
> > -unsigned int delta_idx;
> > -uint8_t use_delta_flag;
> > -uint8_t delta_rps_sign;
> > -unsigned int abs_delta_rps;
> > -unsigned int num_negative_pics;
> > -int num_delta_pocs;
> > -int rps_idx_num_delta_pocs;
> >   int32_t delta_poc[32];
> >   uint32_t used;
> > +
> > +uint8_t delta_idx;
> > +uint8_t num_negative_pics;
> > +uint8_t num_delta_pocs;
> > +uint8_t rps_idx_num_delta_pocs;
> > +
> > +uint16_t abs_delta_rps;
> > +unsigned delta_rps_sign:1;
> 
> Wont the compiler add two bytes of padding if you put this here?

No. Pahole says

struct ShortTermRPS {
int32_tdelta_poc[32];/* 0   128 */
/* --- cacheline 2 boundary (128 bytes) --- */
uint32_t   used; /*   128 4 */
uint8_tdelta_idx;/*   132 1 */
uint8_tnum_negative_pics;/*   133 1 */
uint8_tnum_delta_pocs;   /*   134 1 */
uint8_trps_idx_num_delta_pocs; /*   135 1 */
uint16_t   abs_delta_rps;/*   136 2 */

/* Bitfield combined with previous fields */

unsigned int   delta_rps_sign:1; /*   136:16  4 */
unsigned int   rps_predict:1;/*   136:17  4 */
unsigned int   use_delta:1;  /*   136:18  4 */

/* size: 140, cachelines: 3, members: 10 */
/* bit_padding: 13 bits */
/* last cacheline: 12 bytes */
};

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

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


Re: [FFmpeg-devel] [PATCH v2] lavc/vp9: reset segmentation fields when segmentation isn't enabled

2024-05-24 Thread Hendrik Leppkes
On Thu, May 23, 2024 at 10:38 AM  wrote:
>
> From: llyyr 
>
> Fields under the segmentation switch are never reset on a new frame, and
> retain the value from the previous frame. This bugs out a bunch of
> hwaccel drivers when segmentation is disabled but update_map isn't
> reset because they don't ignore values behind switches. This commit also
> resets the temporal field, though it may not be required.
>
> We also do this for vp8 [1] so this commit is just mirroring the vp8
> logic.
>
> This fixes an issue with certain samples [2] that causes blocky
> artifacts with vaapi, d3d11va and cuda (and possibly others).
> Mesa worked around [3] this by ignoring these fields if
> segmentation.enabled is 0, but d3d11va still displays blocky artifacts.
>
> [1] https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/HEAD:/libavcodec/vp8.c#l811
> [2] https://github.com/mpv-player/mpv/issues/13533
> [3] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27816
>
> Signed-off-by: llyyr 
> ---
>  libavcodec/vp9.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index 6e2d18bf9595..8ede2e2eb358 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -709,6 +709,12 @@ static int decode_frame_header(AVCodecContext *avctx,
>  s->s.h.segmentation.feat[i].skip_enabled = get_bits1(>gb);
>  }
>  }
> +} else {
> +// Reset fields under segmentation switch if segmentation is 
> disabled.
> +// This is necessary because some hwaccels don't ignore these fields
> +// if segmentation is disabled.
> +s->s.h.segmentation.temporal = 0;
> +s->s.h.segmentation.update_map = 0;
>  }
>
>  // set qmul[] based on Y/UV, AC/DC and segmentation Q idx deltas
> --
> 2.45.1

Last call for comments. Otherwise will apply on the weekend with the
updated Git URL.

- Hendrik
___
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 09/10] lavc/hevc_ps: reduce the size of ShortTermRPS.used

2024-05-24 Thread Anton Khirnov
Quoting James Almer (2024-04-10 15:42:51)
> 
> 
> On 4/10/2024 10:31 AM, Anton Khirnov wrote:
> > diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
> > index 5d7c6b1b64..c2b65fc201 100644
> > --- a/libavcodec/vulkan_hevc.c
> > +++ b/libavcodec/vulkan_hevc.c
> > @@ -374,17 +374,17 @@ static void set_sps(const HEVCSPS *sps, int sps_idx,
> >   /* NOTE: This is the predicted, and *reordered* version.
> >* Probably incorrect, but the spec doesn't say which version to 
> > use. */
> >   for (int j = 0; j < sps->st_rps[i].num_delta_pocs; j++)
> > -str[i].used_by_curr_pic_flag |= sps->st_rps[i].used[j] << j;
> > +str[i].used_by_curr_pic_flag |= st_rps->used;
> >   
> >   for (int j = 0; j < str[i].num_negative_pics; j++) {
> > -str[i].delta_poc_s0_minus1[j] = st_rps->delta_poc[j] - (j ? 
> > st_rps->delta_poc[j - 1] : 0) - 1;
> > -str[i].used_by_curr_pic_s0_flag |= sps->st_rps[i].used[j] << j;
> > +str[i].delta_poc_s0_minus1[j]= st_rps->delta_poc[j] - (j ? 
> > st_rps->delta_poc[j - 1] : 0) - 1;
> > +str[i].used_by_curr_pic_s0_flag |= st_rps->used & ((1 << 
> > str[i].num_negative_pics) - 1);
> 
> av_mod_uintp2(st_rps->used, str[i].num_negative_pics).

unrelated change

-- 
Anton Khirnov
___
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 06/10] lavc/hevc_ps/HEVCSPS: change flags into size-1 bitfields

2024-05-24 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2024-04-11 13:55:05)
> Anton Khirnov:
> > Reduces sizeof(HEVCSPS) by 96 bytes.
> > 
> > Also improve flag names: drop redundant suffixes and prefixes, and
> > consistently use disabled/enabled.
> > ---
> >  libavcodec/dxva2_hevc.c| 24 -
> >  libavcodec/hevc_cabac.c| 36 ++---
> >  libavcodec/hevc_filter.c   |  8 +--
> >  libavcodec/hevc_parser.c   |  2 +-
> >  libavcodec/hevc_ps.c   | 95 +-
> >  libavcodec/hevc_ps.h   | 62 +++---
> >  libavcodec/hevcdec.c   | 10 ++--
> >  libavcodec/hevcpred_template.c |  4 +-
> >  libavcodec/mips/hevcpred_msa.c |  6 +--
> >  libavcodec/nvdec_hevc.c| 42 +++
> >  libavcodec/qsvenc_hevc.c   |  2 +-
> >  libavcodec/vaapi_hevc.c| 42 +++
> >  libavcodec/vdpau_hevc.c| 36 ++---
> >  libavcodec/vulkan_hevc.c   | 56 ++--
> >  14 files changed, 212 insertions(+), 213 deletions(-)
> > 
> 
> Making this a bitfield is not worth it. It will necessitate masking
> operations on every access to these fields which may increase the size
> of .text by more than 96B; it may even be that this more than offsets
> the savings of 96B from using a bitfield.

Okay, then changed to uint8_t locally.

-- 
Anton Khirnov
___
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 03/10] lavc/hevcdec: allocate local_ctx as array of structs rather than pointers

2024-05-24 Thread Anton Khirnov
Quoting Andreas Rheinhardt (2024-04-17 11:29:18)
> Anton Khirnov:
> > It is more efficient and easier to manage.
> > ---
> 
> Allocating structures used by slice contexts jointly has the potential
> downside of false sharing if the structures are not sufficiently
> aligned/padded.

What do you suggest? Align first member to cacheline size?

-- 
Anton Khirnov
___
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] tests/checkasm/vvc_alf: Don't use declare_func_emms

2024-05-24 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> VVC does not have MMX code at all, so one can use the stricter
> declare_func to also check that the MMX state has not been clobbered
> with (which would be an ABI violation).
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  tests/checkasm/vvc_alf.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/checkasm/vvc_alf.c b/tests/checkasm/vvc_alf.c
> index 6dd89bfafc..f35fd2cd3e 100644
> --- a/tests/checkasm/vvc_alf.c
> +++ b/tests/checkasm/vvc_alf.c
> @@ -83,7 +83,7 @@ static void check_alf_filter(VVCDSPContext *c, const int 
> bit_depth)
>  ptrdiff_t dst_stride = DST_PIXEL_STRIDE * SIZEOF_PIXEL;
>  int offset = (3 * SRC_PIXEL_STRIDE + 3) * SIZEOF_PIXEL;
>  
> -declare_func_emms(AV_CPU_FLAG_AVX2, void, uint8_t *dst, ptrdiff_t 
> dst_stride, const uint8_t *src, ptrdiff_t src_stride,
> +declare_func(void, uint8_t *dst, ptrdiff_t dst_stride, const uint8_t 
> *src, ptrdiff_t src_stride,
>  int width, int height, const int16_t *filter, const int16_t *clip, 
> const int vb_pos);
>  
>  randomize_buffers(src0, src1, SRC_BUF_SIZE);
> @@ -137,7 +137,7 @@ static void check_alf_classify(VVCDSPContext *c, const 
> int bit_depth)
>  ptrdiff_t stride = SRC_PIXEL_STRIDE * SIZEOF_PIXEL;
>  int offset = (3 * SRC_PIXEL_STRIDE + 3) * SIZEOF_PIXEL;
>  
> -declare_func_emms(AV_CPU_FLAG_AVX2, void, int *class_idx, int 
> *transpose_idx,
> +declare_func(void, int *class_idx, int *transpose_idx,
>  const uint8_t *src, ptrdiff_t src_stride, int width, int height, int 
> vb_pos, int *gradient_tmp);
>  
>  randomize_buffers(src0, src1, SRC_BUF_SIZE);

Will apply this patch 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".


[FFmpeg-devel] [PATCH] avfilter/af_afir: Merge header into af_afir.c

2024-05-24 Thread Andreas Rheinhardt
Done in 0df18f29ae218f30b3ecff7c930176b8ebee56aa,
accidentally undone in 163e737c1793eeea9c2df15298253ffc04906afe.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_afir.c |  81 ++-
 libavfilter/af_afir.h | 110 --
 2 files changed, 80 insertions(+), 111 deletions(-)
 delete mode 100644 libavfilter/af_afir.h

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index 8997fbd7c9..24f8f8cbf1 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -34,15 +34,94 @@
 #include "libavutil/frame.h"
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/rational.h"
 
 #include "audio.h"
 #include "avfilter.h"
 #include "filters.h"
 #include "formats.h"
 #include "internal.h"
-#include "af_afir.h"
 #include "af_afirdsp.h"
 
+#define MAX_IR_STREAMS 32
+
+typedef struct AudioFIRSegment {
+int nb_partitions;
+int part_size;
+int block_size;
+int fft_length;
+int coeff_size;
+int input_size;
+int input_offset;
+
+int *output_offset;
+int *part_index;
+
+AVFrame *sumin;
+AVFrame *sumout;
+AVFrame *blockout;
+AVFrame *tempin;
+AVFrame *tempout;
+AVFrame *buffer;
+AVFrame *coeff;
+AVFrame *input;
+AVFrame *output;
+
+AVTXContext **ctx, **tx, **itx;
+av_tx_fn ctx_fn, tx_fn, itx_fn;
+} AudioFIRSegment;
+
+typedef struct AudioFIRContext {
+const AVClass *class;
+
+float wet_gain;
+float dry_gain;
+float length;
+int gtype;
+float ir_norm;
+float ir_link;
+float ir_gain;
+int ir_format;
+int ir_load;
+float max_ir_len;
+int response;
+int w, h;
+AVRational frame_rate;
+int ir_channel;
+int minp;
+int maxp;
+int nb_irs;
+int prev_selir;
+int selir;
+int precision;
+int format;
+
+int eof_coeffs[MAX_IR_STREAMS];
+int have_coeffs[MAX_IR_STREAMS];
+int nb_taps[MAX_IR_STREAMS];
+int nb_segments[MAX_IR_STREAMS];
+int max_offset[MAX_IR_STREAMS];
+int nb_channels;
+int one2many;
+int prev_is_disabled;
+int *loading;
+double *ch_gain;
+
+AudioFIRSegment seg[MAX_IR_STREAMS][1024];
+
+AVFrame *in;
+AVFrame *xfade[2];
+AVFrame *fadein[2];
+AVFrame *ir[MAX_IR_STREAMS];
+AVFrame *norm_ir[MAX_IR_STREAMS];
+int min_part_size;
+int max_part_size;
+int64_t pts;
+
+AudioFIRDSPContext afirdsp;
+AVFloatDSPContext *fdsp;
+} AudioFIRContext;
+
 #define DEPTH 32
 #include "afir_template.c"
 
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
deleted file mode 100644
index 8e4afd79c9..00
--- a/libavfilter/af_afir.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2017 Paul B Mahol
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVFILTER_AFIR_H
-#define AVFILTER_AFIR_H
-
-#include "libavutil/float_dsp.h"
-#include "libavutil/frame.h"
-#include "libavutil/rational.h"
-#include "libavutil/tx.h"
-#include "avfilter.h"
-#include "af_afirdsp.h"
-
-#define MAX_IR_STREAMS 32
-
-typedef struct AudioFIRSegment {
-int nb_partitions;
-int part_size;
-int block_size;
-int fft_length;
-int coeff_size;
-int input_size;
-int input_offset;
-
-int *output_offset;
-int *part_index;
-
-AVFrame *sumin;
-AVFrame *sumout;
-AVFrame *blockout;
-AVFrame *tempin;
-AVFrame *tempout;
-AVFrame *buffer;
-AVFrame *coeff;
-AVFrame *input;
-AVFrame *output;
-
-AVTXContext **ctx, **tx, **itx;
-av_tx_fn ctx_fn, tx_fn, itx_fn;
-} AudioFIRSegment;
-
-typedef struct AudioFIRContext {
-const AVClass *class;
-
-float wet_gain;
-float dry_gain;
-float length;
-int gtype;
-float ir_norm;
-float ir_link;
-float ir_gain;
-int ir_format;
-int ir_load;
-float max_ir_len;
-int response;
-int w, h;
-AVRational frame_rate;
-int ir_channel;
-int minp;
-int maxp;
-int nb_irs;
-int prev_selir;
-int selir;
-int precision;
-int format;
-
-int eof_coeffs[MAX_IR_STREAMS];
-int have_coeffs[MAX_IR_STREAMS];
-int nb_taps[MAX_IR_STREAMS];
-int nb_segments[MAX_IR_STREAMS];
-int max_offset[MAX_IR_STREAMS];
-int 

[FFmpeg-devel] [PATCH 1/4] avfilter/vf_signalstats: Use 64bit for processing histogram

2024-05-24 Thread Andreas Rheinhardt
The result might not fit into 32bit if an image has gigantic
dimensions and one of the planes has a dominant value
(particularly so if said value is big).

Fixes Coverity issues #1598399, #1598401, #1598402, #1598403, #1598404.

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

diff --git a/libavfilter/vf_signalstats.c b/libavfilter/vf_signalstats.c
index 50c9df4298..78a23bb705 100644
--- a/libavfilter/vf_signalstats.c
+++ b/libavfilter/vf_signalstats.c
@@ -721,10 +721,10 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 if (histv[fil])   maxv   = fil;
 if (histsat[fil]) maxsat = fil;
 
-toty   += histy[fil]   * fil;
-totu   += histu[fil]   * fil;
-totv   += histv[fil]   * fil;
-totsat += histsat[fil] * fil;
+toty   += (uint64_t)histy[fil]   * fil;
+totu   += (uint64_t)histu[fil]   * fil;
+totv   += (uint64_t)histv[fil]   * fil;
+totsat += (uint64_t)histsat[fil] * fil;
 
 accy   += histy[fil];
 accu   += histu[fil];
@@ -745,7 +745,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 maxhue = histhue[0];
 medhue = -1;
 for (fil = 0; fil < 360; fil++) {
-tothue += histhue[fil] * fil;
+tothue += (uint64_t)histhue[fil] * fil;
 acchue += histhue[fil];
 
 if (medhue == -1 && acchue > s->cfs / 2)
-- 
2.40.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/4] avfilter/af_aiir: Avoid unchecked allocation

2024-05-24 Thread Andreas Rheinhardt
W has not been checked at all; allocate it jointly with M
to fix this.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_aiir.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index 324fc367a3..7bd9e37e43 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -828,17 +828,17 @@ static int convert_serial2parallel(AVFilterContext *ctx, 
int channels)
 double *impulse = av_calloc(length, sizeof(*impulse));
 double *y = av_calloc(length, sizeof(*y));
 double *resp = av_calloc(length, sizeof(*resp));
-double *M = av_calloc((length - 1) * 2 * nb_biquads, sizeof(*M));
-double *W = av_calloc((length - 1) * 2 * nb_biquads, sizeof(*W));
+double *M = av_calloc((length - 1) * nb_biquads, 2 * 2 * sizeof(*M));
+double *W;
 
 if (!impulse || !y || !resp || !M) {
 av_free(impulse);
 av_free(y);
 av_free(resp);
 av_free(M);
-av_free(W);
 return AVERROR(ENOMEM);
 }
+W = M + (length - 1) * 2 * nb_biquads;
 
 impulse[0] = 1.;
 
@@ -877,7 +877,6 @@ static int convert_serial2parallel(AVFilterContext *ctx, 
int channels)
 av_free(y);
 av_free(resp);
 av_free(M);
-av_free(W);
 }
 
 return 0;
-- 
2.40.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/4] avfilter/af_aiir: Remove dead code

2024-05-24 Thread Andreas Rheinhardt
Fixes Coverity issue #1468252.

Signed-off-by: Andreas Rheinhardt 
---
 libavfilter/af_aiir.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/libavfilter/af_aiir.c b/libavfilter/af_aiir.c
index b5e5b41db6..324fc367a3 100644
--- a/libavfilter/af_aiir.c
+++ b/libavfilter/af_aiir.c
@@ -820,7 +820,6 @@ static void solve(double *matrix, double *vector, int n, 
double *y, double *x, d
 static int convert_serial2parallel(AVFilterContext *ctx, int channels)
 {
 AudioIIRContext *s = ctx->priv;
-int ret = 0;
 
 for (int ch = 0; ch < channels; ch++) {
 IIRChannel *iir = >iir[ch];
@@ -879,9 +878,6 @@ static int convert_serial2parallel(AVFilterContext *ctx, 
int channels)
 av_free(resp);
 av_free(M);
 av_free(W);
-
-if (ret < 0)
-return ret;
 }
 
 return 0;
-- 
2.40.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] [RFC] STF 2025

2024-05-24 Thread Rémi Denis-Courmont


Le 24 mai 2024 10:11:49 GMT+03:00, Thilo Borgmann via ffmpeg-devel 
 a écrit :
>Unfortunately true, yet you argue to pay more companies to do reviews instead 
>having reviews funded by unbiased means.

That is a blatant and libelous lie and will be reported to CC promptly.
___
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] [RFC] STF 2025

2024-05-24 Thread Thilo Borgmann via ffmpeg-devel

Am 22.05.24 um 14:27 schrieb Rémi Denis-Courmont:



Le 22 mai 2024 00:34:03 GMT+03:00, Thilo Borgmann via ffmpeg-devel 
 a écrit :

I hope you realize what you argue in favor of.


Yes. It's quoted above.

Are you claiming that *no* review is better than *some* review done in
*public* for all to see by a paid professional just because the person is
maybe biased?

First, even volunteers have their own biases. Any expert should have opinions
from their experience, and that by definition makes them "biased".

And second, you can't have it both ways. Either we want people to be paid for
review, and they will be answerable to their sponsor, or we want people to
continue to work on their free time.


I think that is what you don't understand.


You're not answering the question here. The current STF funding of 153k€ for 2 
years is roughly enough to pay for ONE full-time entry-level software engineer 
in Germany. Even if this were doubled with another similar round of funding 
next year, and even if that was to be reliably renewed year on year, and 
assuming that STF keeps an hands-off approach of not influencing the work, that 
will *not* be enough to pay all reviewers.

So is it better to have no reviews or reviews by skilled corporate employees?


Your one question above was: "Are you claiming that [...] because the person is 
maybe biased?"
And I answered about the biasing problem.




And "I hope you realise that you are arguing for" Intel, Loongson, etc.
employees to stop reviewing patches.


Syntax error. What exactly do you mean?


I fail to see a syntax error. You're saying that corporate employees should not review because 
"they [will] want to get [their]" or their colleagues' "stuff in" (your words).

Intel and Loongson are obvious current examples of companies whose employees are pushing and 
reviewing enablement patches for their commercial hardware. That is very definitely not 
"unbiased" nor "independent".


Unfortunately true, yet you argue to pay more companies to do reviews instead 
having reviews funded by unbiased means.



According to my assumptions: No, I value reviews of company employees in 
general which have been proven to be useful and unbiased e.g. in getting part 
of the community reviewing 'stuf' but not their 'own stuff'.


I never said that I wanted biased reviews. I said some reviews were better than 
none, in spite of the risk of bias.

So much for your grandstanding against my alleged not realising what I am 
advocating for, if you end up agreeing with me...


I think we don't agree. You would want to pay some comapny/companies to do 
review work while I'd want reviewers to be paid directly without a middle man 
and corporate bias.

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

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


Re: [FFmpeg-devel] [PATCH] avformat/async, cache: Use more unique context names

2024-05-24 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Otherwise Doxygen thinks any text like "Context for foo"
> is a link to the async protocol's struct called "Context".
> 
> Reported-by: Andrew Sayers 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/async.c | 22 +++---
>  libavformat/cache.c | 18 +-
>  2 files changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/libavformat/async.c b/libavformat/async.c
> index e096b0bc6f..e0329e23ec 100644
> --- a/libavformat/async.c
> +++ b/libavformat/async.c
> @@ -53,7 +53,7 @@ typedef struct RingBuffer
>  int   read_pos;
>  } RingBuffer;
>  
> -typedef struct Context {
> +typedef struct AsyncContext {
>  AVClass*class;
>  URLContext *inner;
>  
> @@ -78,7 +78,7 @@ typedef struct Context {
>  
>  int abort_request;
>  AVIOInterruptCB interrupt_callback;
> -} Context;
> +} AsyncContext;
>  
>  static int ring_init(RingBuffer *ring, unsigned int capacity, int 
> read_back_capacity)
>  {
> @@ -132,7 +132,7 @@ static int ring_read(RingBuffer *ring, void *dest, int 
> buf_size)
>  static int wrapped_url_read(void *src, void *dst, size_t *size)
>  {
>  URLContext *h   = src;
> -Context*c   = h->priv_data;
> +AsyncContext *c = h->priv_data;
>  int ret;
>  
>  ret = ffurl_read(c->inner, dst, *size);
> @@ -170,7 +170,7 @@ static int ring_drain(RingBuffer *ring, int offset)
>  static int async_check_interrupt(void *arg)
>  {
>  URLContext *h   = arg;
> -Context*c   = h->priv_data;
> +AsyncContext *c = h->priv_data;
>  
>  if (c->abort_request)
>  return 1;
> @@ -184,7 +184,7 @@ static int async_check_interrupt(void *arg)
>  static void *async_buffer_task(void *arg)
>  {
>  URLContext   *h= arg;
> -Context  *c= h->priv_data;
> +AsyncContext *c= h->priv_data;
>  RingBuffer   *ring = >ring;
>  int   ret  = 0;
>  int64_t   seek_ret;
> @@ -249,7 +249,7 @@ static void *async_buffer_task(void *arg)
>  
>  static int async_open(URLContext *h, const char *arg, int flags, 
> AVDictionary **options)
>  {
> -Context *c = h->priv_data;
> +AsyncContext *c = h->priv_data;
>  int  ret;
>  AVIOInterruptCB  interrupt_callback = {.callback = 
> async_check_interrupt, .opaque = h};
>  
> @@ -316,7 +316,7 @@ fifo_fail:
>  
>  static int async_close(URLContext *h)
>  {
> -Context *c = h->priv_data;
> +AsyncContext *c = h->priv_data;
>  int  ret;
>  
>  pthread_mutex_lock(>mutex);
> @@ -339,7 +339,7 @@ static int async_close(URLContext *h)
>  
>  static int async_read_internal(URLContext *h, void *dest, int size)
>  {
> -Context  *c   = h->priv_data;
> +AsyncContext *c   = h->priv_data;
>  RingBuffer   *ring= >ring;
>  int read_complete = !dest;
>  int   to_read = size;
> @@ -391,7 +391,7 @@ static int async_read(URLContext *h, unsigned char *buf, 
> int size)
>  
>  static int64_t async_seek(URLContext *h, int64_t pos, int whence)
>  {
> -Context  *c= h->priv_data;
> +AsyncContext *c= h->priv_data;
>  RingBuffer   *ring = >ring;
>  int64_t   ret;
>  int64_t   new_logical_pos;
> @@ -472,7 +472,7 @@ static int64_t async_seek(URLContext *h, int64_t pos, int 
> whence)
>  return ret;
>  }
>  
> -#define OFFSET(x) offsetof(Context, x)
> +#define OFFSET(x) offsetof(AsyncContext, x)
>  #define D AV_OPT_FLAG_DECODING_PARAM
>  
>  static const AVOption options[] = {
> @@ -495,7 +495,7 @@ const URLProtocol ff_async_protocol = {
>  .url_read= async_read,
>  .url_seek= async_seek,
>  .url_close   = async_close,
> -.priv_data_size  = sizeof(Context),
> +.priv_data_size  = sizeof(AsyncContext),
>  .priv_data_class = _context_class,
>  };
>  
> diff --git a/libavformat/cache.c b/libavformat/cache.c
> index 5f78adba9d..5d71e56f3d 100644
> --- a/libavformat/cache.c
> +++ b/libavformat/cache.c
> @@ -52,7 +52,7 @@ typedef struct CacheEntry {
>  int size;
>  } CacheEntry;
>  
> -typedef struct Context {
> +typedef struct CacheContext {
>  AVClass *class;
>  int fd;
>  char *filename;
> @@ -65,7 +65,7 @@ typedef struct Context {
>  URLContext *inner;
>  int64_t cache_hit, cache_miss;
>  int read_ahead_limit;
> -} Context;
> +} CacheContext;
>  
>  static int cmp(const void *key, const void *node)
>  {
> @@ -74,9 +74,9 @@ static int cmp(const void *key, const void *node)
>  
>  static int cache_open(URLContext *h, const char *arg, int flags, 
> AVDictionary **options)
>  {
> +CacheContext *c = h->priv_data;
>  int ret;
>  char *buffername;
> -Context *c= h->priv_data;
>  
>  av_strstart(arg, "cache:", );
>  
> @@ -99,7 +99,7 @@ static int cache_open(URLContext *h, const char *arg, int 
> flags, AVDictionary **
>  
>  static int add_entry(URLContext *h, const unsigned char *buf, 

Re: [FFmpeg-devel] [PATCH] lavc/rv32dsp: remove stray load immediate

2024-05-24 Thread Andreas Rheinhardt
Rémi Denis-Courmont:
> ---
>  libavcodec/riscv/rv34dsp_rvv.S | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavcodec/riscv/rv34dsp_rvv.S b/libavcodec/riscv/rv34dsp_rvv.S
> index f1f6345012..8eda01665d 100644
> --- a/libavcodec/riscv/rv34dsp_rvv.S
> +++ b/libavcodec/riscv/rv34dsp_rvv.S
> @@ -37,7 +37,6 @@ func ff_rv34_idct_dc_add_rvv, zve32x
>  vlse32.v  v0, (a0), a1
>  lit1, 169
>  mul   t1, t1, a2
> -lia2, 255
>  addi  t1, t1, 512
>  srai  t1, t1, 10
>  vsetivli  zero, 4*4, e16, m2, ta, ma

s/rv32dsp/rv34dsp/

- 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/6] avformat/oggdec: Check ffio_ensure_seekback()

2024-05-24 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Fixes Coverity issue #1492327.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/oggdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
> index 8ea81e5d45..5339fdd32c 100644
> --- a/libavformat/oggdec.c
> +++ b/libavformat/oggdec.c
> @@ -364,7 +364,9 @@ static int ogg_read_page(AVFormatContext *s, int *sid, 
> int probing)
>  ffio_init_checksum(bc, ff_crc04C11DB7_update, 0x4fa9b05f);
>  
>  /* To rewind if checksum is bad/check magic on switches - this is the 
> max packet size */
> -ffio_ensure_seekback(bc, MAX_PAGE_SIZE);
> +ret = ffio_ensure_seekback(bc, MAX_PAGE_SIZE);
> +if (ret < 0)
> +return ret;
>  start_pos = avio_tell(bc);
>  
>  version = avio_r8(bc);

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] avformat/mpegts: Don't use uninitialized value in av_log()

2024-05-24 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> It is undefined behaviour in (at least) C11 (see C11 6.3.2.1 (2)).
> Fixes Coverity issue #1500314.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/mpegts.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 3a5cb769ba..c66a1ea6ed 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2189,7 +2189,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
> AVStream *st, int stream_type
>  uint32_t buf;
>  AVDOVIDecoderConfigurationRecord *dovi;
>  size_t dovi_size;
> -int dependency_pid;
> +int dependency_pid = -1; // Unset
>  
>  if (desc_end - *pp < 4) // (8 + 8 + 7 + 6 + 1 + 1 + 1) / 8
>  return AVERROR_INVALIDDATA;

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 4/5] avformat/matroskaenc: Check ff_put_wav_header() failure

2024-05-24 Thread Andreas Rheinhardt
Andreas Rheinhardt:
> Fixes Coverity issue #1506706.
> 
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavformat/matroskaenc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
> index 63bae9fe1c..76c542d50b 100644
> --- a/libavformat/matroskaenc.c
> +++ b/libavformat/matroskaenc.c
> @@ -1250,7 +1250,9 @@ static int mkv_assemble_codecprivate(AVFormatContext 
> *s, AVIOContext *dyn_cp,
>  par->codec_tag = tag;
>  
>  /* Same comment as for ff_put_bmp_header applies here. */
> -ff_put_wav_header(s, dyn_cp, par, 
> FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
> +ret = ff_put_wav_header(s, dyn_cp, par, 
> FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
> +if (ret < 0)
> +return ret;
>  #endif
>  }
>  

Will apply the rest of 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] avformat/demux: Remove dead stores

2024-05-24 Thread Andreas Rheinhardt
Michael Niedermayer:
> Fixes: CID1473512 Unused value
> Fixes: CID1529228 Unused value
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/demux.c | 5 -
>  1 file changed, 5 deletions(-)
> 
> diff --git a/libavformat/demux.c b/libavformat/demux.c
> index ecefe7e0a74..d0a5a39d052 100644
> --- a/libavformat/demux.c
> +++ b/libavformat/demux.c
> @@ -2998,9 +2998,6 @@ int avformat_find_stream_info(AVFormatContext *ic, 
> AVDictionary **options)
>  
>  av_opt_set_int(ic, "skip_clear", 0, AV_OPT_SEARCH_CHILDREN);
>  
> -if (ret >= 0 && ic->nb_streams)
> -/* We could not have all the codec parameters before EOF. */
> -ret = -1;
>  for (unsigned i = 0; i < ic->nb_streams; i++) {
>  AVStream *const st  = ic->streams[i];
>  FFStream *const sti = ffstream(st);
> @@ -3022,8 +3019,6 @@ int avformat_find_stream_info(AVFormatContext *ic, 
> AVDictionary **options)
> "Could not find codec parameters for stream %d (%s): %s\n"
> "Consider increasing the value for the 'analyzeduration' 
> (%"PRId64") and 'probesize' (%"PRId64") options\n",
> i, buf, errmsg, ic->max_analyze_duration, ic->probesize);
> -} else {
> -ret = 0;
>  }
>  }
>  

IIRC these stores are only dead since
ac5a568e6dff8162a2e982f3571b925f1b207e2c; and it doesn't seem as if this
was intended.

- 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 v2 1/5] lavc/vp9dsp: R-V V mc avg

2024-05-24 Thread flow gg
I want to update the VP9 bilin load, just like you did with VP8, but it
seems like this patch([PATCH v2 1/5] lavc/vp9dsp: R-V V mc avg) doesn't
merge the current updates here but merges the previous version instead, so
the subsequent patches will have conflicts.

flow gg  于2024年5月22日周三 01:15写道:

> > Please put commas between operands.
> > This should probably be ff_avg_vp9 or something slightly more specific.
>
> Updated here.
>
>  于2024年5月22日周三 01:14写道:
>
>> From: sunyuechi 
>>
>> C908:
>> vp9_avg4_8bpp_c: 1.2
>> vp9_avg4_8bpp_rvv_i64: 1.0
>> vp9_avg8_8bpp_c: 3.7
>> vp9_avg8_8bpp_rvv_i64: 1.5
>> vp9_avg16_8bpp_c: 14.7
>> vp9_avg16_8bpp_rvv_i64: 3.5
>> vp9_avg32_8bpp_c: 57.7
>> vp9_avg32_8bpp_rvv_i64: 10.0
>> vp9_avg64_8bpp_c: 229.0
>> vp9_avg64_8bpp_rvv_i64: 31.7
>> ---
>>  libavcodec/riscv/Makefile  |  3 +-
>>  libavcodec/riscv/vp9_mc_rvv.S  | 58 ++
>>  libavcodec/riscv/vp9dsp.h  |  4 +--
>>  libavcodec/riscv/vp9dsp_init.c | 18 +++
>>  4 files changed, 80 insertions(+), 3 deletions(-)
>>  create mode 100644 libavcodec/riscv/vp9_mc_rvv.S
>>
>> diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
>> index 07d5c2915d..67e198d754 100644
>> --- a/libavcodec/riscv/Makefile
>> +++ b/libavcodec/riscv/Makefile
>> @@ -69,6 +69,7 @@ RVV-OBJS-$(CONFIG_VP8DSP) += riscv/vp8dsp_rvv.o
>>  OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9dsp_init.o
>>  RV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvi.o \
>>   riscv/vp9_mc_rvi.o
>> -RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o
>> +RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
>> +  riscv/vp9_mc_rvv.o
>>  OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
>>  RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
>> diff --git a/libavcodec/riscv/vp9_mc_rvv.S b/libavcodec/riscv/vp9_mc_rvv.S
>> new file mode 100644
>> index 00..7cb38ec94a
>> --- /dev/null
>> +++ b/libavcodec/riscv/vp9_mc_rvv.S
>> @@ -0,0 +1,58 @@
>> +/*
>> + * Copyright (c) 2024 Institue of Software Chinese Academy of Sciences
>> (ISCAS).
>> + *
>> + * 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/riscv/asm.S"
>> +
>> +.macro vsetvlstatic8 len an maxlen mn=m4
>> +.if \len == 4
>> +vsetivlizero, \len, e8, mf4, ta, ma
>> +.elseif \len == 8
>> +vsetivlizero, \len, e8, mf2, ta, ma
>> +.elseif \len == 16
>> +vsetivlizero, \len, e8, m1, ta, ma
>> +.elseif \len == 32
>> +li  \an, \len
>> +vsetvli zero, \an, e8, m2, ta, ma
>> +.elseif \len == 64
>> +li  \an, \maxlen
>> +vsetvli zero, \an, e8, \mn, ta, ma
>> +.endif
>> +.endm
>> +
>> +.macro copy_avg len
>> +func ff_vp9_avg\len\()_rvv, zve32x
>> +csrwi   vxrm, 0
>> +vsetvlstatic8   \len, t0, 64
>> +1:
>> +vle8.v  v8, (a2)
>> +vle8.v  v16, (a0)
>> +vaaddu.vv   v8, v8, v16
>> +addia4, a4, -1
>> +vse8.v  v8, (a0)
>> +add a2, a2, a3
>> +add a0, a0, a1
>> +bneza4, 1b
>> +ret
>> +endfunc
>> +.endm
>> +
>> +.irp len, 64, 32, 16, 8, 4
>> +copy_avg \len
>> +.endr
>> diff --git a/libavcodec/riscv/vp9dsp.h b/libavcodec/riscv/vp9dsp.h
>> index 79330b4968..ff8431591c 100644
>> --- a/libavcodec/riscv/vp9dsp.h
>> +++ b/libavcodec/riscv/vp9dsp.h
>> @@ -138,11 +138,11 @@ void ff_avg_bilin_##SIZE##hv_rvv(uint8_t *dst,
>> ptrdiff_t dststride,\
>>   int h, int mx, int my);
>>
>>  #define VP9_COPY_AVG_RISCV_RVV_FUNC(SIZE)   \
>> -void ff_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride,\
>> +void ff_vp9_copy##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride,\
>>   const uint8_t *src, ptrdiff_t srcstride,  \
>>   int h, int mx, int my);   \
>> \
>> -void ff_avg##SIZE##_rvv(uint8_t *dst, ptrdiff_t dststride, \
>> +void