* [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
@ 2023-02-22 9:12 copypaste
2023-02-23 13:45 ` Anton Khirnov
2023-02-23 14:37 ` copypaste
0 siblings, 2 replies; 7+ messages in thread
From: copypaste @ 2023-02-22 9:12 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1: Type: text/plain, Size: 57 bytes --]
Best,
Fred Brennan (copypaste.wtf)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-build-on-Android-due-to-termbits.h-collision.patch --]
[-- Type: text/x-diff, Size: 9954 bytes --]
From e9a889bfbf38bda7855792edd8248f4f4a56af7e Mon Sep 17 00:00:00 2001
From: Fredrick Brennan <copypaste@kittens.ph>
Date: Tue, 21 Feb 2023 12:58:38 -0500
Subject: [PATCH 1/2] Fix build on Android due to termbits.h collision!
Applied to libavcodec/aaccoder.c:
:%s/\([*]\)\?\([ \t]\{-}\)\?\(\<[BD-Z]\([0-9]*\)\)\>/\1\2_\3/g
This stops B0 and B1 from colliding with a define in
/usr/include/asm-generic/termbits.h:
```c
```
Because of other defines in the file I used a more inclusive regex as
there's a warning at top that it's autogenerated and may be expanded.
---
libavcodec/aaccoder.c | 62 +++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 31 deletions(-)
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 6291c16123..35791c3040 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -83,8 +83,8 @@ static av_always_inline float quantize_and_encode_band_cost_template(
const float ROUNDING)
{
const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512;
- const float Q = ff_aac_pow2sf_tab [q_idx];
- const float Q34 = ff_aac_pow34sf_tab[q_idx];
+ const float _Q = ff_aac_pow2sf_tab [q_idx];
+ const float _Q34 = ff_aac_pow34sf_tab[q_idx];
const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512];
const float CLIPPED_ESCAPE = 165140.0f*IQ;
float cost = 0;
@@ -111,7 +111,7 @@ static av_always_inline float quantize_and_encode_band_cost_template(
s->abs_pow34(s->scoefs, in, size);
scaled = s->scoefs;
}
- s->quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], Q34, ROUNDING);
+ s->quant_bands(s->qcoefs, in, scaled, size, !BT_UNSIGNED, aac_cb_maxval[cb], _Q34, ROUNDING);
if (BT_UNSIGNED) {
off = 0;
} else {
@@ -138,7 +138,7 @@ static av_always_inline float quantize_and_encode_band_cost_template(
quantized = CLIPPED_ESCAPE;
curbits += 21;
} else {
- int c = av_clip_uintp2(quant(t, Q, ROUNDING), 13);
+ int c = av_clip_uintp2(quant(t, _Q, ROUNDING), 13);
quantized = c*cbrtf(c)*IQ;
curbits += av_log2(c)*2 - 4 + 1;
}
@@ -175,7 +175,7 @@ static av_always_inline float quantize_and_encode_band_cost_template(
if (BT_ESC) {
for (int j = 0; j < 2; j++) {
if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 64.0f) {
- int coef = av_clip_uintp2(quant(fabsf(in[i+j]), Q, ROUNDING), 13);
+ int coef = av_clip_uintp2(quant(fabsf(in[i+j]), _Q, ROUNDING), 13);
int len = av_log2(coef);
put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 2);
@@ -979,9 +979,9 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
{
int start = 0, i, w, w2, g, sid_sf_boost, prev_mid, prev_side;
uint8_t nextband0[128], nextband1[128];
- float *M = s->scoefs + 128*0, *S = s->scoefs + 128*1;
- float *L34 = s->scoefs + 128*2, *R34 = s->scoefs + 128*3;
- float *M34 = s->scoefs + 128*4, *S34 = s->scoefs + 128*5;
+ float *_M = s->scoefs + 128*0, *_S = s->scoefs + 128*1;
+ float *_L34 = s->scoefs + 128*2, *_R34 = s->scoefs + 128*3;
+ float *_M34 = s->scoefs + 128*4, *_S34 = s->scoefs + 128*5;
const float lambda = s->lambda;
const float mslambda = FFMIN(1.0f, lambda / 120.f);
SingleChannelElement *sce0 = &cpe->ch[0];
@@ -1007,22 +1007,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
/* Must compute mid/side SF and book for the whole window group */
for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) {
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
- M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ _M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
- S[i] = M[i]
+ _S[i] = _M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
- s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
- s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_M34, _M, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_S34, _S, sce0->ics.swb_sizes[g]);
for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) {
- Mmax = FFMAX(Mmax, M34[i]);
- Smax = FFMAX(Smax, S34[i]);
+ Mmax = FFMAX(Mmax, _M34[i]);
+ Smax = FFMAX(Smax, _S34[i]);
}
}
for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) {
float dist1 = 0.0f, dist2 = 0.0f;
- int B0 = 0, B1 = 0;
+ int _B0 = 0, _B1 = 0;
int minidx;
int mididx, sididx;
int midcb, sidcb;
@@ -1050,46 +1050,46 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
float minthr = FFMIN(band0->threshold, band1->threshold);
int b1,b2,b3,b4;
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
- M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ _M[i] = (sce0->coeffs[start+(w+w2)*128+i]
+ sce1->coeffs[start+(w+w2)*128+i]) * 0.5;
- S[i] = M[i]
+ _S[i] = _M[i]
- sce1->coeffs[start+(w+w2)*128+i];
}
- s->abs_pow34(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
- s->abs_pow34(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
- s->abs_pow34(M34, M, sce0->ics.swb_sizes[g]);
- s->abs_pow34(S34, S, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_M34, _M, sce0->ics.swb_sizes[g]);
+ s->abs_pow34(_S34, _S, sce0->ics.swb_sizes[g]);
dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128],
- L34,
+ _L34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[w*16+g],
sce0->band_type[w*16+g],
lambda / (band0->threshold + FLT_MIN), INFINITY, &b1, NULL);
dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128],
- R34,
+ _R34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[w*16+g],
sce1->band_type[w*16+g],
lambda / (band1->threshold + FLT_MIN), INFINITY, &b2, NULL);
- dist2 += quantize_band_cost(s, M,
- M34,
+ dist2 += quantize_band_cost(s, _M,
+ _M34,
sce0->ics.swb_sizes[g],
mididx,
midcb,
lambda / (minthr + FLT_MIN), INFINITY, &b3, NULL);
- dist2 += quantize_band_cost(s, S,
- S34,
+ dist2 += quantize_band_cost(s, _S,
+ _S34,
sce1->ics.swb_sizes[g],
sididx,
sidcb,
mslambda / (minthr * bmax + FLT_MIN), INFINITY, &b4, NULL);
- B0 += b1+b2;
- B1 += b3+b4;
+ _B0 += b1+b2;
+ _B1 += b3+b4;
dist1 -= b1+b2;
dist2 -= b3+b4;
}
- cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0;
+ cpe->ms_mask[w*16+g] = dist2 <= dist1 && _B1 < _B0;
if (cpe->ms_mask[w*16+g]) {
if (sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) {
sce0->sf_idx[w*16+g] = mididx;
@@ -1101,7 +1101,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe)
cpe->ms_mask[w*16+g] = 0;
}
break;
- } else if (B1 > B0) {
+ } else if (_B1 > _B0) {
/* More boost won't fix this */
break;
}
--
2.39.2
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Fixed-rest-of-the-build-on-Android.patch --]
[-- Type: text/x-diff, Size: 43388 bytes --]
From ccd0e884e045ed854658fd5e956bbddcd953dcf6 Mon Sep 17 00:00:00 2001
From: Fredrick Brennan <copypaste@kittens.ph>
Date: Wed, 22 Feb 2023 04:07:14 -0500
Subject: [PATCH 2/2] Fixed rest of the build on Android
see last commit
---
libavcodec/faandct.c | 62 +++---
libavcodec/hevcdec.h | 7 +
libavcodec/opus_pvq.c | 446 +++++++++++++++++++++---------------------
3 files changed, 261 insertions(+), 254 deletions(-)
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index 38c392bbae..52136ec9b1 100644
--- a/libavcodec/faandct.c
+++ b/libavcodec/faandct.c
@@ -37,29 +37,29 @@ for this approach). Unfortunately, long double is not always available correctly
e.g ppc has issues.
TODO: add L suffixes when ppc and toolchains sort out their stuff.
*/
-#define B0 1.000000000000000000000000000000000000
-#define B1 0.720959822006947913789091890943021267 // (cos(pi*1/16)sqrt(2))^-1
-#define B2 0.765366864730179543456919968060797734 // (cos(pi*2/16)sqrt(2))^-1
-#define B3 0.850430094767256448766702844371412325 // (cos(pi*3/16)sqrt(2))^-1
-#define B4 1.000000000000000000000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
-#define B5 1.272758580572833938461007018281767032 // (cos(pi*5/16)sqrt(2))^-1
-#define B6 1.847759065022573512256366378793576574 // (cos(pi*6/16)sqrt(2))^-1
-#define B7 3.624509785411551372409941227504289587 // (cos(pi*7/16)sqrt(2))^-1
-
-#define A1 M_SQRT1_2 // cos(pi*4/16)
-#define A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
-#define A5 0.38268343236508977170 // cos(pi*6/16)
-#define A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
+#define _B0 1.000000000000000000000000000000000000
+#define _B1 0.720959822006947913789091890943021267 // (cos(pi*1/16)sqrt(2))^-1
+#define _B2 0.765366864730179543456919968060797734 // (cos(pi*2/16)sqrt(2))^-1
+#define _B3 0.850430094767256448766702844371412325 // (cos(pi*3/16)sqrt(2))^-1
+#define _B4 1.000000000000000000000000000000000000 // (cos(pi*4/16)sqrt(2))^-1
+#define _B5 1.272758580572833938461007018281767032 // (cos(pi*5/16)sqrt(2))^-1
+#define _B6 1.847759065022573512256366378793576574 // (cos(pi*6/16)sqrt(2))^-1
+#define _B7 3.624509785411551372409941227504289587 // (cos(pi*7/16)sqrt(2))^-1
+
+#define _A1 M_SQRT1_2 // cos(pi*4/16)
+#define _A2 0.54119610014619698435 // cos(pi*6/16)sqrt(2)
+#define _A5 0.38268343236508977170 // cos(pi*6/16)
+#define _A4 1.30656296487637652774 // cos(pi*2/16)sqrt(2)
static const FLOAT postscale[64]={
-B0*B0, B0*B1, B0*B2, B0*B3, B0*B4, B0*B5, B0*B6, B0*B7,
-B1*B0, B1*B1, B1*B2, B1*B3, B1*B4, B1*B5, B1*B6, B1*B7,
-B2*B0, B2*B1, B2*B2, B2*B3, B2*B4, B2*B5, B2*B6, B2*B7,
-B3*B0, B3*B1, B3*B2, B3*B3, B3*B4, B3*B5, B3*B6, B3*B7,
-B4*B0, B4*B1, B4*B2, B4*B3, B4*B4, B4*B5, B4*B6, B4*B7,
-B5*B0, B5*B1, B5*B2, B5*B3, B5*B4, B5*B5, B5*B6, B5*B7,
-B6*B0, B6*B1, B6*B2, B6*B3, B6*B4, B6*B5, B6*B6, B6*B7,
-B7*B0, B7*B1, B7*B2, B7*B3, B7*B4, B7*B5, B7*B6, B7*B7,
+_B0*_B0, _B0*_B1, _B0*_B2, _B0*_B3, _B0*_B4, _B0*_B5, _B0*_B6, _B0*_B7,
+_B1*_B0, _B1*_B1, _B1*_B2, _B1*_B3, _B1*_B4, _B1*_B5, _B1*_B6, _B1*_B7,
+_B2*_B0, _B2*_B1, _B2*_B2, _B2*_B3, _B2*_B4, _B2*_B5, _B2*_B6, _B2*_B7,
+_B3*_B0, _B3*_B1, _B3*_B2, _B3*_B3, _B3*_B4, _B3*_B5, _B3*_B6, _B3*_B7,
+_B4*_B0, _B4*_B1, _B4*_B2, _B4*_B3, _B4*_B4, _B4*_B5, _B4*_B6, _B4*_B7,
+_B5*_B0, _B5*_B1, _B5*_B2, _B5*_B3, _B5*_B4, _B5*_B5, _B5*_B6, _B5*_B7,
+_B6*_B0, _B6*_B1, _B6*_B2, _B6*_B3, _B6*_B4, _B6*_B5, _B6*_B6, _B6*_B7,
+_B7*_B0, _B7*_B1, _B7*_B2, _B7*_B3, _B7*_B4, _B7*_B5, _B7*_B6, _B7*_B7,
};
static av_always_inline void row_fdct(FLOAT temp[64], int16_t *data)
@@ -88,7 +88,7 @@ static av_always_inline void row_fdct(FLOAT temp[64], int16_t *data)
temp[4 + i]= tmp10 - tmp11;
tmp12 += tmp13;
- tmp12 *= A1;
+ tmp12 *= _A1;
temp[2 + i]= tmp13 + tmp12;
temp[6 + i]= tmp13 - tmp12;
@@ -96,10 +96,10 @@ static av_always_inline void row_fdct(FLOAT temp[64], int16_t *data)
tmp5 += tmp6;
tmp6 += tmp7;
- z2= tmp4*(A2+A5) - tmp6*A5;
- z4= tmp6*(A4-A5) + tmp4*A5;
+ z2= tmp4*(_A2+_A5) - tmp6*_A5;
+ z4= tmp6*(_A4-_A5) + tmp4*_A5;
- tmp5*=A1;
+ tmp5*=_A1;
z11= tmp7 + tmp5;
z13= tmp7 - tmp5;
@@ -142,7 +142,7 @@ void ff_faandct(int16_t *data)
data[8*4 + i]= lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
- tmp12 *= A1;
+ tmp12 *= _A1;
data[8*2 + i]= lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
data[8*6 + i]= lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
@@ -150,10 +150,10 @@ void ff_faandct(int16_t *data)
tmp5 += tmp6;
tmp6 += tmp7;
- z2= tmp4*(A2+A5) - tmp6*A5;
- z4= tmp6*(A4-A5) + tmp4*A5;
+ z2= tmp4*(_A2+_A5) - tmp6*_A5;
+ z4= tmp6*(_A4-_A5) + tmp4*_A5;
- tmp5*=A1;
+ tmp5*=_A1;
z11= tmp7 + tmp5;
z13= tmp7 - tmp5;
@@ -195,7 +195,7 @@ void ff_faandct248(int16_t *data)
data[8*4 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
- tmp12 *= A1;
+ tmp12 *= _A1;
data[8*2 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
data[8*6 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
@@ -208,7 +208,7 @@ void ff_faandct248(int16_t *data)
data[8*5 + i] = lrintf(postscale[8*4 + i] * (tmp10 - tmp11));
tmp12 += tmp13;
- tmp12 *= A1;
+ tmp12 *= _A1;
data[8*3 + i] = lrintf(postscale[8*2 + i] * (tmp13 + tmp12));
data[8*7 + i] = lrintf(postscale[8*6 + i] * (tmp13 - tmp12));
}
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 9d3f4adbb3..bfb94155e1 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -56,6 +56,13 @@
#define L0 0
#define L1 1
+// Required on Android. Set by asm include!
+#undef A0
+#undef A1
+#undef A2
+#undef B0
+#undef B1
+#undef B2
#define EPEL_EXTRA_BEFORE 1
#define EPEL_EXTRA_AFTER 2
diff --git a/libavcodec/opus_pvq.c b/libavcodec/opus_pvq.c
index d08dcd7413..9deab4c615 100644
--- a/libavcodec/opus_pvq.c
+++ b/libavcodec/opus_pvq.c
@@ -80,21 +80,21 @@ static inline int celt_pulses2bits(const uint8_t *cache, int pulses)
return (pulses == 0) ? 0 : cache[pulses] + 1;
}
-static inline void celt_normalize_residual(const int * av_restrict iy, float * av_restrict X,
- int N, float g)
+static inline void celt_normalize_residual(const int * av_restrict iy, float * av_restrict _X,
+ int _N, float g)
{
int i;
- for (i = 0; i < N; i++)
- X[i] = g * iy[i];
+ for (i = 0; i < _N; i++)
+ _X[i] = g * iy[i];
}
-static void celt_exp_rotation_impl(float *X, uint32_t len, uint32_t stride,
+static void celt_exp_rotation_impl(float *_X, uint32_t len, uint32_t stride,
float c, float s)
{
float *Xptr;
int i;
- Xptr = X;
+ Xptr = _X;
for (i = 0; i < len - stride; i++) {
float x1 = Xptr[0];
float x2 = Xptr[stride];
@@ -102,7 +102,7 @@ static void celt_exp_rotation_impl(float *X, uint32_t len, uint32_t stride,
*Xptr++ = c * x1 - s * x2;
}
- Xptr = &X[len - 2 * stride - 1];
+ Xptr = &_X[len - 2 * stride - 1];
for (i = len - 2 * stride - 1; i >= 0; i--) {
float x1 = Xptr[0];
float x2 = Xptr[stride];
@@ -111,8 +111,8 @@ static void celt_exp_rotation_impl(float *X, uint32_t len, uint32_t stride,
}
}
-static inline void celt_exp_rotation(float *X, uint32_t len,
- uint32_t stride, uint32_t K,
+static inline void celt_exp_rotation(float *_X, uint32_t len,
+ uint32_t stride, uint32_t _K,
enum CeltSpread spread, const int encode)
{
uint32_t stride2 = 0;
@@ -120,10 +120,10 @@ static inline void celt_exp_rotation(float *X, uint32_t len,
float gain, theta;
int i;
- if (2*K >= len || spread == CELT_SPREAD_NONE)
+ if (2*_K >= len || spread == CELT_SPREAD_NONE)
return;
- gain = (float)len / (len + (20 - 5*spread) * K);
+ gain = (float)len / (len + (20 - 5*spread) * _K);
theta = M_PI * gain * gain / 4;
c = cosf(theta);
@@ -140,175 +140,175 @@ static inline void celt_exp_rotation(float *X, uint32_t len,
len /= stride;
for (i = 0; i < stride; i++) {
if (encode) {
- celt_exp_rotation_impl(X + i * len, len, 1, c, -s);
+ celt_exp_rotation_impl(_X + i * len, len, 1, c, -s);
if (stride2)
- celt_exp_rotation_impl(X + i * len, len, stride2, s, -c);
+ celt_exp_rotation_impl(_X + i * len, len, stride2, s, -c);
} else {
if (stride2)
- celt_exp_rotation_impl(X + i * len, len, stride2, s, c);
- celt_exp_rotation_impl(X + i * len, len, 1, c, s);
+ celt_exp_rotation_impl(_X + i * len, len, stride2, s, c);
+ celt_exp_rotation_impl(_X + i * len, len, 1, c, s);
}
}
}
-static inline uint32_t celt_extract_collapse_mask(const int *iy, uint32_t N, uint32_t B)
+static inline uint32_t celt_extract_collapse_mask(const int *iy, uint32_t _N, uint32_t _B)
{
- int i, j, N0 = N / B;
+ int i, j, _N0 = _N / _B;
uint32_t collapse_mask = 0;
- if (B <= 1)
+ if (_B <= 1)
return 1;
- for (i = 0; i < B; i++)
- for (j = 0; j < N0; j++)
- collapse_mask |= (!!iy[i*N0+j]) << i;
+ for (i = 0; i < _B; i++)
+ for (j = 0; j < _N0; j++)
+ collapse_mask |= (!!iy[i*_N0+j]) << i;
return collapse_mask;
}
-static inline void celt_stereo_merge(float *X, float *Y, float mid, int N)
+static inline void celt_stereo_merge(float *_X, float *_Y, float mid, int _N)
{
int i;
float xp = 0, side = 0;
- float E[2];
+ float _E[2];
float mid2;
float gain[2];
- /* Compute the norm of X+Y and X-Y as |X|^2 + |Y|^2 +/- sum(xy) */
- for (i = 0; i < N; i++) {
- xp += X[i] * Y[i];
- side += Y[i] * Y[i];
+ /* Compute the norm of _X+_Y and _X-_Y as |_X|^2 + |_Y|^2 +/- sum(xy) */
+ for (i = 0; i < _N; i++) {
+ xp += _X[i] * _Y[i];
+ side += _Y[i] * _Y[i];
}
/* Compensating for the mid normalization */
xp *= mid;
mid2 = mid;
- E[0] = mid2 * mid2 + side - 2 * xp;
- E[1] = mid2 * mid2 + side + 2 * xp;
- if (E[0] < 6e-4f || E[1] < 6e-4f) {
- for (i = 0; i < N; i++)
- Y[i] = X[i];
+ _E[0] = mid2 * mid2 + side - 2 * xp;
+ _E[1] = mid2 * mid2 + side + 2 * xp;
+ if (_E[0] < 6e-4f || _E[1] < 6e-4f) {
+ for (i = 0; i < _N; i++)
+ _Y[i] = _X[i];
return;
}
- gain[0] = 1.0f / sqrtf(E[0]);
- gain[1] = 1.0f / sqrtf(E[1]);
+ gain[0] = 1.0f / sqrtf(_E[0]);
+ gain[1] = 1.0f / sqrtf(_E[1]);
- for (i = 0; i < N; i++) {
+ for (i = 0; i < _N; i++) {
float value[2];
/* Apply mid scaling (side is already scaled) */
- value[0] = mid * X[i];
- value[1] = Y[i];
- X[i] = gain[0] * (value[0] - value[1]);
- Y[i] = gain[1] * (value[0] + value[1]);
+ value[0] = mid * _X[i];
+ value[1] = _Y[i];
+ _X[i] = gain[0] * (value[0] - value[1]);
+ _Y[i] = gain[1] * (value[0] + value[1]);
}
}
-static void celt_interleave_hadamard(float *tmp, float *X, int N0,
+static void celt_interleave_hadamard(float *tmp, float *_X, int _N0,
int stride, int hadamard)
{
- int i, j, N = N0*stride;
+ int i, j, _N = _N0*stride;
const uint8_t *order = &ff_celt_hadamard_order[hadamard ? stride - 2 : 30];
for (i = 0; i < stride; i++)
- for (j = 0; j < N0; j++)
- tmp[j*stride+i] = X[order[i]*N0+j];
+ for (j = 0; j < _N0; j++)
+ tmp[j*stride+i] = _X[order[i]*_N0+j];
- memcpy(X, tmp, N*sizeof(float));
+ memcpy(_X, tmp, _N*sizeof(float));
}
-static void celt_deinterleave_hadamard(float *tmp, float *X, int N0,
+static void celt_deinterleave_hadamard(float *tmp, float *_X, int _N0,
int stride, int hadamard)
{
- int i, j, N = N0*stride;
+ int i, j, _N = _N0*stride;
const uint8_t *order = &ff_celt_hadamard_order[hadamard ? stride - 2 : 30];
for (i = 0; i < stride; i++)
- for (j = 0; j < N0; j++)
- tmp[order[i]*N0+j] = X[j*stride+i];
+ for (j = 0; j < _N0; j++)
+ tmp[order[i]*_N0+j] = _X[j*stride+i];
- memcpy(X, tmp, N*sizeof(float));
+ memcpy(_X, tmp, _N*sizeof(float));
}
-static void celt_haar1(float *X, int N0, int stride)
+static void celt_haar1(float *_X, int _N0, int stride)
{
int i, j;
- N0 >>= 1;
+ _N0 >>= 1;
for (i = 0; i < stride; i++) {
- for (j = 0; j < N0; j++) {
- float x0 = X[stride * (2 * j + 0) + i];
- float x1 = X[stride * (2 * j + 1) + i];
- X[stride * (2 * j + 0) + i] = (x0 + x1) * M_SQRT1_2;
- X[stride * (2 * j + 1) + i] = (x0 - x1) * M_SQRT1_2;
+ for (j = 0; j < _N0; j++) {
+ float x0 = _X[stride * (2 * j + 0) + i];
+ float x1 = _X[stride * (2 * j + 1) + i];
+ _X[stride * (2 * j + 0) + i] = (x0 + x1) * M_SQRT1_2;
+ _X[stride * (2 * j + 1) + i] = (x0 - x1) * M_SQRT1_2;
}
}
}
-static inline int celt_compute_qn(int N, int b, int offset, int pulse_cap,
+static inline int celt_compute_qn(int _N, int b, int offset, int pulse_cap,
int stereo)
{
int qn, qb;
- int N2 = 2 * N - 1;
- if (stereo && N == 2)
- N2--;
+ int _N2 = 2 * _N - 1;
+ if (stereo && _N == 2)
+ _N2--;
/* The upper limit ensures that in a stereo split with itheta==16384, we'll
* always have enough bits left over to code at least one pulse in the
* side; otherwise it would collapse, since it doesn't get folded. */
- qb = FFMIN3(b - pulse_cap - (4 << 3), (b + N2 * offset) / N2, 8 << 3);
+ qb = FFMIN3(b - pulse_cap - (4 << 3), (b + _N2 * offset) / _N2, 8 << 3);
qn = (qb < (1 << 3 >> 1)) ? 1 : ((ff_celt_qn_exp2[qb & 0x7] >> (14 - (qb >> 3))) + 1) >> 1 << 1;
return qn;
}
/* Convert the quantized vector to an index */
-static inline uint32_t celt_icwrsi(uint32_t N, uint32_t K, const int *y)
+static inline uint32_t celt_icwrsi(uint32_t _N, uint32_t _K, const int *y)
{
int i, idx = 0, sum = 0;
- for (i = N - 1; i >= 0; i--) {
- const uint32_t i_s = CELT_PVQ_U(N - i, sum + FFABS(y[i]) + 1);
- idx += CELT_PVQ_U(N - i, sum) + (y[i] < 0)*i_s;
+ for (i = _N - 1; i >= 0; i--) {
+ const uint32_t i_s = CELT_PVQ_U(_N - i, sum + FFABS(y[i]) + 1);
+ idx += CELT_PVQ_U(_N - i, sum) + (y[i] < 0)*i_s;
sum += FFABS(y[i]);
}
return idx;
}
// this code was adapted from libopus
-static inline uint64_t celt_cwrsi(uint32_t N, uint32_t K, uint32_t i, int *y)
+static inline uint64_t celt_cwrsi(uint32_t _N, uint32_t _K, uint32_t i, int *y)
{
uint64_t norm = 0;
uint32_t q, p;
int s, val;
int k0;
- while (N > 2) {
+ while (_N > 2) {
/*Lots of pulses case:*/
- if (K >= N) {
- const uint32_t *row = ff_celt_pvq_u_row[N];
+ if (_K >= _N) {
+ const uint32_t *row = ff_celt_pvq_u_row[_N];
/* Are the pulses in this dimension negative? */
- p = row[K + 1];
+ p = row[_K + 1];
s = -(i >= p);
i -= p & s;
/*Count how many pulses were placed in this dimension.*/
- k0 = K;
- q = row[N];
+ k0 = _K;
+ q = row[_N];
if (q > i) {
- K = N;
+ _K = _N;
do {
- p = ff_celt_pvq_u_row[--K][N];
+ p = ff_celt_pvq_u_row[--_K][_N];
} while (p > i);
} else
- for (p = row[K]; p > i; p = row[K])
- K--;
+ for (p = row[_K]; p > i; p = row[_K])
+ _K--;
i -= p;
- val = (k0 - K + s) ^ s;
+ val = (k0 - _K + s) ^ s;
norm += val * val;
*y++ = val;
} else { /*Lots of dimensions case:*/
/*Are there any pulses in this dimension at all?*/
- p = ff_celt_pvq_u_row[K ][N];
- q = ff_celt_pvq_u_row[K + 1][N];
+ p = ff_celt_pvq_u_row[_K ][_N];
+ q = ff_celt_pvq_u_row[_K + 1][_N];
if (p <= i && i < q) {
i -= p;
@@ -319,88 +319,88 @@ static inline uint64_t celt_cwrsi(uint32_t N, uint32_t K, uint32_t i, int *y)
i -= q & s;
/*Count how many pulses were placed in this dimension.*/
- k0 = K;
- do p = ff_celt_pvq_u_row[--K][N];
+ k0 = _K;
+ do p = ff_celt_pvq_u_row[--_K][_N];
while (p > i);
i -= p;
- val = (k0 - K + s) ^ s;
+ val = (k0 - _K + s) ^ s;
norm += val * val;
*y++ = val;
}
}
- N--;
+ _N--;
}
- /* N == 2 */
- p = 2 * K + 1;
+ /* _N == 2 */
+ p = 2 * _K + 1;
s = -(i >= p);
i -= p & s;
- k0 = K;
- K = (i + 1) / 2;
+ k0 = _K;
+ _K = (i + 1) / 2;
- if (K)
- i -= 2 * K - 1;
+ if (_K)
+ i -= 2 * _K - 1;
- val = (k0 - K + s) ^ s;
+ val = (k0 - _K + s) ^ s;
norm += val * val;
*y++ = val;
- /* N==1 */
+ /* _N==1 */
s = -i;
- val = (K + s) ^ s;
+ val = (_K + s) ^ s;
norm += val * val;
*y = val;
return norm;
}
-static inline void celt_encode_pulses(OpusRangeCoder *rc, int *y, uint32_t N, uint32_t K)
+static inline void celt_encode_pulses(OpusRangeCoder *rc, int *y, uint32_t _N, uint32_t _K)
{
- ff_opus_rc_enc_uint(rc, celt_icwrsi(N, K, y), CELT_PVQ_V(N, K));
+ ff_opus_rc_enc_uint(rc, celt_icwrsi(_N, _K, y), CELT_PVQ_V(_N, _K));
}
-static inline float celt_decode_pulses(OpusRangeCoder *rc, int *y, uint32_t N, uint32_t K)
+static inline float celt_decode_pulses(OpusRangeCoder *rc, int *y, uint32_t _N, uint32_t _K)
{
- const uint32_t idx = ff_opus_rc_dec_uint(rc, CELT_PVQ_V(N, K));
- return celt_cwrsi(N, K, idx, y);
+ const uint32_t idx = ff_opus_rc_dec_uint(rc, CELT_PVQ_V(_N, _K));
+ return celt_cwrsi(_N, _K, idx, y);
}
#if CONFIG_OPUS_ENCODER
/*
* Faster than libopus's search, operates entirely in the signed domain.
- * Slightly worse/better depending on N, K and the input vector.
+ * Slightly worse/better depending on _N, _K and the input vector.
*/
-static float ppp_pvq_search_c(float *X, int *y, int K, int N)
+static float ppp_pvq_search_c(float *_X, int *y, int _K, int _N)
{
int i, y_norm = 0;
float res = 0.0f, xy_norm = 0.0f;
- for (i = 0; i < N; i++)
- res += FFABS(X[i]);
+ for (i = 0; i < _N; i++)
+ res += FFABS(_X[i]);
- res = K/(res + FLT_EPSILON);
+ res = _K/(res + FLT_EPSILON);
- for (i = 0; i < N; i++) {
- y[i] = lrintf(res*X[i]);
+ for (i = 0; i < _N; i++) {
+ y[i] = lrintf(res*_X[i]);
y_norm += y[i]*y[i];
- xy_norm += y[i]*X[i];
- K -= FFABS(y[i]);
+ xy_norm += y[i]*_X[i];
+ _K -= FFABS(y[i]);
}
- while (K) {
- int max_idx = 0, phase = FFSIGN(K);
+ while (_K) {
+ int max_idx = 0, phase = FFSIGN(_K);
float max_num = 0.0f;
float max_den = 1.0f;
y_norm += 1.0f;
- for (i = 0; i < N; i++) {
+ for (i = 0; i < _N; i++) {
/* If the sum has been overshot and the best place has 0 pulses allocated
* to it, attempting to decrease it further will actually increase the
* sum. Prevent this by disregarding any 0 positions when decrementing. */
const int ca = 1 ^ ((y[i] == 0) & (phase < 0));
const int y_new = y_norm + 2*phase*FFABS(y[i]);
- float xy_new = xy_norm + 1*phase*FFABS(X[i]);
+ float xy_new = xy_norm + 1*phase*FFABS(_X[i]);
xy_new = xy_new * xy_new;
if (ca && (max_den*xy_new) > (y_new*max_num)) {
max_den = y_new;
@@ -409,10 +409,10 @@ static float ppp_pvq_search_c(float *X, int *y, int K, int N)
}
}
- K -= phase;
+ _K -= phase;
- phase *= FFSIGN(X[max_idx]);
- xy_norm += 1*phase*X[max_idx];
+ phase *= FFSIGN(_X[max_idx]);
+ xy_norm += 1*phase*_X[max_idx];
y_norm += 2*phase*y[max_idx];
y[max_idx] += phase;
}
@@ -421,76 +421,76 @@ static float ppp_pvq_search_c(float *X, int *y, int K, int N)
}
#endif
-static uint32_t celt_alg_quant(OpusRangeCoder *rc, float *X, uint32_t N, uint32_t K,
+static uint32_t celt_alg_quant(OpusRangeCoder *rc, float *_X, uint32_t _N, uint32_t _K,
enum CeltSpread spread, uint32_t blocks, float gain,
CeltPVQ *pvq)
{
int *y = pvq->qcoeff;
- celt_exp_rotation(X, N, blocks, K, spread, 1);
- gain /= sqrtf(pvq->pvq_search(X, y, K, N));
- celt_encode_pulses(rc, y, N, K);
- celt_normalize_residual(y, X, N, gain);
- celt_exp_rotation(X, N, blocks, K, spread, 0);
- return celt_extract_collapse_mask(y, N, blocks);
+ celt_exp_rotation(_X, _N, blocks, _K, spread, 1);
+ gain /= sqrtf(pvq->pvq_search(_X, y, _K, _N));
+ celt_encode_pulses(rc, y, _N, _K);
+ celt_normalize_residual(y, _X, _N, gain);
+ celt_exp_rotation(_X, _N, blocks, _K, spread, 0);
+ return celt_extract_collapse_mask(y, _N, blocks);
}
/** Decode pulse vector and combine the result with the pitch vector to produce
the final normalised signal in the current band. */
-static uint32_t celt_alg_unquant(OpusRangeCoder *rc, float *X, uint32_t N, uint32_t K,
+static uint32_t celt_alg_unquant(OpusRangeCoder *rc, float *_X, uint32_t _N, uint32_t _K,
enum CeltSpread spread, uint32_t blocks, float gain,
CeltPVQ *pvq)
{
int *y = pvq->qcoeff;
- gain /= sqrtf(celt_decode_pulses(rc, y, N, K));
- celt_normalize_residual(y, X, N, gain);
- celt_exp_rotation(X, N, blocks, K, spread, 0);
- return celt_extract_collapse_mask(y, N, blocks);
+ gain /= sqrtf(celt_decode_pulses(rc, y, _N, _K));
+ celt_normalize_residual(y, _X, _N, gain);
+ celt_exp_rotation(_X, _N, blocks, _K, spread, 0);
+ return celt_extract_collapse_mask(y, _N, blocks);
}
-static int celt_calc_theta(const float *X, const float *Y, int coupling, int N)
+static int celt_calc_theta(const float *_X, const float *_Y, int coupling, int _N)
{
int i;
float e[2] = { 0.0f, 0.0f };
if (coupling) { /* Coupling case */
- for (i = 0; i < N; i++) {
- e[0] += (X[i] + Y[i])*(X[i] + Y[i]);
- e[1] += (X[i] - Y[i])*(X[i] - Y[i]);
+ for (i = 0; i < _N; i++) {
+ e[0] += (_X[i] + _Y[i])*(_X[i] + _Y[i]);
+ e[1] += (_X[i] - _Y[i])*(_X[i] - _Y[i]);
}
} else {
- for (i = 0; i < N; i++) {
- e[0] += X[i]*X[i];
- e[1] += Y[i]*Y[i];
+ for (i = 0; i < _N; i++) {
+ e[0] += _X[i]*_X[i];
+ e[1] += _Y[i]*_Y[i];
}
}
return lrintf(32768.0f*atan2f(sqrtf(e[1]), sqrtf(e[0]))/M_PI);
}
-static void celt_stereo_is_decouple(float *X, float *Y, float e_l, float e_r, int N)
+static void celt_stereo_is_decouple(float *_X, float *_Y, float e_l, float e_r, int _N)
{
int i;
const float energy_n = 1.0f/(sqrtf(e_l*e_l + e_r*e_r) + FLT_EPSILON);
e_l *= energy_n;
e_r *= energy_n;
- for (i = 0; i < N; i++)
- X[i] = e_l*X[i] + e_r*Y[i];
+ for (i = 0; i < _N; i++)
+ _X[i] = e_l*_X[i] + e_r*_Y[i];
}
-static void celt_stereo_ms_decouple(float *X, float *Y, int N)
+static void celt_stereo_ms_decouple(float *_X, float *_Y, int _N)
{
int i;
- for (i = 0; i < N; i++) {
- const float Xret = X[i];
- X[i] = (X[i] + Y[i])*M_SQRT1_2;
- Y[i] = (Y[i] - Xret)*M_SQRT1_2;
+ for (i = 0; i < _N; i++) {
+ const float Xret = _X[i];
+ _X[i] = (_X[i] + _Y[i])*M_SQRT1_2;
+ _Y[i] = (_Y[i] - Xret)*M_SQRT1_2;
}
}
static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
OpusRangeCoder *rc,
- const int band, float *X,
- float *Y, int N, int b,
+ const int band, float *_X,
+ float *_Y, int _N, int b,
uint32_t blocks, float *lowband,
int duration, float *lowband_out,
int level, float gain,
@@ -499,21 +499,21 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
{
int i;
const uint8_t *cache;
- int stereo = !!Y, split = stereo;
+ int stereo = !!_Y, split = stereo;
int imid = 0, iside = 0;
- uint32_t N0 = N;
- int N_B = N / blocks;
+ uint32_t _N0 = _N;
+ int N_B = _N / blocks;
int N_B0 = N_B;
- int B0 = blocks;
+ int _B0 = blocks;
int time_divide = 0;
int recombine = 0;
int inv = 0;
float mid = 0, side = 0;
- int longblocks = (B0 == 1);
+ int longblocks = (_B0 == 1);
uint32_t cm = 0;
- if (N == 1) {
- float *x = X;
+ if (_N == 1) {
+ float *x = _X;
for (i = 0; i <= stereo; i++) {
int sign = 0;
if (f->remaining2 >= 1 << 3) {
@@ -526,10 +526,10 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
f->remaining2 -= 1 << 3;
}
x[0] = 1.0f - 2.0f*sign;
- x = Y;
+ x = _Y;
}
if (lowband_out)
- lowband_out[0] = X[0];
+ lowband_out[0] = _X[0];
return 1;
}
@@ -541,15 +541,15 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* Band recombining to increase frequency resolution */
if (lowband &&
- (recombine || ((N_B & 1) == 0 && tf_change < 0) || B0 > 1)) {
- for (i = 0; i < N; i++)
+ (recombine || ((N_B & 1) == 0 && tf_change < 0) || _B0 > 1)) {
+ for (i = 0; i < _N; i++)
lowband_scratch[i] = lowband[i];
lowband = lowband_scratch;
}
for (k = 0; k < recombine; k++) {
if (quant || lowband)
- celt_haar1(quant ? X : lowband, N >> k, 1 << k);
+ celt_haar1(quant ? _X : lowband, _N >> k, 1 << k);
fill = ff_celt_bit_interleave[fill & 0xF] | ff_celt_bit_interleave[fill >> 4] << 2;
}
blocks >>= recombine;
@@ -558,29 +558,29 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* Increasing the time resolution */
while ((N_B & 1) == 0 && tf_change < 0) {
if (quant || lowband)
- celt_haar1(quant ? X : lowband, N_B, blocks);
+ celt_haar1(quant ? _X : lowband, N_B, blocks);
fill |= fill << blocks;
blocks <<= 1;
N_B >>= 1;
time_divide++;
tf_change++;
}
- B0 = blocks;
+ _B0 = blocks;
N_B0 = N_B;
/* Reorganize the samples in time order instead of frequency order */
- if (B0 > 1 && (quant || lowband))
- celt_deinterleave_hadamard(pvq->hadamard_tmp, quant ? X : lowband,
- N_B >> recombine, B0 << recombine,
+ if (_B0 > 1 && (quant || lowband))
+ celt_deinterleave_hadamard(pvq->hadamard_tmp, quant ? _X : lowband,
+ N_B >> recombine, _B0 << recombine,
longblocks);
}
/* If we need 1.5 more bit than we can produce, split the band in two. */
cache = ff_celt_cache_bits +
ff_celt_cache_index[(duration + 1) * CELT_MAX_BANDS + band];
- if (!stereo && duration >= 0 && b > cache[cache[0]] + 12 && N > 2) {
- N >>= 1;
- Y = X + N;
+ if (!stereo && duration >= 0 && b > cache[cache[0]] + 12 && _N > 2) {
+ _N >>= 1;
+ _Y = _X + _N;
split = 1;
duration -= 1;
if (blocks == 1)
@@ -590,7 +590,7 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
if (split) {
int qn;
- int itheta = quant ? celt_calc_theta(X, Y, stereo, N) : 0;
+ int itheta = quant ? celt_calc_theta(_X, _Y, stereo, _N) : 0;
int mbits, sbits, delta;
int qalloc;
int pulse_cap;
@@ -600,10 +600,10 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* Decide on the resolution to give to the split parameter theta */
pulse_cap = ff_celt_log_freq_range[band] + duration * 8;
- offset = (pulse_cap >> 1) - (stereo && N == 2 ? CELT_QTHETA_OFFSET_TWOPHASE :
+ offset = (pulse_cap >> 1) - (stereo && _N == 2 ? CELT_QTHETA_OFFSET_TWOPHASE :
CELT_QTHETA_OFFSET);
qn = (stereo && band >= f->intensity_stereo) ? 1 :
- celt_compute_qn(N, b, offset, pulse_cap, stereo);
+ celt_compute_qn(_N, b, offset, pulse_cap, stereo);
tell = opus_rc_tell_frac(rc);
if (qn != 1) {
if (quant)
@@ -611,24 +611,24 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* Entropy coding of the angle. We use a uniform pdf for the
* time split, a step for stereo, and a triangular one for the rest. */
if (quant) {
- if (stereo && N > 2)
+ if (stereo && _N > 2)
ff_opus_rc_enc_uint_step(rc, itheta, qn / 2);
- else if (stereo || B0 > 1)
+ else if (stereo || _B0 > 1)
ff_opus_rc_enc_uint(rc, itheta, qn + 1);
else
ff_opus_rc_enc_uint_tri(rc, itheta, qn);
itheta = itheta * 16384 / qn;
if (stereo) {
if (itheta == 0)
- celt_stereo_is_decouple(X, Y, f->block[0].lin_energy[band],
- f->block[1].lin_energy[band], N);
+ celt_stereo_is_decouple(_X, _Y, f->block[0].lin_energy[band],
+ f->block[1].lin_energy[band], _N);
else
- celt_stereo_ms_decouple(X, Y, N);
+ celt_stereo_ms_decouple(_X, _Y, _N);
}
} else {
- if (stereo && N > 2)
+ if (stereo && _N > 2)
itheta = ff_opus_rc_dec_uint_step(rc, qn / 2);
- else if (stereo || B0 > 1)
+ else if (stereo || _B0 > 1)
itheta = ff_opus_rc_dec_uint(rc, qn+1);
else
itheta = ff_opus_rc_dec_uint_tri(rc, qn);
@@ -638,11 +638,11 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
if (quant) {
inv = f->apply_phase_inv ? itheta > 8192 : 0;
if (inv) {
- for (i = 0; i < N; i++)
- Y[i] *= -1;
+ for (i = 0; i < _N; i++)
+ _Y[i] *= -1;
}
- celt_stereo_is_decouple(X, Y, f->block[0].lin_energy[band],
- f->block[1].lin_energy[band], N);
+ celt_stereo_is_decouple(_X, _Y, f->block[0].lin_energy[band],
+ f->block[1].lin_energy[band], _N);
if (b > 2 << 3 && f->remaining2 > 2 << 3) {
ff_opus_rc_enc_log(rc, inv, 2);
@@ -674,16 +674,16 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
iside = celt_cos(16384-itheta);
/* This is the mid vs side allocation that minimizes squared error
in that band. */
- delta = ROUND_MUL16((N - 1) << 7, celt_log2tan(iside, imid));
+ delta = ROUND_MUL16((_N - 1) << 7, celt_log2tan(iside, imid));
}
mid = imid / 32768.0f;
side = iside / 32768.0f;
- /* This is a special case for N=2 that only works for stereo and takes
+ /* This is a special case for _N=2 that only works for stereo and takes
advantage of the fact that mid and side are orthogonal to encode
the side with just one bit. */
- if (N == 2 && stereo) {
+ if (_N == 2 && stereo) {
int c;
int sign = 0;
float tmp;
@@ -695,8 +695,8 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
c = (itheta > 8192);
f->remaining2 -= qalloc+sbits;
- x2 = c ? Y : X;
- y2 = c ? X : Y;
+ x2 = c ? _Y : _X;
+ y2 = c ? _X : _Y;
if (sbits) {
if (quant) {
sign = x2[0]*y2[1] - x2[1]*y2[0] < 0;
@@ -708,22 +708,22 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
sign = 1 - 2 * sign;
/* We use orig_fill here because we want to fold the side, but if
itheta==16384, we'll have cleared the low bits of fill. */
- cm = pvq->quant_band(pvq, f, rc, band, x2, NULL, N, mbits, blocks, lowband, duration,
+ cm = pvq->quant_band(pvq, f, rc, band, x2, NULL, _N, mbits, blocks, lowband, duration,
lowband_out, level, gain, lowband_scratch, orig_fill);
- /* We don't split N=2 bands, so cm is either 1 or 0 (for a fold-collapse),
+ /* We don't split _N=2 bands, so cm is either 1 or 0 (for a fold-collapse),
and there's no need to worry about mixing with the other channel. */
y2[0] = -sign * x2[1];
y2[1] = sign * x2[0];
- X[0] *= mid;
- X[1] *= mid;
- Y[0] *= side;
- Y[1] *= side;
- tmp = X[0];
- X[0] = tmp - Y[0];
- Y[0] = tmp + Y[0];
- tmp = X[1];
- X[1] = tmp - Y[1];
- Y[1] = tmp + Y[1];
+ _X[0] *= mid;
+ _X[1] *= mid;
+ _Y[0] *= side;
+ _Y[1] *= side;
+ tmp = _X[0];
+ _X[0] = tmp - _Y[0];
+ _Y[0] = tmp + _Y[0];
+ tmp = _X[1];
+ _X[1] = tmp - _Y[1];
+ _Y[1] = tmp + _Y[1];
} else {
/* "Normal" split code */
float *next_lowband2 = NULL;
@@ -734,21 +734,21 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* Give more bits to low-energy MDCTs than they would
* otherwise deserve */
- if (B0 > 1 && !stereo && (itheta & 0x3fff)) {
+ if (_B0 > 1 && !stereo && (itheta & 0x3fff)) {
if (itheta > 8192)
/* Rough approximation for pre-echo masking */
delta -= delta >> (4 - duration);
else
/* Corresponds to a forward-masking slope of
* 1.5 dB per 10 ms */
- delta = FFMIN(0, delta + (N << 3 >> (5 - duration)));
+ delta = FFMIN(0, delta + (_N << 3 >> (5 - duration)));
}
mbits = av_clip((b - delta) / 2, 0, b);
sbits = b - mbits;
f->remaining2 -= qalloc;
if (lowband && !stereo)
- next_lowband2 = lowband + N; /* >32-bit split case */
+ next_lowband2 = lowband + _N; /* >32-bit split case */
/* Only stereo needs to pass on lowband_out.
* Otherwise, it's handled at the end */
@@ -761,7 +761,7 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
if (mbits >= sbits) {
/* In stereo mode, we do not apply a scaling to the mid
* because we need the normalized mid for folding later */
- cm = pvq->quant_band(pvq, f, rc, band, X, NULL, N, mbits, blocks,
+ cm = pvq->quant_band(pvq, f, rc, band, _X, NULL, _N, mbits, blocks,
lowband, duration, next_lowband_out1, next_level,
stereo ? 1.0f : (gain * mid), lowband_scratch, fill);
rebalance = mbits - (rebalance - f->remaining2);
@@ -770,24 +770,24 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
/* For a stereo split, the high bits of fill are always zero,
* so no folding will be done to the side. */
- cmt = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+ cmt = pvq->quant_band(pvq, f, rc, band, _Y, NULL, _N, sbits, blocks,
next_lowband2, duration, NULL, next_level,
gain * side, NULL, fill >> blocks);
- cm |= cmt << ((B0 >> 1) & (stereo - 1));
+ cm |= cmt << ((_B0 >> 1) & (stereo - 1));
} else {
/* For a stereo split, the high bits of fill are always zero,
* so no folding will be done to the side. */
- cm = pvq->quant_band(pvq, f, rc, band, Y, NULL, N, sbits, blocks,
+ cm = pvq->quant_band(pvq, f, rc, band, _Y, NULL, _N, sbits, blocks,
next_lowband2, duration, NULL, next_level,
gain * side, NULL, fill >> blocks);
- cm <<= ((B0 >> 1) & (stereo - 1));
+ cm <<= ((_B0 >> 1) & (stereo - 1));
rebalance = sbits - (rebalance - f->remaining2);
if (rebalance > 3 << 3 && itheta != 16384)
mbits += rebalance - (3 << 3);
/* In stereo mode, we do not apply a scaling to the mid because
* we need the normalized mid for folding later */
- cm |= pvq->quant_band(pvq, f, rc, band, X, NULL, N, mbits, blocks,
+ cm |= pvq->quant_band(pvq, f, rc, band, _X, NULL, _N, mbits, blocks,
lowband, duration, next_lowband_out1, next_level,
stereo ? 1.0f : (gain * mid), lowband_scratch, fill);
}
@@ -808,10 +808,10 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
if (q != 0) {
/* Finally do the actual (de)quantization */
if (quant) {
- cm = celt_alg_quant(rc, X, N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1),
+ cm = celt_alg_quant(rc, _X, _N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1),
f->spread, blocks, gain, pvq);
} else {
- cm = celt_alg_unquant(rc, X, N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1),
+ cm = celt_alg_unquant(rc, _X, _N, (q < 8) ? q : (8 + (q & 7)) << ((q >> 3) - 1),
f->spread, blocks, gain, pvq);
}
} else {
@@ -821,61 +821,61 @@ static av_always_inline uint32_t quant_band_template(CeltPVQ *pvq, CeltFrame *f,
if (fill) {
if (!lowband) {
/* Noise */
- for (i = 0; i < N; i++)
- X[i] = (((int32_t)celt_rng(f)) >> 20);
+ for (i = 0; i < _N; i++)
+ _X[i] = (((int32_t)celt_rng(f)) >> 20);
cm = cm_mask;
} else {
/* Folded spectrum */
- for (i = 0; i < N; i++) {
+ for (i = 0; i < _N; i++) {
/* About 48 dB below the "normal" folding level */
- X[i] = lowband[i] + (((celt_rng(f)) & 0x8000) ? 1.0f / 256 : -1.0f / 256);
+ _X[i] = lowband[i] + (((celt_rng(f)) & 0x8000) ? 1.0f / 256 : -1.0f / 256);
}
cm = fill;
}
- celt_renormalize_vector(X, N, gain);
+ celt_renormalize_vector(_X, _N, gain);
} else {
- memset(X, 0, N*sizeof(float));
+ memset(_X, 0, _N*sizeof(float));
}
}
}
/* This code is used by the decoder and by the resynthesis-enabled encoder */
if (stereo) {
- if (N > 2)
- celt_stereo_merge(X, Y, mid, N);
+ if (_N > 2)
+ celt_stereo_merge(_X, _Y, mid, _N);
if (inv) {
- for (i = 0; i < N; i++)
- Y[i] *= -1;
+ for (i = 0; i < _N; i++)
+ _Y[i] *= -1;
}
} else if (level == 0) {
int k;
/* Undo the sample reorganization going from time order to frequency order */
- if (B0 > 1)
- celt_interleave_hadamard(pvq->hadamard_tmp, X, N_B >> recombine,
- B0 << recombine, longblocks);
+ if (_B0 > 1)
+ celt_interleave_hadamard(pvq->hadamard_tmp, _X, N_B >> recombine,
+ _B0 << recombine, longblocks);
/* Undo time-freq changes that we did earlier */
N_B = N_B0;
- blocks = B0;
+ blocks = _B0;
for (k = 0; k < time_divide; k++) {
blocks >>= 1;
N_B <<= 1;
cm |= cm >> blocks;
- celt_haar1(X, N_B, blocks);
+ celt_haar1(_X, N_B, blocks);
}
for (k = 0; k < recombine; k++) {
cm = ff_celt_bit_deinterleave[cm];
- celt_haar1(X, N0>>k, 1<<k);
+ celt_haar1(_X, _N0>>k, 1<<k);
}
blocks <<= recombine;
/* Scale output for later folding */
if (lowband_out) {
- float n = sqrtf(N0);
- for (i = 0; i < N0; i++)
- lowband_out[i] = n * X[i];
+ float n = sqrtf(_N0);
+ for (i = 0; i < _N0; i++)
+ lowband_out[i] = n * _X[i];
}
cm = av_mod_uintp2(cm, blocks);
}
--
2.39.2
[-- Attachment #4: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-22 9:12 [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include copypaste
@ 2023-02-23 13:45 ` Anton Khirnov
2023-02-23 14:37 ` copypaste
1 sibling, 0 replies; 7+ messages in thread
From: Anton Khirnov @ 2023-02-23 13:45 UTC (permalink / raw)
To: ffmpeg-devel
Quoting copypaste (2023-02-22 10:12:08)
> Applied to libavcodec/aaccoder.c:
> :%s/\([*]\)\?\([ \t]\{-}\)\?\(\<[BD-Z]\([0-9]*\)\)\>/\1\2_\3/g
>
> This stops B0 and B1 from colliding with a define in
> /usr/include/asm-generic/termbits.h:
Why is that file even being included?
Also
> All identifiers that begin with an underscore and either an uppercase
> letter or another underscore are always reserved for any use.
--
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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-22 9:12 [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include copypaste
2023-02-23 13:45 ` Anton Khirnov
@ 2023-02-23 14:37 ` copypaste
2023-02-23 14:46 ` copypaste
` (2 more replies)
1 sibling, 3 replies; 7+ messages in thread
From: copypaste @ 2023-02-23 14:37 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1: Type: text/plain, Size: 539 bytes --]
It gets included because this platform does indeed have Video4Linux so some of the aarch64 stuff is relevant. Furthermore I think that the HEVC stuff includes it.
I have attached the file, whether or not it is not allowed seems immaterial because it is done by Android whether we like it or not.
>
> On Feb 23, 2023 at 8:47 AM, Anton Khirnov <anton@khirnov.net> wrote:
>
>
> Quoting copypaste (2023-02-22 10:12:08)
> > Applied to libavcodec/aaccoder.c:
> Why is that file even being included?
>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: termbits.h --]
[-- Type: text/x-chdr, Size: 4739 bytes --]
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_GENERIC_TERMBITS_H
#define __ASM_GENERIC_TERMBITS_H
#include <linux/posix_types.h>
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
#define NCCS 19
struct termios {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_line;
cc_t c_cc[NCCS];
};
struct termios2 {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_line;
cc_t c_cc[NCCS];
speed_t c_ispeed;
speed_t c_ospeed;
};
struct ktermios {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
cc_t c_line;
cc_t c_cc[NCCS];
speed_t c_ispeed;
speed_t c_ospeed;
};
#define VINTR 0
#define VQUIT 1
#define VERASE 2
#define VKILL 3
#define VEOF 4
#define VTIME 5
#define VMIN 6
#define VSWTC 7
#define VSTART 8
#define VSTOP 9
#define VSUSP 10
#define VEOL 11
#define VREPRINT 12
#define VDISCARD 13
#define VWERASE 14
#define VLNEXT 15
#define VEOL2 16
#define IGNBRK 0000001
#define BRKINT 0000002
#define IGNPAR 0000004
#define PARMRK 0000010
#define INPCK 0000020
#define ISTRIP 0000040
#define INLCR 0000100
#define IGNCR 0000200
#define ICRNL 0000400
#define IUCLC 0001000
#define IXON 0002000
#define IXANY 0004000
#define IXOFF 0010000
#define IMAXBEL 0020000
#define IUTF8 0040000
#define OPOST 0000001
#define OLCUC 0000002
#define ONLCR 0000004
#define OCRNL 0000010
#define ONOCR 0000020
#define ONLRET 0000040
#define OFILL 0000100
#define OFDEL 0000200
#define NLDLY 0000400
#define NL0 0000000
#define NL1 0000400
#define CRDLY 0003000
#define CR0 0000000
#define CR1 0001000
#define CR2 0002000
#define CR3 0003000
#define TABDLY 0014000
#define TAB0 0000000
#define TAB1 0004000
#define TAB2 0010000
#define TAB3 0014000
#define XTABS 0014000
#define BSDLY 0020000
#define BS0 0000000
#define BS1 0020000
#define VTDLY 0040000
#define VT0 0000000
#define VT1 0040000
#define FFDLY 0100000
#define FF0 0000000
#define FF1 0100000
#define CBAUD 0010017
#define B0 0000000
#define B50 0000001
#define B75 0000002
#define B110 0000003
#define B134 0000004
#define B150 0000005
#define B200 0000006
#define B300 0000007
#define B600 0000010
#define B1200 0000011
#define B1800 0000012
#define B2400 0000013
#define B4800 0000014
#define B9600 0000015
#define B19200 0000016
#define B38400 0000017
#define EXTA B19200
#define EXTB B38400
#define CSIZE 0000060
#define CS5 0000000
#define CS6 0000020
#define CS7 0000040
#define CS8 0000060
#define CSTOPB 0000100
#define CREAD 0000200
#define PARENB 0000400
#define PARODD 0001000
#define HUPCL 0002000
#define CLOCAL 0004000
#define CBAUDEX 0010000
#define BOTHER 0010000
#define B57600 0010001
#define B115200 0010002
#define B230400 0010003
#define B460800 0010004
#define B500000 0010005
#define B576000 0010006
#define B921600 0010007
#define B1000000 0010010
#define B1152000 0010011
#define B1500000 0010012
#define B2000000 0010013
#define B2500000 0010014
#define B3000000 0010015
#define B3500000 0010016
#define B4000000 0010017
#define CIBAUD 002003600000
#define CMSPAR 010000000000
#define CRTSCTS 020000000000
#define IBSHIFT 16
#define ISIG 0000001
#define ICANON 0000002
#define XCASE 0000004
#define ECHO 0000010
#define ECHOE 0000020
#define ECHOK 0000040
#define ECHONL 0000100
#define NOFLSH 0000200
#define TOSTOP 0000400
#define ECHOCTL 0001000
#define ECHOPRT 0002000
#define ECHOKE 0004000
#define FLUSHO 0010000
#define PENDIN 0040000
#define IEXTEN 0100000
#define EXTPROC 0200000
#define TCOOFF 0
#define TCOON 1
#define TCIOFF 2
#define TCION 3
#define TCIFLUSH 0
#define TCOFLUSH 1
#define TCIOFLUSH 2
#define TCSANOW 0
#define TCSADRAIN 1
/* TCSAFLUSH is patched to be TCSANOW in Termux to work around Android SELinux rule */
#define TCSAFLUSH 0
#endif
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-23 14:37 ` copypaste
@ 2023-02-23 14:46 ` copypaste
2023-02-23 15:01 ` Hendrik Leppkes
2023-02-24 14:55 ` copypaste
2 siblings, 0 replies; 7+ messages in thread
From: copypaste @ 2023-02-23 14:46 UTC (permalink / raw)
To: ffmpeg-devel
Sorry Anton, I stupidly misread your message. You are telling me not to start my identifiers with underscores not talking about Android. Well, I can certainly change it but just making them lowercase will not fix the issue because those collide with ffmpeg's variables.
Perhaps what I should do is more of the #undef thing I did in file libavcodec/hevcdec.h.
_______________________________________________
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] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-23 14:37 ` copypaste
2023-02-23 14:46 ` copypaste
@ 2023-02-23 15:01 ` Hendrik Leppkes
2023-02-27 13:44 ` "zhilizhao(赵志立)"
2023-02-24 14:55 ` copypaste
2 siblings, 1 reply; 7+ messages in thread
From: Hendrik Leppkes @ 2023-02-23 15:01 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Thu, Feb 23, 2023 at 3:37 PM copypaste <copypaste@kittens.ph> wrote:
> It gets included because this platform does indeed have Video4Linux so some of the aarch64 stuff is relevant. Furthermore I think that the HEVC stuff includes it.
>
If its relevant for V4L or other hardware integration is fine and all
... but the real question is, how does it end up in aaccoder.c and
other files entirely unrelated to video or hardware? And can we just
get it out of those?
- 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-23 15:01 ` Hendrik Leppkes
@ 2023-02-27 13:44 ` "zhilizhao(赵志立)"
0 siblings, 0 replies; 7+ messages in thread
From: "zhilizhao(赵志立)" @ 2023-02-27 13:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> On Feb 23, 2023, at 23:01, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
>
> On Thu, Feb 23, 2023 at 3:37 PM copypaste <copypaste@kittens.ph> wrote:
>> It gets included because this platform does indeed have Video4Linux so some of the aarch64 stuff is relevant. Furthermore I think that the HEVC stuff includes it.
>>
>
> If its relevant for V4L or other hardware integration is fine and all
> ... but the real question is, how does it end up in aaccoder.c and
> other files entirely unrelated to video or hardware? And can we just
> get it out of those?
I know this issue exists for a long time. But I can’t reproduce it
these days.
https://github.com/android/ndk/issues/630
https://trac.ffmpeg.org/ticket/7130
The ‘B0’ macro comes from <sys/ioctl.h>, which is defined by
asm-generic/termbits.h. <sys/ioctl.h> is included by libavutil/timer.h.
Thanks to the cleanup work done by Andreas Rheinhardt, the conflicts
has been reduced a lot, I think that’s why I didn’t get build errors.
Google suggests FFmpeg to fix the code problem, while NDK has
break more than one projects, see
https://github.com/jupyter-xeus/cpp-terminal/issues/35
You can reproduce the build error with:
$ cat foo.c
#include <sys/ioctl.h>
int main()
{
int B0 = 123;
}
$ make foo
cc foo.c -o foo
foo.c:5:9: error: expected identifier or '('
int B0 = 123;
^
/data/data/com.termux/files/usr/include/asm-generic/termbits.h:118:12: note: expanded from macro 'B0'
#define B0 0000000
^
1 error generated.
make: *** [<builtin>: foo] Error 1
>
> - 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-request@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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include
2023-02-23 14:37 ` copypaste
2023-02-23 14:46 ` copypaste
2023-02-23 15:01 ` Hendrik Leppkes
@ 2023-02-24 14:55 ` copypaste
2 siblings, 0 replies; 7+ messages in thread
From: copypaste @ 2023-02-24 14:55 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1: Type: text/plain, Size: 575 bytes --]
Here's my attempt to do just that. :-)
Compiled fine with:
configuration: --prefix=/data/data/com.termux/files/usr/local --enable-indev=alsa --enable-indev=xcbgrab --enable-libfreetype --enable-libfontconfig --cc=clang --cxx=clang++ --disable-libxcb-shm --enable-vulkan --enable-opencl --enable-opengl --enable-libass --enable-libopus --enable-libfribidi --enable-librsvg --disable-stripping --enable-logging --enable-debug --logfile=/dev/tty --enable-nonfree --enable-jni --enable-gpl --enable-version3 --host-os=android --target-os=android --enable-mediacodec
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Prevent-collisions-between-Android-s-asm-generic-ter.patch --]
[-- Type: text/x-diff, Size: 2511 bytes --]
From 44d7cfe5d10b367b289549d90fabb3b985acb128 Mon Sep 17 00:00:00 2001
From: Fredrick Brennan <copypaste@kittens.ph>
Date: Fri, 24 Feb 2023 09:51:16 -0500
Subject: [PATCH] Prevent collisions between Android's asm-generic/termbits.h
and ffmpeg
---
libavcodec/aaccoder.c | 5 +++++
libavcodec/faandct.c | 15 +++++++++++++++
libavcodec/hevcdec.h | 9 +++++++++
libavcodec/opus_pvq.h | 4 ++++
4 files changed, 33 insertions(+)
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 6291c16123..de51fa80fb 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -52,6 +52,11 @@
#include "libavcodec/aaccoder_twoloop.h"
+#ifdef __ANDROID__
+#undef B0
+#undef B1
+#endif
+
/* Parameter of f(x) = a*(lambda/100), defines the maximum fourier spread
* beyond which no PNS is used (since the SFBs contain tone rather than noise) */
#define NOISE_SPREAD_THRESHOLD 0.9f
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
index 38c392bbae..923fa9beda 100644
--- a/libavcodec/faandct.c
+++ b/libavcodec/faandct.c
@@ -37,6 +37,21 @@ for this approach). Unfortunately, long double is not always available correctly
e.g ppc has issues.
TODO: add L suffixes when ppc and toolchains sort out their stuff.
*/
+#ifdef __ANDROID__
+#undef B0
+#undef B1
+#undef B2
+#undef B3
+#undef B4
+#undef B5
+#undef B6
+#undef B7
+#undef A1
+#undef A2
+#undef A3
+#undef A4
+#undef A5
+#endif
#define B0 1.000000000000000000000000000000000000
#define B1 0.720959822006947913789091890943021267 // (cos(pi*1/16)sqrt(2))^-1
#define B2 0.765366864730179543456919968060797734 // (cos(pi*2/16)sqrt(2))^-1
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 9d3f4adbb3..4b500350c0 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -57,6 +57,15 @@
#define L0 0
#define L1 1
+#ifdef __ANDROID__
+#undef A0
+#undef A1
+#undef A2
+#undef B0
+#undef B1
+#undef B2
+#endif
+
#define EPEL_EXTRA_BEFORE 1
#define EPEL_EXTRA_AFTER 2
#define EPEL_EXTRA 3
diff --git a/libavcodec/opus_pvq.h b/libavcodec/opus_pvq.h
index b71bc49034..91c59f2812 100644
--- a/libavcodec/opus_pvq.h
+++ b/libavcodec/opus_pvq.h
@@ -27,6 +27,10 @@
#include "opus_celt.h"
+#ifdef __ANDROID__
+#undef B0
+#endif
+
#define QUANT_FN(name) uint32_t (name)(struct CeltPVQ *pvq, CeltFrame *f, \
OpusRangeCoder *rc, const int band, float *X, \
float *Y, int N, int b, uint32_t blocks, \
--
2.39.2
[-- Attachment #3: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 7+ messages in thread
end of thread, other threads:[~2023-02-27 13:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-22 9:12 [FFmpeg-devel] [PATCH] Fix broken build on Android due to broken asm-generic/termbits.h include copypaste
2023-02-23 13:45 ` Anton Khirnov
2023-02-23 14:37 ` copypaste
2023-02-23 14:46 ` copypaste
2023-02-23 15:01 ` Hendrik Leppkes
2023-02-27 13:44 ` "zhilizhao(赵志立)"
2023-02-24 14:55 ` copypaste
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