~ubuntu-branches/debian/wheezy/vlc/wheezy

« back to all changes in this revision

Viewing changes to plugins/downmix/ac3_downmix_c.c

Tags: upstream-0.7.2.final
ImportĀ upstreamĀ versionĀ 0.7.2.final

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 * ac3_downmix_c.c: ac3 downmix functions in C
3
 
 *****************************************************************************
4
 
 * Copyright (C) 1999, 2000, 2001 VideoLAN
5
 
 * $Id: ac3_downmix_c.c,v 1.2 2001/11/28 15:08:05 massiot Exp $
6
 
 *
7
 
 * Authors: Renaud Dartus <reno@videolan.org>
8
 
 *          Aaron Holtzman <aholtzma@engr.uvic.ca>
9
 
 *
10
 
 * This program is free software; you can redistribute it and/or modify
11
 
 * it under the terms of the GNU General Public License as published by
12
 
 * the Free Software Foundation; either version 2 of the License, or
13
 
 * (at your option) any later version.
14
 
 * 
15
 
 * This program is distributed in the hope that it will be useful,
16
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 
 * GNU General Public License for more details.
19
 
 *
20
 
 * You should have received a copy of the GNU General Public License
21
 
 * along with this program; if not, write to the Free Software
22
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23
 
 *****************************************************************************/
24
 
 
25
 
#define MODULE_NAME downmix
26
 
#include "modules_inner.h"
27
 
 
28
 
/*****************************************************************************
29
 
 * Preamble
30
 
 *****************************************************************************/
31
 
#include "defs.h"
32
 
 
33
 
#include <string.h>                                              /* memcpy() */
34
 
 
35
 
#include "config.h"
36
 
#include "common.h"
37
 
 
38
 
#include "ac3_downmix.h"
39
 
 
40
 
void _M( downmix_3f_2r_to_2ch ) (float *samples, dm_par_t *dm_par)
41
 
{
42
 
    int i;
43
 
    float *left, *right, *center, *left_sur, *right_sur;
44
 
    float left_tmp, right_tmp;
45
 
    
46
 
    left      = samples;
47
 
    center    = samples + 256;
48
 
    right     = samples + 256*2;
49
 
    left_sur  = samples + 256*3;
50
 
    right_sur = samples + 256*4;
51
 
 
52
 
    for (i=0; i < 256; i++) {
53
 
        left_tmp = dm_par->unit * *left + dm_par->clev * *center + dm_par->slev * *left_sur++;
54
 
        right_tmp = dm_par->unit * *right++ + dm_par->clev * *center + dm_par->slev * *right_sur++;
55
 
        *left++ = left_tmp;
56
 
        *center++ = right_tmp;
57
 
    }
58
 
}
59
 
 
60
 
void _M( downmix_2f_2r_to_2ch ) (float *samples, dm_par_t *dm_par)
61
 
{
62
 
    int i;
63
 
    float *left, *right, *left_sur, *right_sur;
64
 
    float left_tmp, right_tmp;
65
 
               
66
 
    left = &samples[0];
67
 
    right = &samples[256];
68
 
    left_sur = &samples[512];
69
 
    right_sur = &samples[768];
70
 
 
71
 
    for (i = 0; i < 256; i++) {
72
 
        left_tmp = dm_par->unit * *left  + dm_par->slev * *left_sur++;
73
 
        right_tmp= dm_par->unit * *right + dm_par->slev * *right_sur++;
74
 
        *left++ = left_tmp;
75
 
        *right++ = right_tmp;
76
 
    }
77
 
}
78
 
 
79
 
void _M( downmix_3f_1r_to_2ch ) (float *samples, dm_par_t *dm_par)
80
 
{
81
 
    int i;
82
 
    float *left, *right, *center, *right_sur;
83
 
    float left_tmp, right_tmp;
84
 
 
85
 
    left = &samples[0];
86
 
    right = &samples[512];
87
 
    center = &samples[256];
88
 
    right_sur = &samples[768];
89
 
 
90
 
    for (i = 0; i < 256; i++) {
91
 
        left_tmp = dm_par->unit * *left  + dm_par->clev * *center  - dm_par->slev * *right_sur;
92
 
        right_tmp= dm_par->unit * *right++ + dm_par->clev * *center + dm_par->slev * *right_sur++;
93
 
        *left++ = left_tmp;
94
 
        *center++ = right_tmp;
95
 
    }
96
 
}
97
 
 
98
 
 
99
 
void _M( downmix_2f_1r_to_2ch ) (float *samples, dm_par_t *dm_par)
100
 
{
101
 
    int i;
102
 
    float *left, *right, *right_sur;
103
 
    float left_tmp, right_tmp;
104
 
 
105
 
    left = &samples[0];
106
 
    right = &samples[256];
107
 
    right_sur = &samples[512];
108
 
 
109
 
    for (i = 0; i < 256; i++) {
110
 
        left_tmp = dm_par->unit * *left  - dm_par->slev * *right_sur;
111
 
        right_tmp= dm_par->unit * *right + dm_par->slev * *right_sur++;
112
 
        *left++ = left_tmp;
113
 
        *right++ = right_tmp;
114
 
    }
115
 
}
116
 
 
117
 
 
118
 
void _M( downmix_3f_0r_to_2ch ) (float *samples, dm_par_t *dm_par)
119
 
{
120
 
    int i;
121
 
    float *left, *right, *center;
122
 
    float left_tmp, right_tmp;
123
 
 
124
 
    left = &samples[0];
125
 
    center = &samples[256];
126
 
    right = &samples[512];
127
 
 
128
 
    for (i = 0; i < 256; i++) {
129
 
        left_tmp = dm_par->unit * *left  + dm_par->clev * *center;
130
 
        right_tmp= dm_par->unit * *right++ + dm_par->clev * *center;
131
 
        *left++ = left_tmp;
132
 
        *center++ = right_tmp;
133
 
    }
134
 
}
135
 
 
136
 
 
137
 
void _M( stream_sample_2ch_to_s16 ) (s16 *out_buf, float *left, float *right)
138
 
{
139
 
    int i;
140
 
    for (i=0; i < 256; i++) {
141
 
        *out_buf++ = (s16) (*left++);
142
 
        *out_buf++ = (s16) (*right++);
143
 
    }
144
 
}
145
 
 
146
 
 
147
 
void _M( stream_sample_1ch_to_s16 ) (s16 *out_buf, float *center)
148
 
{
149
 
    int i;
150
 
    float tmp;
151
 
 
152
 
    for (i=0; i < 256; i++) {
153
 
        *out_buf++ = tmp = (s16) (0.7071f * *center++);
154
 
        *out_buf++ = tmp;
155
 
    }
156
 
}
157