Mercurial > mplayer.hg
annotate libaf/af_mp.c @ 14180:6f40d266143a
added conditional lowres description
author | nicodvb |
---|---|
date | Sat, 18 Dec 2004 09:41:16 +0000 |
parents | d40a1dfbf1d9 |
children |
rev | line source |
---|---|
8167 | 1 #include "af.h" |
2 | |
3 /* Decodes the format from mplayer format to libaf format */ | |
4 int af_format_decode(int ifmt) | |
5 { | |
6 int ofmt = ~0; | |
7 // Check input ifmt | |
8 switch(ifmt){ | |
9 case(AFMT_U8): | |
10 ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; | |
11 case(AFMT_S8): | |
12 ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; | |
13 case(AFMT_S16_LE): | |
14 ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; | |
15 case(AFMT_S16_BE): | |
16 ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; | |
17 case(AFMT_U16_LE): | |
18 ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; | |
19 case(AFMT_U16_BE): | |
20 ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; | |
13552 | 21 case(AFMT_S24_LE): |
22 ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; | |
23 case(AFMT_S24_BE): | |
24 ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; | |
25 case(AFMT_U24_LE): | |
26 ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; | |
27 case(AFMT_U24_BE): | |
28 ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; | |
8167 | 29 case(AFMT_S32_LE): |
30 ofmt = AF_FORMAT_LE|AF_FORMAT_SI; break; | |
31 case(AFMT_S32_BE): | |
32 ofmt = AF_FORMAT_BE|AF_FORMAT_SI; break; | |
13552 | 33 case(AFMT_U32_LE): |
34 ofmt = AF_FORMAT_LE|AF_FORMAT_US; break; | |
35 case(AFMT_U32_BE): | |
36 ofmt = AF_FORMAT_BE|AF_FORMAT_US; break; | |
8167 | 37 case(AFMT_IMA_ADPCM): |
38 ofmt = AF_FORMAT_IMA_ADPCM; break; | |
39 case(AFMT_MU_LAW): | |
40 ofmt = AF_FORMAT_MU_LAW; break; | |
41 case(AFMT_A_LAW): | |
42 ofmt = AF_FORMAT_A_LAW; break; | |
43 case(AFMT_MPEG): | |
44 ofmt = AF_FORMAT_MPEG2; break; | |
45 case(AFMT_AC3): | |
46 ofmt = AF_FORMAT_AC3; break; | |
8233 | 47 case(AFMT_FLOAT): |
8952
2369087bb777
Fix for endianess conversion if input to libaf is float
anders
parents:
8233
diff
changeset
|
48 ofmt = AF_FORMAT_F | AF_FORMAT_NE; break; |
8167 | 49 default: |
12667 | 50 if ((ifmt & AFMT_AF_FLAGS) == AFMT_AF_FLAGS) { |
12478 | 51 ofmt = ifmt & ~AFMT_AF_FLAGS; |
52 break; | |
53 } | |
8167 | 54 //This can not happen .... |
55 af_msg(AF_MSG_FATAL,"Unrecognized input audio format %i\n",ifmt); | |
56 break; | |
57 } | |
58 return ofmt; | |
59 } | |
8993
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
60 |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
61 /* Encodes the format from libaf format to mplayer (OSS) format */ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
62 int af_format_encode(void* fmtp) |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
63 { |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
64 af_data_t* fmt=(af_data_t*) fmtp; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
65 switch(fmt->format&AF_FORMAT_SPECIAL_MASK){ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
66 case 0: // PCM: |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
67 if((fmt->format&AF_FORMAT_POINT_MASK)==AF_FORMAT_I){ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
68 if((fmt->format&AF_FORMAT_SIGN_MASK)==AF_FORMAT_SI){ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
69 // signed int PCM: |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
70 switch(fmt->bps){ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
71 case 1: return AFMT_S8; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
72 case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_S16_LE : AFMT_S16_BE; |
13552 | 73 case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_S24_LE : AFMT_S24_BE; |
8993
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
74 case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_S32_LE : AFMT_S32_BE; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
75 } |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
76 } else { |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
77 // unsigned int PCM: |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
78 switch(fmt->bps){ |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
79 case 1: return AFMT_U8; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
80 case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_U16_LE : AFMT_U16_BE; |
13552 | 81 case 3: return (fmt->format&AF_FORMAT_LE) ? AFMT_U24_LE : AFMT_U24_BE; |
82 case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_U32_LE : AFMT_U32_BE; | |
8993
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
83 } |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
84 } |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
85 } else { |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
86 // float PCM: |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
87 return AFMT_FLOAT; // FIXME? |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
88 } |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
89 break; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
90 case AF_FORMAT_MU_LAW: return AFMT_MU_LAW; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
91 case AF_FORMAT_A_LAW: return AFMT_A_LAW; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
92 case AF_FORMAT_MPEG2: return AFMT_MPEG; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
93 case AF_FORMAT_AC3: return AFMT_AC3; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
94 case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM; |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
95 } |
12478 | 96 return (fmt->format | AFMT_AF_FLAGS); |
8993
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
97 } |
a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
arpi
parents:
8952
diff
changeset
|
98 |