annotate liba52/resample.c @ 30888:ff7b06c867cd

Split codec path related code into a separate file to fix Windows build.
author reimar
date Thu, 18 Mar 2010 20:44:01 +0000
parents 25337a2147e7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25483
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
1 /*
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
2 * resample.c
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
3 * Copyright (C) 2001 Árpád Gereöffy
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
4 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
5 * This file is part of a52dec, a free ATSC A-52 stream decoder.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
6 * See http://liba52.sourceforge.net/ for updates.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
7 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
8 * File added for use with MPlayer and not part of original a52dec.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
9 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
10 * a52dec is free software; you can redistribute it and/or modify
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
11 * it under the terms of the GNU General Public License as published by
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
13 * (at your option) any later version.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
14 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
15 * a52dec is distributed in the hope that it will be useful,
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
18 * GNU General Public License for more details.
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
19 *
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
20 * You should have received a copy of the GNU General Public License
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
21 * along with this program; if not, write to the Free Software
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
170fc6d9dfa1 Add proper copyright/license headers.
diego
parents: 16173
diff changeset
23 */
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
24
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
25 // a52_resample_init should find the requested converter (from type flags ->
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
26 // given number of channels) and set up some function pointers...
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
27
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
28 // a52_resample() should do the conversion.
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
29
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
30 #include <inttypes.h>
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
31 #include <stdio.h>
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
32 #include "a52.h"
3908
0cc94b1eec0f runtime cpudetect in liba52 way
michael
parents: 3907
diff changeset
33 #include "mm_accel.h"
26544
f20a11161e62 Use consistent #include paths without "../".
diego
parents: 25484
diff changeset
34 #include "config.h"
4247
2dbd637ffe05 mangle for win32 in liba52 (includes dummy mangle.h pointing to the one in main)
atmos4
parents: 3909
diff changeset
35 #include "mangle.h"
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
36
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
37 int (* a52_resample) (float * _f, int16_t * s16)=NULL;
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
38
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
39 #include "resample_c.c"
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
40
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 26544
diff changeset
41 #if ARCH_X86 || ARCH_X86_64
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
42 #include "resample_mmx.c"
3567
9e1e88b3ca18 mmx opt
michael
parents: 3412
diff changeset
43 #endif
3412
21d65a4ae3c9 resample.c added - float->int conversion and channel ordering
arpi
parents:
diff changeset
44
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 26544
diff changeset
45 #if HAVE_ALTIVEC
11849
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
46 #include "resample_altivec.c"
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
47 #endif
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
48
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
49 void* a52_resample_init(uint32_t mm_accel,int flags,int chans){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
50 void* tmp;
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
51
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 26544
diff changeset
52 #if ARCH_X86 || ARCH_X86_64
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
53 if(mm_accel&MM_ACCEL_X86_MMX){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
54 tmp=a52_resample_MMX(flags,chans);
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
55 if(tmp){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
56 if(a52_resample==NULL) fprintf(stderr, "Using MMX optimized resampler\n");
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
57 a52_resample=tmp;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
58 return tmp;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
59 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
60 }
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
61 #endif
28290
25337a2147e7 Lots and lots of #ifdef ARCH_... -> #if ARCH_...
reimar
parents: 26544
diff changeset
62 #if HAVE_ALTIVEC
11849
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
63 if(mm_accel&MM_ACCEL_PPC_ALTIVEC){
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
64 tmp=a52_resample_altivec(flags,chans);
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
65 if(tmp){
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
66 if(a52_resample==NULL) fprintf(stderr, "Using AltiVec optimized resampler\n");
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
67 a52_resample=tmp;
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
68 return tmp;
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
69 }
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
70 }
459ba3f14302 Altivec optimized stereo resampler by Romain Dolbeau (made it working under Linux myself)
alex
parents: 4247
diff changeset
71 #endif
25484
943f37a4323d cosmetics: Remove trailing whitespace, reformat one comment.
diego
parents: 25483
diff changeset
72
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
73 tmp=a52_resample_C(flags,chans);
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
74 if(tmp){
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
75 if(a52_resample==NULL) fprintf(stderr, "No accelerated resampler found\n");
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
76 a52_resample=tmp;
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
77 return tmp;
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
78 }
25484
943f37a4323d cosmetics: Remove trailing whitespace, reformat one comment.
diego
parents: 25483
diff changeset
79
3909
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
80 fprintf(stderr, "Unimplemented resampler for mode 0x%X -> %d channels conversion - Contact MPlayer developers!\n", flags, chans);
ef32c8bdee81 c, mmx versions separated. a52 style runtime stuff
arpi
parents: 3908
diff changeset
81 return NULL;
3626
e22ff7ebdc05 runtime cpu detection for the resample stuff
michael
parents: 3578
diff changeset
82 }