mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1229475 - libopus: Patch out asm flags for run_analysis. r=jmspeex
Patch from upstream. This still requires that the webrtc client code call the new tonality_analysis_init() function before first use of the TonalityAnalysisState struct.
This commit is contained in:
parent
c36050f9eb
commit
ef201d081c
@ -138,6 +138,21 @@ static OPUS_INLINE float fast_atan2f(float y, float x) {
|
||||
}
|
||||
}
|
||||
|
||||
void tonality_analysis_init(TonalityAnalysisState *tonal)
|
||||
{
|
||||
/* Initialize reusable fields. */
|
||||
tonal->arch = opus_select_arch();
|
||||
/* Clear remaining fields. */
|
||||
tonality_analysis_reset(tonal);
|
||||
}
|
||||
|
||||
void tonality_analysis_reset(TonalityAnalysisState *tonal)
|
||||
{
|
||||
/* Clear non-reusable fields. */
|
||||
char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START;
|
||||
OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal));
|
||||
}
|
||||
|
||||
void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len)
|
||||
{
|
||||
int pos;
|
||||
@ -187,7 +202,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int
|
||||
info_out->music_prob = psum;
|
||||
}
|
||||
|
||||
static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix, int arch)
|
||||
static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix)
|
||||
{
|
||||
int i, b;
|
||||
const kiss_fft_state *kfft;
|
||||
@ -260,7 +275,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
|
||||
remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill);
|
||||
downmix(x, &tonal->inmem[240], remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C);
|
||||
tonal->mem_fill = 240 + remaining;
|
||||
opus_fft(kfft, in, out, arch);
|
||||
opus_fft(kfft, in, out, tonal->arch);
|
||||
#ifndef FIXED_POINT
|
||||
/* If there's any NaN on the input, the entire output will be NaN, so we only need to check one value. */
|
||||
if (celt_isnan(out[0].r))
|
||||
@ -633,7 +648,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
|
||||
|
||||
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
|
||||
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
|
||||
int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info, int arch)
|
||||
int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info)
|
||||
{
|
||||
int offset;
|
||||
int pcm_len;
|
||||
@ -646,7 +661,7 @@ void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, co
|
||||
pcm_len = analysis_frame_size - analysis->analysis_offset;
|
||||
offset = analysis->analysis_offset;
|
||||
do {
|
||||
tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix, arch);
|
||||
tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix);
|
||||
offset += 480;
|
||||
pcm_len -= 480;
|
||||
} while (pcm_len>0);
|
||||
|
@ -39,6 +39,8 @@
|
||||
#define DETECT_SIZE 200
|
||||
|
||||
typedef struct {
|
||||
int arch;
|
||||
#define TONALITY_ANALYSIS_RESET_START angle
|
||||
float angle[240];
|
||||
float d_angle[240];
|
||||
float d2_angle[240];
|
||||
@ -78,10 +80,24 @@ typedef struct {
|
||||
AnalysisInfo info[DETECT_SIZE];
|
||||
} TonalityAnalysisState;
|
||||
|
||||
/** Initialize a TonalityAnalysisState struct.
|
||||
*
|
||||
* This performs some possibly slow initialization steps which should
|
||||
* not be repeated every analysis step. No allocated memory is retained
|
||||
* by the state struct, so no cleanup call is required.
|
||||
*/
|
||||
void tonality_analysis_init(TonalityAnalysisState *analysis);
|
||||
|
||||
/** Reset a TonalityAnalysisState stuct.
|
||||
*
|
||||
* Call this when there's a discontinuity in the data.
|
||||
*/
|
||||
void tonality_analysis_reset(TonalityAnalysisState *analysis);
|
||||
|
||||
void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len);
|
||||
|
||||
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
|
||||
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
|
||||
int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info, int arch);
|
||||
int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info);
|
||||
|
||||
#endif
|
||||
|
@ -81,6 +81,9 @@ struct OpusEncoder {
|
||||
int lsb_depth;
|
||||
int encoder_buffer;
|
||||
int lfe;
|
||||
#ifndef DISABLE_FLOAT_API
|
||||
TonalityAnalysisState analysis;
|
||||
#endif
|
||||
|
||||
#define OPUS_ENCODER_RESET_START stream_channels
|
||||
int stream_channels;
|
||||
@ -100,7 +103,6 @@ struct OpusEncoder {
|
||||
StereoWidthState width_mem;
|
||||
opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2];
|
||||
#ifndef DISABLE_FLOAT_API
|
||||
TonalityAnalysisState analysis;
|
||||
int detected_bandwidth;
|
||||
int analysis_offset;
|
||||
#endif
|
||||
@ -243,6 +245,10 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
|
||||
st->mode = MODE_HYBRID;
|
||||
st->bandwidth = OPUS_BANDWIDTH_FULLBAND;
|
||||
|
||||
#ifndef DISABLE_FLOAT_API
|
||||
tonality_analysis_init(&st->analysis);
|
||||
#endif
|
||||
|
||||
return OPUS_OK;
|
||||
}
|
||||
|
||||
@ -1006,7 +1012,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
|
||||
analysis_read_subframe_bak = st->analysis.read_subframe;
|
||||
run_analysis(&st->analysis, celt_mode, analysis_pcm, analysis_size, frame_size,
|
||||
c1, c2, analysis_channels, st->Fs,
|
||||
lsb_depth, downmix, &analysis_info, st->arch);
|
||||
lsb_depth, downmix, &analysis_info);
|
||||
}
|
||||
#else
|
||||
(void)analysis_pcm;
|
||||
@ -2450,10 +2456,12 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
|
||||
void *silk_enc;
|
||||
silk_EncControlStruct dummy;
|
||||
silk_enc = (char*)st+st->silk_enc_offset;
|
||||
#ifndef DISABLE_FLOAT_API
|
||||
tonality_analysis_reset(&st->analysis);
|
||||
#endif
|
||||
|
||||
OPUS_CLEAR((char*)&st->OPUS_ENCODER_RESET_START,
|
||||
sizeof(OpusEncoder)-
|
||||
((char*)&st->OPUS_ENCODER_RESET_START - (char*)st));
|
||||
char *start = (char*)&st->OPUS_ENCODER_RESET_START;
|
||||
OPUS_CLEAR(start, sizeof(OpusEncoder) - (start - (char*)st));
|
||||
|
||||
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
|
||||
silk_InitEncoder( silk_enc, st->arch, &dummy );
|
||||
|
158
media/libopus/tonality_init.patch
Normal file
158
media/libopus/tonality_init.patch
Normal file
@ -0,0 +1,158 @@
|
||||
diff --git a/src/analysis.c b/src/analysis.c
|
||||
index 322e53c..360ebcc 100644
|
||||
--- a/src/analysis.c
|
||||
+++ b/src/analysis.c
|
||||
@@ -138,6 +138,21 @@ static OPUS_INLINE float fast_atan2f(float y, float x) {
|
||||
}
|
||||
}
|
||||
|
||||
+void tonality_analysis_init(TonalityAnalysisState *tonal)
|
||||
+{
|
||||
+ /* Initialize reusable fields. */
|
||||
+ tonal->arch = opus_select_arch();
|
||||
+ /* Clear remaining fields. */
|
||||
+ tonality_analysis_reset(tonal);
|
||||
+}
|
||||
+
|
||||
+void tonality_analysis_reset(TonalityAnalysisState *tonal)
|
||||
+{
|
||||
+ /* Clear non-reusable fields. */
|
||||
+ char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START;
|
||||
+ OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal));
|
||||
+}
|
||||
+
|
||||
void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len)
|
||||
{
|
||||
int pos;
|
||||
@@ -187,7 +202,7 @@ void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int
|
||||
info_out->music_prob = psum;
|
||||
}
|
||||
|
||||
-static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix, int arch)
|
||||
+static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix)
|
||||
{
|
||||
int i, b;
|
||||
const kiss_fft_state *kfft;
|
||||
@@ -260,7 +275,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
|
||||
remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill);
|
||||
downmix(x, &tonal->inmem[240], remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C);
|
||||
tonal->mem_fill = 240 + remaining;
|
||||
- opus_fft(kfft, in, out, arch);
|
||||
+ opus_fft(kfft, in, out, tonal->arch);
|
||||
#ifndef FIXED_POINT
|
||||
/* If there's any NaN on the input, the entire output will be NaN, so we only need to check one value. */
|
||||
if (celt_isnan(out[0].r))
|
||||
@@ -633,7 +648,7 @@ static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt
|
||||
|
||||
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
|
||||
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
|
||||
- int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info, int arch)
|
||||
+ int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info)
|
||||
{
|
||||
int offset;
|
||||
int pcm_len;
|
||||
@@ -646,7 +661,7 @@ void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, co
|
||||
pcm_len = analysis_frame_size - analysis->analysis_offset;
|
||||
offset = analysis->analysis_offset;
|
||||
do {
|
||||
- tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix, arch);
|
||||
+ tonality_analysis(analysis, celt_mode, analysis_pcm, IMIN(480, pcm_len), offset, c1, c2, C, lsb_depth, downmix);
|
||||
offset += 480;
|
||||
pcm_len -= 480;
|
||||
} while (pcm_len>0);
|
||||
diff --git a/src/analysis.h b/src/analysis.h
|
||||
index 9c328e8..9eae56a 100644
|
||||
--- a/src/analysis.h
|
||||
+++ b/src/analysis.h
|
||||
@@ -39,6 +39,8 @@
|
||||
#define DETECT_SIZE 200
|
||||
|
||||
typedef struct {
|
||||
+ int arch;
|
||||
+#define TONALITY_ANALYSIS_RESET_START angle
|
||||
float angle[240];
|
||||
float d_angle[240];
|
||||
float d2_angle[240];
|
||||
@@ -78,10 +80,24 @@ typedef struct {
|
||||
AnalysisInfo info[DETECT_SIZE];
|
||||
} TonalityAnalysisState;
|
||||
|
||||
+/** Initialize a TonalityAnalysisState struct.
|
||||
+ *
|
||||
+ * This performs some possibly slow initialization steps which should
|
||||
+ * not be repeated every analysis step. No allocated memory is retained
|
||||
+ * by the state struct, so no cleanup call is required.
|
||||
+ */
|
||||
+void tonality_analysis_init(TonalityAnalysisState *analysis);
|
||||
+
|
||||
+/** Reset a TonalityAnalysisState stuct.
|
||||
+ *
|
||||
+ * Call this when there's a discontinuity in the data.
|
||||
+ */
|
||||
+void tonality_analysis_reset(TonalityAnalysisState *analysis);
|
||||
+
|
||||
void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len);
|
||||
|
||||
void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm,
|
||||
int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs,
|
||||
- int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info, int arch);
|
||||
+ int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info);
|
||||
|
||||
#endif
|
||||
diff --git a/src/opus_encoder.c b/src/opus_encoder.c
|
||||
index 7403a4c..4340de4 100644
|
||||
--- a/src/opus_encoder.c
|
||||
+++ b/src/opus_encoder.c
|
||||
@@ -82,5 +82,8 @@ struct OpusEncoder {
|
||||
int encoder_buffer;
|
||||
int lfe;
|
||||
+#ifndef DISABLE_FLOAT_API
|
||||
+ TonalityAnalysisState analysis;
|
||||
+#endif
|
||||
|
||||
#define OPUS_ENCODER_RESET_START stream_channels
|
||||
int stream_channels;
|
||||
@@ -101,7 +104,6 @@ struct OpusEncoder {
|
||||
StereoWidthState width_mem;
|
||||
opus_val16 delay_buffer[MAX_ENCODER_BUFFER*2];
|
||||
#ifndef DISABLE_FLOAT_API
|
||||
- TonalityAnalysisState analysis;
|
||||
int detected_bandwidth;
|
||||
#endif
|
||||
opus_uint32 rangeFinal;
|
||||
@@ -242,6 +244,10 @@ int opus_encoder_init(OpusEncoder* st, opus_int32 Fs, int channels, int applicat
|
||||
st->mode = MODE_HYBRID;
|
||||
st->bandwidth = OPUS_BANDWIDTH_FULLBAND;
|
||||
|
||||
+#ifndef DISABLE_FLOAT_API
|
||||
+ tonality_analysis_init(&st->analysis);
|
||||
+#endif
|
||||
+
|
||||
return OPUS_OK;
|
||||
}
|
||||
|
||||
@@ -1005,7 +1011,7 @@ opus_int32 opus_encode_native(OpusEncoder *st, const opus_val16 *pcm, int frame_
|
||||
analysis_read_subframe_bak = st->analysis.read_subframe;
|
||||
run_analysis(&st->analysis, celt_mode, analysis_pcm, analysis_size, frame_size,
|
||||
c1, c2, analysis_channels, st->Fs,
|
||||
- lsb_depth, downmix, &analysis_info, st->arch);
|
||||
+ lsb_depth, downmix, &analysis_info);
|
||||
}
|
||||
#else
|
||||
(void)analysis_pcm;
|
||||
@@ -2449,10 +2455,12 @@ int opus_encoder_ctl(OpusEncoder *st, int request, ...)
|
||||
void *silk_enc;
|
||||
silk_EncControlStruct dummy;
|
||||
silk_enc = (char*)st+st->silk_enc_offset;
|
||||
+#ifndef DISABLE_FLOAT_API
|
||||
+ tonality_analysis_reset(&st->analysis);
|
||||
+#endif
|
||||
|
||||
- OPUS_CLEAR((char*)&st->OPUS_ENCODER_RESET_START,
|
||||
- sizeof(OpusEncoder)-
|
||||
- ((char*)&st->OPUS_ENCODER_RESET_START - (char*)st));
|
||||
+ char *start = (char*)&st->OPUS_ENCODER_RESET_START;
|
||||
+ OPUS_CLEAR(start, sizeof(OpusEncoder) - (start - (char*)st));
|
||||
|
||||
celt_encoder_ctl(celt_enc, OPUS_RESET_STATE);
|
||||
silk_InitEncoder( silk_enc, st->arch, &dummy );
|
@ -75,3 +75,4 @@ python gen-sources.py $1
|
||||
|
||||
# apply outstanding local patches
|
||||
patch -p3 < ./gcc-4.8-ICE.patch
|
||||
patch -p1 < ./tonality_init.patch
|
||||
|
Loading…
Reference in New Issue
Block a user