libavcodec/lpc.h

Go to the documentation of this file.
00001 
00022 #ifndef AVCODEC_LPC_H
00023 #define AVCODEC_LPC_H
00024 
00025 #include <stdint.h>
00026 #include "dsputil.h"
00027 
00028 #define ORDER_METHOD_EST 0
00029 #define ORDER_METHOD_2LEVEL 1
00030 #define ORDER_METHOD_4LEVEL 2
00031 #define ORDER_METHOD_8LEVEL 3
00032 #define ORDER_METHOD_SEARCH 4
00033 #define ORDER_METHOD_LOG 5
00034 
00035 #define MIN_LPC_ORDER 1
00036 #define MAX_LPC_ORDER 32
00037 
00038 
00042 int ff_lpc_calc_coefs(DSPContext *s,
00043 const int32_t *samples, int blocksize, int min_order,
00044 int max_order, int precision,
00045 int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,
00046 int omethod, int max_shift, int zero_shift);
00047 
00048 #ifdef LPC_USE_DOUBLE
00049 #define LPC_TYPE double
00050 #else
00051 #define LPC_TYPE float
00052 #endif
00053 
00058 static inline int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order,
00059 LPC_TYPE *lpc, int lpc_stride, int fail,
00060 int normalize)
00061 {
00062 int i, j;
00063 LPC_TYPE err;
00064 LPC_TYPE *lpc_last = lpc;
00065 
00066 if (normalize)
00067 err = *autoc++;
00068 
00069 if (fail && (autoc[max_order - 1] == 0 || err <= 0))
00070 return -1;
00071 
00072 for(i=0; i<max_order; i++) {
00073 LPC_TYPE r = -autoc[i];
00074 
00075 if (normalize) {
00076 for(j=0; j<i; j++)
00077 r -= lpc_last[j] * autoc[i-j-1];
00078 
00079 r /= err;
00080 err *= 1.0 - (r * r);
00081 }
00082 
00083 lpc[i] = r;
00084 
00085 for(j=0; j < (i+1)>>1; j++) {
00086 LPC_TYPE f = lpc_last[ j];
00087 LPC_TYPE b = lpc_last[i-1-j];
00088 lpc[ j] = f + r * b;
00089 lpc[i-1-j] = b + r * f;
00090 }
00091 
00092 if (fail && err < 0)
00093 return -1;
00094 
00095 lpc_last = lpc;
00096 lpc += lpc_stride;
00097 }
00098 
00099 return 0;
00100 }
00101 
00102 #endif /* AVCODEC_LPC_H */

Generated on Fri Oct 26 02:35:37 2012 for FFmpeg by doxygen 1.5.8

AltStyle によって変換されたページ (->オリジナル) /