Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS
@ 2022-09-25 15:05 Andreas Rheinhardt
  2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 2/3] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c Andreas Rheinhardt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-09-25 15:05 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/amrwbdec.c | 4 ++++
 libavcodec/lsp.c      | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index ea3812cd9a..b59066adcf 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -24,6 +24,8 @@
  * AMR wideband decoder
  */
 
+#include "config.h"
+
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "libavutil/lfg.h"
@@ -42,7 +44,9 @@
 #include "amr.h"
 
 #include "amrwbdata.h"
+#if ARCH_MIPS
 #include "mips/amrwbdec_mips.h"
+#endif /* ARCH_MIPS */
 
 typedef struct AMRWBContext {
     AMRWBFrame                             frame; ///< AMRWB parameters decoded from bitstream
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 90f2efaafe..9e7bc5f87a 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -23,11 +23,15 @@
 
 #include <math.h>
 
+#include "config.h"
+
 #define FRAC_BITS 14
 #include "libavutil/macros.h"
 #include "mathops.h"
 #include "lsp.h"
+#if ARCH_MIPS
 #include "libavcodec/mips/lsp_mips.h"
+#endif /* ARCH_MIPS */
 #include "libavutil/avassert.h"
 
 void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order)
-- 
2.34.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/3] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c
  2022-09-25 15:05 [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
@ 2022-09-25 15:06 ` Andreas Rheinhardt
  2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 3/3] avcodec/lsp: Make ff_lsp2polyf() static Andreas Rheinhardt
  2022-09-28  1:07 ` [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-09-25 15:06 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Will avoid a forward declaration lateron.
Also adapt the function to modern style while at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/lsp.c | 35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 9e7bc5f87a..9536d8078b 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -124,6 +124,22 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
     }
 }
 
+#ifndef ff_lsp2polyf
+void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
+{
+    f[0] = 1.0;
+    f[1] = -2 * lsp[0];
+    lsp -= 2;
+    for (int i = 2; i <= lp_half_order; i++) {
+        double val = -2 * lsp[2*i];
+        f[i] = val * f[i-1] + 2*f[i-2];
+        for (int j = i-1; j > 1; j--)
+            f[j] += f[j-1] * val + f[j-2];
+        f[1] += val;
+    }
+}
+#endif /* ff_lsp2polyf */
+
 void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
 {
     int i;
@@ -191,25 +207,6 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd
     ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1);
 }
 
-#ifndef ff_lsp2polyf
-void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
-{
-    int i, j;
-
-    f[0] = 1.0;
-    f[1] = -2 * lsp[0];
-    lsp -= 2;
-    for(i=2; i<=lp_half_order; i++)
-    {
-        double val = -2 * lsp[2*i];
-        f[i] = val * f[i-1] + 2*f[i-2];
-        for(j=i-1; j>1; j--)
-            f[j] += f[j-1] * val + f[j-2];
-        f[1] += val;
-    }
-}
-#endif /* ff_lsp2polyf */
-
 void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
 {
     double pa[MAX_LP_HALF_ORDER+1], qa[MAX_LP_HALF_ORDER+1];
-- 
2.34.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 3/3] avcodec/lsp: Make ff_lsp2polyf() static
  2022-09-25 15:05 [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
  2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 2/3] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c Andreas Rheinhardt
@ 2022-09-25 15:06 ` Andreas Rheinhardt
  2022-09-28  1:07 ` [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-09-25 15:06 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Possible since 48ac225db2563fe534b1d9e999bf8e70d5a577f8.
Furthermore, the current code would not work on mips
in case ff_lsp2polyf() were used outside of lsp.c,
because it is not compiled on mips since commit
3827a86eacd04d9d7b356f769be553f7b8cca361 at all;
instead it is overridden with a static av_always_inline
function which only works for the callers in lsp.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/lsp.c           | 24 +++++++++++++++++-------
 libavcodec/lsp.h           | 12 ------------
 libavcodec/mips/lsp_mips.h | 12 ++++++------
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
index 9536d8078b..275984097d 100644
--- a/libavcodec/lsp.c
+++ b/libavcodec/lsp.c
@@ -124,8 +124,18 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order)
     }
 }
 
