1 | /******************************************************************** |
2 | * * |
3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
7 | * * |
8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009 * |
9 | * by the Xiph.Org Foundation https://xiph.org/ * |
10 | * * |
11 | ******************************************************************** |
12 | |
13 | function: PCM data envelope analysis and manipulation |
14 | |
15 | ********************************************************************/ |
16 | |
17 | #ifndef _V_ENVELOPE_ |
18 | #define _V_ENVELOPE_ |
19 | |
20 | #include "mdct.h" |
21 | |
22 | #define VE_PRE 16 |
23 | #define VE_WIN 4 |
24 | #define VE_POST 2 |
25 | #define VE_AMP (VE_PRE+VE_POST-1) |
26 | |
27 | #define VE_BANDS 7 |
28 | #define VE_NEARDC 15 |
29 | |
30 | #define VE_MINSTRETCH 2 /* a bit less than short block */ |
31 | #define VE_MAXSTRETCH 12 /* one-third full block */ |
32 | |
33 | typedef struct { |
34 | float ampbuf[VE_AMP]; |
35 | int ampptr; |
36 | |
37 | float nearDC[VE_NEARDC]; |
38 | float nearDC_acc; |
39 | float nearDC_partialacc; |
40 | int nearptr; |
41 | |
42 | } envelope_filter_state; |
43 | |
44 | typedef struct { |
45 | int begin; |
46 | int end; |
47 | float *window; |
48 | float total; |
49 | } envelope_band; |
50 | |
51 | typedef struct { |
52 | int ch; |
53 | int winlength; |
54 | int searchstep; |
55 | float minenergy; |
56 | |
57 | mdct_lookup mdct; |
58 | float *mdct_win; |
59 | |
60 | envelope_band band[VE_BANDS]; |
61 | envelope_filter_state *filter; |
62 | int stretch; |
63 | |
64 | int *mark; |
65 | |
66 | long storage; |
67 | long current; |
68 | long curmark; |
69 | long cursor; |
70 | } envelope_lookup; |
71 | |
72 | extern void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi); |
73 | extern void _ve_envelope_clear(envelope_lookup *e); |
74 | extern long _ve_envelope_search(vorbis_dsp_state *v); |
75 | extern void _ve_envelope_shift(envelope_lookup *e,long shift); |
76 | extern int _ve_envelope_mark(vorbis_dsp_state *v); |
77 | |
78 | |
79 | #endif |
80 | |