diff options
Diffstat (limited to 'ffmpeg/libswresample')
| -rw-r--r-- | ffmpeg/libswresample/Makefile | 3 | ||||
| -rw-r--r-- | ffmpeg/libswresample/dither.c | 1 | ||||
| -rw-r--r-- | ffmpeg/libswresample/libswresample.pc | 6 | ||||
| -rw-r--r-- | ffmpeg/libswresample/rematrix.c | 50 | ||||
| -rw-r--r-- | ffmpeg/libswresample/rematrix_template.c | 24 | ||||
| -rw-r--r-- | ffmpeg/libswresample/resample.c | 2 | ||||
| -rw-r--r-- | ffmpeg/libswresample/swresample.c | 43 | ||||
| -rw-r--r-- | ffmpeg/libswresample/swresample.h | 8 | ||||
| -rw-r--r-- | ffmpeg/libswresample/swresample_internal.h | 2 | ||||
| -rw-r--r-- | ffmpeg/libswresample/version.h | 2 | ||||
| -rw-r--r-- | ffmpeg/libswresample/x86/audio_convert.asm | 8 | ||||
| -rw-r--r-- | ffmpeg/libswresample/x86/rematrix.asm | 3 | ||||
| -rw-r--r-- | ffmpeg/libswresample/x86/swresample_x86.c | 5 |
13 files changed, 106 insertions, 51 deletions
diff --git a/ffmpeg/libswresample/Makefile b/ffmpeg/libswresample/Makefile index 0b75bd0..953c945 100644 --- a/ffmpeg/libswresample/Makefile +++ b/ffmpeg/libswresample/Makefile @@ -15,4 +15,7 @@ OBJS = audioconvert.o \ OBJS-$(CONFIG_LIBSOXR) += soxr_resample.o OBJS-$(CONFIG_SHARED) += log2_tab.o +# Windows resource file +SLIBOBJS-$(HAVE_GNU_WINDRES) += swresampleres.o + TESTPROGS = swresample diff --git a/ffmpeg/libswresample/dither.c b/ffmpeg/libswresample/dither.c index d0193dd..7cbe410 100644 --- a/ffmpeg/libswresample/dither.c +++ b/ffmpeg/libswresample/dither.c @@ -88,6 +88,7 @@ int swri_dither_init(SwrContext *s, enum AVSampleFormat out_fmt, enum AVSampleFo if(out_fmt == AV_SAMPLE_FMT_S16) scale = 1.0/(1L<<15); if(out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1.0/(1L<< 7); } + if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_S32 && (s->dither.output_sample_bits&31)) scale = 1; if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_S16) scale = 1L<<16; if(in_fmt == AV_SAMPLE_FMT_S32 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<24; if(in_fmt == AV_SAMPLE_FMT_S16 && out_fmt == AV_SAMPLE_FMT_U8 ) scale = 1L<<8; diff --git a/ffmpeg/libswresample/libswresample.pc b/ffmpeg/libswresample/libswresample.pc index f71c409..8cde71d 100644 --- a/ffmpeg/libswresample/libswresample.pc +++ b/ffmpeg/libswresample/libswresample.pc @@ -5,10 +5,10 @@ includedir=${prefix}/include Name: libswresample Description: FFmpeg audio resampling library -Version: 0.17.102 +Version: 0.17.104 Requires: -Requires.private: libavutil = 52.22.100 +Requires.private: libavutil = 52.59.100 Conflicts: -Libs: -L${libdir} -lswresample +Libs: -L${libdir} -lswresample Libs.private: -lm Cflags: -I${includedir} diff --git a/ffmpeg/libswresample/rematrix.c b/ffmpeg/libswresample/rematrix.c index 51658ce..e146edf 100644 --- a/ffmpeg/libswresample/rematrix.c +++ b/ffmpeg/libswresample/rematrix.c @@ -34,6 +34,10 @@ #include "rematrix_template.c" #undef TEMPLATE_REMATRIX_S16 +#define TEMPLATE_REMATRIX_S32 +#include "rematrix_template.c" +#undef TEMPLATE_REMATRIX_S32 + #define FRONT_LEFT 0 #define FRONT_RIGHT 1 #define FRONT_CENTER 2 @@ -78,9 +82,6 @@ static int even(int64_t layout){ } static int clean_layout(SwrContext *s, int64_t layout){ - if((layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == AV_CH_LAYOUT_STEREO_DOWNMIX) - return AV_CH_LAYOUT_STEREO; - if(layout && layout != AV_CH_FRONT_CENTER && !(layout&(layout-1))) { char buf[128]; av_get_channel_layout_string(buf, sizeof(buf), -1, layout); @@ -116,15 +117,22 @@ av_cold static int auto_matrix(SwrContext *s) double maxcoef=0; char buf[128]; const int matrix_encoding = s->matrix_encoding; + float maxval; in_ch_layout = clean_layout(s, s->in_ch_layout); + out_ch_layout = clean_layout(s, s->out_ch_layout); + + if( out_ch_layout == AV_CH_LAYOUT_STEREO_DOWNMIX + && (in_ch_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == 0 + ) + out_ch_layout = AV_CH_LAYOUT_STEREO; + if(!sane_layout(in_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->in_ch_layout); av_log(s, AV_LOG_ERROR, "Input channel layout '%s' is not supported\n", buf); return AVERROR(EINVAL); } - out_ch_layout = clean_layout(s, s->out_ch_layout); if(!sane_layout(out_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->out_ch_layout); av_log(s, AV_LOG_ERROR, "Output channel layout '%s' is not supported\n", buf); @@ -300,8 +308,16 @@ av_cold static int auto_matrix(SwrContext *s) if(s->rematrix_volume < 0) maxcoef = -s->rematrix_volume; - if(( av_get_packed_sample_fmt(s->out_sample_fmt) < AV_SAMPLE_FMT_FLT - || av_get_packed_sample_fmt(s->int_sample_fmt) < AV_SAMPLE_FMT_FLT) && maxcoef > 1.0){ + if (s->rematrix_maxval > 0) { + maxval = s->rematrix_maxval; + } else if ( av_get_packed_sample_fmt(s->out_sample_fmt) < AV_SAMPLE_FMT_FLT + || av_get_packed_sample_fmt(s->int_sample_fmt) < AV_SAMPLE_FMT_FLT) { + maxval = 1.0; + } else + maxval = INT_MAX; + + if(maxcoef > maxval || s->rematrix_volume < 0){ + maxcoef /= maxval; for(i=0; i<SWR_CH_MAX; i++) for(j=0; j<SWR_CH_MAX; j++){ s->matrix[i][j] /= maxcoef; @@ -337,7 +353,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ return r; } if (s->midbuf.fmt == AV_SAMPLE_FMT_S16P){ - s->native_matrix = av_mallocz(nb_in * nb_out * sizeof(int)); + s->native_matrix = av_calloc(nb_in * nb_out, sizeof(int)); s->native_one = av_mallocz(sizeof(int)); for (i = 0; i < nb_out; i++) for (j = 0; j < nb_in; j++) @@ -347,7 +363,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_2_1_f = (mix_2_1_func_type*)sum2_s16; s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s16(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){ - s->native_matrix = av_mallocz(nb_in * nb_out * sizeof(float)); + s->native_matrix = av_calloc(nb_in * nb_out, sizeof(float)); s->native_one = av_mallocz(sizeof(float)); for (i = 0; i < nb_out; i++) for (j = 0; j < nb_in; j++) @@ -357,7 +373,7 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_2_1_f = (mix_2_1_func_type*)sum2_float; s->mix_any_f = (mix_any_func_type*)get_mix_any_func_float(s); }else if(s->midbuf.fmt == AV_SAMPLE_FMT_DBLP){ - s->native_matrix = av_mallocz(nb_in * nb_out * sizeof(double)); + s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); s->native_one = av_mallocz(sizeof(double)); for (i = 0; i < nb_out; i++) for (j = 0; j < nb_in; j++) @@ -366,6 +382,17 @@ av_cold int swri_rematrix_init(SwrContext *s){ s->mix_1_1_f = (mix_1_1_func_type*)copy_double; s->mix_2_1_f = (mix_2_1_func_type*)sum2_double; s->mix_any_f = (mix_any_func_type*)get_mix_any_func_double(s); + }else if(s->midbuf.fmt == AV_SAMPLE_FMT_S32P){ + // Only for dithering currently +// s->native_matrix = av_calloc(nb_in * nb_out, sizeof(double)); + s->native_one = av_mallocz(sizeof(int)); +// for (i = 0; i < nb_out; i++) +// for (j = 0; j < nb_in; j++) +// ((double*)s->native_matrix)[i * nb_in + j] = s->matrix[i][j]; + *((int*)s->native_one) = 32768; + s->mix_1_1_f = (mix_1_1_func_type*)copy_s32; + s->mix_2_1_f = (mix_2_1_func_type*)sum2_s32; + s->mix_any_f = (mix_any_func_type*)get_mix_any_func_s32(s); }else av_assert0(0); //FIXME quantize for integeres @@ -388,6 +415,7 @@ av_cold void swri_rematrix_free(SwrContext *s){ av_freep(&s->native_matrix); av_freep(&s->native_one); av_freep(&s->native_simd_matrix); + av_freep(&s->native_simd_one); } int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy){ @@ -405,8 +433,8 @@ int swri_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mus off = len1 * out->bps; } - av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); - av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); + av_assert0(!s->out_ch_layout || out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); + av_assert0(!s-> in_ch_layout || in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); for(out_i=0; out_i<out->ch_count; out_i++){ switch(s->matrix_ch[out_i][0]){ diff --git a/ffmpeg/libswresample/rematrix_template.c b/ffmpeg/libswresample/rematrix_template.c index b8ca901..95a3b9a 100644 --- a/ffmpeg/libswresample/rematrix_template.c +++ b/ffmpeg/libswresample/rematrix_template.c @@ -36,14 +36,20 @@ # define COEFF int # define INTER int # define RENAME(x) x ## _s16 +#elif defined(TEMPLATE_REMATRIX_S32) +# define R(x) (((x) + 16384)>>15) +# define SAMPLE int32_t +# define COEFF int +# define INTER int64_t +# define RENAME(x) x ## _s32 #endif typedef void (RENAME(mix_any_func_type))(SAMPLE **out, const SAMPLE **in1, COEFF *coeffp, integer len); static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEFF *coeffp, integer index1, integer index2, integer len){ int i; - COEFF coeff1 = coeffp[index1]; - COEFF coeff2 = coeffp[index2]; + INTER coeff1 = coeffp[index1]; + INTER coeff2 = coeffp[index2]; for(i=0; i<len; i++) out[i] = R(coeff1*in1[i] + coeff2*in2[i]); @@ -51,7 +57,7 @@ static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEF static void RENAME(copy)(SAMPLE *out, const SAMPLE *in, COEFF *coeffp, integer index, integer len){ int i; - COEFF coeff = coeffp[index]; + INTER coeff = coeffp[index]; for(i=0; i<len; i++) out[i] = R(coeff*in[i]); } @@ -60,9 +66,9 @@ static void RENAME(mix6to2)(SAMPLE **out, const SAMPLE **in, COEFF *coeffp, inte int i; for(i=0; i<len; i++) { - INTER t = in[2][i]*coeffp[0*6+2] + in[3][i]*coeffp[0*6+3]; - out[0][i] = R(t + in[0][i]*coeffp[0*6+0] + in[4][i]*coeffp[0*6+4]); - out[1][i] = R(t + in[1][i]*coeffp[1*6+1] + in[5][i]*coeffp[1*6+5]); + INTER t = in[2][i]*(INTER)coeffp[0*6+2] + in[3][i]*(INTER)coeffp[0*6+3]; + out[0][i] = R(t + in[0][i]*(INTER)coeffp[0*6+0] + in[4][i]*(INTER)coeffp[0*6+4]); + out[1][i] = R(t + in[1][i]*(INTER)coeffp[1*6+1] + in[5][i]*(INTER)coeffp[1*6+5]); } } @@ -70,9 +76,9 @@ static void RENAME(mix8to2)(SAMPLE **out, const SAMPLE **in, COEFF *coeffp, inte int i; for(i=0; i<len; i++) { - INTER t = in[2][i]*coeffp[0*8+2] + in[3][i]*coeffp[0*8+3]; - out[0][i] = R(t + in[0][i]*coeffp[0*8+0] + in[4][i]*coeffp[0*8+4] + in[6][i]*coeffp[0*8+6]); - out[1][i] = R(t + in[1][i]*coeffp[1*8+1] + in[5][i]*coeffp[1*8+5] + in[7][i]*coeffp[1*8+7]); + INTER t = in[2][i]*(INTER)coeffp[0*8+2] + in[3][i]*(INTER)coeffp[0*8+3]; + out[0][i] = R(t + in[0][i]*(INTER)coeffp[0*8+0] + in[4][i]*(INTER)coeffp[0*8+4] + in[6][i]*(INTER)coeffp[0*8+6]); + out[1][i] = R(t + in[1][i]*(INTER)coeffp[1*8+1] + in[5][i]*(INTER)coeffp[1*8+5] + in[7][i]*(INTER)coeffp[1*8+7]); } } diff --git a/ffmpeg/libswresample/resample.c b/ffmpeg/libswresample/resample.c index fb9da7c..8b1b6ca 100644 --- a/ffmpeg/libswresample/resample.c +++ b/ffmpeg/libswresample/resample.c @@ -256,7 +256,7 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r return c; error: - av_free(c->filter_bank); + av_freep(&c->filter_bank); av_free(c); return NULL; } diff --git a/ffmpeg/libswresample/swresample.c b/ffmpeg/libswresample/swresample.c index 9b71b2e..c1bee00 100644 --- a/ffmpeg/libswresample/swresample.c +++ b/ffmpeg/libswresample/swresample.c @@ -51,16 +51,16 @@ static const AVOption options[]={ {"in_sample_rate" , "set input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM}, {"osr" , "set output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM}, {"out_sample_rate" , "set output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT , {.i64=0 }, 0 , INT_MAX , PARAM}, -{"isf" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"in_sample_fmt" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"osf" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"tsf" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"internal_sample_fmt" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , AV_SAMPLE_FMT_NB-1, PARAM}, -{"icl" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_INT64, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, -{"in_channel_layout" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_INT64, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, -{"ocl" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_INT64, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, -{"out_channel_layout" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_INT64, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, +{"isf" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"in_sample_fmt" , "set input sample format" , OFFSET( in_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"osf" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"out_sample_fmt" , "set output sample format" , OFFSET(out_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"tsf" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"internal_sample_fmt" , "set internal sample format" , OFFSET(int_sample_fmt ), AV_OPT_TYPE_SAMPLE_FMT , {.i64=AV_SAMPLE_FMT_NONE}, -1 , INT_MAX, PARAM}, +{"icl" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, +{"in_channel_layout" , "set input channel layout" , OFFSET( in_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, +{"ocl" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, +{"out_channel_layout" , "set output channel layout" , OFFSET(out_ch_layout ), AV_OPT_TYPE_CHANNEL_LAYOUT, {.i64=0 }, 0 , INT64_MAX , PARAM, "channel_layout"}, {"clev" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM}, {"center_mix_level" , "set center mix level" , OFFSET(clev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM}, {"slev" , "set surround mix level" , OFFSET(slev ), AV_OPT_TYPE_FLOAT, {.dbl=C_30DB }, -32 , 32 , PARAM}, @@ -68,6 +68,7 @@ static const AVOption options[]={ {"lfe_mix_level" , "set LFE mix level" , OFFSET(lfe_mix_level ), AV_OPT_TYPE_FLOAT, {.dbl=0 }, -32 , 32 , PARAM}, {"rmvol" , "set rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0 }, -1000 , 1000 , PARAM}, {"rematrix_volume" , "set rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0 }, -1000 , 1000 , PARAM}, +{"rematrix_maxval" , "set rematrix maxval" , OFFSET(rematrix_maxval), AV_OPT_TYPE_FLOAT, {.dbl=0.0 }, 0 , 1000 , PARAM}, {"flags" , "set flags" , OFFSET(flags ), AV_OPT_TYPE_FLAGS, {.i64=0 }, 0 , UINT_MAX , PARAM, "flags"}, {"swr_flags" , "set flags" , OFFSET(flags ), AV_OPT_TYPE_FLAGS, {.i64=0 }, 0 , UINT_MAX , PARAM, "flags"}, @@ -127,7 +128,7 @@ static const AVOption options[]={ { "kaiser_beta" , "set swr Kaiser Window Beta" , OFFSET(kaiser_beta) , AV_OPT_TYPE_INT , {.i64=9 }, 2 , 16 , PARAM }, -{ "output_sample_bits" , "" , OFFSET(dither.output_sample_bits) , AV_OPT_TYPE_INT , {.i64=0 }, 0 , 64 , 0 }, +{ "output_sample_bits" , "set swr number of output sample bits", OFFSET(dither.output_sample_bits), AV_OPT_TYPE_INT , {.i64=0 }, 0 , 64 , PARAM }, {0} }; @@ -467,7 +468,7 @@ int swri_realloc_audio(AudioData *a, int count){ if(a->planar) memcpy(a->ch[i], old.ch[i], a->count*a->bps); } if(!a->planar) memcpy(a->ch[0], old.ch[0], a->count*a->ch_count*a->bps); - av_free(old.data); + av_freep(&old.data); a->count= count; return 1; @@ -533,6 +534,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count, AudioData in, out, tmp; int ret_sum=0; int border=0; + int padless = ARCH_X86 && s->engine == SWR_ENGINE_SWR ? 7 : 0; av_assert1(s->in_buffer.ch_count == in_param->ch_count); av_assert1(s->in_buffer.planar == in_param->planar); @@ -563,9 +565,9 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count, } } - if((s->flushed || in_count) && !s->in_buffer_count){ + if((s->flushed || in_count > padless) && !s->in_buffer_count){ s->in_buffer_index=0; - ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, in_count, &consumed); + ret= s->resampler->multiple_resample(s->resample, &out, out_count, &in, FFMAX(in_count-padless, 0), &consumed); out_count -= ret; ret_sum += ret; buf_set(&out, &out, ret); @@ -597,6 +599,10 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count, s->resample_in_constraint= 0; if(s->in_buffer_count != count || in_count) continue; + if (padless) { + padless = 0; + continue; + } } break; }while(1); @@ -651,7 +657,8 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co if(s->resample_first ? !s->rematrix : !s->resample) preout= midbuf; - if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar){ + if(s->int_sample_fmt == s->out_sample_fmt && s->out.planar + && !(s->out_sample_fmt==AV_SAMPLE_FMT_S32P && (s->dither.output_sample_bits&31))){ if(preout==in){ out_count= FFMIN(out_count, in_count); //TODO check at the end if this is needed or redundant av_assert0(s->in.planar); //we only support planar internally so it has to be, we support copying non planar though @@ -708,7 +715,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co if(len1) for(ch=0; ch<preout->ch_count; ch++) - s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_one, 0, 0, len1); + s->mix_2_1_simd(conv_src->ch[ch], preout->ch[ch], s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos, s->native_simd_one, 0, 0, len1); if(out_count != len1) for(ch=0; ch<preout->ch_count; ch++) s->mix_2_1_f(conv_src->ch[ch] + off, preout->ch[ch] + off, s->dither.noise.ch[ch] + s->dither.noise.bps * s->dither.noise_pos + off + len1, s->native_one, 0, 0, out_count - len1); @@ -726,7 +733,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co } s->dither.noise_pos += out_count; } -//FIXME packed doesnt need more than 1 chan here! +//FIXME packed doesn't need more than 1 chan here! swri_audio_convert(s->out_convert, out, conv_src, out_count); } return out_count; @@ -746,7 +753,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun reversefill_audiodata(&s->drop_temp, tmp_arg); s->drop_output *= -1; //FIXME find a less hackish solution - ret = swr_convert(s, tmp_arg, FFMIN(-s->drop_output, MAX_DROP_STEP), in_arg, in_count); //FIXME optimize but this is as good as never called so maybe it doesnt matter + ret = swr_convert(s, tmp_arg, FFMIN(-s->drop_output, MAX_DROP_STEP), in_arg, in_count); //FIXME optimize but this is as good as never called so maybe it doesn't matter s->drop_output *= -1; in_count = 0; if(ret>0) { diff --git a/ffmpeg/libswresample/swresample.h b/ffmpeg/libswresample/swresample.h index 95e8a5a..3811301 100644 --- a/ffmpeg/libswresample/swresample.h +++ b/ffmpeg/libswresample/swresample.h @@ -44,8 +44,8 @@ * matrix): * @code * SwrContext *swr = swr_alloc(); - * av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); - * av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_channel_layout(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_channel_layout(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); * av_opt_set_int(swr, "in_sample_rate", 48000, 0); * av_opt_set_int(swr, "out_sample_rate", 44100, 0); * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); @@ -84,8 +84,8 @@ * input, in_samples); * handle_output(output, out_samples); * av_freep(&output); - * } - * @endcode + * } + * @endcode * * When the conversion is finished, the conversion * context and everything associated with it must be freed with swr_free(). diff --git a/ffmpeg/libswresample/swresample_internal.h b/ffmpeg/libswresample/swresample_internal.h index 17b85d5..ab19f21 100644 --- a/ffmpeg/libswresample/swresample_internal.h +++ b/ffmpeg/libswresample/swresample_internal.h @@ -82,6 +82,7 @@ struct SwrContext { float clev; ///< center mixing level float lfe_mix_level; ///< LFE mixing level float rematrix_volume; ///< rematrixing volume coefficient + float rematrix_maxval; ///< maximum value for rematrixing output enum AVMatrixEncoding matrix_encoding; /**< matrixed stereo encoding */ const int *channel_map; ///< channel index (or -1 if muted channel) map int used_ch_count; ///< number of used input channels (mapped channel count if channel_map, otherwise in.ch_count) @@ -134,6 +135,7 @@ struct SwrContext { float matrix[SWR_CH_MAX][SWR_CH_MAX]; ///< floating point rematrixing coefficients uint8_t *native_matrix; uint8_t *native_one; + uint8_t *native_simd_one; uint8_t *native_simd_matrix; int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX]; ///< 17.15 fixed point rematrixing coefficients uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1]; ///< Lists of input channels per output channel that have non zero rematrixing coefficients diff --git a/ffmpeg/libswresample/version.h b/ffmpeg/libswresample/version.h index df9df48..464c86d 100644 --- a/ffmpeg/libswresample/version.h +++ b/ffmpeg/libswresample/version.h @@ -30,7 +30,7 @@ #define LIBSWRESAMPLE_VERSION_MAJOR 0 #define LIBSWRESAMPLE_VERSION_MINOR 17 -#define LIBSWRESAMPLE_VERSION_MICRO 102 +#define LIBSWRESAMPLE_VERSION_MICRO 104 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ LIBSWRESAMPLE_VERSION_MINOR, \ diff --git a/ffmpeg/libswresample/x86/audio_convert.asm b/ffmpeg/libswresample/x86/audio_convert.asm index ad46977..b6e9e5d 100644 --- a/ffmpeg/libswresample/x86/audio_convert.asm +++ b/ffmpeg/libswresample/x86/audio_convert.asm @@ -20,8 +20,7 @@ %include "libavutil/x86/x86util.asm" -SECTION_RODATA -align 32 +SECTION_RODATA 32 flt2pm31: times 8 dd 4.6566129e-10 flt2p31 : times 8 dd 2147483648.0 flt2p15 : times 8 dd 32768.0 @@ -195,7 +194,12 @@ cglobal %2_to_%1_%3, 3, 3, 6, dst, src, len add lenq, 2*mmsize/(1<<%4) %endif jl .next +%if mmsize == 8 + emms + RET +%else REP_RET +%endif %endmacro %macro PACK_6CH 5-7 diff --git a/ffmpeg/libswresample/x86/rematrix.asm b/ffmpeg/libswresample/x86/rematrix.asm index 84448e8..f0ae959 100644 --- a/ffmpeg/libswresample/x86/rematrix.asm +++ b/ffmpeg/libswresample/x86/rematrix.asm @@ -21,8 +21,7 @@ %include "libavutil/x86/x86util.asm" -SECTION_RODATA -align 32 +SECTION_RODATA 32 dw1: times 8 dd 1 w1 : times 16 dw 1 diff --git a/ffmpeg/libswresample/x86/swresample_x86.c b/ffmpeg/libswresample/x86/swresample_x86.c index e18f0c5..581dc17 100644 --- a/ffmpeg/libswresample/x86/swresample_x86.c +++ b/ffmpeg/libswresample/x86/swresample_x86.c @@ -169,6 +169,7 @@ av_cold void swri_rematrix_init_x86(struct SwrContext *s){ s->mix_2_1_simd = ff_mix_2_1_a_int16_sse2; } s->native_simd_matrix = av_mallocz(2 * num * sizeof(int16_t)); + s->native_simd_one = av_mallocz(2 * sizeof(int16_t)); for(i=0; i<nb_out; i++){ int sh = 0; for(j=0; j<nb_in; j++) @@ -180,6 +181,8 @@ av_cold void swri_rematrix_init_x86(struct SwrContext *s){ ((((int*)s->native_matrix)[i * nb_in + j]) + (1<<sh>>1)) >> sh; } } + ((int16_t*)s->native_simd_one)[1] = 14; + ((int16_t*)s->native_simd_one)[0] = 16384; } else if(s->midbuf.fmt == AV_SAMPLE_FMT_FLTP){ if(mm_flags & AV_CPU_FLAG_SSE) { s->mix_1_1_simd = ff_mix_1_1_a_float_sse; @@ -191,5 +194,7 @@ av_cold void swri_rematrix_init_x86(struct SwrContext *s){ } s->native_simd_matrix = av_mallocz(num * sizeof(float)); memcpy(s->native_simd_matrix, s->native_matrix, num * sizeof(float)); + s->native_simd_one = av_mallocz(sizeof(float)); + memcpy(s->native_simd_one, s->native_one, sizeof(float)); } } |
