~ubuntu-branches/ubuntu/lucid/gavl/lucid

« back to all changes in this revision

Viewing changes to gavl/c/sampleformat_c.c

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2006-05-17 14:24:46 UTC
  • Revision ID: james.westby@ubuntu.com-20060517142446-iqm0jgfbkmy27n5w
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <audio.h>
 
2
#include <sampleformat.h>
 
3
#include <float_cast.h>
 
4
 
 
5
#include <stdio.h>
 
6
 
 
7
 
 
8
#define SWAP_ENDIAN(n) ((n >> 8)|(n << 8))
 
9
#define CLAMP(i, min, max) if(i<min)i=min;if(i>max)i=max;
 
10
 
 
11
#define CONVERSION_FUNC_START \
 
12
int i, j;\
 
13
for(i = 0; i < ctx->input_format.num_channels; i++)\
 
14
  { \
 
15
  for(j = 0; j < ctx->input_frame->valid_samples; j++) \
 
16
    {
 
17
    
 
18
#define CONVERSION_FUNC_END \
 
19
    } \
 
20
  }
 
21
 
 
22
#define U_8 channels.u_8[i][j]
 
23
#define S_8 channels.s_8[i][j]
 
24
#define U_16 channels.u_16[i][j]
 
25
#define S_16 channels.s_16[i][j]
 
26
#define S_32 channels.s_32[i][j]
 
27
#define FLOAT channels.f[i][j]
 
28
 
 
29
#define RENAME(a) a ## _ni
 
30
 
 
31
#include "_sampleformat_c.c"
 
32
 
 
33
#undef CONVERSION_FUNC_START
 
34
#undef CONVERSION_FUNC_END
 
35
 
 
36
#undef U_8
 
37
#undef S_8
 
38
#undef U_16
 
39
#undef S_16
 
40
#undef S_32
 
41
#undef FLOAT
 
42
 
 
43
#undef RENAME
 
44
 
 
45
/* */
 
46
 
 
47
#define CONVERSION_FUNC_START \
 
48
int i, imax;\
 
49
imax = ctx->input_format.num_channels * ctx->input_frame->valid_samples; \
 
50
for(i = 0; i < imax; i++)\
 
51
  {
 
52
    
 
53
#define CONVERSION_FUNC_END \
 
54
  }
 
55
 
 
56
#define U_8 samples.u_8[i]
 
57
#define S_8 samples.s_8[i]
 
58
#define U_16 samples.u_16[i]
 
59
#define S_16 samples.s_16[i]
 
60
#define S_32 samples.s_32[i]
 
61
#define FLOAT samples.f[i]
 
62
 
 
63
#define RENAME(a) a ## _i
 
64
 
 
65
#include "_sampleformat_c.c"
 
66
 
 
67
void gavl_init_sampleformat_funcs_c(gavl_sampleformat_table_t * t, gavl_interleave_mode_t interleave_mode)
 
68
  {
 
69
  if(interleave_mode == GAVL_INTERLEAVE_NONE)
 
70
    return gavl_init_sampleformat_funcs_c_ni(t);
 
71
  else if(interleave_mode == GAVL_INTERLEAVE_ALL)
 
72
    return gavl_init_sampleformat_funcs_c_i(t);
 
73
  else
 
74
    {
 
75
    fprintf(stderr, "BUUUG: Unsupported interleave mode for sampleformat conversion\n");
 
76
    }
 
77
  }