-#ifndef ff_lsp2polyf
-void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
+#ifndef lsp2polyf
+/**
+ * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
+ * needed for LSP to LPC conversion.
+ * We only need to calculate the 6 first elements of the polynomial.
+ *
+ * @param lsp line spectral pairs in cosine domain
+ * @param[out] f polynomial input/output as a vector
+ *
+ * TIA/EIA/IS-733 2.4.3.3.5-1/2
+ */
+static void lsp2polyf(const double *lsp, double *f, int lp_half_order)
 {
     f[0] = 1.0;
     f[1] = -2 * lsp[0];
@@ -138,7 +148,7 @@ void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order)
         f[1] += val;
     }
 }
-#endif /* ff_lsp2polyf */
+#endif /* lsp2polyf */
 
 void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order)
 {
@@ -172,8 +182,8 @@ void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
 
     qa[-1] = 0.0;
 
-    ff_lsp2polyf(lsp    , pa, lp_half_order    );
-    ff_lsp2polyf(lsp + 1, qa, lp_half_order - 1);
+    lsp2polyf(lsp    , pa, lp_half_order    );
+    lsp2polyf(lsp + 1, qa, lp_half_order - 1);
 
     for (i = 1, j = lp_order - 1; i < lp_half_order; i++, j--) {
         double paf =  pa[i]            * (1 + lsp[lp_order - 1]);
@@ -214,8 +224,8 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order)
 
     av_assert2(lp_half_order <= MAX_LP_HALF_ORDER);
 
-    ff_lsp2polyf(lsp,     pa, lp_half_order);
-    ff_lsp2polyf(lsp + 1, qa, lp_half_order);
+    lsp2polyf(lsp,     pa, lp_half_order);
+    lsp2polyf(lsp + 1, qa, lp_half_order);
 
     while (lp_half_order--) {
         double paf = pa[lp_half_order+1] + pa[lp_half_order];
diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h
index 621ebeaebe..26b1382eda 100644
--- a/libavcodec/lsp.h
+++ b/libavcodec/lsp.h
@@ -115,16 +115,4 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order);
  */
 void ff_sort_nearly_sorted_floats(float *vals, int len);
 
-/**
- * Compute the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
- * needed for LSP to LPC conversion.
- * We only need to calculate the 6 first elements of the polynomial.
- *
- * @param lsp line spectral pairs in cosine domain
- * @param[out] f polynomial input/output as a vector
- *
- * TIA/EIA/IS-733 2.4.3.3.5-1/2
- */
-void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order);
-
 #endif /* AVCODEC_LSP_H */
diff --git a/libavcodec/mips/lsp_mips.h b/libavcodec/mips/lsp_mips.h
index c69f8b770c..2d67403888 100644
--- a/libavcodec/mips/lsp_mips.h
+++ b/libavcodec/mips/lsp_mips.h
@@ -61,7 +61,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/mips/asmdefs.h"
 
