Mercurial > libavcodec.hg
annotate audioconvert.c @ 7619:0753d03d232a libavcodec
alacenc: last few hunks approved by michael
author | jai_menon |
---|---|
date | Tue, 19 Aug 2008 17:20:41 +0000 |
parents | 1302ec81afc0 |
children | 8d5e06d2eed8 |
rev | line source |
---|---|
3594 | 1 /* |
3596 | 2 * audio conversion |
3594 | 3 * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> |
4 * | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
3594 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
3594 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
3594 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3596
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3594 | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 */ | |
21 | |
22 /** | |
23 * @file audioconvert.c | |
3596 | 24 * audio conversion |
3594 | 25 * @author Michael Niedermayer <michaelni@gmx.at> |
26 */ | |
27 | |
7458
eb63aa50bf85
Revert r14484 hunk that deleted the 'include avcodec.h' statement.
pross
parents:
7453
diff
changeset
|
28 #include "avcodec.h" |
7453
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
29 #include "audioconvert.h" |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
30 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
31 typedef struct SampleFmtInfo { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
32 const char *name; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
33 int bits; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
34 } SampleFmtInfo; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
35 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
36 /** this table gives more information about formats */ |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
37 static const SampleFmtInfo sample_fmt_info[SAMPLE_FMT_NB] = { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
38 [SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 }, |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
39 [SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 }, |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
40 [SAMPLE_FMT_S24] = { .name = "s24", .bits = 24 }, |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
41 [SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 }, |
7612 | 42 [SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 }, |
43 [SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 }, | |
7453
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
44 }; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
45 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
46 const char *avcodec_get_sample_fmt_name(int sample_fmt) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
47 { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
48 if (sample_fmt < 0 || sample_fmt >= SAMPLE_FMT_NB) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
49 return NULL; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
50 return sample_fmt_info[sample_fmt].name; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
51 } |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
52 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
53 enum SampleFormat avcodec_get_sample_fmt(const char* name) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
54 { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
55 int i; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
56 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
57 for (i=0; i < SAMPLE_FMT_NB; i++) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
58 if (!strcmp(sample_fmt_info[i].name, name)) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
59 return i; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
60 return SAMPLE_FMT_NONE; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
61 } |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
62 |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
63 void avcodec_sample_fmt_string (char *buf, int buf_size, int sample_fmt) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
64 { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
65 /* print header */ |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
66 if (sample_fmt < 0) |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
67 snprintf (buf, buf_size, "name " " depth"); |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
68 else if (sample_fmt < SAMPLE_FMT_NB) { |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
69 SampleFmtInfo info= sample_fmt_info[sample_fmt]; |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
70 snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
71 } |
d1d15f2dca4c
Add sample format support functions: avcodec_get_sample_fmt_name(), avcodec_get_sample_fmt(), avcodec_sample_fmt_string()
pross
parents:
5215
diff
changeset
|
72 } |
3594 | 73 |
7459
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
74 struct AVAudioConvert { |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
75 int in_channels, out_channels; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
76 int fmt_pair; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
77 }; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
78 |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
79 AVAudioConvert *av_audio_convert_alloc(enum SampleFormat out_fmt, int out_channels, |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
80 enum SampleFormat in_fmt, int in_channels, |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
81 const const float *matrix, int flags) |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
82 { |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
83 AVAudioConvert *ctx; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
84 if (in_channels!=out_channels) |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
85 return NULL; /* FIXME: not supported */ |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
86 ctx = av_malloc(sizeof(AVAudioConvert)); |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
87 if (!ctx) |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
88 return NULL; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
89 ctx->in_channels = in_channels; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
90 ctx->out_channels = out_channels; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
91 ctx->fmt_pair = out_fmt + SAMPLE_FMT_NB*in_fmt; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
92 return ctx; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
93 } |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
94 |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
95 void av_audio_convert_free(AVAudioConvert *ctx) |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
96 { |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
97 av_free(ctx); |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
98 } |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
99 |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
100 int av_audio_convert(AVAudioConvert *ctx, |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
101 void * const out[6], const int out_stride[6], |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
102 const void * const in[6], const int in_stride[6], int len) |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
103 { |
3594 | 104 int ch; |
105 | |
106 //FIXME optimize common cases | |
107 | |
7459
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
108 for(ch=0; ch<ctx->out_channels; ch++){ |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
109 const int is= in_stride[ch]; |
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
110 const int os= out_stride[ch]; |
3594 | 111 uint8_t *pi= in[ch]; |
112 uint8_t *po= out[ch]; | |
7459
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
113 uint8_t *end= po + os*len; |
3594 | 114 if(!out[ch]) |
115 continue; | |
116 | |
117 #define CONV(ofmt, otype, ifmt, expr)\ | |
7459
283eeda62184
Modify av_audio_convert() to use AVAudioConvert context struct; add av_audio_convert_alloc() and av_audio_convert_free() support functions.
pross
parents:
7458
diff
changeset
|
118 if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\ |
3594 | 119 do{\ |
120 *(otype*)po = expr; pi += is; po += os;\ | |
121 }while(po < end);\ | |
122 } | |
123 | |
5127 | 124 //FIXME put things below under ifdefs so we do not waste space for cases no codec will need |
125 //FIXME rounding and clipping ? | |
3594 | 126 |
127 CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 , *(uint8_t*)pi) | |
128 else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)<<8) | |
129 else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)<<24) | |
130 else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)*(1.0 / (1<<7))) | |
7612 | 131 else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)*(1.0 / (1<<7))) |
3594 | 132 else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S16, (*(int16_t*)pi>>8) + 0x80) |
133 else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S16, *(int16_t*)pi) | |
134 else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S16, *(int16_t*)pi<<16) | |
135 else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S16, *(int16_t*)pi*(1.0 / (1<<15))) | |
7612 | 136 else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S16, *(int16_t*)pi*(1.0 / (1<<15))) |
3594 | 137 else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S32, (*(int32_t*)pi>>24) + 0x80) |
138 else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S32, *(int32_t*)pi>>16) | |
139 else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32, *(int32_t*)pi) | |
140 else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_S32, *(int32_t*)pi*(1.0 / (1<<31))) | |
7612 | 141 else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32, *(int32_t*)pi*(1.0 / (1<<31))) |
3594 | 142 else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<7)) + 0x80) |
143 else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<15))) | |
144 else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<31))) | |
145 else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_FLT, *(float*)pi) | |
7612 | 146 else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(float*)pi) |
147 else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<7)) + 0x80) | |
148 else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<15))) | |
149 else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<31))) | |
150 else CONV(SAMPLE_FMT_FLT, float , SAMPLE_FMT_DBL, *(double*)pi) | |
151 else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(double*)pi) | |
3594 | 152 else return -1; |
153 } | |
154 return 0; | |
155 } |