1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/src/analysis.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,90 @@ 1.4 +/* Copyright (c) 2011 Xiph.Org Foundation 1.5 + Written by Jean-Marc Valin */ 1.6 +/* 1.7 + Redistribution and use in source and binary forms, with or without 1.8 + modification, are permitted provided that the following conditions 1.9 + are met: 1.10 + 1.11 + - Redistributions of source code must retain the above copyright 1.12 + notice, this list of conditions and the following disclaimer. 1.13 + 1.14 + - Redistributions in binary form must reproduce the above copyright 1.15 + notice, this list of conditions and the following disclaimer in the 1.16 + documentation and/or other materials provided with the distribution. 1.17 + 1.18 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.19 + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.20 + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.21 + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR 1.22 + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 1.23 + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 1.24 + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 1.25 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 1.26 + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 1.27 + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 1.28 + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.29 +*/ 1.30 + 1.31 +#ifndef ANALYSIS_H 1.32 +#define ANALYSIS_H 1.33 + 1.34 +#include "celt.h" 1.35 +#include "opus_private.h" 1.36 + 1.37 +#define NB_FRAMES 8 1.38 +#define NB_TBANDS 18 1.39 +#define NB_TOT_BANDS 21 1.40 +#define ANALYSIS_BUF_SIZE 720 /* 15 ms at 48 kHz */ 1.41 + 1.42 +#define DETECT_SIZE 200 1.43 + 1.44 +typedef struct { 1.45 + float angle[240]; 1.46 + float d_angle[240]; 1.47 + float d2_angle[240]; 1.48 + opus_val32 inmem[ANALYSIS_BUF_SIZE]; 1.49 + int mem_fill; /* number of usable samples in the buffer */ 1.50 + float prev_band_tonality[NB_TBANDS]; 1.51 + float prev_tonality; 1.52 + float E[NB_FRAMES][NB_TBANDS]; 1.53 + float lowE[NB_TBANDS]; 1.54 + float highE[NB_TBANDS]; 1.55 + float meanE[NB_TOT_BANDS]; 1.56 + float mem[32]; 1.57 + float cmean[8]; 1.58 + float std[9]; 1.59 + float music_prob; 1.60 + float Etracker; 1.61 + float lowECount; 1.62 + int E_count; 1.63 + int last_music; 1.64 + int last_transition; 1.65 + int count; 1.66 + float subframe_mem[3]; 1.67 + int analysis_offset; 1.68 + /** Probability of having speech for time i to DETECT_SIZE-1 (and music before). 1.69 + pspeech[0] is the probability that all frames in the window are speech. */ 1.70 + float pspeech[DETECT_SIZE]; 1.71 + /** Probability of having music for time i to DETECT_SIZE-1 (and speech before). 1.72 + pmusic[0] is the probability that all frames in the window are music. */ 1.73 + float pmusic[DETECT_SIZE]; 1.74 + float speech_confidence; 1.75 + float music_confidence; 1.76 + int speech_confidence_count; 1.77 + int music_confidence_count; 1.78 + int write_pos; 1.79 + int read_pos; 1.80 + int read_subframe; 1.81 + AnalysisInfo info[DETECT_SIZE]; 1.82 +} TonalityAnalysisState; 1.83 + 1.84 +void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info, 1.85 + const CELTMode *celt_mode, const void *x, int len, int offset, int c1, int c2, int C, int lsb_depth, downmix_func downmix); 1.86 + 1.87 +void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len); 1.88 + 1.89 +void run_analysis(TonalityAnalysisState *analysis, const CELTMode *celt_mode, const void *analysis_pcm, 1.90 + int analysis_frame_size, int frame_size, int c1, int c2, int C, opus_int32 Fs, 1.91 + int lsb_depth, downmix_func downmix, AnalysisInfo *analysis_info); 1.92 + 1.93 +#endif