summaryrefslogtreecommitdiff
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-09-29 04:53:50 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-10-01 01:17:39 +0200
commita75b254c74d71414f15764979e718e74cd90f5aa (patch)
tree24327535806e2ed2a919dc85d81b8279947e86ce /libswresample
parent7322483d72d4abefae9f5c08c611f521de7236a5 (diff)
downloadffmpeg-a75b254c74d71414f15764979e718e74cd90f5aa.tar.gz
swr: minor fixes to get planar audio working
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/swresample.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 20a1e641d7..519cadf97c 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -39,10 +39,10 @@ static const AVOption options[]={
{"och", "output channel count", OFFSET(out.ch_count ), FF_OPT_TYPE_INT, {.dbl=2}, 1, SWR_CH_MAX, 0},
{"isr", "input sample rate" , OFFSET( in_sample_rate), FF_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0},
{"osr", "output sample rate" , OFFSET(out_sample_rate), FF_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0},
-{"ip" , "input planar" , OFFSET( in.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0},
-{"op" , "output planar" , OFFSET(out.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0},
-{"isf", "input sample format", OFFSET( in_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1, 0},
-{"osf", "output sample format", OFFSET(out_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1, 0},
+//{"ip" , "input planar" , OFFSET( in.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0},
+//{"op" , "output planar" , OFFSET(out.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0},
+{"isf", "input sample format", OFFSET( in_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0},
+{"osf", "output sample format", OFFSET(out_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0},
{"tsf", "internal sample format", OFFSET(int_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_FLT, 0},
{"icl", "input channel layout" , OFFSET( in_ch_layout), FF_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"},
{"ocl", "output channel layout", OFFSET(out_ch_layout), FF_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"},
@@ -139,6 +139,11 @@ int swr_init(SwrContext *s){
swr_audio_convert_free(&s-> in_convert);
swr_audio_convert_free(&s->out_convert);
+ s-> in.planar= s-> in_sample_fmt >= 0x100;
+ s->out.planar= s->out_sample_fmt >= 0x100;
+ s-> in_sample_fmt &= 0xFF;
+ s->out_sample_fmt &= 0xFF;
+
//We assume AVOptions checked the various values and the defaults where allowed
if( s->int_sample_fmt != AV_SAMPLE_FMT_S16
&&s->int_sample_fmt != AV_SAMPLE_FMT_FLT){
@@ -250,6 +255,17 @@ static void copy(AudioData *out, AudioData *in,
memcpy(out->ch[0], in->ch[0], count*out->ch_count*out->bps);
}
+static void fill_audiodata(AudioData *out, uint8_t *in_arg [SWR_CH_MAX]){
+ int i;
+ if(out->planar){
+ for(i=0; i<out->ch_count; i++)
+ out->ch[i]= in_arg[i];
+ }else{
+ for(i=0; i<out->ch_count; i++)
+ out->ch[i]= in_arg[0] + i*out->bps;
+ }
+}
+
int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count,
const uint8_t *in_arg [SWR_CH_MAX], int in_count){
AudioData *postin, *midbuf, *preout;
@@ -264,12 +280,8 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
out_count = in_count;
}
- av_assert0(in ->planar == 0);
- av_assert0(out->planar == 0);
- for(i=0; i<s-> in.ch_count; i++)
- in ->ch[i]= in_arg[0] + i* in->bps;
- for(i=0; i<s->out.ch_count; i++)
- out->ch[i]= out_arg[0] + i*out->bps;
+ fill_audiodata(in , in_arg);
+ fill_audiodata(out, out_arg);
// in_max= out_count*(int64_t)s->in_sample_rate / s->out_sample_rate + resample_filter_taps;
// in_count= FFMIN(in_count, in_in + 2 - s->hist_buffer_count);