-static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int lp_half_order)
+static av_always_inline void lsp2polyf_mips(const double *lsp, double *f, int lp_half_order)
 {
     int i, j = 0;
     double * p_fi = f;
@@ -88,8 +88,8 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int
             "addiu  %[j],       %[i], -2                        \n\t"
             "ldc1   %[f_j_2],   -8(%[p_f])                      \n\t"
             "sdc1   %[tmp],     16(%[p_f])                      \n\t"
-            "beqz   %[j],       ff_lsp2polyf_lp_j_end%=         \n\t"
-            "ff_lsp2polyf_lp_j%=:                               \n\t"
+            "beqz   %[j],       lsp2polyf_lp_j_end%=            \n\t"
+            "lsp2polyf_lp_j%=:                                  \n\t"
             "add.d  %[tmp],     %[f_j],     %[f_j_2]            \n\t"
             "madd.d %[tmp],     %[tmp],     %[f_j_1], %[val]    \n\t"
             "mov.d  %[f_j],     %[f_j_1]                        \n\t"
@@ -98,8 +98,8 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int
             "ldc1   %[f_j_2],   -16(%[p_f])                     \n\t"
             "sdc1   %[tmp],     8(%[p_f])                       \n\t"
             PTR_ADDIU "%[p_f], -8                              \n\t"
-            "bgtz   %[j],       ff_lsp2polyf_lp_j%=             \n\t"
-            "ff_lsp2polyf_lp_j_end%=:                           \n\t"
+            "bgtz   %[j],       lsp2polyf_lp_j%=                \n\t"
+            "lsp2polyf_lp_j_end%=:                              \n\t"
 
             : [f_j_2]"=&f"(f_j_2), [f_j_1]"=&f"(f_j_1), [val]"+f"(val),
               [tmp]"=&f"(tmp), [f_j]"=&f"(f_j), [p_f]"+r"(p_f),
@@ -110,7 +110,7 @@ static av_always_inline void ff_lsp2polyf_mips(const double *lsp, double *f, int
         f[1] += val;
     }
 }
-#define ff_lsp2polyf ff_lsp2polyf_mips
+#define lsp2polyf lsp2polyf_mips
 #endif /* !HAVE_MIPS32R6 && !HAVE_MIPS64R6 */
 #endif /* HAVE_MIPSFPU && HAVE_INLINE_ASM */
 #endif /* AVCODEC_MIPS_LSP_MIPS_H */
-- 
2.34.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS
  2022-09-25 15:05 [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
  2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 2/3] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c Andreas Rheinhardt
  2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 3/3] avcodec/lsp: Make ff_lsp2polyf() static Andreas Rheinhardt
@ 2022-09-28  1:07 ` Andreas Rheinhardt
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2022-09-28  1:07 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/amrwbdec.c | 4 ++++
>  libavcodec/lsp.c      | 4 ++++
>  2 files changed, 8 insertions(+)
> 
> diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
> index ea3812cd9a..b59066adcf 100644
> --- a/libavcodec/amrwbdec.c
> +++ b/libavcodec/amrwbdec.c
> @@ -24,6 +24,8 @@
>   * AMR wideband decoder
>   */
>  
> +#include "config.h"
> +
>  #include "libavutil/channel_layout.h"
>  #include "libavutil/common.h"
>  #include "libavutil/lfg.h"
> @@ -42,7 +44,9 @@
>  #include "amr.h"
>  
>  #include "amrwbdata.h"
> +#if ARCH_MIPS
>  #include "mips/amrwbdec_mips.h"
> +#endif /* ARCH_MIPS */
>  
>  typedef struct AMRWBContext {
>      AMRWBFrame                             frame; ///< AMRWB parameters decoded from bitstream
> diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
> index 90f2efaafe..9e7bc5f87a 100644
> --- a/libavcodec/lsp.c
> +++ b/libavcodec/lsp.c
> @@ -23,11 +23,15 @@
>  
>  #include <math.h>
>  
> +#include "config.h"
> +
>  #define FRAC_BITS 14
>  #include "libavutil/macros.h"
>  #include "mathops.h"
>  #include "lsp.h"
> +#if ARCH_MIPS
>  #include "libavcodec/mips/lsp_mips.h"
> +#endif /* ARCH_MIPS */
>  #include "libavutil/avassert.h"
>  
>  void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, int lsfq_max, int lp_order)

Will apply tonight unless there are objections.

- Andreas

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-28  1:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 15:05 [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt
2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 2/3] avcodec/lsp: Move ff_lsp2polyf() upwards in lsp.c Andreas Rheinhardt
2022-09-25 15:06 ` [FFmpeg-devel] [PATCH 3/3] avcodec/lsp: Make ff_lsp2polyf() static Andreas Rheinhardt
2022-09-28  1:07 ` [FFmpeg-devel] [PATCH 1/3] avcodec/amrwbdec, lsp: Include mips headers only #if ARCH_MIPS Andreas Rheinhardt

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git