FFmpeg
g728_template.c
Go to the documentation of this file.
1 /*
2  * G.728 / RealAudio 2.0 (28.8K) decoder
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 static void convolve(float *tgt, const float *src, int len, int n)
22 {
23  for (; n >= 0; n--)
24  tgt[n] = ff_scalarproduct_float_c(src, src - n, len);
25 
26 }
27 
28 /**
29  * Hybrid window filtering, see blocks 36 and 49 of the G.728 specification.
30  *
31  * @param order filter order
32  * @param n input length
33  * @param non_rec number of non-recursive samples
34  * @param out filter output
35  * @param hist pointer to the input history of the filter
36  * @param out pointer to the non-recursive part of the output
37  * @param out2 pointer to the recursive part of the output
38  * @param window pointer to the windowing function table
39  */
40 static void do_hybrid_window(void (*vector_fmul)(float *dst, const float *src0, const float *src1, int len),
41  int order, int n, int non_rec, float *out,
42  const float *hist, float *out2, const float *window)
43 {
44  int i;
45  float buffer1[MAX_BACKWARD_FILTER_ORDER + 1];
46  float buffer2[MAX_BACKWARD_FILTER_ORDER + 1];
50 
51  av_assert2(order>=0);
52 
53  vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
54 
55  convolve(buffer1, work + order , n , order);
56  convolve(buffer2, work + order + n, non_rec, order);
57 
58  for (i=0; i <= order; i++) {
59  out2[i] = out2[i] * ATTEN + buffer1[i];
60  out [i] = out2[i] + buffer2[i];
61  }
62 
63  /* Multiply by the white noise correcting factor (WNCF). */
64  *out *= 257.0 / 256.0;
65 }
MAX_BACKWARD_FILTER_ORDER
#define MAX_BACKWARD_FILTER_ORDER
Definition: g728dec.c:36
out
FILE * out
Definition: movenc.c:55
src1
const pixel * src1
Definition: h264pred_template.c:420
window
static SDL_Window * window
Definition: ffplay.c:361
LOCAL_ALIGNED
#define LOCAL_ALIGNED(a, t, v,...)
Definition: mem_internal.h:124
ATTEN
#define ATTEN
Definition: g728dec.c:39
work
must be printed separately If there s no standard function for printing the type you the WRITE_1D_FUNC_ARGV macro is a very quick way to create one See libavcodec dv_tablegen c for an example The h file This file should the initialization functions should not do and instead of the variable declarations the generated *_tables h file should be included Since that will be generated in the build the path must be i e not Makefile changes To make the automatic table creation work
Definition: tablegen.txt:66
ff_scalarproduct_float_c
float ff_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors of floats.
Definition: float_scalarproduct.c:24
MAX_BACKWARD_FILTER_LEN
#define MAX_BACKWARD_FILTER_LEN
Definition: g728dec.c:37
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
convolve
static void convolve(float *tgt, const float *src, int len, int n)
Definition: g728_template.c:21
MAX_BACKWARD_FILTER_NONREC
#define MAX_BACKWARD_FILTER_NONREC
Definition: g728dec.c:38
do_hybrid_window
static void do_hybrid_window(void(*vector_fmul)(float *dst, const float *src0, const float *src1, int len), int order, int n, int non_rec, float *out, const float *hist, float *out2, const float *window)
Hybrid window filtering, see blocks 36 and 49 of the G.728 specification.
Definition: g728_template.c:40
av_assert2
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:68
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
len
int len
Definition: vorbis_enc_data.h:426
src0
const pixel *const src0
Definition: h264pred_template.c:419
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
src
#define src
Definition: vp8dsp.c:248