summaryrefslogtreecommitdiff
path: root/chromium/third_party/ffmpeg/libswresample
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-09-18 14:34:04 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-10-04 11:15:27 +0000
commite6430e577f105ad8813c92e75c54660c4985026e (patch)
tree88115e5d1fb471fea807111924dcccbeadbf9e4f /chromium/third_party/ffmpeg/libswresample
parent53d399fe6415a96ea6986ec0d402a9c07da72453 (diff)
downloadqtwebengine-chromium-e6430e577f105ad8813c92e75c54660c4985026e.tar.gz
BASELINE: Update Chromium to 61.0.3163.99
Change-Id: I8452f34574d88ca2b27af9bd56fc9ff3f16b1367 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/third_party/ffmpeg/libswresample')
-rw-r--r--chromium/third_party/ffmpeg/libswresample/Makefile3
-rw-r--r--chromium/third_party/ffmpeg/libswresample/options.c4
-rw-r--r--chromium/third_party/ffmpeg/libswresample/resample.c78
-rw-r--r--chromium/third_party/ffmpeg/libswresample/swresample.c5
-rw-r--r--chromium/third_party/ffmpeg/libswresample/version.h2
-rw-r--r--chromium/third_party/ffmpeg/libswresample/x86/resample.asm15
-rw-r--r--chromium/third_party/ffmpeg/libswresample/x86/resample_init.c10
7 files changed, 58 insertions, 59 deletions
diff --git a/chromium/third_party/ffmpeg/libswresample/Makefile b/chromium/third_party/ffmpeg/libswresample/Makefile
index 120ee3385d8..42666e4dd23 100644
--- a/chromium/third_party/ffmpeg/libswresample/Makefile
+++ b/chromium/third_party/ffmpeg/libswresample/Makefile
@@ -1,6 +1,5 @@
-include $(SUBDIR)../config.mak
-
NAME = swresample
+DESC = FFmpeg audio resampling library
FFLIBS = avutil
HEADERS = swresample.h \
diff --git a/chromium/third_party/ffmpeg/libswresample/options.c b/chromium/third_party/ffmpeg/libswresample/options.c
index 4abf5e05189..00d4f7c1c90 100644
--- a/chromium/third_party/ffmpeg/libswresample/options.c
+++ b/chromium/third_party/ffmpeg/libswresample/options.c
@@ -84,8 +84,8 @@ static const AVOption options[]={
{"filter_size" , "set swr resampling filter size", OFFSET(filter_size) , AV_OPT_TYPE_INT , {.i64=32 }, 0 , INT_MAX , PARAM },
{"phase_shift" , "set swr resampling phase shift", OFFSET(phase_shift) , AV_OPT_TYPE_INT , {.i64=10 }, 0 , 24 , PARAM },
-{"linear_interp" , "enable linear interpolation" , OFFSET(linear_interp) , AV_OPT_TYPE_BOOL , {.i64=0 }, 0 , 1 , PARAM },
-{"exact_rational" , "enable exact rational" , OFFSET(exact_rational) , AV_OPT_TYPE_BOOL , {.i64=0 }, 0 , 1 , PARAM },
+{"linear_interp" , "enable linear interpolation" , OFFSET(linear_interp) , AV_OPT_TYPE_BOOL , {.i64=1 }, 0 , 1 , PARAM },
+{"exact_rational" , "enable exact rational" , OFFSET(exact_rational) , AV_OPT_TYPE_BOOL , {.i64=1 }, 0 , 1 , PARAM },
{"cutoff" , "set cutoff frequency ratio" , OFFSET(cutoff) , AV_OPT_TYPE_DOUBLE,{.dbl=0. }, 0 , 1 , PARAM },
/* duplicate option in order to work with avconv */
diff --git a/chromium/third_party/ffmpeg/libswresample/resample.c b/chromium/third_party/ffmpeg/libswresample/resample.c
index 8e2f76901a3..39c242bf413 100644
--- a/chromium/third_party/ffmpeg/libswresample/resample.c
+++ b/chromium/third_party/ffmpeg/libswresample/resample.c
@@ -149,23 +149,25 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
double *tab = av_malloc_array(tap_count+1, sizeof(*tab));
double *sin_lut = av_malloc_array(ph_nb, sizeof(*sin_lut));
const int center= (tap_count-1)/2;
+ double norm = 0;
int ret = AVERROR(ENOMEM);
if (!tab || !sin_lut)
goto fail;
+ av_assert0(tap_count == 1 || tap_count % 2 == 0);
+
/* if upsampling, only need to interpolate, no filter */
if (factor > 1.0)
factor = 1.0;
if (factor == 1.0) {
for (ph = 0; ph < ph_nb; ph++)
- sin_lut[ph] = sin(M_PI * ph / phase_count);
+ sin_lut[ph] = sin(M_PI * ph / phase_count) * (center & 1 ? 1 : -1);
}
for(ph = 0; ph < ph_nb; ph++) {
- double norm = 0;
s = sin_lut[ph];
- for(i=0;i<=tap_count;i++) {
+ for(i=0;i<tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else if (factor == 1.0)
@@ -194,7 +196,7 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
tab[i] = y;
s = -s;
- if (i < tap_count)
+ if (!ph)
norm += y;
}
@@ -204,55 +206,29 @@ static int build_filter(ResampleContext *c, void *filter, double factor, int tap
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip_int16(lrintf(tab[i] * scale / norm));
if (phase_count % 2) break;
- if (tap_count % 2 == 0 || tap_count == 1) {
- for (i = 0; i < tap_count; i++)
- ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
- }
- else {
- for (i = 1; i <= tap_count; i++)
- ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
- av_clip_int16(lrintf(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
- }
+ for (i = 0; i < tap_count; i++)
+ ((int16_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int16_t*)filter)[ph * alloc + i];
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
if (phase_count % 2) break;
- if (tap_count % 2 == 0 || tap_count == 1) {
- for (i = 0; i < tap_count; i++)
- ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
- }
- else {
- for (i = 1; i <= tap_count; i++)
- ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-i] =
- av_clipl_int32(llrint(tab[i] * scale / (norm - tab[0] + tab[tap_count])));
- }
+ for (i = 0; i < tap_count; i++)
+ ((int32_t*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((int32_t*)filter)[ph * alloc + i];
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (phase_count % 2) break;
- if (tap_count % 2 == 0 || tap_count == 1) {
- for (i = 0; i < tap_count; i++)
- ((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
- }
- else {
- for (i = 1; i <= tap_count; i++)
- ((float*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
- }
+ for (i = 0; i < tap_count; i++)
+ ((float*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((float*)filter)[ph * alloc + i];
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
if (phase_count % 2) break;
- if (tap_count % 2 == 0 || tap_count == 1) {
- for (i = 0; i < tap_count; i++)
- ((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
- }
- else {
- for (i = 1; i <= tap_count; i++)
- ((double*)filter)[(phase_count-ph) * alloc + tap_count-i] = tab[i] * scale / (norm - tab[0] + tab[tap_count]);
- }
+ for (i = 0; i < tap_count; i++)
+ ((double*)filter)[(phase_count-ph) * alloc + tap_count-1-i] = ((double*)filter)[ph * alloc + i];
break;
}
}
@@ -300,6 +276,14 @@ fail:
return ret;
}
+static void resample_free(ResampleContext **cc){
+ ResampleContext *c = *cc;
+ if(!c)
+ return;
+ av_freep(&c->filter_bank);
+ av_freep(cc);
+}
+
static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_rate, int filter_size, int phase_shift, int linear,
double cutoff0, enum AVSampleFormat format, enum SwrFilterType filter_type, double kaiser_beta,
double precision, int cheby, int exact_rational)
@@ -308,6 +292,10 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r
double factor= FFMIN(out_rate * cutoff / in_rate, 1.0);
int phase_count= 1<<phase_shift;
int phase_count_compensation = phase_count;
+ int filter_length = FFMAX((int)ceil(filter_size/factor), 1);
+
+ if (filter_length > 1)
+ filter_length = FFALIGN(filter_length, 2);
if (exact_rational) {
int phase_count_exact, phase_count_exact_den;
@@ -320,8 +308,9 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r
}
if (!c || c->phase_count != phase_count || c->linear!=linear || c->factor != factor
- || c->filter_length != FFMAX((int)ceil(filter_size/factor), 1) || c->format != format
+ || c->filter_length != filter_length || c->format != format
|| c->filter_type != filter_type || c->kaiser_beta != kaiser_beta) {
+ resample_free(&c);
c = av_mallocz(sizeof(*c));
if (!c)
return NULL;
@@ -354,7 +343,7 @@ static ResampleContext *resample_init(ResampleContext *c, int out_rate, int in_r
c->phase_count = phase_count;
c->linear = linear;
c->factor = factor;
- c->filter_length = FFMAX((int)ceil(filter_size/factor), 1);
+ c->filter_length = filter_length;
c->filter_alloc = FFALIGN(c->filter_length, 8);
c->filter_bank = av_calloc(c->filter_alloc, (phase_count+1)*c->felem_size);
c->filter_type = filter_type;
@@ -391,13 +380,6 @@ error:
return NULL;
}
-static void resample_free(ResampleContext **c){
- if(!*c)
- return;
- av_freep(&(*c)->filter_bank);
- av_freep(c);
-}
-
static int rebuild_filter_bank_with_compensation(ResampleContext *c)
{
uint8_t *new_filter_bank;
@@ -408,7 +390,7 @@ static int rebuild_filter_bank_with_compensation(ResampleContext *c)
if (phase_count == c->phase_count)
return 0;
- av_assert0(!c->frac && !c->dst_incr_mod && !c->compensation_distance);
+ av_assert0(!c->frac && !c->dst_incr_mod);
new_filter_bank = av_calloc(c->filter_alloc, (phase_count + 1) * c->felem_size);
if (!new_filter_bank)
diff --git a/chromium/third_party/ffmpeg/libswresample/swresample.c b/chromium/third_party/ffmpeg/libswresample/swresample.c
index dea61391ac0..74c96dce605 100644
--- a/chromium/third_party/ffmpeg/libswresample/swresample.c
+++ b/chromium/third_party/ffmpeg/libswresample/swresample.c
@@ -84,9 +84,6 @@ struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
if (av_opt_set_int(s, "isr", in_sample_rate, 0) < 0)
goto fail;
- if (av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_NONE, 0) < 0)
- goto fail;
-
if (av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> user_in_ch_layout), 0) < 0)
goto fail;
@@ -226,6 +223,8 @@ av_cold int swr_init(struct SwrContext *s){
}else if( av_get_planar_sample_fmt(s-> in_sample_fmt) == AV_SAMPLE_FMT_S32P
&& av_get_planar_sample_fmt(s->out_sample_fmt) == AV_SAMPLE_FMT_S32P
&& !s->rematrix
+ && s->out_sample_rate == s->in_sample_rate
+ && !(s->flags & SWR_FLAG_RESAMPLE)
&& s->engine != SWR_ENGINE_SOXR){
s->int_sample_fmt= AV_SAMPLE_FMT_S32P;
}else if(av_get_bytes_per_sample(s->in_sample_fmt) <= 4){
diff --git a/chromium/third_party/ffmpeg/libswresample/version.h b/chromium/third_party/ffmpeg/libswresample/version.h
index 37d44dde4b9..379177a1f46 100644
--- a/chromium/third_party/ffmpeg/libswresample/version.h
+++ b/chromium/third_party/ffmpeg/libswresample/version.h
@@ -29,7 +29,7 @@
#include "libavutil/avutil.h"
#define LIBSWRESAMPLE_VERSION_MAJOR 2
-#define LIBSWRESAMPLE_VERSION_MINOR 4
+#define LIBSWRESAMPLE_VERSION_MINOR 8
#define LIBSWRESAMPLE_VERSION_MICRO 100
#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \
diff --git a/chromium/third_party/ffmpeg/libswresample/x86/resample.asm b/chromium/third_party/ffmpeg/libswresample/x86/resample.asm
index 4163df1aa1a..7107cf9d42a 100644
--- a/chromium/third_party/ffmpeg/libswresample/x86/resample.asm
+++ b/chromium/third_party/ffmpeg/libswresample/x86/resample.asm
@@ -203,7 +203,7 @@ cglobal resample_common_%1, 1, 7, 2, ctx, phase_count, dst, frac, \
; horizontal sum & store
%if mmsize == 32
vextractf128 xm1, m0, 0x1
- addps xm0, xm1
+ addp%4 xm0, xm1
%endif
movhlps xm1, xm0
%ifidn %1, float
@@ -489,8 +489,8 @@ cglobal resample_linear_%1, 1, 7, 5, ctx, min_filter_length_x4, filter2, \
%if mmsize == 32
vextractf128 xm1, m0, 0x1
vextractf128 xm3, m2, 0x1
- addps xm0, xm1
- addps xm2, xm3
+ addp%4 xm0, xm1
+ addp%4 xm2, xm3
%endif
cvtsi2s%4 xm1, fracd
subp%4 xm2, xm0
@@ -608,3 +608,12 @@ RESAMPLE_FNS int16, 2, 1
INIT_XMM sse2
RESAMPLE_FNS double, 8, 3, d, pdbl_1
+
+%if HAVE_AVX_EXTERNAL
+INIT_YMM avx
+RESAMPLE_FNS double, 8, 3, d, pdbl_1
+%endif
+%if HAVE_FMA3_EXTERNAL
+INIT_YMM fma3
+RESAMPLE_FNS double, 8, 3, d, pdbl_1
+%endif
diff --git a/chromium/third_party/ffmpeg/libswresample/x86/resample_init.c b/chromium/third_party/ffmpeg/libswresample/x86/resample_init.c
index e515762b989..c6b2a36060d 100644
--- a/chromium/third_party/ffmpeg/libswresample/x86/resample_init.c
+++ b/chromium/third_party/ffmpeg/libswresample/x86/resample_init.c
@@ -42,6 +42,8 @@ RESAMPLE_FUNCS(float, avx);
RESAMPLE_FUNCS(float, fma3);
RESAMPLE_FUNCS(float, fma4);
RESAMPLE_FUNCS(double, sse2);
+RESAMPLE_FUNCS(double, avx);
+RESAMPLE_FUNCS(double, fma3);
av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
{
@@ -85,6 +87,14 @@ av_cold void swri_resample_dsp_x86_init(ResampleContext *c)
c->dsp.resample_linear = ff_resample_linear_double_sse2;
c->dsp.resample_common = ff_resample_common_double_sse2;
}
+ if (EXTERNAL_AVX_FAST(mm_flags)) {
+ c->dsp.resample_linear = ff_resample_linear_double_avx;
+ c->dsp.resample_common = ff_resample_common_double_avx;
+ }
+ if (EXTERNAL_FMA3_FAST(mm_flags)) {
+ c->dsp.resample_linear = ff_resample_linear_double_fma3;
+ c->dsp.resample_common = ff_resample_common_double_fma3;
+ }
break;
}
}