Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Copyright (c) 2011 Xiph.Org Foundation |
michael@0 | 2 | Written by Jean-Marc Valin */ |
michael@0 | 3 | /* |
michael@0 | 4 | Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | modification, are permitted provided that the following conditions |
michael@0 | 6 | are met: |
michael@0 | 7 | |
michael@0 | 8 | - Redistributions of source code must retain the above copyright |
michael@0 | 9 | notice, this list of conditions and the following disclaimer. |
michael@0 | 10 | |
michael@0 | 11 | - Redistributions in binary form must reproduce the above copyright |
michael@0 | 12 | notice, this list of conditions and the following disclaimer in the |
michael@0 | 13 | documentation and/or other materials provided with the distribution. |
michael@0 | 14 | |
michael@0 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
michael@0 | 16 | ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
michael@0 | 17 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
michael@0 | 18 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR |
michael@0 | 19 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 21 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 22 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
michael@0 | 23 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
michael@0 | 24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
michael@0 | 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 26 | */ |
michael@0 | 27 | |
michael@0 | 28 | #ifndef ANALYSIS_H |
michael@0 | 29 | #define ANALYSIS_H |
michael@0 | 30 | |
michael@0 | 31 | #include "celt.h" |
michael@0 | 32 | #include "opus_private.h" |
michael@0 | 33 | |
michael@0 | 34 | #define NB_FRAMES 8 |
michael@0 | 35 | #define NB_TBANDS 18 |
michael@0 | 36 | #define NB_TOT_BANDS 21 |
michael@0 | 37 | #define ANALYSIS_BUF_SIZE 720 /* 15 ms at 48 kHz */ |
michael@0 | 38 | |
michael@0 | 39 | #define DETECT_SIZE 200 |
michael@0 | 40 | |
michael@0 | 41 | typedef struct { |
michael@0 | 42 | float angle[240]; |
michael@0 | 43 | float d_angle[240]; |
michael@0 | 44 | float d2_angle[240]; |
michael@0 | 45 | opus_val32 inmem[ANALYSIS_BUF_SIZE]; |
michael@0 | 46 | int mem_fill; /* number of usable samples in the buffer */ |
michael@0 | 47 | float prev_band_tonality[NB_TBANDS]; |
michael@0 | 48 | float prev_tonality; |
michael@0 | 49 | float E[NB_FRAMES][NB_TBANDS]; |
michael@0 | 50 | float lowE[NB_TBANDS]; |
michael@0 | 51 | float highE[NB_TBANDS]; |
michael@0 | 52 | float meanE[NB_TOT_BANDS]; |
michael@0 | 53 | float mem[32]; |
michael@0 | 54 | float cmean[8]; |
michael@0 | 55 | float std[9]; |
michael@0 | 56 | float music_prob; |
michael@0 | 57 | float Etracker; |
michael@0 | 58 | float lowECount; |
michael@0 | 59 | int E_count; |
michael@0 | 60 | int last_music; |
michael@0 | 61 | int last_transition; |
michael@0 | 62 | int count; |
michael@0 | 63 | float subframe_mem[3]; |
michael@0 | 64 | int analysis_offset; |
michael@0 | 65 | /** Probability of having speech for time i to DETECT_SIZE-1 (and music before). |
michael@0 | 66 | pspeech[0] is the probability that all frames in the window are speech. */ |
michael@0 | 67 | float pspeech[DETECT_SIZE]; |
michael@0 | 68 | /** Probability of having music for time i to DETECT_SIZE-1 (and speech before). |
michael@0 | 69 | pmusic[0] is the probability that all frames in the window are music. */ |
michael@0 | 70 | float pmusic[DETECT_SIZE]; |
michael@0 | 71 | float speech_confidence; |
michael@0 | 72 | float music_confidence; |
michael@0 | 73 | int speech_confidence_count; |
michael@0 | 74 | int music_confidence_count; |
michael@0 | 75 | int write_pos; |
michael@0 | 76 | int read_pos; |
michael@0 | 77 | int read_subframe; |
michael@0 | 78 | AnalysisInfo info[DETECT_SIZE]; |
michael@0 | 79 | } TonalityAnalysisState; |
michael@0 | 80 | |
michael@0 | 81 | void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info, |
michael@0 | 82 | const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix); |
michael@0 | 83 | |
michael@0 | 84 | void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len); |
michael@0 | 85 | |
michael@0 | 86 | void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm, |
michael@0 | 87 | int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs, |
michael@0 | 88 | int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info); |
michael@0 | 89 | |
michael@0 | 90 | #endif |