summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-03 22:47:58 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-05 02:15:43 +0200
commitc095358289559d91932bd2ea48f90848ecee1f80 (patch)
treec36a638e81c8f2caaa6579263e4b47e73ad0c524
parent81b927a53bafd51b3874ae7c36c6948cc632c267 (diff)
avcodec/opus: Move defines to better places
Move ROUND_MUL* macros to their only users and the Celt macros to opus_celt.h. Also improve the other headers a bit while at it. Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/opus.h9
-rw-r--r--libavcodec/opus_celt.c2
-rw-r--r--libavcodec/opus_celt.h10
-rw-r--r--libavcodec/opus_pvq.c5
-rw-r--r--libavcodec/opus_silk.c3
-rw-r--r--libavcodec/opusenc.c2
-rw-r--r--libavcodec/opusenc.h3
-rw-r--r--libavcodec/opusenc_psy.c5
-rw-r--r--libavcodec/opusenc_psy.h2
9 files changed, 27 insertions, 14 deletions
diff --git a/libavcodec/opus.h b/libavcodec/opus.h
index 2dc6085207..0f1cb8b98b 100644
--- a/libavcodec/opus.h
+++ b/libavcodec/opus.h
@@ -32,18 +32,9 @@
#define MAX_FRAMES 48
#define MAX_PACKET_DUR 5760
-#define CELT_SHORT_BLOCKSIZE 120
-#define CELT_OVERLAP CELT_SHORT_BLOCKSIZE
-#define CELT_MAX_LOG_BLOCKS 3
-#define CELT_MAX_FRAME_SIZE (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS))
-#define CELT_MAX_BANDS 21
-
#define SILK_HISTORY 322
#define SILK_MAX_LPC 16
-#define ROUND_MULL(a,b,s) (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
-#define ROUND_MUL16(a,b) ((MUL16(a, b) + 16384) >> 15)
-
#define OPUS_TS_HEADER 0x7FE0 // 0x3ff (11 bits)
#define OPUS_TS_MASK 0xFFE0 // top 11 bits
diff --git a/libavcodec/opus_celt.c b/libavcodec/opus_celt.c
index f1fb88a56d..c2904cc9e0 100644
--- a/libavcodec/opus_celt.c
+++ b/libavcodec/opus_celt.c
@@ -25,6 +25,8 @@
* Opus CELT decoder
*/
+#include <float.h>
+
#include "opus_celt.h"
#include "opustab.h"
#include "opus_pvq.h"
diff --git a/libavcodec/opus_celt.h b/libavcodec/opus_celt.h
index 3dbf197160..2dbb79be6c 100644
--- a/libavcodec/opus_celt.h
+++ b/libavcodec/opus_celt.h
@@ -24,9 +24,9 @@
#ifndef AVCODEC_OPUS_CELT_H
#define AVCODEC_OPUS_CELT_H
-#include <float.h>
+#include <stdint.h>
-#include "opus.h"
+#include "avcodec.h"
#include "opusdsp.h"
#include "opus_rc.h"
@@ -35,6 +35,12 @@
#include "libavutil/mem_internal.h"
#include "libavutil/tx.h"
+#define CELT_SHORT_BLOCKSIZE 120
+#define CELT_OVERLAP CELT_SHORT_BLOCKSIZE
+#define CELT_MAX_LOG_BLOCKS 3
+#define CELT_MAX_FRAME_SIZE (CELT_SHORT_BLOCKSIZE * (1 << CELT_MAX_LOG_BLOCKS))
+#define CELT_MAX_BANDS 21
+
#define CELT_VECTORS 11
#define CELT_ALLOC_STEPS 6
#define CELT_FINE_OFFSET 21
diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index a4e44b7a14..79101847af 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -23,11 +23,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <float.h>
+
#include "config_components.h"
+#include "mathops.h"
#include "opustab.h"
#include "opus_pvq.h"
+#define ROUND_MUL16(a,b) ((MUL16(a, b) + 16384) >> 15)
+
#define CELT_PVQ_U(n, k) (ff_celt_pvq_u_row[FFMIN(n, k)][FFMAX(n, k)])
#define CELT_PVQ_V(n, k) (CELT_PVQ_U(n, k) + CELT_PVQ_U(n, (k) + 1))
diff --git a/libavcodec/opus_silk.c b/libavcodec/opus_silk.c
index f9d67f4fb3..fd1e83659c 100644
--- a/libavcodec/opus_silk.c
+++ b/libavcodec/opus_silk.c
@@ -26,9 +26,12 @@
#include <stdint.h>
+#include "mathops.h"
#include "opus.h"
#include "opustab.h"
+#define ROUND_MULL(a,b,s) (((MUL64(a, b) >> ((s) - 1)) + 1) >> 1)
+
typedef struct SilkFrame {
int coded;
int log_gain;
diff --git a/libavcodec/opusenc.c b/libavcodec/opusenc.c
index 58e3f5fa38..7695e95884 100644
--- a/libavcodec/opusenc.c
+++ b/libavcodec/opusenc.c
@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <float.h>
+
#include "encode.h"
#include "opusenc.h"
#include "opus_pvq.h"
diff --git a/libavcodec/opusenc.h b/libavcodec/opusenc.h
index 32d23deead..4d691d6a7d 100644
--- a/libavcodec/opusenc.h
+++ b/libavcodec/opusenc.h
@@ -22,7 +22,8 @@
#ifndef AVCODEC_OPUSENC_H
#define AVCODEC_OPUSENC_H
-#include "opus_celt.h"
+#include "libavutil/intmath.h"
+#include "opus.h"
/* Determines the maximum delay the psychoacoustic system will use for lookahead */
#define FF_BUFQUEUE_SIZE 145
diff --git a/libavcodec/opusenc_psy.c b/libavcodec/opusenc_psy.c
index 3bff57d347..9b11651dbe 100644
--- a/libavcodec/opusenc_psy.c
+++ b/libavcodec/opusenc_psy.c
@@ -19,10 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <float.h>
+
#include "opusenc_psy.h"
+#include "opus_celt.h"
#include "opus_pvq.h"
#include "opustab.h"
-#include "libavutil/qsort.h"
+#include "libavfilter/window_func.h"
static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int band,
float *bits, float lambda)
diff --git a/libavcodec/opusenc_psy.h b/libavcodec/opusenc_psy.h
index 0a7cdb6f2c..67e96b2fa5 100644
--- a/libavcodec/opusenc_psy.h
+++ b/libavcodec/opusenc_psy.h
@@ -26,8 +26,8 @@
#include "libavutil/mem_internal.h"
#include "opusenc.h"
+#include "opus_celt.h"
#include "opusenc_utils.h"
-#include "libavfilter/window_func.h"
/* Each step is 2.5ms */
typedef struct OpusPsyStep {